@opentiny/vue-renderless 3.1.0-alpha.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/action-sheet/index.js +28 -0
- package/action-sheet/vue.js +29 -0
- package/alert/index.js +23 -0
- package/alert/vue.js +37 -0
- package/autocomplete/index.js +175 -0
- package/autocomplete/vue.js +171 -0
- package/avatar/index.js +29 -0
- package/avatar/vue.js +24 -0
- package/badge/index.js +16 -0
- package/badge/vue.js +30 -0
- package/breadcrumb/vue.js +4 -0
- package/breadcrumb-item/vue.js +24 -0
- package/bulletin-board/index.js +21 -0
- package/bulletin-board/vue.js +36 -0
- package/button/index.js +19 -0
- package/button/vue.js +43 -0
- package/button-group/index.js +25 -0
- package/button-group/vue.js +51 -0
- package/calendar/index.js +279 -0
- package/calendar/vue.js +124 -0
- package/card-template/index.js +39 -0
- package/card-template/vue.js +34 -0
- package/carousel/index.js +206 -0
- package/carousel/vue.js +222 -0
- package/carousel-item/index.js +93 -0
- package/carousel-item/vue.js +57 -0
- package/cascader/index.js +511 -0
- package/cascader/vue.js +342 -0
- package/cascader-menu/index.js +41 -0
- package/cascader-menu/vue.js +36 -0
- package/cascader-node/index.js +63 -0
- package/cascader-node/vue.js +62 -0
- package/cascader-panel/index.js +359 -0
- package/cascader-panel/node.js +199 -0
- package/cascader-panel/store.js +80 -0
- package/cascader-panel/vue.js +217 -0
- package/checkbox/index.js +145 -0
- package/checkbox/vue.js +139 -0
- package/checkbox-button/index.js +102 -0
- package/checkbox-button/vue.js +150 -0
- package/checkbox-group/index.js +12 -0
- package/checkbox-group/vue.js +33 -0
- package/col/index.js +132 -0
- package/col/vue.js +34 -0
- package/collapse/index.js +45 -0
- package/collapse/vue.js +35 -0
- package/collapse-item/index.js +38 -0
- package/collapse-item/vue.js +48 -0
- package/common/array.js +120 -0
- package/common/bigInt.js +352 -0
- package/common/browser.js +69 -0
- package/common/dataset/index.js +135 -0
- package/common/date.js +352 -0
- package/common/decimal.js +203 -0
- package/common/deps/ResizeObserver.js +474 -0
- package/common/deps/after-leave.js +25 -0
- package/common/deps/clickoutside.js +61 -0
- package/common/deps/date-util.js +262 -0
- package/common/deps/date.js +308 -0
- package/common/deps/debounce.js +4 -0
- package/common/deps/dom.js +190 -0
- package/common/deps/fullscreen/apis.js +157 -0
- package/common/deps/fullscreen/screenfull.js +106 -0
- package/common/deps/letter-only.js +15 -0
- package/common/deps/memorize.js +149 -0
- package/common/deps/number-only.js +16 -0
- package/common/deps/popper.js +713 -0
- package/common/deps/popup-manager.js +179 -0
- package/common/deps/repeat-click.js +24 -0
- package/common/deps/requestAnimationFrame.js +25 -0
- package/common/deps/resize-event.js +29 -0
- package/common/deps/scroll-into-view.js +29 -0
- package/common/deps/scrollbar-width.js +25 -0
- package/common/deps/throttle.js +34 -0
- package/common/deps/touch.js +33 -0
- package/common/deps/tree-model/node.js +586 -0
- package/common/deps/tree-model/tree-store.js +377 -0
- package/common/deps/tree-model/util.js +14 -0
- package/common/deps/upload-ajax.js +71 -0
- package/common/deps/vue-emitter.js +30 -0
- package/common/deps/vue-popper.js +291 -0
- package/common/deps/vue-popup.js +211 -0
- package/common/event.js +17 -0
- package/common/index.js +288 -0
- package/common/object.js +228 -0
- package/common/runtime.js +52 -0
- package/common/string.js +446 -0
- package/common/type.js +65 -0
- package/common/validate/index.js +6 -0
- package/common/validate/messages.js +68 -0
- package/common/validate/rules/enum.js +8 -0
- package/common/validate/rules/index.js +14 -0
- package/common/validate/rules/pattern.js +16 -0
- package/common/validate/rules/range.js +62 -0
- package/common/validate/rules/required.js +13 -0
- package/common/validate/rules/type.js +110 -0
- package/common/validate/rules/whitespace.js +6 -0
- package/common/validate/schema.js +323 -0
- package/common/validate/util.js +198 -0
- package/common/validate/validations/array.js +25 -0
- package/common/validate/validations/date.js +35 -0
- package/common/validate/validations/enum.js +24 -0
- package/common/validate/validations/float.js +24 -0
- package/common/validate/validations/index.js +42 -0
- package/common/validate/validations/integer.js +24 -0
- package/common/validate/validations/method.js +23 -0
- package/common/validate/validations/number.js +27 -0
- package/common/validate/validations/pattern.js +23 -0
- package/common/validate/validations/required.js +15 -0
- package/common/validate/validations/string.js +29 -0
- package/common/validate/validations/type.js +25 -0
- package/common/xss.js +325 -0
- package/container/index.js +110 -0
- package/container/vue.js +63 -0
- package/credit-card/index.js +107 -0
- package/credit-card/vue.js +117 -0
- package/credit-card-form/index.js +143 -0
- package/credit-card-form/vue.js +150 -0
- package/crop/index.js +297 -0
- package/crop/vue.js +191 -0
- package/date-panel/index.js +584 -0
- package/date-panel/vue.js +319 -0
- package/date-picker/index.js +301 -0
- package/date-picker/vue.js +169 -0
- package/date-range/index.js +463 -0
- package/date-range/vue.js +297 -0
- package/date-table/index.js +457 -0
- package/date-table/vue.js +151 -0
- package/detail-page/index.js +135 -0
- package/detail-page/vue.js +145 -0
- package/dialog-box/index.js +268 -0
- package/dialog-box/vue.js +226 -0
- package/drop-times/index.js +23 -0
- package/drop-times/vue.js +28 -0
- package/dropdown/index.js +259 -0
- package/dropdown/vue.js +107 -0
- package/dropdown-item/index.js +155 -0
- package/dropdown-item/vue.js +124 -0
- package/dropdown-menu/index.js +148 -0
- package/dropdown-menu/vue.js +44 -0
- package/exception/index.js +13 -0
- package/exception/vue.js +25 -0
- package/fall-menu/index.js +121 -0
- package/fall-menu/vue.js +90 -0
- package/file-upload/index.js +1940 -0
- package/file-upload/vue.js +458 -0
- package/floatbar/index.js +10 -0
- package/floatbar/vue.js +17 -0
- package/form/index.js +186 -0
- package/form/vue.js +69 -0
- package/form-item/index.js +364 -0
- package/form-item/vue.js +210 -0
- package/fullscreen/index.js +138 -0
- package/fullscreen/vue.js +77 -0
- package/grid/core/index.js +3 -0
- package/grid/core/interceptor.js +38 -0
- package/grid/core/storeMap.js +19 -0
- package/grid/plugins/export.js +169 -0
- package/grid/plugins/exportExcel.js +749 -0
- package/grid/plugins/header.js +58 -0
- package/grid/plugins/resize.js +82 -0
- package/grid/static/array/arrayEach.js +12 -0
- package/grid/static/array/arrayIndexOf.js +11 -0
- package/grid/static/array/eachTree.js +32 -0
- package/grid/static/array/every.js +2 -0
- package/grid/static/array/filterTree.js +16 -0
- package/grid/static/array/find.js +3 -0
- package/grid/static/array/findTree.js +46 -0
- package/grid/static/array/helperCreateIterateHandle.js +59 -0
- package/grid/static/array/helperCreateTreeFunc.js +18 -0
- package/grid/static/array/includes.js +5 -0
- package/grid/static/array/lastArrayEach.js +6 -0
- package/grid/static/array/map.js +23 -0
- package/grid/static/array/mapTree.js +33 -0
- package/grid/static/array/slice.js +10 -0
- package/grid/static/array/sortBy.js +69 -0
- package/grid/static/array/sum.js +28 -0
- package/grid/static/array/toArray.js +7 -0
- package/grid/static/array/toTreeArray.js +24 -0
- package/grid/static/base/clear.js +44 -0
- package/grid/static/base/clone.js +18 -0
- package/grid/static/base/destructuring.js +18 -0
- package/grid/static/base/each.js +9 -0
- package/grid/static/base/eqNull.js +6 -0
- package/grid/static/base/findIndexOf.js +10 -0
- package/grid/static/base/get.js +42 -0
- package/grid/static/base/has.js +60 -0
- package/grid/static/base/hasOwnProp.js +4 -0
- package/grid/static/base/helperCreateGetObjects.js +26 -0
- package/grid/static/base/helperCreateInInObjectString.js +7 -0
- package/grid/static/base/helperCreateInTypeof.js +6 -0
- package/grid/static/base/helperCreateIndexOf.js +21 -0
- package/grid/static/base/helperCreateiterateIndexOf.js +21 -0
- package/grid/static/base/helperDefaultCompare.js +4 -0
- package/grid/static/base/helperDeleteProperty.js +8 -0
- package/grid/static/base/helperEqualCompare.js +60 -0
- package/grid/static/base/helperGetHGSKeys.js +4 -0
- package/grid/static/base/indexOf.js +3 -0
- package/grid/static/base/isArray.js +3 -0
- package/grid/static/base/isBoolean.js +4 -0
- package/grid/static/base/isDate.js +3 -0
- package/grid/static/base/isEmpty.js +8 -0
- package/grid/static/base/isEqual.js +11 -0
- package/grid/static/base/isFunction.js +4 -0
- package/grid/static/base/isNaN.js +5 -0
- package/grid/static/base/isNull.js +4 -0
- package/grid/static/base/isNumber.js +4 -0
- package/grid/static/base/isObject.js +5 -0
- package/grid/static/base/isPlainObject.js +2 -0
- package/grid/static/base/isRegExp.js +3 -0
- package/grid/static/base/isSet.js +5 -0
- package/grid/static/base/isString.js +4 -0
- package/grid/static/base/isUndefined.js +4 -0
- package/grid/static/base/keys.js +3 -0
- package/grid/static/base/lastEach.js +9 -0
- package/grid/static/base/remove.js +44 -0
- package/grid/static/base/set.js +43 -0
- package/grid/static/base/toJSONString.js +4 -0
- package/grid/static/base/toStringJSON.js +13 -0
- package/grid/static/base/uniqueId.js +5 -0
- package/grid/static/browse/browse.js +54 -0
- package/grid/static/function/property.js +7 -0
- package/grid/static/function/throttle.js +43 -0
- package/grid/static/index.js +55 -0
- package/grid/static/number/helperCreateToNumber.js +12 -0
- package/grid/static/number/toNumber.js +3 -0
- package/grid/static/object/assign.js +41 -0
- package/grid/static/object/extend.js +3 -0
- package/grid/static/object/lastObjectEach.js +8 -0
- package/grid/static/object/objectEach.js +11 -0
- package/grid/static/object/objectMap.js +20 -0
- package/grid/static/object/values.js +9 -0
- package/grid/static/static/staticDocument.js +4 -0
- package/grid/static/static/staticHGKeyRE.js +2 -0
- package/grid/static/static/staticParseInt.js +2 -0
- package/grid/static/static/staticStrUndefined.js +2 -0
- package/grid/static/static/staticWindow.js +4 -0
- package/grid/static/string/template.js +12 -0
- package/grid/static/string/toString.js +12 -0
- package/grid/utils/column.js +72 -0
- package/grid/utils/common.js +155 -0
- package/grid/utils/dom.js +213 -0
- package/grid/utils/event.js +40 -0
- package/grid/utils/index.js +5 -0
- package/image/index.js +187 -0
- package/image/vue.js +142 -0
- package/image-viewer/index.js +469 -0
- package/image-viewer/vue.js +243 -0
- package/input/index.js +319 -0
- package/input/vue.js +319 -0
- package/ip-address/index.js +370 -0
- package/ip-address/vue.js +185 -0
- package/layout/vue.js +4 -0
- package/link/index.js +10 -0
- package/link/vue.js +26 -0
- package/link-menu/index.js +146 -0
- package/link-menu/vue.js +138 -0
- package/list/index.js +13 -0
- package/list/vue.js +17 -0
- package/loading/index.js +29 -0
- package/loading/vue.js +28 -0
- package/milestone/index.js +92 -0
- package/milestone/vue.js +31 -0
- package/mini-picker/index.js +227 -0
- package/mini-picker/vue.js +142 -0
- package/modal/index.js +866 -0
- package/modal/vue.js +130 -0
- package/month-range/index.js +169 -0
- package/month-range/vue.js +104 -0
- package/month-table/index.js +232 -0
- package/month-table/vue.js +72 -0
- package/nav-menu/index.js +457 -0
- package/nav-menu/vue.js +187 -0
- package/notify/index.js +91 -0
- package/notify/vue.js +67 -0
- package/numeric/index.js +419 -0
- package/numeric/vue.js +218 -0
- package/option/index.js +79 -0
- package/option/vue.js +219 -0
- package/option-group/index.js +18 -0
- package/option-group/vue.js +37 -0
- package/package.json +179 -0
- package/pager-item/index.js +122 -0
- package/pager-item/vue.js +52 -0
- package/panel/index.js +30 -0
- package/panel/vue.js +26 -0
- package/picker/index.js +1039 -0
- package/picker/timezone.js +974 -0
- package/picker/vue.js +415 -0
- package/picker-column/index.js +261 -0
- package/picker-column/vue.js +163 -0
- package/pop-upload/index.js +324 -0
- package/pop-upload/vue.js +292 -0
- package/popeditor/index.js +884 -0
- package/popeditor/vue.js +368 -0
- package/popover/index.js +203 -0
- package/popover/vue.js +174 -0
- package/popup/index.js +139 -0
- package/popup/vue.js +129 -0
- package/progress/index.js +174 -0
- package/progress/vue.js +118 -0
- package/pull-refresh/index.js +104 -0
- package/pull-refresh/vue.js +64 -0
- package/radio/index.js +83 -0
- package/radio/vue.js +99 -0
- package/radio-button/index.js +58 -0
- package/radio-button/vue.js +70 -0
- package/radio-group/index.js +51 -0
- package/radio-group/vue.js +34 -0
- package/rate/index.js +254 -0
- package/rate/vue.js +158 -0
- package/row/index.js +19 -0
- package/row/vue.js +24 -0
- package/scroll-text/index.js +24 -0
- package/scroll-text/vue.js +31 -0
- package/scrollbar/index.js +127 -0
- package/scrollbar/vue-bar.js +49 -0
- package/scrollbar/vue.js +43 -0
- package/search/index.js +110 -0
- package/search/vue.js +110 -0
- package/select/index.js +1766 -0
- package/select/vue.js +693 -0
- package/select-dropdown/index.js +23 -0
- package/select-dropdown/vue.js +122 -0
- package/slide-bar/index.js +94 -0
- package/slide-bar/vue.js +58 -0
- package/slider/index.js +434 -0
- package/slider/vue.js +172 -0
- package/split/index.js +122 -0
- package/split/vue.js +131 -0
- package/steps/vue.js +4 -0
- package/switch/index.js +45 -0
- package/switch/vue.js +62 -0
- package/tab-bar/index.js +51 -0
- package/tab-bar/vue.js +16 -0
- package/tab-dropdown/index.js +11 -0
- package/tab-dropdown/vue.js +17 -0
- package/tab-item/index.js +37 -0
- package/tab-item/vue.js +49 -0
- package/tab-nav/index.js +247 -0
- package/tab-nav/vue.js +106 -0
- package/tabbar/index.js +32 -0
- package/tabbar/vue.js +54 -0
- package/tabbar-item/index.js +55 -0
- package/tabbar-item/vue.js +53 -0
- package/table/index.js +111 -0
- package/table/vue.js +66 -0
- package/tabs/index.js +174 -0
- package/tabs/vue.js +141 -0
- package/tag/index.js +14 -0
- package/tag/vue.js +13 -0
- package/tall-storage/index.js +161 -0
- package/tall-storage/vue-storage-box.js +25 -0
- package/tall-storage/vue.js +38 -0
- package/text-popup/index.js +75 -0
- package/text-popup/vue.js +64 -0
- package/time/index.js +121 -0
- package/time/vue.js +124 -0
- package/time-line/index.js +60 -0
- package/time-line/vue.js +49 -0
- package/time-panel/index.js +189 -0
- package/time-panel/scrollIntoView.js +23 -0
- package/time-panel/vue.js +110 -0
- package/time-range/index.js +199 -0
- package/time-range/vue.js +129 -0
- package/time-spinner/index.js +175 -0
- package/time-spinner/vue.js +122 -0
- package/toggle-menu/index.js +104 -0
- package/toggle-menu/vue.js +74 -0
- package/tooltip/index.js +171 -0
- package/tooltip/vue.js +133 -0
- package/top-box/index.js +81 -0
- package/top-box/vue.js +77 -0
- package/transfer/index.js +296 -0
- package/transfer/vue.js +138 -0
- package/transfer-panel/index.js +364 -0
- package/transfer-panel/vue.js +258 -0
- package/tree/index.js +642 -0
- package/tree/vue.js +268 -0
- package/tree-menu/index.js +124 -0
- package/tree-menu/vue.js +60 -0
- package/tree-node/index.js +271 -0
- package/tree-node/vue.js +211 -0
- package/upload/index.js +324 -0
- package/upload/vue.js +93 -0
- package/upload-dragger/index.js +50 -0
- package/upload-dragger/vue.js +27 -0
- package/upload-list/index.js +55 -0
- package/upload-list/vue.js +48 -0
- package/user-contact/index.js +13 -0
- package/user-contact/vue.js +20 -0
- package/user-head/index.js +71 -0
- package/user-head/vue.js +47 -0
- package/wizard/index.js +123 -0
- package/wizard/vue.js +45 -0
- package/year-table/index.js +40 -0
- package/year-table/vue.js +23 -0
package/upload/index.js
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { KEY_CODE } from '@opentiny/vue-renderless/common';
|
|
2
|
+
export var isImage = function isImage(str) {
|
|
3
|
+
return str.indexOf('image') !== -1;
|
|
4
|
+
};
|
|
5
|
+
export var handleChange = function handleChange(api) {
|
|
6
|
+
return function (event) {
|
|
7
|
+
var files = event.target.files;
|
|
8
|
+
if (!files) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
api.uploadFiles(files);
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export var getFormData = function getFormData(_ref) {
|
|
15
|
+
var constants = _ref.constants,
|
|
16
|
+
state = _ref.state,
|
|
17
|
+
parent = _ref.parent,
|
|
18
|
+
props = _ref.props;
|
|
19
|
+
return function (_ref2) {
|
|
20
|
+
var formData = _ref2.formData,
|
|
21
|
+
file = _ref2.file,
|
|
22
|
+
type = _ref2.type;
|
|
23
|
+
formData.append(constants.EDM.FILENAME, file.name);
|
|
24
|
+
if (parent.edm.isCheckCode === true) {
|
|
25
|
+
formData.append(constants.EDM.ISCHECKCODE, 'Y');
|
|
26
|
+
formData.append(constants.EDM.CHECKCODE, file.hash);
|
|
27
|
+
} else {
|
|
28
|
+
formData.append(constants.EDM.ISCHECKCODE, 'N');
|
|
29
|
+
}
|
|
30
|
+
if (props.isFolder) {
|
|
31
|
+
formData.append('filePath', file.path);
|
|
32
|
+
}
|
|
33
|
+
var updateId = state.updateId || parent.edm.updateId;
|
|
34
|
+
if (type === constants.EDM.SINGLEUPLOAD) {
|
|
35
|
+
formData.append(constants.EDM.MULTIPART, file, props.isFolder ? file.path + file.name : file.name);
|
|
36
|
+
updateId && formData.append(constants.EDM.DOCID, updateId);
|
|
37
|
+
} else {
|
|
38
|
+
var docId = updateId || file.docId;
|
|
39
|
+
formData.append(constants.EDM.DOCID, docId);
|
|
40
|
+
formData.append(constants.EDM.FILESIZE, file.size);
|
|
41
|
+
}
|
|
42
|
+
if (updateId) {
|
|
43
|
+
formData.append('updateFile', true);
|
|
44
|
+
state.updateId = '';
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export var uploadFiles = function uploadFiles(_ref3) {
|
|
49
|
+
var api = _ref3.api,
|
|
50
|
+
state = _ref3.state,
|
|
51
|
+
constants = _ref3.constants,
|
|
52
|
+
Modal = _ref3.Modal,
|
|
53
|
+
props = _ref3.props,
|
|
54
|
+
t = _ref3.t;
|
|
55
|
+
return function (files) {
|
|
56
|
+
if (props.limit && props.fileList.length + files.length > props.limit) {
|
|
57
|
+
props.onExceed && props.onExceed(files, props.fileList);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
var postFiles = Array.prototype.slice.call(files);
|
|
61
|
+
if (props.isFolder) {
|
|
62
|
+
postFiles = postFiles.filter(function (item) {
|
|
63
|
+
var folderAry = item.webkitRelativePath.split('/');
|
|
64
|
+
item.path = folderAry.slice(0, folderAry.length - 1).join('/') + '/';
|
|
65
|
+
if (folderAry.length >= 7) {
|
|
66
|
+
Modal.message({
|
|
67
|
+
message: "".concat(item.name).concat(t(constants.EDM.FOLDERKEY)),
|
|
68
|
+
status: 'warning'
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return folderAry.length < 7;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (!props.isFolder) {
|
|
75
|
+
if (!props.multiple) {
|
|
76
|
+
postFiles = postFiles.slice(0, 1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (postFiles.length === 0) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
props.onStart(postFiles, state.updateId);
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export var upload = function upload(_ref4) {
|
|
86
|
+
var api = _ref4.api,
|
|
87
|
+
props = _ref4.props,
|
|
88
|
+
refs = _ref4.refs;
|
|
89
|
+
return function (rawFile) {
|
|
90
|
+
refs.input.value = null;
|
|
91
|
+
if (!props.beforeUpload) {
|
|
92
|
+
return api.post(rawFile);
|
|
93
|
+
}
|
|
94
|
+
var previous = props.beforeUpload(rawFile);
|
|
95
|
+
if (previous && previous.then) {
|
|
96
|
+
previous.then(function (fileProcessed) {
|
|
97
|
+
var typeOfFile = Object.prototype.toString.call(fileProcessed);
|
|
98
|
+
if (typeOfFile === '[object File]' || typeOfFile === '[object Blob]') {
|
|
99
|
+
if (typeOfFile === '[object Blob]') {
|
|
100
|
+
fileProcessed = new File([fileProcessed], rawFile.name, {
|
|
101
|
+
type: rawFile.type
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
Object.keys(rawFile).forEach(function (p) {
|
|
105
|
+
fileProcessed[p] = rawFile[p];
|
|
106
|
+
});
|
|
107
|
+
api.post(fileProcessed);
|
|
108
|
+
} else {
|
|
109
|
+
api.post(rawFile);
|
|
110
|
+
}
|
|
111
|
+
}, function () {
|
|
112
|
+
props.onRemove(null, rawFile);
|
|
113
|
+
});
|
|
114
|
+
} else if (previous !== false) {
|
|
115
|
+
api.post(rawFile);
|
|
116
|
+
} else {
|
|
117
|
+
props.onRemove(null, rawFile);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
export var abort = function abort(_ref5) {
|
|
122
|
+
var state = _ref5.state,
|
|
123
|
+
props = _ref5.props;
|
|
124
|
+
return function (file) {
|
|
125
|
+
var reqs = state.reqs;
|
|
126
|
+
var cancel = function cancel(uid) {
|
|
127
|
+
var fn = reqs[uid] && reqs[uid].abort || state.cancelToken[uid];
|
|
128
|
+
fn && fn();
|
|
129
|
+
delete reqs[uid];
|
|
130
|
+
delete state.cancelToken[uid];
|
|
131
|
+
};
|
|
132
|
+
if (file && file.isLargeFile && file.cancelToken) {
|
|
133
|
+
file.cancelToken && file.cancelToken.forEach(function (cancel) {
|
|
134
|
+
return cancel();
|
|
135
|
+
});
|
|
136
|
+
delete file.cancelToken;
|
|
137
|
+
} else if (file) {
|
|
138
|
+
var uid = file;
|
|
139
|
+
if (file.uid) {
|
|
140
|
+
uid = file.uid;
|
|
141
|
+
}
|
|
142
|
+
cancel(uid);
|
|
143
|
+
} else {
|
|
144
|
+
Object.keys(reqs).forEach(function (uid) {
|
|
145
|
+
return cancel(uid);
|
|
146
|
+
});
|
|
147
|
+
props.fileList.forEach(function (file) {
|
|
148
|
+
file.cancelToken && file.cancelToken.forEach(function (cancel) {
|
|
149
|
+
return cancel();
|
|
150
|
+
});
|
|
151
|
+
file.status = 'fail';
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
var getOptionsOfPost = function getOptionsOfPost(_ref6) {
|
|
157
|
+
var props = _ref6.props,
|
|
158
|
+
state = _ref6.state,
|
|
159
|
+
rawFile = _ref6.rawFile,
|
|
160
|
+
parent = _ref6.parent,
|
|
161
|
+
uid = _ref6.uid;
|
|
162
|
+
return {
|
|
163
|
+
headers: Object.assign(props.headers, state.headers),
|
|
164
|
+
withCredentials: props.withCredentials,
|
|
165
|
+
file: rawFile,
|
|
166
|
+
data: props.data,
|
|
167
|
+
filename: props.name,
|
|
168
|
+
action: parent.action || props.action,
|
|
169
|
+
onProgress: function onProgress(event) {
|
|
170
|
+
props.onProgress(event, rawFile);
|
|
171
|
+
},
|
|
172
|
+
onSuccess: function onSuccess(res) {
|
|
173
|
+
props.onSuccess(res, rawFile);
|
|
174
|
+
delete state.reqs[uid];
|
|
175
|
+
},
|
|
176
|
+
onError: function onError(error) {
|
|
177
|
+
props.onError(error, rawFile);
|
|
178
|
+
delete state.reqs[uid];
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
var modifyOptionsOfPost = function modifyOptionsOfPost(_ref7) {
|
|
183
|
+
var service = _ref7.service,
|
|
184
|
+
props = _ref7.props,
|
|
185
|
+
options = _ref7.options,
|
|
186
|
+
rawFile = _ref7.rawFile,
|
|
187
|
+
state = _ref7.state,
|
|
188
|
+
uid = _ref7.uid,
|
|
189
|
+
parent = _ref7.parent,
|
|
190
|
+
api = _ref7.api,
|
|
191
|
+
constants = _ref7.constants;
|
|
192
|
+
if (service && service.network && props.httpRequest === service.network.request) {
|
|
193
|
+
options.method = 'post';
|
|
194
|
+
options.url = options.action;
|
|
195
|
+
options.onUploadProgress = function (event) {
|
|
196
|
+
props.onProgress(event, rawFile);
|
|
197
|
+
};
|
|
198
|
+
delete options.action;
|
|
199
|
+
delete options.onProgress;
|
|
200
|
+
var formData = new FormData();
|
|
201
|
+
var source = service.network.CancelToken.source();
|
|
202
|
+
options.cancelToken = source.token;
|
|
203
|
+
state.cancelToken[uid] = source.cancel;
|
|
204
|
+
if (parent.edm.upload) {
|
|
205
|
+
!rawFile.isLargeFile && (options.method = 'put');
|
|
206
|
+
options.data = options.data || {};
|
|
207
|
+
}
|
|
208
|
+
if (options.data) {
|
|
209
|
+
Object.keys(options.data).forEach(function (key) {
|
|
210
|
+
formData.append(key, options.data[key]);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (Array.isArray(rawFile)) {
|
|
214
|
+
rawFile.forEach(function (file) {
|
|
215
|
+
return formData.append(file.name, file.raw || file);
|
|
216
|
+
});
|
|
217
|
+
} else {
|
|
218
|
+
if (state.isEdm) {
|
|
219
|
+
api.getFormData({
|
|
220
|
+
formData: formData,
|
|
221
|
+
file: rawFile,
|
|
222
|
+
type: !rawFile.isLargeFile ? constants.EDM.SINGLEUPLOAD : ''
|
|
223
|
+
});
|
|
224
|
+
} else {
|
|
225
|
+
formData.append(options.filename, rawFile, rawFile.name);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
options.data = formData;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
export var post = function post(_ref8) {
|
|
232
|
+
var api = _ref8.api,
|
|
233
|
+
constants = _ref8.constants,
|
|
234
|
+
parent = _ref8.parent,
|
|
235
|
+
props = _ref8.props,
|
|
236
|
+
state = _ref8.state,
|
|
237
|
+
service = _ref8.service;
|
|
238
|
+
return function (rawFile) {
|
|
239
|
+
var uid = rawFile.uid;
|
|
240
|
+
var options = getOptionsOfPost({
|
|
241
|
+
props: props,
|
|
242
|
+
state: state,
|
|
243
|
+
rawFile: rawFile,
|
|
244
|
+
parent: parent,
|
|
245
|
+
uid: uid
|
|
246
|
+
});
|
|
247
|
+
modifyOptionsOfPost({
|
|
248
|
+
service: service,
|
|
249
|
+
props: props,
|
|
250
|
+
options: options,
|
|
251
|
+
rawFile: rawFile,
|
|
252
|
+
state: state,
|
|
253
|
+
uid: uid,
|
|
254
|
+
parent: parent,
|
|
255
|
+
api: api,
|
|
256
|
+
constants: constants
|
|
257
|
+
});
|
|
258
|
+
var excuteReq = function excuteReq(options) {
|
|
259
|
+
var req = props.httpRequest(options);
|
|
260
|
+
state.reqs[uid] = req;
|
|
261
|
+
if (req && req.then) {
|
|
262
|
+
req.then(options.onSuccess, options.onError);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
if (rawFile.isLargeFile) {
|
|
266
|
+
service.common.getChunkMergeUrl().then(function (url) {
|
|
267
|
+
options.url = url;
|
|
268
|
+
excuteReq(options);
|
|
269
|
+
});
|
|
270
|
+
} else {
|
|
271
|
+
excuteReq(options);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
export var handleClick = function handleClick(_ref9) {
|
|
276
|
+
var props = _ref9.props,
|
|
277
|
+
refs = _ref9.refs;
|
|
278
|
+
return function () {
|
|
279
|
+
if (!props.disabled) {
|
|
280
|
+
refs.input.value = null;
|
|
281
|
+
refs.input.click();
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
export var handleKeydown = function handleKeydown(api) {
|
|
286
|
+
return function (event) {
|
|
287
|
+
if (event.target !== event.currentTarget) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (event.keyCode === KEY_CODE.Enter || event.keyCode === KEY_CODE.Space) {
|
|
291
|
+
api.handleClick();
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
export var handleUpdate = function handleUpdate(_ref10) {
|
|
296
|
+
var props = _ref10.props,
|
|
297
|
+
state = _ref10.state;
|
|
298
|
+
return function (file) {
|
|
299
|
+
if (!props.disabled) {
|
|
300
|
+
state.updateInput.value = null;
|
|
301
|
+
state.updateId = file.docId;
|
|
302
|
+
state.updateInput.click();
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
export var mounted = function mounted(_ref11) {
|
|
307
|
+
var state = _ref11.state,
|
|
308
|
+
props = _ref11.props,
|
|
309
|
+
api = _ref11.api;
|
|
310
|
+
return function () {
|
|
311
|
+
var updateInput = document.createElement('input');
|
|
312
|
+
updateInput.type = 'file';
|
|
313
|
+
updateInput.name = props.name;
|
|
314
|
+
updateInput.accept = props.accept;
|
|
315
|
+
updateInput.onchange = api.handleChange;
|
|
316
|
+
state.updateInput = Object.freeze(updateInput);
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
export var onBeforeDestroy = function onBeforeDestroy(state) {
|
|
320
|
+
return function () {
|
|
321
|
+
state.updateInput.onchange = null;
|
|
322
|
+
state.updateInput = null;
|
|
323
|
+
};
|
|
324
|
+
};
|
package/upload/vue.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { getFormData, isImage, handleChange, uploadFiles, upload, abort, post, handleClick, handleKeydown, handleUpdate, mounted, onBeforeDestroy } from './index';
|
|
3
|
+
export var api = ['state', 'isImage', 'handleChange', 'uploadFiles', 'upload', 'abort', 'post', 'handleClick', 'handleKeydown', 'handleUpdate'];
|
|
4
|
+
export var renderless = function renderless(props, _ref, _ref2, _ref3) {
|
|
5
|
+
var computed = _ref.computed,
|
|
6
|
+
inject = _ref.inject,
|
|
7
|
+
reactive = _ref.reactive,
|
|
8
|
+
onMounted = _ref.onMounted,
|
|
9
|
+
onBeforeUnmount = _ref.onBeforeUnmount;
|
|
10
|
+
var refs = _ref2.refs,
|
|
11
|
+
service = _ref2.service,
|
|
12
|
+
parent = _ref2.parent,
|
|
13
|
+
t = _ref2.t;
|
|
14
|
+
var Modal = _ref3.Modal;
|
|
15
|
+
var api = {};
|
|
16
|
+
var constants = parent.$parent.$constants;
|
|
17
|
+
var state = reactive({
|
|
18
|
+
mouseover: false,
|
|
19
|
+
reqs: {},
|
|
20
|
+
uploader: inject('uploader'),
|
|
21
|
+
accecpt: '',
|
|
22
|
+
isEdm: computed(function () {
|
|
23
|
+
return parent.state.isEdm;
|
|
24
|
+
}),
|
|
25
|
+
openEdmDownload: computed(function () {
|
|
26
|
+
return parent.edm.download;
|
|
27
|
+
}),
|
|
28
|
+
headers: computed(function () {
|
|
29
|
+
if (state.isEdm) {
|
|
30
|
+
var _ref4;
|
|
31
|
+
return _ref4 = {}, _defineProperty(_ref4, constants.EDM.EDMTOKEN, props.edmToken.edmToken || ''), _defineProperty(_ref4, constants.EDM.TRACEID, props.edmToken.traceId || ''), _ref4;
|
|
32
|
+
}
|
|
33
|
+
}),
|
|
34
|
+
formData: {},
|
|
35
|
+
cancelToken: {},
|
|
36
|
+
updateId: '',
|
|
37
|
+
updateInput: null
|
|
38
|
+
});
|
|
39
|
+
Object.assign(api, {
|
|
40
|
+
state: state,
|
|
41
|
+
isImage: isImage,
|
|
42
|
+
abort: abort({
|
|
43
|
+
state: state,
|
|
44
|
+
props: props
|
|
45
|
+
}),
|
|
46
|
+
getFormData: getFormData({
|
|
47
|
+
state: state,
|
|
48
|
+
constants: constants,
|
|
49
|
+
parent: parent,
|
|
50
|
+
props: props
|
|
51
|
+
}),
|
|
52
|
+
handleClick: handleClick({
|
|
53
|
+
props: props,
|
|
54
|
+
refs: refs
|
|
55
|
+
}),
|
|
56
|
+
onBeforeDestroy: onBeforeDestroy(state),
|
|
57
|
+
handleUpdate: handleUpdate({
|
|
58
|
+
state: state,
|
|
59
|
+
props: props
|
|
60
|
+
}),
|
|
61
|
+
uploadFiles: uploadFiles({
|
|
62
|
+
api: api,
|
|
63
|
+
constants: constants,
|
|
64
|
+
Modal: Modal,
|
|
65
|
+
props: props,
|
|
66
|
+
state: state,
|
|
67
|
+
t: t
|
|
68
|
+
}),
|
|
69
|
+
post: post({
|
|
70
|
+
api: api,
|
|
71
|
+
constants: constants,
|
|
72
|
+
parent: parent,
|
|
73
|
+
props: props,
|
|
74
|
+
state: state,
|
|
75
|
+
service: service
|
|
76
|
+
}),
|
|
77
|
+
handleChange: handleChange(api),
|
|
78
|
+
handleKeydown: handleKeydown(api),
|
|
79
|
+
upload: upload({
|
|
80
|
+
api: api,
|
|
81
|
+
props: props,
|
|
82
|
+
refs: refs
|
|
83
|
+
}),
|
|
84
|
+
mounted: mounted({
|
|
85
|
+
state: state,
|
|
86
|
+
props: props,
|
|
87
|
+
api: api
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
onMounted(api.mounted);
|
|
91
|
+
onBeforeUnmount(api.onBeforeDestroy);
|
|
92
|
+
return api;
|
|
93
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export var onDragOver = function onDragOver(_ref) {
|
|
2
|
+
var props = _ref.props,
|
|
3
|
+
state = _ref.state;
|
|
4
|
+
return function () {
|
|
5
|
+
return !props.disabled && (state.dragover = true);
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export var onDrop = function onDrop(_ref2) {
|
|
9
|
+
var emit = _ref2.emit,
|
|
10
|
+
props = _ref2.props,
|
|
11
|
+
state = _ref2.state;
|
|
12
|
+
return function (event) {
|
|
13
|
+
if (props.disabled || !state.uploader) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
var accept = state.uploader.accept;
|
|
17
|
+
state.dragover = false;
|
|
18
|
+
if (!accept) {
|
|
19
|
+
emit('file', event.dataTransfer.files);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
var notAcceptedFiles = [];
|
|
23
|
+
var filteredFile = [].slice.call(event.dataTransfer.files).filter(function (file) {
|
|
24
|
+
var type = file.type,
|
|
25
|
+
name = file.name;
|
|
26
|
+
var extension = name.indexOf('.') > -1 ? ".".concat(name.split('.').pop()) : '';
|
|
27
|
+
var baseType = type.replace(/\/.*$/, '');
|
|
28
|
+
var isValid = accept.split(',').map(function (type) {
|
|
29
|
+
return type.trim();
|
|
30
|
+
}).filter(function (type) {
|
|
31
|
+
return type;
|
|
32
|
+
}).some(function (type) {
|
|
33
|
+
if (/\..+$/.test(type)) {
|
|
34
|
+
return extension === type;
|
|
35
|
+
}
|
|
36
|
+
if (/\/\*$/.test(type)) {
|
|
37
|
+
return baseType === type.replace(/\/\*$/, '');
|
|
38
|
+
}
|
|
39
|
+
if (/^[^/]+\/[^/]+$/.test(type)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
});
|
|
44
|
+
!isValid && notAcceptedFiles.push(file);
|
|
45
|
+
return isValid;
|
|
46
|
+
});
|
|
47
|
+
notAcceptedFiles.length && state.uploader.$emit('drop-error', notAcceptedFiles);
|
|
48
|
+
emit('file', filteredFile);
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { onDragOver, onDrop } from './index';
|
|
2
|
+
export var api = ['state', 'onDragOver', 'onDrop'];
|
|
3
|
+
export var renderless = function renderless(props, _ref, _ref2) {
|
|
4
|
+
var inject = _ref.inject,
|
|
5
|
+
reactive = _ref.reactive,
|
|
6
|
+
ref = _ref.ref;
|
|
7
|
+
var emit = _ref2.emit;
|
|
8
|
+
var state = reactive({
|
|
9
|
+
dragover: false,
|
|
10
|
+
uploader: inject('uploader') || ref({
|
|
11
|
+
"default": ''
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
var api = {
|
|
15
|
+
state: state,
|
|
16
|
+
onDragOver: onDragOver({
|
|
17
|
+
props: props,
|
|
18
|
+
state: state
|
|
19
|
+
}),
|
|
20
|
+
onDrop: onDrop({
|
|
21
|
+
emit: emit,
|
|
22
|
+
props: props,
|
|
23
|
+
state: state
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
return api;
|
|
27
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
+
export var parsePercentage = function parsePercentage() {
|
|
3
|
+
return function (val) {
|
|
4
|
+
return parseInt(val, 10);
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
export var handleClick = function handleClick(_ref) {
|
|
8
|
+
var props = _ref.props,
|
|
9
|
+
api = _ref.api,
|
|
10
|
+
parent = _ref.parent;
|
|
11
|
+
return function (file) {
|
|
12
|
+
if (parent.state.isEdm) {
|
|
13
|
+
props.openDownloadFile && api.edmDownloadFile(file);
|
|
14
|
+
} else {
|
|
15
|
+
props.openDownloadFile && api.downloadFile(file);
|
|
16
|
+
}
|
|
17
|
+
return props.handlePreview && props.handlePreview(file);
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export var downloadFile = function downloadFile(service) {
|
|
21
|
+
return function (file) {
|
|
22
|
+
var data = file && file.response && file.response.data;
|
|
23
|
+
var responseFile;
|
|
24
|
+
if (Array.isArray(data)) {
|
|
25
|
+
responseFile = data[0];
|
|
26
|
+
} else if (data && _typeof(data) === 'object') {
|
|
27
|
+
for (var _i = 0, _Object$keys = Object.keys(data); _i < _Object$keys.length; _i++) {
|
|
28
|
+
var key = _Object$keys[_i];
|
|
29
|
+
responseFile = data[key];
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (responseFile) {
|
|
34
|
+
var getFileDownloadUrl = service && service.common && service.common.getFileDownloadUrl;
|
|
35
|
+
getFileDownloadUrl && getFileDownloadUrl().then(function (url) {
|
|
36
|
+
window.open(url + '&id=' + responseFile.attachmentId + '&type=AttachmentDemo').opener = null;
|
|
37
|
+
});
|
|
38
|
+
} else if (file.url) {
|
|
39
|
+
window.open(file.url).opener = null;
|
|
40
|
+
} else {
|
|
41
|
+
throw new Error('[tiny Error][FileUpload]file.url must not be empty');
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export var picturefilePreview = function picturefilePreview(state) {
|
|
46
|
+
return function (index) {
|
|
47
|
+
state.startPostion = index;
|
|
48
|
+
state.shows = true;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export var getDeleteData = function getDeleteData(emit) {
|
|
52
|
+
return function (data) {
|
|
53
|
+
emit('remove', data);
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { parsePercentage, handleClick, picturefilePreview, getDeleteData, downloadFile } from './index';
|
|
2
|
+
import { downloadFile as edmDownloadFile, getToken } from '@opentiny/vue-renderless/file-upload';
|
|
3
|
+
export var api = ['t', 'state', 'parsePercentage', 'handleClick', 'handlePreview', 'picturefilePreview', 'getDeleteData', 'downloadFile'];
|
|
4
|
+
export var renderless = function renderless(props, _ref, _ref2, _ref3) {
|
|
5
|
+
var reactive = _ref.reactive;
|
|
6
|
+
var t = _ref2.t,
|
|
7
|
+
parent = _ref2.parent,
|
|
8
|
+
tinyMode = _ref2.mode,
|
|
9
|
+
emit = _ref2.emit,
|
|
10
|
+
service = _ref2.service;
|
|
11
|
+
var Modal = _ref3.Modal;
|
|
12
|
+
var mode = props._mode || parent.$mode || (tinyMode ? tinyMode.value ? tinyMode.value : 'pc' : 'pc');
|
|
13
|
+
var state = reactive({
|
|
14
|
+
focusing: false,
|
|
15
|
+
shows: false,
|
|
16
|
+
startPostion: 0,
|
|
17
|
+
screenType: mode === 'pc' ? false : true
|
|
18
|
+
});
|
|
19
|
+
parent.getToken = getToken({
|
|
20
|
+
constants: parent.$constants,
|
|
21
|
+
props: parent,
|
|
22
|
+
state: parent.state,
|
|
23
|
+
t: t,
|
|
24
|
+
Modal: Modal
|
|
25
|
+
});
|
|
26
|
+
var api = {
|
|
27
|
+
state: state,
|
|
28
|
+
getDeleteData: getDeleteData(emit),
|
|
29
|
+
parsePercentage: parsePercentage(),
|
|
30
|
+
downloadFile: downloadFile(service),
|
|
31
|
+
picturefilePreview: picturefilePreview(state),
|
|
32
|
+
edmDownloadFile: edmDownloadFile({
|
|
33
|
+
api: parent,
|
|
34
|
+
constants: parent.$constants,
|
|
35
|
+
props: parent,
|
|
36
|
+
service: service,
|
|
37
|
+
state: parent.state
|
|
38
|
+
})
|
|
39
|
+
};
|
|
40
|
+
Object.assign(api, {
|
|
41
|
+
handleClick: handleClick({
|
|
42
|
+
props: props,
|
|
43
|
+
api: api,
|
|
44
|
+
parent: parent
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
return api;
|
|
48
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export var getUserHref = function getUserHref(_ref) {
|
|
2
|
+
var api = _ref.api,
|
|
3
|
+
props = _ref.props;
|
|
4
|
+
return function () {
|
|
5
|
+
var href = 'javascript:;';
|
|
6
|
+
if (!props.isNewImMode) {
|
|
7
|
+
var data = props.data;
|
|
8
|
+
var userDescription = data.userDescription ? data.userDescription.toLocaleLowerCase() : '';
|
|
9
|
+
href = 'javascript:;';
|
|
10
|
+
}
|
|
11
|
+
return href;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getUserHref } from './index';
|
|
2
|
+
export var api = ['show', 'getUserHref'];
|
|
3
|
+
export var renderless = function renderless(props, _ref) {
|
|
4
|
+
var reactive = _ref.reactive,
|
|
5
|
+
ref = _ref.ref;
|
|
6
|
+
var state = reactive({
|
|
7
|
+
initialized: false
|
|
8
|
+
});
|
|
9
|
+
var api = {
|
|
10
|
+
state: state,
|
|
11
|
+
show: ref(false)
|
|
12
|
+
};
|
|
13
|
+
Object.assign(api, {
|
|
14
|
+
getUserHref: getUserHref({
|
|
15
|
+
api: api,
|
|
16
|
+
props: props
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
return api;
|
|
20
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export var computedStyle = function computedStyle(_ref) {
|
|
2
|
+
var state = _ref.state,
|
|
3
|
+
props = _ref.props;
|
|
4
|
+
return function () {
|
|
5
|
+
return {
|
|
6
|
+
fill: props.color,
|
|
7
|
+
color: props.color,
|
|
8
|
+
backgroundColor: props.backgroundColor,
|
|
9
|
+
backgroundImage: /^(image)$/.test(props.type) && state.internalValue ? "url(".concat(state.internalValue, ")") : 'none'
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export var computedMessage = function computedMessage(_ref2) {
|
|
14
|
+
var props = _ref2.props;
|
|
15
|
+
return function () {
|
|
16
|
+
var result = '';
|
|
17
|
+
var total = Math.floor(props.messageTotal);
|
|
18
|
+
if (props.messageType === 'details' && !isNaN(total) && total > 0) {
|
|
19
|
+
result = total;
|
|
20
|
+
if (props.messageUpperLimit && total > props.messageUpperLimit) {
|
|
21
|
+
result = "".concat(props.messageUpperLimit, "+");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export var computedFontSize = function computedFontSize(_ref3) {
|
|
28
|
+
var props = _ref3.props,
|
|
29
|
+
state = _ref3.state;
|
|
30
|
+
return function () {
|
|
31
|
+
var fontSize = '';
|
|
32
|
+
if (props.type === 'label' && state.label && !props.min) {
|
|
33
|
+
var length = state.label.length;
|
|
34
|
+
var sizeMap = {
|
|
35
|
+
1: '40px',
|
|
36
|
+
2: '30px',
|
|
37
|
+
3: '22px',
|
|
38
|
+
4: '20px',
|
|
39
|
+
5: '18px',
|
|
40
|
+
6: '16px'
|
|
41
|
+
};
|
|
42
|
+
fontSize = sizeMap[length];
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
fontSize: fontSize
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export var computedLabel = function computedLabel(_ref4) {
|
|
50
|
+
var state = _ref4.state,
|
|
51
|
+
props = _ref4.props;
|
|
52
|
+
return function () {
|
|
53
|
+
return props.min ? state.internalValue.substr(0, 2) : state.internalValue.substr(0, 6);
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export var getInternalValue = function getInternalValue(_ref5) {
|
|
57
|
+
var props = _ref5.props;
|
|
58
|
+
return function () {
|
|
59
|
+
if (props.modelValue === null) {
|
|
60
|
+
var result = '';
|
|
61
|
+
if (props.type === 'icon') {
|
|
62
|
+
result = 'icon-user';
|
|
63
|
+
} else if (props.type === 'label') {
|
|
64
|
+
result = 'U';
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
} else {
|
|
68
|
+
return props.modelValue;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
};
|