@opentiny/vue-renderless 3.9.3 → 3.10.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.
Files changed (197) hide show
  1. package/action-sheet/vue.js +25 -2
  2. package/anchor/index.js +3 -3
  3. package/anchor/vue.js +7 -1
  4. package/area/index.js +4 -4
  5. package/button/vue.js +4 -2
  6. package/button-group/index.js +8 -1
  7. package/button-group/vue.js +5 -10
  8. package/calendar/index.js +14 -14
  9. package/calendar-bar/index.js +3 -3
  10. package/carousel-item/index.js +1 -1
  11. package/cascader/vue.js +1 -1
  12. package/cascader-mobile/index.js +299 -0
  13. package/cascader-mobile/vue.js +102 -0
  14. package/cascader-panel/store.js +3 -1
  15. package/chart-boxplot/index.js +0 -1
  16. package/chart-core/deps/constants.js +20 -2
  17. package/chart-core/index.js +9 -1
  18. package/chart-core/modules/extend.js +14 -1
  19. package/chart-gauge/index.js +3 -1
  20. package/chart-graph/index.js +3 -1
  21. package/chart-map/index.js +11 -1
  22. package/chart-scatter/index.js +10 -2
  23. package/chart-waterfall/index.js +4 -1
  24. package/checkbox/index.js +8 -16
  25. package/checkbox/vue.js +7 -9
  26. package/column-list-item/vue.js +10 -1
  27. package/common/bigInt.js +4 -11
  28. package/common/date.js +2 -2
  29. package/common/deps/ResizeObserver.js +3 -1
  30. package/common/deps/date-util.js +9 -1
  31. package/common/deps/date.js +18 -5
  32. package/common/deps/fastdom/async.js +41 -0
  33. package/common/deps/fastdom/index.js +9 -0
  34. package/common/deps/fastdom/sandbox.js +53 -0
  35. package/common/deps/fastdom/singleton.js +80 -0
  36. package/common/deps/fullscreen/screenfull.js +16 -2
  37. package/common/deps/memorize.js +3 -3
  38. package/common/deps/popup-manager.js +0 -1
  39. package/common/deps/requestAnimationFrame.js +1 -1
  40. package/common/deps/throttle.js +2 -2
  41. package/common/deps/tree-model/node.js +23 -11
  42. package/common/deps/tree-model/tree-store.js +28 -7
  43. package/common/deps/vue-popper.js +14 -2
  44. package/common/deps/vue-popup.js +16 -23
  45. package/common/index.js +7 -35
  46. package/common/runtime.js +1 -1
  47. package/common/validate/rules/type.js +3 -1
  48. package/credit-card-form/vue.js +2 -2
  49. package/date-panel/index.js +35 -31
  50. package/date-panel/vue.js +12 -12
  51. package/date-picker/index.js +9 -5
  52. package/date-picker/vue.js +20 -8
  53. package/date-picker-mobile/index.js +3 -3
  54. package/date-range/index.js +91 -19
  55. package/date-range/vue.js +19 -11
  56. package/date-table/index.js +39 -6
  57. package/date-table/vue.js +2 -2
  58. package/dept/index.js +1 -1
  59. package/detail-page/vue.js +9 -1
  60. package/dialog-box/index.js +11 -2
  61. package/dialog-box/vue.js +30 -6
  62. package/dialog-select/index.js +27 -5
  63. package/dialog-select/vue.js +11 -4
  64. package/drop-roles/index.js +3 -1
  65. package/dropdown/index.js +28 -7
  66. package/dropdown/vue.js +12 -7
  67. package/dropdown-item/index.js +9 -1
  68. package/dropdown-item/mf.js +3 -3
  69. package/dropdown-item/vue.js +12 -10
  70. package/dropdown-menu/index.js +13 -14
  71. package/dropdown-menu/vue.js +8 -7
  72. package/espace/vue.js +9 -1
  73. package/fall-menu/vue.js +12 -1
  74. package/file-upload/index.js +137 -89
  75. package/file-upload/vue.js +24 -14
  76. package/filter/index.js +1 -1
  77. package/filter/vue.js +1 -3
  78. package/floating-button/index.js +73 -0
  79. package/floating-button/vue.js +35 -0
  80. package/form/index.js +13 -4
  81. package/form/vue.js +7 -2
  82. package/form-item/index.js +4 -1
  83. package/form-item/vue.js +6 -3
  84. package/fullscreen/vue.js +24 -3
  85. package/grid/plugins/exportExcel.js +54 -8
  86. package/grid/static/base/helperGetHGSKeys.js +1 -4
  87. package/grid/utils/common.js +15 -11
  88. package/grid/utils/dom.js +5 -1
  89. package/guide/index.js +2 -3
  90. package/hrapprover/index.js +3 -1
  91. package/index-bar/vue.js +8 -1
  92. package/input/index.js +1 -11
  93. package/input/vue.js +6 -12
  94. package/ip-address/index.js +4 -11
  95. package/ip-address/vue.js +8 -1
  96. package/link-menu/vue.js +22 -2
  97. package/locales/index.js +4 -2
  98. package/logon-user/index.js +3 -1
  99. package/logout/index.js +6 -2
  100. package/milestone/vue.js +1 -1
  101. package/mini-picker/index.js +12 -10
  102. package/mini-picker/vue.js +10 -10
  103. package/modal/index.js +5 -3
  104. package/modal/vue.js +4 -2
  105. package/month-range/index.js +18 -18
  106. package/month-range/vue.js +16 -4
  107. package/month-table/index.js +7 -3
  108. package/multi-select/vue.js +1 -9
  109. package/nav-menu/index.js +33 -4
  110. package/nav-menu/vue.js +9 -1
  111. package/notify/vue.js +12 -1
  112. package/numeric/vue.js +6 -2
  113. package/option/index.js +10 -2
  114. package/option/vue.js +20 -9
  115. package/option-group/index.js +3 -1
  116. package/package.json +2 -1
  117. package/picker/index.js +88 -17
  118. package/picker/vue.js +42 -17
  119. package/picker-column/index.js +6 -6
  120. package/picker-column/vue.js +5 -5
  121. package/popconfirm/vue.js +3 -1
  122. package/popeditor/index.js +55 -13
  123. package/popeditor/vue.js +23 -7
  124. package/popover/vue.js +1 -2
  125. package/popup/vue.js +15 -2
  126. package/progress/index.js +9 -7
  127. package/progress/vue.js +12 -4
  128. package/pull-refresh/vue.js +10 -1
  129. package/query-builder/index.js +9 -0
  130. package/query-builder/vue.js +18 -0
  131. package/radio/vue.js +3 -1
  132. package/radio-button/vue.js +1 -1
  133. package/rate/index.js +8 -2
  134. package/rate/vue.js +27 -4
  135. package/recycle-scroller/index.js +0 -1
  136. package/scrollbar/vue-bar.js +18 -2
  137. package/search/index.js +12 -5
  138. package/search/vue.js +7 -5
  139. package/select/index.js +567 -283
  140. package/select/vue.js +141 -85
  141. package/select-dropdown/vue.js +8 -6
  142. package/select-mobile/index.js +26 -13
  143. package/select-mobile/vue.js +14 -5
  144. package/select-view/index.js +5 -21
  145. package/select-view/vue.js +0 -3
  146. package/selected-box/index.js +3 -1
  147. package/slider/index.js +5 -5
  148. package/slider/vue.js +16 -0
  149. package/slider-button/index.js +41 -0
  150. package/slider-button/vue.js +36 -0
  151. package/slider-button-group/slide-button.js +142 -0
  152. package/slider-button-group/vue.js +52 -0
  153. package/steps/slide-bar.js +0 -1
  154. package/switch/index.js +1 -1
  155. package/switch/vue.js +1 -1
  156. package/tab-bar/index.js +8 -6
  157. package/tab-nav/index.js +19 -13
  158. package/tab-nav/vue.js +10 -9
  159. package/tabs/index.js +21 -17
  160. package/tabs/vue.js +1 -4
  161. package/tag/vue.js +2 -1
  162. package/tag-group/index.js +23 -10
  163. package/tag-group/vue.js +5 -4
  164. package/time/index.js +8 -8
  165. package/time/vue.js +9 -9
  166. package/time-line/index.js +24 -2
  167. package/time-line/vue.js +30 -4
  168. package/time-panel/index.js +2 -2
  169. package/time-panel/vue.js +2 -2
  170. package/time-range/index.js +24 -21
  171. package/time-range/vue.js +26 -16
  172. package/time-spinner/index.js +32 -21
  173. package/time-spinner/vue.js +37 -12
  174. package/timeline-item/index.js +77 -0
  175. package/timeline-item/vue.js +44 -0
  176. package/toggle-menu/vue.js +0 -1
  177. package/tooltip/index.js +11 -12
  178. package/tooltip/vue.js +11 -1
  179. package/top-box/vue.js +13 -1
  180. package/tree/index.js +228 -15
  181. package/tree/vue.js +119 -15
  182. package/tree-menu/index.js +35 -0
  183. package/tree-menu/vue.js +27 -5
  184. package/tree-node/index.js +75 -10
  185. package/tree-node/vue.js +45 -23
  186. package/upload/index.js +90 -49
  187. package/upload/vue.js +22 -10
  188. package/upload-dragger/index.js +4 -3
  189. package/upload-list/index.js +67 -16
  190. package/upload-list/vue.js +26 -9
  191. package/user/index.js +7 -4
  192. package/user-link/index.js +2 -1
  193. package/wizard/index.js +4 -1
  194. package/wizard/vue.js +19 -2
  195. package/year-range/index.js +1 -1
  196. package/year-range/vue.js +3 -3
  197. package/year-table/index.js +2 -2
@@ -17,7 +17,8 @@ import {
17
17
  clickWrapper,
18
18
  getItemStyle,
19
19
  handleClick,
20
- computedGetIcon
20
+ computedGetIcon,
21
+ getTip
21
22
  } from "./index";
22
23
  const api = [
23
24
  "state",
@@ -33,9 +34,10 @@ const api = [
33
34
  "opened",
34
35
  "close",
35
36
  "closed",
36
- "handleClick"
37
+ "handleClick",
38
+ "getTip"
37
39
  ];
38
- const initState = ({ reactive, computed, api: api2, props, parent, dropdownMenu }) => {
40
+ const initState = ({ reactive, computed, api: api2, props, parent, dropdownMenuVm }) => {
39
41
  const state = reactive({
40
42
  sort: props.modelValue,
41
43
  transition: true,
@@ -50,9 +52,8 @@ const initState = ({ reactive, computed, api: api2, props, parent, dropdownMenu
50
52
  itemStyle: computed(() => api2.getItemStyle()),
51
53
  activeColor: computed(() => parent.activeColor),
52
54
  closeOnClickOverlay: computed(() => parent.closeOnClickOverlay),
53
- children: [],
54
- textField: (dropdownMenu == null ? void 0 : dropdownMenu.textField) || props.textField,
55
- popperClass: (dropdownMenu == null ? void 0 : dropdownMenu.popperClass) || "",
55
+ textField: (dropdownMenuVm == null ? void 0 : dropdownMenuVm.textField) || props.textField,
56
+ popperClass: (dropdownMenuVm == null ? void 0 : dropdownMenuVm.popperClass) || "",
56
57
  getIcon: computed(() => api2.computedGetIcon())
57
58
  });
58
59
  return state;
@@ -77,17 +78,18 @@ const initApi = ({ api: api2, state, emit, props, parent, dispatch, vm, constant
77
78
  bindScroll: bindScroll({ api: api2, parent }),
78
79
  confirm: confirm({ emit, props, state }),
79
80
  handleClick: handleClick({ props, dispatch, vm, emit }),
80
- computedGetIcon: computedGetIcon({ constants, designConfig })
81
+ computedGetIcon: computedGetIcon({ constants, designConfig }),
82
+ getTip: getTip({ props, vm })
81
83
  });
82
84
  };
83
85
  const renderless = (props, { computed, reactive, watch, inject }, { parent, emit, vm, dispatch, mode, constants, designConfig }) => {
84
86
  const api2 = {};
85
- const dropdownMenu = inject("dropdownMenu", null);
87
+ const dropdownMenuVm = inject("dropdownMenuVm", null);
86
88
  if (mode === "mobile") {
87
- dropdownMenu.state.children = [...dropdownMenu.state.children, vm];
89
+ dropdownMenuVm.state.children = [...dropdownMenuVm.state.children, vm];
88
90
  }
89
91
  parent = parent.$parent;
90
- const state = initState({ reactive, computed, api: api2, props, parent, dropdownMenu });
92
+ const state = initState({ reactive, computed, api: api2, props, parent, dropdownMenuVm });
91
93
  initApi({ api: api2, state, emit, props, parent, dispatch, vm, constants, designConfig });
92
94
  watch(() => state.showPopup, api2.bindScroll);
93
95
  return api2;
@@ -27,11 +27,11 @@ const toggleItem = (state) => (active, item) => {
27
27
  });
28
28
  }
29
29
  };
30
- const updateOffset = ({ props, state, refs }) => () => {
31
- if (!refs.menu) {
30
+ const updateOffset = ({ props, state, vm }) => () => {
31
+ if (!vm.$refs.menu) {
32
32
  return;
33
33
  }
34
- const rect = refs.menu.getBoundingClientRect();
34
+ const rect = vm.$refs.menu.getBoundingClientRect();
35
35
  if (props.direction === "down") {
36
36
  state.offset = rect.bottom;
37
37
  } else {
@@ -64,10 +64,9 @@ const getScroller = (el, root) => {
64
64
  }
65
65
  return root;
66
66
  };
67
- const useVuePopper = ({ api, props, hooks, instance, state }) => {
68
- const { inject, nextTick, onBeforeUnmount, onDeactivated, onMounted, reactive, toRefs, watch } = hooks;
67
+ const useVuePopper = ({ api, props, hooks, instance, state, dropdownVm }) => {
68
+ const { nextTick, onBeforeUnmount, onDeactivated, onMounted, reactive, toRefs, watch } = hooks;
69
69
  const { emit, refs, slots, vm, parent } = instance;
70
- const dropdown = inject("dropdown");
71
70
  const popper = userPopper({
72
71
  emit,
73
72
  nextTick,
@@ -85,11 +84,11 @@ const useVuePopper = ({ api, props, hooks, instance, state }) => {
85
84
  watch
86
85
  });
87
86
  onMounted(() => {
88
- dropdown.popperElm = popper.popperElm.value = vm.$el;
89
- popper.referenceElm.value = dropdown.$el;
90
- dropdown.initDomOperation();
91
- if (dropdown.inheritWidth) {
92
- dropdown.popperElm.style.minWidth = dropdown.$el.clientWidth + "px";
87
+ dropdownVm.popperElm = popper.popperElm.value = vm.$el;
88
+ nextTick(() => popper.referenceElm.value = dropdownVm.$el);
89
+ !props.multiStage && dropdownVm.initDomOperation();
90
+ if (dropdownVm.inheritWidth) {
91
+ dropdownVm.popperElm.style.minWidth = dropdownVm.$el.clientWidth + "px";
93
92
  }
94
93
  });
95
94
  onBeforeUnmount(() => {
@@ -98,7 +97,7 @@ const useVuePopper = ({ api, props, hooks, instance, state }) => {
98
97
  popper.referenceElm = null;
99
98
  });
100
99
  api.doDestroy = popper.doDestroy;
101
- state.size = dropdown.size;
100
+ state.size = dropdownVm.size;
102
101
  state.showPopper = popper.showPopper.value;
103
102
  parent.$on("updatePopper", () => {
104
103
  if (state.showPopper) {
@@ -130,10 +129,10 @@ const mounted = ({ api, parent, state }) => () => {
130
129
  state.showContent = showContent;
131
130
  });
132
131
  };
133
- const handleMenuItemClick = ({ state, dispatch }) => (itemData, instance, label, showContent) => {
132
+ const handleMenuItemClick = ({ state, dispatch }) => (itemData, instance, label, showContent, isDisabled) => {
134
133
  state.label = label;
135
134
  state.showContent = showContent;
136
- dispatch("TinyDropdown", "current-item-click", [itemData, instance]);
135
+ dispatch("TinyDropdown", "current-item-click", [itemData, instance, isDisabled]);
137
136
  };
138
137
  const handleMouseenter = ({ emit }) => ($event) => {
139
138
  emit("mouseenter", $event);
@@ -21,8 +21,8 @@ const api = [
21
21
  ];
22
22
  const renderless = (props, hooks, instance) => {
23
23
  const api2 = {};
24
- const { reactive, provide, onMounted } = hooks;
25
- const { nextTick, mode, vm, parent, dispatch, emit, refs } = instance;
24
+ const { reactive, provide, onMounted, inject } = hooks;
25
+ const { nextTick, mode, vm, parent, dispatch, emit } = instance;
26
26
  const state = reactive({
27
27
  offset: 0,
28
28
  scroller: null,
@@ -34,20 +34,21 @@ const renderless = (props, hooks, instance) => {
34
34
  selected: false,
35
35
  selectedIndex: -1
36
36
  });
37
- provide("dropdownMenu", vm);
37
+ provide("dropdownMenuVm", vm);
38
38
  provide("multiStage", props.multiStage);
39
+ const dropdownVm = inject("dropdownVm");
39
40
  if (mode === "mobile") {
40
41
  nextTick(() => {
41
- state.scroller = getScroller(refs.menu);
42
+ state.scroller = getScroller(vm.$refs.menu);
42
43
  });
43
44
  } else {
44
- useVuePopper({ api: api2, hooks, props, instance, state });
45
+ useVuePopper({ api: api2, hooks, props, instance, state, dropdownVm });
45
46
  }
46
47
  Object.assign(api2, {
47
48
  state,
48
49
  toggleItem: toggleItem(state),
49
- clickOutside: clickOutside({ props, refs, state }),
50
- updateOffset: updateOffset({ props, state, refs }),
50
+ clickOutside: clickOutside({ props, state }),
51
+ updateOffset: updateOffset({ props, state, vm }),
51
52
  mounted: mounted({ api: api2, parent, state }),
52
53
  handleMouseenter: handleMouseenter({ emit }),
53
54
  handleMouseleave: handleMouseleave({ emit }),
package/espace/vue.js CHANGED
@@ -1,7 +1,15 @@
1
1
  import "../chunk-PKUHTIDK.js";
2
2
  import { init } from "../common/deps/eSpaceCtrl";
3
3
  import { getUserHref, getUserTitle, doUserAction, initEspaceLink, openEspace, testUID, soundEspace } from "./index";
4
- const api = ["getUserHref", "getUserTitle", "doUserAction", "initEspaceLink", "openEspace", "testUID", "soundEspace"];
4
+ const api = [
5
+ "getUserHref",
6
+ "getUserTitle",
7
+ "doUserAction",
8
+ "initEspaceLink",
9
+ "openEspace",
10
+ "testUID",
11
+ "soundEspace"
12
+ ];
5
13
  const renderless = (props, { reactive }, { service }) => {
6
14
  const api2 = {};
7
15
  const { setting = {} } = service || {};
package/fall-menu/vue.js CHANGED
@@ -1,5 +1,16 @@
1
1
  import "../chunk-PKUHTIDK.js";
2
- import { mouseover, mouseout, computePx, reRender, arrowClick, overContent, mounted, beforeDestroy, computeLeft, computeData } from "./index";
2
+ import {
3
+ mouseover,
4
+ mouseout,
5
+ computePx,
6
+ reRender,
7
+ arrowClick,
8
+ overContent,
9
+ mounted,
10
+ beforeDestroy,
11
+ computeLeft,
12
+ computeData
13
+ } from "./index";
3
14
  const api = ["state", "fall", "arrowClick", "mouseover", "mouseout", "overContent", "reRender", "left"];
4
15
  const initState = ({ reactive, computed, api: api2, props }) => {
5
16
  const state = reactive({
@@ -11,12 +11,12 @@ let initTokenPromise = null;
11
11
  const noopFnCreator = (fn, propName) => {
12
12
  const noFn = () => {
13
13
  if (propName) {
14
- return Promise.reject(new Error(`[TINY Error][FileUpload] Prop ${propName} is not configured`));
14
+ return Promise.reject(
15
+ new Error(`[TINY Error][FileUpload] Prop ${propName} is mandatory when the framework service is not used`)
16
+ );
15
17
  } else {
16
18
  return Promise.reject(
17
- new Error(
18
- "[TINY Error][FileUpload] This component depends on @opentiny/vue-service, Currently unable to generate a default gateway, please set a value for the action"
19
- )
19
+ new Error("[TINY Error][FileUpload] Prop action is mandatory when the framework service is not used")
20
20
  );
21
21
  }
22
22
  };
@@ -56,8 +56,11 @@ const initService = ({ props, service }) => {
56
56
  };
57
57
  };
58
58
  const computedUploadDisabled = ({ props, state }) => () => props.disabled || (state.elForm || {}).disabled;
59
- const computedUploadingSize = ({ state, constants }) => () => state.uploadingFiles.reduce((total, file) => total + file.status !== constants.FILE_STATUS.FAIL ? file.size : 0, 0);
60
- const watchListType = ({ constants, state }) => (type) => {
59
+ const computedUploadingSize = ({ state, constants }) => () => state.uploadingFiles.reduce(
60
+ (total, file) => total + file.status !== constants.FILE_STATUS.FAIL ? file.size : 0,
61
+ 0
62
+ );
63
+ const watchListType = ({ constants, state, api }) => (type) => {
61
64
  if ([
62
65
  constants.LIST_TYPE.PICTURE_CARD,
63
66
  constants.LIST_TYPE.PICTURE,
@@ -65,6 +68,7 @@ const watchListType = ({ constants, state }) => (type) => {
65
68
  constants.LIST_TYPE.DRAG_SINGLE
66
69
  ].includes(type)) {
67
70
  state.uploadFiles = state.uploadFiles.map((file) => {
71
+ file.type = api.getFileSourceType({ file });
68
72
  if (!file.url && file.raw) {
69
73
  try {
70
74
  file.url = URL.createObjectURL(file.raw);
@@ -76,11 +80,12 @@ const watchListType = ({ constants, state }) => (type) => {
76
80
  });
77
81
  }
78
82
  };
79
- const watchFileList = ({ constants, state, props }) => (fileList) => {
80
- let uploadFiles = fileList && fileList.map((item) => {
81
- item.uid = item.uid || Date.now() + state.tempIndex++;
82
- item.status = item.status || constants.FILE_STATUS.SUCESS;
83
- return item;
83
+ const watchFileList = ({ constants, state, props, api }) => (fileList) => {
84
+ let uploadFiles = fileList && fileList.map((file) => {
85
+ file.uid = file.uid || Date.now() + state.tempIndex++;
86
+ file.status = file.status || constants.FILE_STATUS.SUCESS;
87
+ file.type = api.getFileSourceType({ file });
88
+ return file;
84
89
  });
85
90
  if ([constants.LIST_TYPE.PICTURE_SINGLE, constants.LIST_TYPE.DRAG_SINGLE].includes(props.listType)) {
86
91
  uploadFiles = uploadFiles.slice(0, 1);
@@ -114,7 +119,16 @@ const onBeforeIsPromise = ({ before, rawFile, file, doUpload, autoRemove, api })
114
119
  }
115
120
  );
116
121
  };
117
- const getFileType = ({ file }) => file.name && file.name.split(".")[file.name.split(".").length - 1].toLowerCase();
122
+ const getFileType = ({ file }) => {
123
+ const { name, url } = file;
124
+ let fileType = "";
125
+ if (name && /\.[^.]+$/.test(name)) {
126
+ fileType = name.split(".")[name.split(".").length - 1].toLowerCase();
127
+ } else if (url && /\.[.]+$/.test(url)) {
128
+ fileType = url.split(".")[url.split(".").length - 1].toLowerCase();
129
+ }
130
+ return fileType;
131
+ };
118
132
  const remove = ({ api, file, autoRemove }) => {
119
133
  if (autoRemove) {
120
134
  const rawFile = file.raw;
@@ -134,18 +148,27 @@ const beforeUpload = ({ props, api, Modal, constants, t, state }) => (file, auto
134
148
  });
135
149
  }
136
150
  if (file) {
151
+ let isValid = true;
137
152
  const accept = state.isEdm ? state.accept : props.accept;
153
+ const types = constants.FILE_TYPE[state.triggerClickType.toUpperCase()];
138
154
  const fileType = getFileType({ file });
139
- const isExist = accept && accept.split(",").some((type) => {
140
- if (type.toLowerCase() === constants.IMAGE_TYPE) {
141
- return constants.IMAGE_TYPES.includes(fileType.toLowerCase());
142
- }
143
- return new RegExp(type.trim(), "i").test(`.${fileType}` || file.raw.type);
144
- });
145
- if (accept && !isExist) {
155
+ if (accept) {
156
+ const isExist = accept.split(",").some((type) => {
157
+ if (type.toLowerCase() === constants.IMAGE_TYPE) {
158
+ return constants.FILE_TYPE.PICTURE.split("/").includes(fileType);
159
+ }
160
+ return new RegExp(`(${type.trim()})$`, "i").test(file.name);
161
+ });
162
+ !isExist && (isValid = false);
163
+ }
164
+ if (state.triggerClickType && types) {
165
+ const isExist = types.split("/").includes(fileType);
166
+ !isExist && (isValid = false);
167
+ }
168
+ if (!isValid) {
146
169
  remove({ api, file, autoRemove });
147
170
  return Modal.message({
148
- message: t("ui.fileUpload.notSupport"),
171
+ message: t(constants.EDM.notSupport, { format: fileType }),
149
172
  status: "warning"
150
173
  });
151
174
  }
@@ -196,10 +219,10 @@ const calcFileForMobile = (rawFile, file) => {
196
219
  file.fileType = rawFile.name.substring(fileName + 1, fileNameLen);
197
220
  const size = rawFile.size / 1024;
198
221
  if (size < 1024) {
199
- file.size = Math.round(size * 10 ** 1) / 10 ** 1 + "KB";
222
+ file.size = Math.round(size * Math.pow(10, 1)) / Math.pow(10, 1) + "KB";
200
223
  } else {
201
224
  const fileSize = size / 1024;
202
- file.size = Math.round(fileSize * 10 ** 1) / 10 ** 1 + "MB";
225
+ file.size = Math.round(fileSize * Math.pow(10, 1)) / Math.pow(10, 1) + "MB";
203
226
  }
204
227
  };
205
228
  const properFileSize = ({ props, state, constants, Modal, t }) => (file) => {
@@ -214,7 +237,7 @@ const properFileSize = ({ props, state, constants, Modal, t }) => (file) => {
214
237
  if (state.isEdm || !state.isEdm && Array.isArray(props.fileSize) && props.fileSize[1]) {
215
238
  if (file.size > maxSize * 1024 * 1024) {
216
239
  Modal.message({
217
- message: `${file.name} ${t(constants.EDM.EXCEED)} ${maxSize} MB`,
240
+ message: t(constants.EDM.EXCEED, { maxSize }),
218
241
  status: "warning"
219
242
  });
220
243
  return false;
@@ -241,6 +264,7 @@ const addFileToList = ({ api, constants, emit, props, state, mode }) => (rawFile
241
264
  !reUpload && (rawFile.uid = Date.now() + state.tempIndex++);
242
265
  let file = { status: constants.FILE_STATUS.READY, name: rawFile.name, size: rawFile.size };
243
266
  Object.assign(file, { percentage: 0, uid: rawFile.uid, raw: rawFile, response: {} });
267
+ file.type = api.getFileSourceType({ file });
244
268
  if (state.isEdm) {
245
269
  let fileBase = { serverName: "", docRelativePath: "", docId: "", docVersion: "", cacheSign: rawFile.uid };
246
270
  file = Object.assign(file, fileBase);
@@ -253,7 +277,7 @@ const addFileToList = ({ api, constants, emit, props, state, mode }) => (rawFile
253
277
  constants.LIST_TYPE.PICTURE,
254
278
  constants.LIST_TYPE.PICTURE_SINGLE,
255
279
  constants.LIST_TYPE.DRAG_SINGLE
256
- ].includes(props.listType) && !state.isHwh5) {
280
+ ].includes(props.listType)) {
257
281
  try {
258
282
  if (state.isHwh5) {
259
283
  file.url = rawFile.filePath;
@@ -338,21 +362,18 @@ const handleHwh5Files = (files) => {
338
362
  return files.map((file) => {
339
363
  if (file instanceof File)
340
364
  return file;
365
+ let url;
341
366
  let f = {};
342
367
  if (isObject(file)) {
343
- const { fileName, fileSize, filePath } = file;
344
- f = __spreadProps(__spreadValues({}, file), {
345
- name: fileName,
346
- size: fileSize,
347
- webkitRelativePath: filePath
348
- });
368
+ url = file.url;
369
+ f = file;
349
370
  } else {
350
- const [name, index] = file.match(/[^/]*$/);
351
- const [type] = file.match(/\.[^.]*$/);
352
- const filePath = file.substring(0, index);
353
- f = { type, name, filePath, webkitRelativePath: filePath };
371
+ url = file;
354
372
  }
355
- return f;
373
+ const [name, index] = url.match(/[^/]*$/);
374
+ const [type] = url.match(/\.[^.]*$/);
375
+ const filePath = url.substring(0, index);
376
+ return __spreadProps(__spreadValues({}, f), { type, name, filePath, webkitRelativePath: filePath });
356
377
  });
357
378
  };
358
379
  const handleStart = ({ api, constants, props, state, vm }) => (rawFiles, updateId, reUpload = false) => {
@@ -362,7 +383,7 @@ const handleStart = ({ api, constants, props, state, vm }) => (rawFiles, updateI
362
383
  state.currentUploadingFileUids = [];
363
384
  rawFiles.forEach((rawFile) => api.addFileToList(rawFile, updateId, reUpload));
364
385
  const { UPLOADING, READY } = constants.FILE_STATUS;
365
- state.uploadingFiles = state.uploadFiles.filter((file) => [UPLOADING, READY].includes(file.status));
386
+ state.uploadingFiles = state.uploadFiles.filter((file) => [UPLOADING, READY].indexOf(file.status) > -1);
366
387
  if (state.isEdm && state.isSuccess) {
367
388
  rawFiles.forEach((rawFile) => {
368
389
  const file = api.getFile(rawFile);
@@ -535,6 +556,7 @@ const handleRemove = ({ api, emit, props, state, constants }) => (file, raw) =>
535
556
  file = api.getFile(raw);
536
557
  }
537
558
  let doRemove = () => {
559
+ file.status = constants.FILE_STATUS.FAIL;
538
560
  api.abort(file);
539
561
  let fileList = state.uploadFiles;
540
562
  fileList.splice(fileList.indexOf(file), 1);
@@ -558,7 +580,7 @@ const handleRemove = ({ api, emit, props, state, constants }) => (file, raw) =>
558
580
  };
559
581
  const clearUploadingFiles = ({ constants, state }) => () => {
560
582
  const { SUCESS, FAIL } = constants.FILE_STATUS;
561
- const isUploadComplete = state.uploadingFiles.every((file) => [SUCESS, FAIL].includes(file.status));
583
+ const isUploadComplete = state.uploadingFiles.every((file) => [SUCESS, FAIL].indexOf(file.status) > -1);
562
584
  if (isUploadComplete) {
563
585
  state.uploadingFiles = [];
564
586
  }
@@ -712,9 +734,14 @@ const getCalcProgress = () => (evt) => {
712
734
  progress = Math.min(progress, 100);
713
735
  return progress;
714
736
  };
715
- const modifyServiceUrlSingle = ({ constants }) => ({ file, serviceUrl, range }) => {
737
+ const modifyServiceUrlSingle = ({ state, props, constants }) => ({ file, serviceUrl, range }) => {
716
738
  if (typeof file === "object") {
717
- let tempFile = Object.assign({}, file, range);
739
+ const downloadOps = props.edm.download || {};
740
+ const paramsWhitelist = Array.isArray(downloadOps.paramsWhitelist) ? downloadOps.paramsWhitelist : [];
741
+ const downloadParamsWhitelist = state.downloadParamsWhitelist.concat(paramsWhitelist);
742
+ let tempFile = {};
743
+ downloadParamsWhitelist.forEach((key) => tempFile[key] = file[key]);
744
+ tempFile = Object.assign(tempFile, range);
718
745
  delete tempFile.docId;
719
746
  delete tempFile.docVersion;
720
747
  delete tempFile["x-download-sign"];
@@ -753,7 +780,7 @@ const validateDownloadStatus = ({ state, Modal }) => ({ downloadOps, file, isLes
753
780
  downloadOps2.fail(errRes, file2);
754
781
  }
755
782
  };
756
- if (data.data && data.data.type && data.data.type.includes("application/json")) {
783
+ if (data.data && data.data.type && data.data.type.indexOf("application/json") > -1) {
757
784
  const reader = new FileReader();
758
785
  reader.onload = (e) => {
759
786
  const errRes = JSON.parse(e.target.result);
@@ -762,7 +789,7 @@ const validateDownloadStatus = ({ state, Modal }) => ({ downloadOps, file, isLes
762
789
  reader.readAsText(data.data);
763
790
  return true;
764
791
  }
765
- if (!isLessThan17G && data.headers["content-type"].includes("application/json")) {
792
+ if (!isLessThan17G && data.headers["content-type"].indexOf("application/json") > -1) {
766
793
  const errRes = JSON.parse(String.fromCharCode.apply(null, new Uint8Array(data.data)));
767
794
  errorHandle({ state, file, errRes, Modal, downloadOps });
768
795
  return true;
@@ -1039,14 +1066,7 @@ const batchSegmentDownload = ({ state, api }) => ({ batchIndex, batches, docId,
1039
1066
  }
1040
1067
  }
1041
1068
  };
1042
- const downloadFileInner = ({ api, props, state }) => ({
1043
- batchIndex,
1044
- file,
1045
- range,
1046
- isBatch,
1047
- isChunk,
1048
- isLessThan17G
1049
- }) => {
1069
+ const downloadFileInner = ({ api, props, state }) => ({ batchIndex, file, range, isBatch, isChunk, isLessThan17G }) => {
1050
1070
  const downloadOps = props.edm.download || {};
1051
1071
  const translateFile = getTranslateFile({ api, isChunk, isLessThan17G, file, state });
1052
1072
  const handleSuccess2 = getHandleSuccess({ downloadOps, file, translateFile, isChunk, state, isLessThan17G });
@@ -1071,15 +1091,7 @@ const downloadFileInner = ({ api, props, state }) => ({
1071
1091
  const params = { downloadOps, file, calcProgress, handleSuccess: handleSuccess2, range };
1072
1092
  isBatch && api.downloadFileBatch(params);
1073
1093
  };
1074
- const afterDownload = ({ api, state }) => ({
1075
- batchIndex,
1076
- range,
1077
- data,
1078
- file,
1079
- isBatch,
1080
- isChunk,
1081
- isLessThan17G
1082
- }) => {
1094
+ const afterDownload = ({ api, state }) => ({ batchIndex, range, data, file, isBatch, isChunk, isLessThan17G }) => {
1083
1095
  if (data.status === 200) {
1084
1096
  const key = file.docId + "-" + batchIndex;
1085
1097
  const count = state.downloadBatchQueue[key];
@@ -1363,12 +1375,7 @@ const segmentUpload = ({ api, props, service, state, emit, constants, CryptoJS }
1363
1375
  });
1364
1376
  }
1365
1377
  };
1366
- const batchSegmentUpload = ({ api, constants, props, vm, state }) => ({
1367
- docId,
1368
- batchIndex,
1369
- batches,
1370
- progress
1371
- }) => {
1378
+ const batchSegmentUpload = ({ api, constants, props, vm, state }) => ({ docId, batchIndex, batches, progress }) => {
1372
1379
  if (batchIndex < batches.length && progress.file.cancelToken) {
1373
1380
  const key = docId + "-" + batchIndex;
1374
1381
  const batch = batches[batchIndex];
@@ -1403,7 +1410,7 @@ const sliceChunk = ({ state }) => (file) => {
1403
1410
  state.batchQueue[file.docId + "-0"] = 0;
1404
1411
  state.batchQueueListen[file.docId + "-0"] = 0;
1405
1412
  for (let i = 0; i < chunkSize; i++) {
1406
- if (file.records.includes(i.toString())) {
1413
+ if (file.records.indexOf(i.toString()) > -1) {
1407
1414
  continue;
1408
1415
  }
1409
1416
  const start = i * state.chunkSize;
@@ -1429,13 +1436,7 @@ const sliceChunk = ({ state }) => (file) => {
1429
1436
  }
1430
1437
  return chunkBatchArray;
1431
1438
  };
1432
- const getToken = ({ constants, props, state, t, Modal }) => ({
1433
- token,
1434
- file,
1435
- isOnlinePreview = false,
1436
- type = "",
1437
- isinit = false
1438
- }) => {
1439
+ const getToken = ({ constants, props, state, t, Modal }) => ({ token, file, isOnlinePreview = false, type = "", isinit = false }) => {
1439
1440
  if (props.edm.isExtranet && !isOnlinePreview) {
1440
1441
  state.isSuccess = true;
1441
1442
  state.accept = props.accept;
@@ -1455,7 +1456,7 @@ const getToken = ({ constants, props, state, t, Modal }) => ({
1455
1456
  return new Promise((resolve, reject) => {
1456
1457
  try {
1457
1458
  let promise;
1458
- if (isinit) {
1459
+ if (isinit && props.cacheToken) {
1459
1460
  !initTokenPromise && (initTokenPromise = token(file));
1460
1461
  promise = initTokenPromise;
1461
1462
  } else {
@@ -1569,15 +1570,12 @@ const previewFileBatch = ({ service, props, state, api }) => ({ file, resolve, o
1569
1570
  });
1570
1571
  };
1571
1572
  const getPreviewUrlSync = ({ constants, props, state }) => (file, batch) => {
1572
- const { ASPOSE, WPS } = constants.EDM.FILE_PREVIEW_TYPE;
1573
1573
  const edm = props.edm || {};
1574
1574
  const preview = edm.preview || {};
1575
1575
  const { watermark, online, bar = {}, lang } = preview;
1576
- const { filePreviewType = ASPOSE, http = false, jslibhtml, appid, baseurl } = online;
1577
- const { styles } = bar;
1578
- bar.styles = JSON.stringify(styles);
1576
+ const { webPreview = false, http = false, jslibhtml, appid, baseurl } = online;
1579
1577
  let html;
1580
- if (filePreviewType === WPS) {
1578
+ if (webPreview) {
1581
1579
  html = `${http ? "http:" : "https:"}${baseurl.replace(/\/$/, "")}/edm/projects/${appid}/web/preview`;
1582
1580
  } else {
1583
1581
  html = jslibhtml.split("?").shift();
@@ -1590,21 +1588,28 @@ const getPreviewUrlSync = ({ constants, props, state }) => (file, batch) => {
1590
1588
  const { generate, size } = file;
1591
1589
  paramsData = { generate, "EDM-Authorization": edmToken, docIndex: 1, size };
1592
1590
  } else {
1593
- paramsData = Object.assign(
1594
- {},
1595
- online,
1596
- watermark,
1597
- filePreviewType === WPS ? { "EDM-Authorization": edmToken } : { authToken: edmToken },
1598
- {
1591
+ if (webPreview) {
1592
+ const { styles } = bar;
1593
+ paramsData = Object.assign({}, watermark, {
1594
+ "EDM-Authorization": edmToken,
1595
+ lang,
1596
+ bar: window.btoa(
1597
+ JSON.stringify(__spreadProps(__spreadValues({}, bar), {
1598
+ styles: JSON.stringify(styles)
1599
+ }))
1600
+ ),
1601
+ docId: file.docId
1602
+ });
1603
+ } else {
1604
+ paramsData = Object.assign({}, online, watermark, {
1605
+ authToken: edmToken,
1599
1606
  jslibhtml: html,
1600
1607
  docId: file.docId,
1601
1608
  docVersion: file.docVersion || file.version || "V1",
1602
1609
  type: "doc",
1603
- pageNum: "1",
1604
- lang,
1605
- bar: window.btoa(JSON.stringify(bar))
1606
- }
1607
- );
1610
+ pageNum: "1"
1611
+ });
1612
+ }
1608
1613
  }
1609
1614
  for (let key in paramsData) {
1610
1615
  const val = paramsData[key];
@@ -1723,6 +1728,32 @@ const computeDocChunkSize = ({ props, state, constants }) => () => {
1723
1728
  state.docSize = docSize * 1024;
1724
1729
  state.chunkSize = chunkSize * 1024;
1725
1730
  };
1731
+ const computedSourcetype = ({ props, constants }) => () => {
1732
+ const { sourceType, listType } = props;
1733
+ let types = sourceType.split("/");
1734
+ if (listType !== constants.LIST_TYPE.PICTURE_CARD) {
1735
+ types = types.slice(0, 1);
1736
+ }
1737
+ return types;
1738
+ };
1739
+ const getFileSourceType = ({ state, props, constants }) => ({ file }) => {
1740
+ const { PICTURE_SINGLE, PICTURE_CARD } = constants.LIST_TYPE;
1741
+ const { listType } = props;
1742
+ if (![PICTURE_SINGLE, PICTURE_CARD].includes(listType))
1743
+ return;
1744
+ let type = state.types[0];
1745
+ if (file.type) {
1746
+ type = file.type;
1747
+ } else if (listType === PICTURE_CARD) {
1748
+ const { VIDEO, AUDIO, PICTURE } = constants.FILE_TYPE;
1749
+ const { SOURCE_VIDEO, SOURCE_AUDIO, SOURCE_PICTURE } = constants.SOURCE_TYPE;
1750
+ const matchs = { [VIDEO]: SOURCE_VIDEO, [AUDIO]: SOURCE_AUDIO, [PICTURE]: SOURCE_PICTURE };
1751
+ const fileType = getFileType({ file });
1752
+ const key = Object.keys(matchs).find((key2) => key2.split("/").includes(fileType));
1753
+ matchs[key] && (type = matchs[key]);
1754
+ }
1755
+ return type;
1756
+ };
1726
1757
  const updateFile = ({ constants, vm }) => (file) => {
1727
1758
  vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].handleUpdate(file);
1728
1759
  };
@@ -1735,6 +1766,20 @@ const handleChange = ({ vm, constants }) => (file) => {
1735
1766
  vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].handleChange({ target: { files } });
1736
1767
  }
1737
1768
  };
1769
+ const handleTriggerClick = ({ vm, state, constants, props, emit }) => ($event, type) => {
1770
+ const { PICTURE_CARD, PICTURE_SINGLE } = constants.LIST_TYPE;
1771
+ const { isHwh5 } = state;
1772
+ const { listType } = props;
1773
+ if (![PICTURE_CARD, PICTURE_SINGLE].includes(listType)) {
1774
+ type = "";
1775
+ }
1776
+ state.triggerClickType = type;
1777
+ if (listType === PICTURE_CARD && isHwh5) {
1778
+ vm.$refs[constants.UPLOAD_LIST_INNER].$refs[constants.UPLOAD_LIST_INNER_TEMPLATE].chooseFile(type);
1779
+ return;
1780
+ }
1781
+ emit("trigger-click", $event, type);
1782
+ };
1738
1783
  const onBeforeDestroy = (state) => () => {
1739
1784
  state.uploadFiles.forEach((file) => {
1740
1785
  if (file.url && file.url.indexOf("blob:") === 0) {
@@ -1761,6 +1806,7 @@ export {
1761
1806
  clearFiles,
1762
1807
  clearUploadingFiles,
1763
1808
  computeDocChunkSize,
1809
+ computedSourcetype,
1764
1810
  computedUploadDisabled,
1765
1811
  computedUploadingSize,
1766
1812
  createDownloadCancelToken,
@@ -1774,6 +1820,7 @@ export {
1774
1820
  getDownloadFileInfo,
1775
1821
  getFile,
1776
1822
  getFileHash,
1823
+ getFileSourceType,
1777
1824
  getFileUploadUrl,
1778
1825
  getFormData,
1779
1826
  getKiaScanTip,
@@ -1788,6 +1835,7 @@ export {
1788
1835
  handleRemove,
1789
1836
  handleStart,
1790
1837
  handleSuccess,
1838
+ handleTriggerClick,
1791
1839
  initService,
1792
1840
  largeDocumentDownload,
1793
1841
  largeDocumentUpload,