@opentiny/vue-renderless 3.6.8 → 3.8.2

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 (317) hide show
  1. package/action-sheet/index.js +28 -1
  2. package/action-sheet/vue.js +10 -4
  3. package/alert/index.js +24 -2
  4. package/alert/vue.js +15 -11
  5. package/amount/index.js +4 -4
  6. package/anchor/index.js +1 -1
  7. package/autocomplete/vue.js +3 -3
  8. package/autonavi-map/index.js +1 -1
  9. package/badge/vue.js +6 -6
  10. package/baidu-map/index.js +1 -1
  11. package/bulletin-board/index.js +1 -1
  12. package/button-group/vue.js +5 -4
  13. package/calendar/index.js +2 -2
  14. package/calendar-bar/index.js +268 -0
  15. package/calendar-bar/vue.js +87 -0
  16. package/card/index.js +84 -0
  17. package/card/vue.js +70 -0
  18. package/card-group/index.js +16 -0
  19. package/card-group/vue.js +21 -0
  20. package/card-template/index.js +1 -1
  21. package/carousel/index.js +89 -2
  22. package/carousel/vue.js +14 -5
  23. package/carousel-item/index.js +8 -0
  24. package/carousel-item/vue.js +7 -3
  25. package/cascader/index.js +6 -6
  26. package/cascader/vue.js +3 -3
  27. package/cascader-menu/vue.js +2 -2
  28. package/cascader-panel/index.js +4 -4
  29. package/cascader-panel/node.js +4 -4
  30. package/cascader-panel/vue.js +2 -2
  31. package/cascader-select/index.js +179 -0
  32. package/cascader-select/vue.js +74 -0
  33. package/cell/vue.js +16 -0
  34. package/chart-bar/index.js +3 -3
  35. package/chart-boxplot/index.js +2 -2
  36. package/chart-candle/index.js +3 -3
  37. package/chart-core/deps/utils.js +7 -7
  38. package/chart-core/index.js +2 -2
  39. package/chart-funnel/index.js +3 -3
  40. package/chart-gauge/index.js +3 -3
  41. package/chart-graph/index.js +1 -1
  42. package/chart-heatmap/index.js +2 -2
  43. package/chart-line/index.js +3 -3
  44. package/chart-liquidfill/index.js +2 -2
  45. package/chart-map/index.js +3 -3
  46. package/chart-pie/index.js +3 -3
  47. package/chart-radar/index.js +3 -3
  48. package/chart-sankey/index.js +3 -3
  49. package/chart-scatter/index.js +4 -4
  50. package/chart-sunburst/index.js +1 -1
  51. package/chart-tree/index.js +2 -2
  52. package/chart-waterfall/index.js +3 -3
  53. package/chart-wordcloud/index.js +2 -2
  54. package/checkbox/index.js +21 -0
  55. package/checkbox/vue.js +16 -3
  56. package/checkbox-button/vue.js +1 -1
  57. package/collapse-item/vue.js +1 -1
  58. package/column-list-group/index.js +0 -0
  59. package/column-list-group/vue.js +14 -0
  60. package/column-list-item/index.js +50 -0
  61. package/column-list-item/vue.js +39 -0
  62. package/common/array.js +3 -3
  63. package/common/bigInt.js +5 -2
  64. package/common/dataset/index.js +3 -3
  65. package/common/date.js +2 -2
  66. package/common/deps/ResizeObserver.js +1 -1
  67. package/common/deps/clickoutside.js +1 -1
  68. package/common/deps/date-util.js +4 -4
  69. package/common/deps/date.js +2 -2
  70. package/common/deps/debounce.js +1 -1
  71. package/common/deps/dom.js +1 -1
  72. package/common/deps/fullscreen/apis.js +3 -3
  73. package/common/deps/fullscreen/screenfull.js +1 -1
  74. package/common/deps/infinite-scroll.js +176 -0
  75. package/common/deps/letter-only.js +1 -1
  76. package/common/deps/number-only.js +1 -1
  77. package/common/deps/observe-visibility.js +106 -0
  78. package/common/deps/popper.js +20 -22
  79. package/common/deps/popup-manager.js +2 -2
  80. package/common/deps/repeat-click.js +1 -1
  81. package/common/deps/resize-event.js +1 -1
  82. package/common/deps/tree-model/node.js +5 -5
  83. package/common/deps/tree-model/tree-store.js +3 -3
  84. package/common/deps/upload-ajax.js +2 -2
  85. package/common/deps/vue-popper.js +6 -6
  86. package/common/deps/vue-popup.js +4 -4
  87. package/common/index.js +2 -2
  88. package/common/object.js +1 -1
  89. package/common/runtime.js +24 -24
  90. package/common/string.js +23 -4
  91. package/common/validate/rules/range.js +2 -2
  92. package/common/validate/rules/required.js +1 -1
  93. package/common/validate/rules/type.js +3 -3
  94. package/common/validate/schema.js +1 -1
  95. package/common/validate/util.js +1 -1
  96. package/common/validate/validations/array.js +1 -1
  97. package/common/validate/validations/date.js +1 -1
  98. package/common/validate/validations/enum.js +1 -1
  99. package/common/validate/validations/float.js +1 -1
  100. package/common/validate/validations/integer.js +1 -1
  101. package/common/validate/validations/method.js +1 -1
  102. package/common/validate/validations/number.js +1 -1
  103. package/common/validate/validations/pattern.js +1 -1
  104. package/common/validate/validations/string.js +1 -1
  105. package/common/validate/validations/type.js +1 -1
  106. package/container/index.js +1 -1
  107. package/crop/index.js +2 -2
  108. package/currency/index.js +2 -2
  109. package/date-panel/index.js +7 -7
  110. package/date-panel/vue.js +3 -2
  111. package/date-picker-mobile/index.js +250 -0
  112. package/date-picker-mobile/vue.js +86 -0
  113. package/date-range/index.js +1 -1
  114. package/date-range/vue.js +1 -1
  115. package/date-table/index.js +3 -3
  116. package/date-table/vue.js +1 -1
  117. package/dialog-box/index.js +6 -4
  118. package/dialog-box/vue.js +1 -1
  119. package/dialog-select/index.js +345 -0
  120. package/dialog-select/vue.js +110 -0
  121. package/drawer/index.js +83 -0
  122. package/drawer/vue.js +51 -0
  123. package/drop-times/index.js +1 -1
  124. package/dropdown/index.js +2 -2
  125. package/dropdown/vue.js +4 -3
  126. package/dropdown-item/index.js +5 -1
  127. package/dropdown-item/mf.js +79 -0
  128. package/dropdown-item/vue.js +9 -6
  129. package/dropdown-menu/index.js +30 -1
  130. package/dropdown-menu/vue.js +17 -7
  131. package/dynamic-scroller/index.js +117 -0
  132. package/dynamic-scroller/vue.js +88 -0
  133. package/dynamic-scroller-item/index.js +147 -0
  134. package/dynamic-scroller-item/vue.js +92 -0
  135. package/espace/index.js +1 -1
  136. package/espace/vue.js +1 -1
  137. package/exception/vue.js +3 -1
  138. package/fall-menu/index.js +4 -4
  139. package/file-upload/index.js +872 -408
  140. package/file-upload/vue.js +87 -36
  141. package/filter/index.js +131 -0
  142. package/filter/tag-group.js +43 -0
  143. package/filter/vue.js +73 -0
  144. package/filter-bar/index.js +9 -0
  145. package/filter-bar/vue.js +16 -0
  146. package/filter-box/index.js +17 -0
  147. package/filter-box/vue.js +19 -0
  148. package/filter-panel/index.js +42 -0
  149. package/filter-panel/vue.js +33 -0
  150. package/floatbar/index.js +1 -1
  151. package/flowchart/index.js +721 -0
  152. package/flowchart/vue.js +81 -0
  153. package/form/index.js +15 -1
  154. package/form/vue.js +10 -4
  155. package/form-item/index.js +46 -6
  156. package/form-item/vue.js +27 -3
  157. package/fullscreen/index.js +1 -1
  158. package/fullscreen/vue.js +1 -1
  159. package/grid/plugins/export.js +2 -2
  160. package/grid/plugins/exportExcel.js +2 -2
  161. package/grid/plugins/resize.js +1 -1
  162. package/grid/static/base/helperEqualCompare.js +1 -1
  163. package/grid/static/base/isPlainObject.js +1 -1
  164. package/grid/utils/common.js +3 -3
  165. package/grid/utils/dom.js +3 -3
  166. package/grid/utils/event.js +2 -2
  167. package/guide/index.js +168 -0
  168. package/guide/vue.js +36 -0
  169. package/hrapprover/index.js +1 -1
  170. package/image/index.js +8 -4
  171. package/image/vue.js +12 -6
  172. package/image-viewer/index.js +3 -3
  173. package/image-viewer/vue.js +16 -6
  174. package/input/index.js +34 -1
  175. package/input/vue.js +22 -6
  176. package/ip-address/index.js +1 -1
  177. package/ip-address/vue.js +1 -1
  178. package/link-menu/index.js +2 -2
  179. package/link-menu/vue.js +2 -2
  180. package/loading/index.js +2 -2
  181. package/loading/vue.js +2 -1
  182. package/locales/index.js +1 -1
  183. package/logout/index.js +1 -1
  184. package/milestone/index.js +5 -1
  185. package/modal/index.js +68 -39
  186. package/modal/vue.js +15 -12
  187. package/month-range/index.js +1 -1
  188. package/month-range/vue.js +1 -1
  189. package/month-table/index.js +5 -5
  190. package/month-table/vue.js +1 -1
  191. package/multi-select/index.js +5 -2
  192. package/multi-select/vue.js +4 -5
  193. package/nav-menu/index.js +6 -6
  194. package/notify/index.js +3 -3
  195. package/numeric/index.js +15 -5
  196. package/numeric/vue.js +15 -6
  197. package/option/index.js +1 -1
  198. package/package.json +2 -1
  199. package/pager/vue.js +10 -0
  200. package/pager-item/index.js +1 -1
  201. package/panel/index.js +1 -1
  202. package/picker/index.js +7 -7
  203. package/picker/vue.js +1 -1
  204. package/picker-column/index.js +1 -1
  205. package/popconfirm/index.js +25 -0
  206. package/popconfirm/vue.js +22 -0
  207. package/popeditor/index.js +7 -7
  208. package/popeditor/vue.js +2 -2
  209. package/popover/index.js +11 -3
  210. package/popover/vue.js +33 -10
  211. package/popup/index.js +4 -4
  212. package/pull-refresh/index.js +8 -11
  213. package/pull-refresh/vue.js +7 -7
  214. package/radio/index.js +17 -0
  215. package/radio/vue.js +18 -3
  216. package/radio-button/index.js +8 -0
  217. package/radio-button/vue.js +19 -4
  218. package/radio-group/index.js +1 -1
  219. package/radio-group/vue.js +5 -2
  220. package/rate/index.js +4 -2
  221. package/rate/vue.js +1 -1
  222. package/record/index.js +190 -0
  223. package/record/vue.js +44 -0
  224. package/recycle-scroller/index.js +470 -0
  225. package/recycle-scroller/vue.js +135 -0
  226. package/river/index.js +371 -0
  227. package/river/river.js +352 -0
  228. package/river/vue.js +77 -0
  229. package/roles/index.js +1 -1
  230. package/scrollbar/vue-bar.js +1 -1
  231. package/scrollbar/vue.js +1 -1
  232. package/search/index.js +3 -3
  233. package/select/index.js +21 -14
  234. package/select/vue.js +38 -15
  235. package/select-dropdown/vue.js +1 -1
  236. package/select-mobile/index.js +111 -0
  237. package/select-mobile/vue.js +58 -0
  238. package/select-view/index.js +170 -0
  239. package/select-view/vue.js +82 -0
  240. package/selected-box/index.js +216 -0
  241. package/selected-box/vue.js +98 -0
  242. package/slide-bar/index.js +1 -1
  243. package/slider/index.js +49 -4
  244. package/slider/vue.js +15 -4
  245. package/split/vue.js +1 -1
  246. package/standard-list-item/index.js +18 -0
  247. package/standard-list-item/vue.js +22 -0
  248. package/steps/index.js +30 -0
  249. package/steps/slide-bar.js +122 -0
  250. package/steps/vue.js +15 -3
  251. package/switch/index.js +1 -1
  252. package/switch/vue.js +2 -1
  253. package/tab-bar/index.js +2 -2
  254. package/tab-item/index.js +3 -3
  255. package/tab-item/vue.js +4 -3
  256. package/tab-item-mf/index.js +0 -0
  257. package/tab-item-mf/vue.js +16 -0
  258. package/tab-nav/index.js +78 -4
  259. package/tab-nav/vue.js +11 -3
  260. package/tabbar-item/index.js +1 -1
  261. package/tabbar-item/vue.js +1 -1
  262. package/tabs/index.js +8 -9
  263. package/tabs/vue.js +1 -1
  264. package/tabs-mf/index.js +109 -0
  265. package/tabs-mf/vue-bar.js +49 -0
  266. package/tabs-mf/vue-nav-item.js +22 -0
  267. package/tabs-mf/vue-nav.js +13 -0
  268. package/tabs-mf/vue.js +45 -0
  269. package/tabs-mf/wheel.js +71 -0
  270. package/tag/index.js +8 -2
  271. package/tag/vue.js +13 -5
  272. package/tag-group/index.js +24 -0
  273. package/tag-group/vue.js +29 -0
  274. package/tall-storage/index.js +1 -1
  275. package/tall-storage/vue.js +1 -1
  276. package/time/index.js +1 -1
  277. package/time/vue.js +2 -2
  278. package/time-line/index.js +28 -7
  279. package/time-line/vue.js +9 -4
  280. package/time-panel/index.js +2 -2
  281. package/time-panel/vue.js +1 -1
  282. package/time-picker-mobile/index.js +30 -0
  283. package/time-picker-mobile/vue.js +30 -0
  284. package/time-range/index.js +1 -1
  285. package/time-range/vue.js +1 -1
  286. package/time-spinner/index.js +2 -2
  287. package/time-spinner/vue.js +1 -1
  288. package/toggle-menu/index.js +2 -2
  289. package/toggle-menu/vue.js +1 -1
  290. package/tooltip/index.js +30 -3
  291. package/tooltip/vue.js +34 -13
  292. package/top-box/index.js +3 -3
  293. package/transfer/index.js +1 -1
  294. package/transfer-panel/index.js +2 -2
  295. package/tree/index.js +6 -6
  296. package/tree/vue.js +1 -1
  297. package/tree-node/index.js +1 -1
  298. package/upload/index.js +1 -1
  299. package/upload/vue.js +2 -2
  300. package/upload-dragger/index.js +5 -1
  301. package/upload-dragger/vue.js +9 -3
  302. package/upload-list/index.js +158 -8
  303. package/upload-list/vue.js +77 -25
  304. package/user/index.js +86 -70
  305. package/user/vue.js +15 -5
  306. package/user-account/vue.js +1 -1
  307. package/user-contact/index.js +49 -3
  308. package/user-contact/vue.js +17 -8
  309. package/user-head-group/vue.js +17 -0
  310. package/user-link/index.js +10 -2
  311. package/user-link/vue.js +11 -6
  312. package/wheel/index.js +1 -1
  313. package/wizard/index.js +3 -3
  314. package/year-range/index.js +125 -0
  315. package/year-range/vue.js +88 -0
  316. package/year-table/index.js +175 -11
  317. package/year-table/vue.js +17 -5
@@ -1,39 +1,91 @@
1
1
  import "../chunk-PKUHTIDK.js";
2
- import { parsePercentage, handleClick, picturefilePreview, getDeleteData, downloadFile } from "./index";
3
- import { downloadFile as edmDownloadFile, getToken } from "@opentiny/vue-renderless/file-upload";
4
- const api = ["t", "state", "parsePercentage", "handleClick", "handlePreview", "picturefilePreview", "getDeleteData", "downloadFile"];
5
- const renderless = (props, { reactive }, { t, parent, mode: tinyMode, emit, service }, { Modal }) => {
6
- const mode = props._mode || parent.$mode || (tinyMode ? tinyMode.value ? tinyMode.value : "pc" : "pc");
2
+ import {
3
+ parsePercentage,
4
+ handleClick,
5
+ picturefilePreview,
6
+ getDeleteData,
7
+ downloadFile,
8
+ play,
9
+ pause,
10
+ handleLoadedmetadata,
11
+ handleTimeupdate,
12
+ destroyed,
13
+ showOperatePanel,
14
+ getFileType,
15
+ getFileIcon,
16
+ mounted,
17
+ calcUploadListLiWidth,
18
+ reUpload,
19
+ remove
20
+ } from "./index";
21
+ import { getToken, initService } from "../file-upload";
22
+ import { getApi } from "../file-upload/vue";
23
+ const api = [
24
+ "t",
25
+ "state",
26
+ "parsePercentage",
27
+ "handleClick",
28
+ "handlePreview",
29
+ "picturefilePreview",
30
+ "getDeleteData",
31
+ "downloadFile",
32
+ "play",
33
+ "pause",
34
+ "handleLoadedmetadata",
35
+ "handleTimeupdate",
36
+ "showOperatePanel",
37
+ "getFileType",
38
+ "getFileIcon",
39
+ "reUpload",
40
+ "remove"
41
+ ];
42
+ const renderless = (props, { reactive, onMounted, onUnmounted, watch }, { t, parent, mode, emit, service, vm, nextTick }, { Modal }) => {
43
+ const api2 = { getApi };
44
+ parent = parent.$parent;
45
+ const constants = parent.$constants;
46
+ const $service = initService({ props, service });
7
47
  const state = reactive({
8
48
  focusing: false,
9
49
  shows: false,
10
50
  startPostion: 0,
11
- screenType: mode !== "pc"
51
+ screenType: mode === "mobile" ? true : false,
52
+ showPanel: false
12
53
  });
13
- parent.getToken = getToken({
14
- constants: parent.$constants,
15
- props: parent,
16
- state: parent.state,
17
- t,
18
- Modal
19
- });
20
- const api2 = {
54
+ parent.getToken = getToken({ constants, props: parent, state: parent.state, t, Modal });
55
+ Object.assign(api2, {
21
56
  state,
22
57
  getDeleteData: getDeleteData(emit),
23
58
  parsePercentage: parsePercentage(),
24
- downloadFile: downloadFile(service),
59
+ downloadFile: downloadFile($service),
25
60
  picturefilePreview: picturefilePreview(state),
26
- edmDownloadFile: edmDownloadFile({
27
- api: parent,
28
- constants: parent.$constants,
29
- props: parent,
30
- service,
31
- state: parent.state
32
- })
33
- };
34
- Object.assign(api2, {
35
- handleClick: handleClick({ props, api: api2, parent })
61
+ handleClick: handleClick({ props, api: api2, parent }),
62
+ play: play({ vm, api: api2 }),
63
+ pause: pause({ vm }),
64
+ handleLoadedmetadata: handleLoadedmetadata({ vm }),
65
+ handleTimeupdate: handleTimeupdate(),
66
+ destroyed: destroyed({ api: api2, props, vm }),
67
+ showOperatePanel: showOperatePanel({ state }),
68
+ getFileType: getFileType(),
69
+ getFileIcon: getFileIcon(),
70
+ mounted: mounted({ api: api2, vm }),
71
+ calcUploadListLiWidth: calcUploadListLiWidth({ vm, nextTick, props, constants }),
72
+ reUpload: reUpload({ emit, props, parent }),
73
+ remove: remove({ emit })
36
74
  });
75
+ props.listType === constants.LIST_TYPE.DRAG_SINGLE && watch(
76
+ () => props.files && props.files[0],
77
+ (file) => {
78
+ if (file && file.status === constants.FILE_STATUS.FAIL) {
79
+ setTimeout(() => {
80
+ api2.remove({ file });
81
+ }, 2e3);
82
+ }
83
+ },
84
+ { immediate: true, deep: true }
85
+ );
86
+ watch(() => props.files, api2.calcUploadListLiWidth);
87
+ onMounted(api2.mounted);
88
+ onUnmounted(api2.destroyed);
37
89
  return api2;
38
90
  };
39
91
  export {
package/user/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import "../chunk-PKUHTIDK.js";
2
- import debounce from "@opentiny/vue-renderless/common/deps/debounce";
3
- import { toDateStr } from "@opentiny/vue-renderless/common/date";
4
- import { toJsonStr } from "@opentiny/vue-renderless/common/object";
5
- import { toJson } from "@opentiny/vue-renderless/common/string";
6
- import { log } from "@opentiny/vue-renderless/common";
2
+ import debounce from "../common/deps/debounce";
3
+ import { toDateStr } from "../common/date";
4
+ import { toJsonStr } from "../common/object";
5
+ import { toJson } from "../common/string";
6
+ import { log } from "../common/xss";
7
7
  const request = {
8
8
  timmer: null,
9
9
  group: {},
@@ -17,9 +17,8 @@ const request = {
17
17
  this.group[valueField] = [];
18
18
  }
19
19
  queryIds.forEach((id) => {
20
- if (!~this.group[valueField].indexOf(id)) {
20
+ if (!~this.group[valueField].indexOf(id))
21
21
  !this.group[valueField].push(id);
22
- }
23
22
  });
24
23
  },
25
24
  removeRequest(item) {
@@ -36,20 +35,18 @@ const request = {
36
35
  getParams() {
37
36
  const args = [];
38
37
  for (let key in this.group) {
39
- if (Object.prototype.hasOwnProperty.call(this.group, key)) {
40
- const all = this.group[key];
41
- const items = this.splitArr(all, this.batch);
42
- if (key === "userId") {
43
- args.push(...items.map((item) => item.join(",")));
44
- } else {
45
- args.push(
46
- ...items.map((item) => ({
47
- valueField: key,
48
- valueSplit: item.valueSplit,
49
- [key]: item.join(",")
50
- }))
51
- );
52
- }
38
+ const all = this.group[key];
39
+ const items = this.splitArr(all, this.batch);
40
+ if (key === "userId") {
41
+ args.push(...items.map((item) => item.join(",")));
42
+ } else {
43
+ args.push(
44
+ ...items.map((item) => ({
45
+ valueField: key,
46
+ valueSplit: item.valueSplit,
47
+ [key]: item.join(",")
48
+ }))
49
+ );
53
50
  }
54
51
  }
55
52
  return args;
@@ -61,12 +58,9 @@ const request = {
61
58
  }
62
59
  data.forEach((item) => {
63
60
  for (let key in this.group) {
64
- if (Object.prototype.hasOwnProperty.call(this.group, key)) {
65
- if (!me.cache[key]) {
66
- me.cache[key] = {};
67
- }
68
- me.cache[key][item[key]] = item;
69
- }
61
+ if (!me.cache[key])
62
+ me.cache[key] = {};
63
+ me.cache[key][item[key]] = item;
70
64
  }
71
65
  });
72
66
  },
@@ -84,7 +78,7 @@ const request = {
84
78
  const me = this;
85
79
  const reqParamsSeq = me.getParams();
86
80
  let reqLen = reqParamsSeq.length;
87
- reqParamsSeq.forEach((params) => {
81
+ reqParamsSeq.map((params) => {
88
82
  api.fetchW3Accounts(params).then((data) => {
89
83
  me.setCache(data);
90
84
  me.requests.slice().forEach((reqItem) => {
@@ -112,7 +106,7 @@ const request = {
112
106
  }
113
107
  });
114
108
  });
115
- errors.length && log(`user [${errors.join(",")}] not found`, "warn");
109
+ errors.length && log.logger.warn(`user [${errors.join(",")}] not found`);
116
110
  this.clearRequest();
117
111
  }
118
112
  });
@@ -149,17 +143,20 @@ const request = {
149
143
  return result;
150
144
  }
151
145
  };
152
- const suggestUser = (api) => (query) => new Promise((resolve, reject) => {
153
- api.fetchSuggestUser(query).then((users) => {
154
- if (users.length) {
155
- resolve(users);
156
- } else {
157
- resolve({ invalid: query });
158
- }
159
- }).catch(reject);
160
- });
146
+ const suggestUser = (api) => (query) => {
147
+ return new Promise((resolve, reject) => {
148
+ api.fetchSuggestUser(query).then((users) => {
149
+ if (users.length) {
150
+ resolve(users);
151
+ } else {
152
+ resolve({ invalid: query });
153
+ }
154
+ }).catch(reject);
155
+ });
156
+ };
161
157
  const updateOptions = ({ props, state, nextTick }) => (usersList) => {
162
- const { valueField, textField, noDataText } = props;
158
+ const { noDataText } = props;
159
+ const { valueField, textField } = state;
163
160
  const values = [].concat(state.user || []);
164
161
  const options = [].concat(state.selected);
165
162
  const hides = [];
@@ -194,7 +191,7 @@ const autoSelect = ({ props, state, nextTick }) => (usersList) => {
194
191
  const values = props.multiple ? [].concat(state.user) : [];
195
192
  usersList.forEach((list) => {
196
193
  if (list.length === 1) {
197
- const value = list[0][props.valueField];
194
+ const value = list[0][state.valueField];
198
195
  !~values.indexOf(value) && values.push(value);
199
196
  if (props.autoClose) {
200
197
  state.visible = false;
@@ -232,9 +229,8 @@ const searchMethod = ({ api, props, state, emit }) => debounce(props.delay, (que
232
229
  usersList.push(item);
233
230
  }
234
231
  });
235
- if (failList.length) {
232
+ if (failList.length)
236
233
  emit("error", failList);
237
- }
238
234
  api.updateOptions(usersList).then(() => {
239
235
  api.autoSelect(usersList).then(() => {
240
236
  api.userChange(state.user);
@@ -245,13 +241,15 @@ const searchMethod = ({ api, props, state, emit }) => debounce(props.delay, (que
245
241
  }
246
242
  });
247
243
  const setSelected = ({ api, props, state }) => (value) => {
248
- const values = Array.isArray(value) ? value.map((v) => String(v).toLocaleLowerCase()) : String(value).toLocaleLowerCase().split(props.valueSplit);
249
- state.selected = state.options.filter((user) => ~values.indexOf(String(user[props.valueField]).toLocaleLowerCase()));
244
+ const values = Array.isArray(value) ? value.map((v) => (v + "").toLocaleLowerCase()) : (value + "").toLocaleLowerCase().split(props.valueSplit);
245
+ state.selected = state.options.filter((user) => {
246
+ return ~values.indexOf((user[state.valueField] + "").toLocaleLowerCase());
247
+ });
250
248
  props.cache && api.cacheUser(state.selected);
251
249
  };
252
250
  const userChange = ({ api, emit, props, state }) => (value) => {
253
251
  const { multiple } = props;
254
- let newVal = multiple && Array.isArray(value) ? value.join(props.valueSplit) : String(value || "");
252
+ let newVal = multiple && Array.isArray(value) ? value.join(props.valueSplit) : (value || "") + "";
255
253
  api.setSelected(newVal);
256
254
  if (typeof state.lastValue === "string" && state.lastValue !== null && state.lastValue.toLocaleLowerCase() !== newVal.toLocaleLowerCase()) {
257
255
  emit("update:modelValue", newVal);
@@ -259,13 +257,14 @@ const userChange = ({ api, emit, props, state }) => (value) => {
259
257
  }
260
258
  state.lastValue = newVal;
261
259
  };
262
- const syncCacheIds = (ids, props, queryIds, cacheData) => {
263
- const { valueField, cacheFields, cacheKey } = props;
260
+ const syncCacheIds = ({ props, state }) => (ids, queryIds, cacheData) => {
261
+ const { cacheFields, cacheKey } = props;
262
+ const { valueField } = state;
264
263
  const cacheUsers = toJson(window.localStorage.getItem(cacheKey)) || {};
265
264
  ids.forEach((id) => {
266
265
  if (cacheUsers[id]) {
267
266
  const cacheUser2 = cacheUsers[id];
268
- const textField = props.textField === "userCN" || props.textField === "userId" || props.textField === "dept" ? "" : props.textField;
267
+ const textField = state.textField === "userCN" || state.textField === "userId" || state.textField === "dept" ? "" : state.textField;
269
268
  if (textField !== "" && !cacheUser2.a) {
270
269
  window.localStorage.removeItem(cacheKey);
271
270
  queryIds.push(id);
@@ -291,12 +290,13 @@ const syncCacheIds = (ids, props, queryIds, cacheData) => {
291
290
  });
292
291
  };
293
292
  const getUsers = ({ api, props, state }) => (value) => {
294
- const { valueField, cache } = props;
293
+ const { cache } = props;
294
+ const { valueField } = state;
295
295
  const ids = Array.isArray(value) ? value : value.split(props.valueSplit);
296
296
  const cacheData = [];
297
297
  const queryIds = cache ? [] : ids;
298
298
  if (cache) {
299
- syncCacheIds(ids, props, queryIds, cacheData);
299
+ api.syncCacheIds(ids, queryIds, cacheData);
300
300
  request.setCache(cacheData, valueField);
301
301
  if (!queryIds.length) {
302
302
  return Promise.resolve(cacheData);
@@ -308,7 +308,8 @@ const getUsers = ({ api, props, state }) => (value) => {
308
308
  if (data.error) {
309
309
  reject(data.error);
310
310
  } else {
311
- resolve(data.concat(cacheData));
311
+ const filterData = cacheData.filter((cache2) => !~data.findIndex((d) => d[valueField] === cache2[valueField]));
312
+ resolve(data.concat(filterData));
312
313
  }
313
314
  };
314
315
  request.getusers({ param, api, batch: state.batch, cb });
@@ -335,8 +336,9 @@ const updateCache = ({ props, state }) => () => {
335
336
  const saveCache = ({ props }) => (cache) => {
336
337
  window.localStorage.setItem(props.cacheKey, toJsonStr(cache));
337
338
  };
338
- const cacheUser = ({ api, props, service }) => (users) => {
339
- const { valueField, cacheKey } = props;
339
+ const cacheUser = ({ api, props, service, state }) => (users) => {
340
+ const { cacheKey } = props;
341
+ const { valueField } = state;
340
342
  const cacheUser2 = toJson(window.localStorage.getItem(cacheKey)) || {};
341
343
  const cacheFields = service.userCache;
342
344
  let user;
@@ -354,7 +356,7 @@ const cacheUser = ({ api, props, service }) => (users) => {
354
356
  u: u[cacheFields.userCN],
355
357
  d: u[cacheFields.dept],
356
358
  e: u[cacheFields.eno],
357
- a: ~["userCN", "userId", "dept"].indexOf(props.textField) ? null : u[props.textField],
359
+ a: ~["userCN", "userId", "dept"].indexOf(state.textField) ? null : u[state.textField],
358
360
  r: 0
359
361
  };
360
362
  props.cacheFields.forEach((field) => {
@@ -366,21 +368,21 @@ const cacheUser = ({ api, props, service }) => (users) => {
366
368
  try {
367
369
  api.saveCache(cacheUser2);
368
370
  } catch (e) {
369
- const sortUsers = Object.keys(cacheUser2).sort((a, b) => cacheUser2[a].r < cacheUser2[b].r ? 1 : -1);
371
+ const sortUsers = Object.keys(cacheUser2).sort((a, b) => {
372
+ return cacheUser2[a].r < cacheUser2[b].r ? 1 : -1;
373
+ });
370
374
  const cutUser = sortUsers.splice(0, sortUsers.length / 2);
371
375
  const newCache = {};
372
376
  for (let i in cutUser) {
373
- if (Object.prototype.hasOwnProperty.call(cutUser, i)) {
374
- newCache[cutUser[i]] = cacheUser2[cutUser[i]];
375
- }
377
+ newCache[cutUser[i]] = cacheUser2[cutUser[i]];
376
378
  }
377
379
  api.saveCache(newCache);
378
380
  }
379
381
  };
380
- const useSortable = ({ api, props, state, refs }) => () => {
381
- const selectDom = refs.select.$el;
382
+ const useSortable = ({ api, props, state, vm }) => () => {
383
+ const selectDom = vm.$refs.select.$el;
382
384
  if (props.sortable && props.multiple && !state.sortable) {
383
- const tagsDom = selectDom.querySelector(".tiny-select__tags>span");
385
+ const tagsDom = selectDom.querySelector(".tiny-select__tags>span>span");
384
386
  state.sortable = props.sortable.create(tagsDom, {
385
387
  handle: ".tiny-tag",
386
388
  ghostClass: "tiny-user__ghost",
@@ -405,7 +407,7 @@ const initUser = ({ api, props, state }) => (value) => {
405
407
  }
406
408
  state.user = !props.multiple ? "" : [];
407
409
  if (typeof value === "number") {
408
- value = String(value);
410
+ value += "";
409
411
  }
410
412
  if (!value) {
411
413
  state.options = [];
@@ -414,10 +416,12 @@ const initUser = ({ api, props, state }) => (value) => {
414
416
  return;
415
417
  }
416
418
  value && api.getUsers(value).then((info) => {
417
- info.sort((a, b) => value.indexOf(String(a[props.valueField])) > value.indexOf(String(b[props.valueField])) ? 1 : -1);
419
+ info.sort((a, b) => {
420
+ return value.indexOf(a[state.valueField] + "") > value.indexOf(b[state.valueField] + "") ? 1 : -1;
421
+ });
418
422
  const list = info.map((user) => {
419
423
  user._show = true;
420
- return user[props.valueField];
424
+ return user[state.valueField];
421
425
  });
422
426
  state.options = info;
423
427
  state.user = props.multiple ? list : list[0];
@@ -432,14 +436,17 @@ const initService = ({ props, service }) => {
432
436
  if (propName) {
433
437
  return Promise.reject(new Error(`[TINY Error][User]] Prop ${propName} is not configured`));
434
438
  } else {
435
- return Promise.reject(new Error("[TINY Error][User]] This component depends on @opentiny/vue-service"));
439
+ return Promise.reject(new Error("[TINY Error][User]] This component depends on @opentiny/service"));
436
440
  }
437
441
  };
438
442
  const $service = service || {};
439
443
  const { common = {}, setting = {}, base = {} } = $service;
440
444
  const { fetchUser, fetchW3Accounts, fetchSuggestUser, fetchUserByUserId } = $service;
441
445
  const { options = {} } = setting;
442
- const { UserCache = { uuid: "uuid", userId: "userId", userCN: "userCN", dept: "dept", eno: "employeeNumber" }, User = { batch: 50 } } = options;
446
+ const {
447
+ UserCache = { uuid: "uuid", userId: "userId", userCN: "userCN", dept: "dept", eno: "employeeNumber" },
448
+ User = { batch: 50, textField: "", valueField: "" }
449
+ } = options;
443
450
  return {
444
451
  fetchUser: props.fetchUser || fetchUser || noopFnCreator("fetchUser"),
445
452
  fetchW3Accounts: props.fetchW3Accounts || fetchW3Accounts || noopFnCreator("fetchW3Accounts"),
@@ -449,21 +456,29 @@ const initService = ({ props, service }) => {
449
456
  getLangData: props.getLangData || base.getLangData || noopFnCreator("getLangData"),
450
457
  getUserInfo: props.getUserInfo || base.getUserInfo || noopFnCreator("getUserInfo"),
451
458
  userCache: props.UserCache || UserCache,
452
- batch: User.batch
459
+ batch: User.batch,
460
+ textField: User.textField,
461
+ valueField: User.valueField
453
462
  };
454
463
  };
455
464
  const filter = ({ props, state }) => () => {
456
465
  if (props.multiple && props.hideSelected) {
457
466
  const selectedUsers = state.user.map((value) => typeof value === "string" ? value.toLocaleLowerCase() : value);
458
- return state.options.filter(
459
- (user) => !~selectedUsers.indexOf(typeof user[props.valueField] === "string" ? user[props.valueField].toLocaleLowerCase() : user[props.valueField])
460
- );
467
+ return state.options.filter((user) => {
468
+ return !~selectedUsers.indexOf(
469
+ typeof user[state.valueField] === "string" ? user[state.valueField].toLocaleLowerCase() : user[state.textField]
470
+ );
471
+ });
461
472
  }
462
473
  return state.options;
463
474
  };
475
+ const computedTextField = ({ service, props }) => () => props.textField || service.textField || "userCN";
476
+ const computedValueField = ({ service, props }) => () => props.valueField || service.valueField || "userId";
464
477
  export {
465
478
  autoSelect,
466
479
  cacheUser,
480
+ computedTextField,
481
+ computedValueField,
467
482
  filter,
468
483
  getUsers,
469
484
  handleBlur,
@@ -473,6 +488,7 @@ export {
473
488
  searchMethod,
474
489
  setSelected,
475
490
  suggestUser,
491
+ syncCacheIds,
476
492
  updateCache,
477
493
  updateOptions,
478
494
  useSortable,
package/user/vue.js CHANGED
@@ -15,10 +15,13 @@ import {
15
15
  cacheUser,
16
16
  visibleChange,
17
17
  initService,
18
- filter
18
+ filter,
19
+ computedTextField,
20
+ computedValueField,
21
+ syncCacheIds
19
22
  } from "./index";
20
23
  const api = ["state", "handleBlur", "searchMethod", "userChange", "visibleChange", "useSortable", "filter"];
21
- const renderless = (props, { reactive, watch }, { emit, nextTick, refs, service, constants, dispatch }) => {
24
+ const renderless = (props, { reactive, watch, computed, provide }, { emit, nextTick, vm, service, constants, dispatch }) => {
22
25
  const api2 = {};
23
26
  const $service = initService({ props, service });
24
27
  const state = reactive({
@@ -33,7 +36,9 @@ const renderless = (props, { reactive, watch }, { emit, nextTick, refs, service,
33
36
  sortable: null,
34
37
  overflow: false,
35
38
  addevnet: false,
36
- batch: props.batch === false ? false : props.batch || $service.batch
39
+ batch: props.batch === false ? false : props.batch || $service.batch,
40
+ textField: computed(() => api2.computedTextField()),
41
+ valueField: computed(() => api2.computedValueField())
37
42
  });
38
43
  Object.assign(api2, {
39
44
  state,
@@ -48,16 +53,21 @@ const renderless = (props, { reactive, watch }, { emit, nextTick, refs, service,
48
53
  handleBlur: handleBlur({ constants, dispatch, state }),
49
54
  filter: filter({ props, state }),
50
55
  suggestUser: suggestUser(api2),
51
- cacheUser: cacheUser({ api: api2, props, service: $service }),
56
+ cacheUser: cacheUser({ api: api2, props, service: $service, state }),
52
57
  initUser: initUser({ api: api2, props, state }),
53
58
  getUsers: getUsers({ api: api2, props, state }),
54
59
  setSelected: setSelected({ api: api2, props, state }),
55
60
  searchMethod: searchMethod({ api: api2, props, state, emit }),
56
61
  userChange: userChange({ api: api2, emit, props, state }),
57
- useSortable: useSortable({ api: api2, props, state, refs })
62
+ useSortable: useSortable({ api: api2, props, state, vm }),
63
+ computedTextField: computedTextField({ service: $service, props }),
64
+ computedValueField: computedValueField({ service: $service, props }),
65
+ syncCacheIds: syncCacheIds({ props, state })
58
66
  });
59
67
  props.cache && api2.updateCache();
60
68
  watch(() => props.modelValue, api2.initUser, { immediate: true });
69
+ provide("showContent", props.showTips);
70
+ provide("tips-max-width", props.maxWidth);
61
71
  return api2;
62
72
  };
63
73
  export {
@@ -1,5 +1,5 @@
1
1
  import "../chunk-PKUHTIDK.js";
2
- import { initService } from "@opentiny/vue-renderless/user";
2
+ import { initService } from "../user";
3
3
  import { init } from "./index";
4
4
  const api = ["state"];
5
5
  const renderless = (props, { reactive }, { service }) => {
@@ -1,11 +1,57 @@
1
1
  import "../chunk-PKUHTIDK.js";
2
- const getUserHref = ({ props }) => () => {
2
+ import { xss } from "../common/xss";
3
+ const getUserHref = ({ api, props }) => () => {
3
4
  let href = "javascript:;";
4
5
  if (!props.isNewImMode) {
5
- href = "javascript:;";
6
+ const data = props.data;
7
+ const roleNumber = data.roleNumber ? data.roleNumber.toLocaleLowerCase() : "";
8
+ if (roleNumber && api.testUID(roleNumber)) {
9
+ href = `im:${roleNumber}`;
10
+ return xss.filterUrl(href);
11
+ }
6
12
  }
7
13
  return href;
8
14
  };
15
+ const doUserAction = ({ api, props, state, eSpaceCtrl }) => () => {
16
+ if (props.isNewImMode) {
17
+ if (eSpaceCtrl) {
18
+ if (state.initialized) {
19
+ api.openEspace();
20
+ } else {
21
+ api.initEspaceLink();
22
+ }
23
+ }
24
+ }
25
+ };
26
+ const initEspaceLink = ({ api, props, state, eSpaceCtrl, eSpaceCtrlDisabled }) => () => {
27
+ const flag = localStorage.getItem("eSpaceCtrl_initialized");
28
+ if (Number(flag)) {
29
+ state.initialized = true;
30
+ api.openEspace();
31
+ } else if (!eSpaceCtrlDisabled) {
32
+ const timeout = props.timeout || 3e3;
33
+ const pollingInterval = props.pollingInterval || 1e3;
34
+ const options = { timeout, pollingInterval };
35
+ eSpaceCtrl.init && eSpaceCtrl.init(options);
36
+ eSpaceCtrl.ready && eSpaceCtrl.ready(() => {
37
+ state.initialized = true;
38
+ api.openEspace();
39
+ });
40
+ eSpaceCtrl.error && eSpaceCtrl.error(() => {
41
+ state.initialized = false;
42
+ });
43
+ }
44
+ };
45
+ const openEspace = ({ api, props, eSpaceCtrl }) => () => {
46
+ const data = props.data;
47
+ const roleNumber = data.roleNumber ? data.roleNumber.toLocaleLowerCase() : "";
48
+ if (roleNumber && api.testUID(roleNumber)) {
49
+ eSpaceCtrl.showImDialog(roleNumber);
50
+ }
51
+ };
9
52
  export {
10
- getUserHref
53
+ doUserAction,
54
+ getUserHref,
55
+ initEspaceLink,
56
+ openEspace
11
57
  };
@@ -1,16 +1,25 @@
1
1
  import "../chunk-PKUHTIDK.js";
2
- import { getUserHref } from "./index";
3
- const api = ["show", "getUserHref"];
4
- const renderless = (props, { reactive, ref }) => {
2
+ import { init } from "../common/deps/eSpaceCtrl";
3
+ import { getUserHref, doUserAction, initEspaceLink, openEspace } from "./index";
4
+ import { testUID } from "../espace";
5
+ const api = ["show", "getUserHref", "doUserAction", "initEspaceLink", "openEspace", "testUID"];
6
+ const renderless = (props, { reactive, ref }, { service }) => {
7
+ const api2 = {};
8
+ const { setting = {} } = service || {};
9
+ const { widgets = {} } = setting;
10
+ const eSpaceCtrlDisabled = widgets.ESpaceCtrl && !widgets.ESpaceCtrl.autoLink;
11
+ const eSpaceCtrl = eSpaceCtrlDisabled ? {} : init();
5
12
  const state = reactive({
6
13
  initialized: false
7
14
  });
8
- const api2 = {
9
- state,
10
- show: ref(false)
11
- };
12
15
  Object.assign(api2, {
13
- getUserHref: getUserHref({ api: api2, props })
16
+ state,
17
+ testUID,
18
+ show: ref(false),
19
+ getUserHref: getUserHref({ api: api2, props }),
20
+ initEspaceLink: initEspaceLink({ api: api2, props, state, eSpaceCtrl, eSpaceCtrlDisabled }),
21
+ doUserAction: doUserAction({ api: api2, props, state, eSpaceCtrl }),
22
+ openEspace: openEspace({ api: api2, props, eSpaceCtrl })
14
23
  });
15
24
  return api2;
16
25
  };
@@ -0,0 +1,17 @@
1
+ import "../chunk-PKUHTIDK.js";
2
+ const api = ["state"];
3
+ const renderless = (props, { reactive, provide }) => {
4
+ const state = reactive({
5
+ groupSize: props.groupSize,
6
+ list: props.list
7
+ });
8
+ const api2 = {
9
+ state
10
+ };
11
+ provide("groupSize", state.groupSize);
12
+ return api2;
13
+ };
14
+ export {
15
+ api,
16
+ renderless
17
+ };
@@ -5,8 +5,12 @@ const initUser = ({ api, props, state }) => (value) => {
5
5
  return;
6
6
  }
7
7
  api.getUsers(value).then((info) => {
8
- info.sort((a, b) => value.indexOf(String(a[props.valueField])) > value.indexOf(String(b[props.valueField])) ? 1 : -1);
9
- const list = info.map((user) => user[props.valueField]);
8
+ info.sort((a, b) => {
9
+ return value.indexOf(a[state.valueField] + "") > value.indexOf(b[state.valueField] + "") ? 1 : -1;
10
+ });
11
+ const list = info.map((user) => {
12
+ return user[state.valueField];
13
+ });
10
14
  state.options = info;
11
15
  state.user = props.multiple ? list : list[0];
12
16
  props.cache && api.cacheUser(info);
@@ -26,7 +30,11 @@ const showCard = ({ api, service, state }) => (user) => {
26
30
  const showDetail = (state) => () => {
27
31
  state.expand = !state.expand;
28
32
  };
33
+ const computedTextField = ({ service, props }) => () => props.textField || service.textField || "userCN";
34
+ const computedValueField = ({ service, props }) => () => props.valueField || service.valueField || "userId";
29
35
  export {
36
+ computedTextField,
37
+ computedValueField,
30
38
  initUser,
31
39
  showCard,
32
40
  showDetail