@opentiny/vue-renderless 3.6.7 → 3.8.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 (314) 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/calendar/index.js +2 -2
  13. package/calendar-bar/index.js +268 -0
  14. package/calendar-bar/vue.js +87 -0
  15. package/card/index.js +84 -0
  16. package/card/vue.js +70 -0
  17. package/card-group/index.js +16 -0
  18. package/card-group/vue.js +21 -0
  19. package/card-template/index.js +1 -1
  20. package/carousel/index.js +89 -2
  21. package/carousel/vue.js +14 -5
  22. package/carousel-item/index.js +8 -0
  23. package/carousel-item/vue.js +7 -3
  24. package/cascader/index.js +6 -6
  25. package/cascader/vue.js +3 -3
  26. package/cascader-menu/vue.js +2 -2
  27. package/cascader-panel/index.js +4 -4
  28. package/cascader-panel/node.js +4 -4
  29. package/cascader-panel/vue.js +2 -2
  30. package/cascader-select/index.js +179 -0
  31. package/cascader-select/vue.js +74 -0
  32. package/cell/vue.js +16 -0
  33. package/chart-bar/index.js +3 -3
  34. package/chart-boxplot/index.js +2 -2
  35. package/chart-candle/index.js +3 -3
  36. package/chart-core/deps/utils.js +7 -7
  37. package/chart-core/index.js +2 -2
  38. package/chart-funnel/index.js +3 -3
  39. package/chart-gauge/index.js +3 -3
  40. package/chart-graph/index.js +1 -1
  41. package/chart-heatmap/index.js +2 -2
  42. package/chart-line/index.js +3 -3
  43. package/chart-liquidfill/index.js +2 -2
  44. package/chart-map/index.js +3 -3
  45. package/chart-pie/index.js +3 -3
  46. package/chart-radar/index.js +3 -3
  47. package/chart-sankey/index.js +3 -3
  48. package/chart-scatter/index.js +4 -4
  49. package/chart-sunburst/index.js +1 -1
  50. package/chart-tree/index.js +2 -2
  51. package/chart-waterfall/index.js +3 -3
  52. package/chart-wordcloud/index.js +2 -2
  53. package/checkbox/index.js +21 -0
  54. package/checkbox/vue.js +16 -3
  55. package/checkbox-button/vue.js +1 -1
  56. package/collapse-item/vue.js +1 -1
  57. package/column-list-group/index.js +0 -0
  58. package/column-list-group/vue.js +14 -0
  59. package/column-list-item/index.js +50 -0
  60. package/column-list-item/vue.js +39 -0
  61. package/common/array.js +3 -3
  62. package/common/bigInt.js +5 -2
  63. package/common/dataset/index.js +3 -3
  64. package/common/date.js +2 -2
  65. package/common/deps/ResizeObserver.js +1 -1
  66. package/common/deps/clickoutside.js +1 -1
  67. package/common/deps/date-util.js +4 -4
  68. package/common/deps/date.js +2 -2
  69. package/common/deps/debounce.js +1 -1
  70. package/common/deps/dom.js +1 -1
  71. package/common/deps/fullscreen/apis.js +3 -3
  72. package/common/deps/fullscreen/screenfull.js +1 -1
  73. package/common/deps/infinite-scroll.js +176 -0
  74. package/common/deps/letter-only.js +1 -1
  75. package/common/deps/number-only.js +1 -1
  76. package/common/deps/observe-visibility.js +106 -0
  77. package/common/deps/popper.js +20 -22
  78. package/common/deps/popup-manager.js +2 -2
  79. package/common/deps/repeat-click.js +1 -1
  80. package/common/deps/resize-event.js +1 -1
  81. package/common/deps/tree-model/node.js +5 -5
  82. package/common/deps/tree-model/tree-store.js +3 -3
  83. package/common/deps/upload-ajax.js +2 -2
  84. package/common/deps/vue-popper.js +4 -4
  85. package/common/deps/vue-popup.js +4 -4
  86. package/common/index.js +2 -2
  87. package/common/object.js +1 -1
  88. package/common/runtime.js +24 -24
  89. package/common/string.js +23 -4
  90. package/common/validate/rules/range.js +2 -2
  91. package/common/validate/rules/required.js +1 -1
  92. package/common/validate/rules/type.js +3 -3
  93. package/common/validate/schema.js +1 -1
  94. package/common/validate/util.js +1 -1
  95. package/common/validate/validations/array.js +1 -1
  96. package/common/validate/validations/date.js +1 -1
  97. package/common/validate/validations/enum.js +1 -1
  98. package/common/validate/validations/float.js +1 -1
  99. package/common/validate/validations/integer.js +1 -1
  100. package/common/validate/validations/method.js +1 -1
  101. package/common/validate/validations/number.js +1 -1
  102. package/common/validate/validations/pattern.js +1 -1
  103. package/common/validate/validations/string.js +1 -1
  104. package/common/validate/validations/type.js +1 -1
  105. package/container/index.js +1 -1
  106. package/crop/index.js +2 -2
  107. package/currency/index.js +2 -2
  108. package/date-panel/index.js +7 -7
  109. package/date-panel/vue.js +3 -2
  110. package/date-picker-mobile/index.js +250 -0
  111. package/date-picker-mobile/vue.js +86 -0
  112. package/date-range/index.js +1 -1
  113. package/date-range/vue.js +1 -1
  114. package/date-table/index.js +3 -3
  115. package/date-table/vue.js +1 -1
  116. package/dialog-box/index.js +10 -6
  117. package/dialog-box/vue.js +1 -1
  118. package/dialog-select/index.js +345 -0
  119. package/dialog-select/vue.js +110 -0
  120. package/drawer/index.js +83 -0
  121. package/drawer/vue.js +51 -0
  122. package/drop-times/index.js +1 -1
  123. package/dropdown/index.js +2 -2
  124. package/dropdown/vue.js +1 -1
  125. package/dropdown-item/index.js +1 -1
  126. package/dropdown-item/mf.js +79 -0
  127. package/dropdown-menu/index.js +30 -1
  128. package/dropdown-menu/vue.js +17 -7
  129. package/dynamic-scroller/index.js +117 -0
  130. package/dynamic-scroller/vue.js +88 -0
  131. package/dynamic-scroller-item/index.js +147 -0
  132. package/dynamic-scroller-item/vue.js +92 -0
  133. package/espace/index.js +1 -1
  134. package/espace/vue.js +1 -1
  135. package/exception/vue.js +3 -1
  136. package/fall-menu/index.js +4 -4
  137. package/file-upload/index.js +872 -408
  138. package/file-upload/vue.js +87 -36
  139. package/filter/index.js +131 -0
  140. package/filter/tag-group.js +43 -0
  141. package/filter/vue.js +73 -0
  142. package/filter-bar/index.js +9 -0
  143. package/filter-bar/vue.js +16 -0
  144. package/filter-box/index.js +17 -0
  145. package/filter-box/vue.js +19 -0
  146. package/filter-panel/index.js +42 -0
  147. package/filter-panel/vue.js +33 -0
  148. package/floatbar/index.js +1 -1
  149. package/flowchart/index.js +721 -0
  150. package/flowchart/vue.js +81 -0
  151. package/form/index.js +15 -1
  152. package/form/vue.js +10 -4
  153. package/form-item/index.js +46 -6
  154. package/form-item/vue.js +27 -3
  155. package/fullscreen/index.js +1 -1
  156. package/fullscreen/vue.js +1 -1
  157. package/grid/plugins/export.js +2 -2
  158. package/grid/plugins/exportExcel.js +2 -2
  159. package/grid/plugins/resize.js +1 -1
  160. package/grid/static/base/helperEqualCompare.js +1 -1
  161. package/grid/static/base/isPlainObject.js +1 -1
  162. package/grid/utils/common.js +3 -3
  163. package/grid/utils/dom.js +3 -3
  164. package/grid/utils/event.js +2 -2
  165. package/guide/index.js +168 -0
  166. package/guide/vue.js +36 -0
  167. package/hrapprover/index.js +1 -1
  168. package/image/index.js +8 -4
  169. package/image/vue.js +12 -6
  170. package/image-viewer/index.js +3 -3
  171. package/image-viewer/vue.js +16 -6
  172. package/input/index.js +34 -1
  173. package/input/vue.js +22 -6
  174. package/ip-address/index.js +1 -1
  175. package/ip-address/vue.js +1 -1
  176. package/link-menu/index.js +2 -2
  177. package/link-menu/vue.js +2 -2
  178. package/loading/index.js +2 -2
  179. package/loading/vue.js +2 -1
  180. package/locales/index.js +1 -1
  181. package/logout/index.js +1 -1
  182. package/milestone/index.js +5 -1
  183. package/modal/index.js +68 -39
  184. package/modal/vue.js +15 -12
  185. package/month-range/index.js +1 -1
  186. package/month-range/vue.js +1 -1
  187. package/month-table/index.js +5 -5
  188. package/month-table/vue.js +1 -1
  189. package/multi-select/index.js +5 -2
  190. package/multi-select/vue.js +4 -5
  191. package/nav-menu/index.js +6 -6
  192. package/notify/index.js +3 -3
  193. package/numeric/index.js +15 -5
  194. package/numeric/vue.js +15 -6
  195. package/option/index.js +1 -1
  196. package/package.json +2 -1
  197. package/pager-item/index.js +1 -1
  198. package/panel/index.js +1 -1
  199. package/picker/index.js +7 -7
  200. package/picker/vue.js +1 -1
  201. package/picker-column/index.js +1 -1
  202. package/popconfirm/index.js +25 -0
  203. package/popconfirm/vue.js +22 -0
  204. package/popeditor/index.js +7 -7
  205. package/popeditor/vue.js +2 -2
  206. package/popover/index.js +11 -3
  207. package/popover/vue.js +33 -10
  208. package/popup/index.js +4 -4
  209. package/pull-refresh/index.js +8 -11
  210. package/pull-refresh/vue.js +7 -7
  211. package/radio/index.js +17 -0
  212. package/radio/vue.js +18 -3
  213. package/radio-button/index.js +8 -0
  214. package/radio-button/vue.js +19 -4
  215. package/radio-group/index.js +1 -1
  216. package/radio-group/vue.js +5 -2
  217. package/rate/index.js +4 -2
  218. package/rate/vue.js +1 -1
  219. package/record/index.js +190 -0
  220. package/record/vue.js +44 -0
  221. package/recycle-scroller/index.js +470 -0
  222. package/recycle-scroller/vue.js +135 -0
  223. package/river/index.js +371 -0
  224. package/river/river.js +352 -0
  225. package/river/vue.js +77 -0
  226. package/roles/index.js +1 -1
  227. package/scrollbar/vue-bar.js +1 -1
  228. package/scrollbar/vue.js +1 -1
  229. package/search/index.js +3 -3
  230. package/select/index.js +17 -14
  231. package/select/vue.js +14 -8
  232. package/select-dropdown/vue.js +1 -1
  233. package/select-mobile/index.js +111 -0
  234. package/select-mobile/vue.js +58 -0
  235. package/select-view/index.js +170 -0
  236. package/select-view/vue.js +82 -0
  237. package/selected-box/index.js +216 -0
  238. package/selected-box/vue.js +98 -0
  239. package/slide-bar/index.js +1 -1
  240. package/slider/index.js +49 -4
  241. package/slider/vue.js +15 -4
  242. package/split/vue.js +1 -1
  243. package/standard-list-item/index.js +18 -0
  244. package/standard-list-item/vue.js +22 -0
  245. package/steps/index.js +30 -0
  246. package/steps/slide-bar.js +122 -0
  247. package/steps/vue.js +15 -3
  248. package/switch/index.js +1 -1
  249. package/switch/vue.js +2 -1
  250. package/tab-bar/index.js +2 -2
  251. package/tab-item/index.js +2 -2
  252. package/tab-item/vue.js +1 -1
  253. package/tab-item-mf/index.js +0 -0
  254. package/tab-item-mf/vue.js +16 -0
  255. package/tab-nav/index.js +78 -4
  256. package/tab-nav/vue.js +11 -3
  257. package/tabbar-item/index.js +1 -1
  258. package/tabbar-item/vue.js +1 -1
  259. package/tabs/index.js +8 -9
  260. package/tabs/vue.js +1 -1
  261. package/tabs-mf/index.js +109 -0
  262. package/tabs-mf/vue-bar.js +49 -0
  263. package/tabs-mf/vue-nav-item.js +22 -0
  264. package/tabs-mf/vue-nav.js +13 -0
  265. package/tabs-mf/vue.js +45 -0
  266. package/tabs-mf/wheel.js +71 -0
  267. package/tag/index.js +8 -2
  268. package/tag/vue.js +13 -5
  269. package/tag-group/index.js +24 -0
  270. package/tag-group/vue.js +29 -0
  271. package/tall-storage/index.js +1 -1
  272. package/tall-storage/vue.js +1 -1
  273. package/time/index.js +1 -1
  274. package/time/vue.js +2 -2
  275. package/time-line/index.js +28 -7
  276. package/time-line/vue.js +9 -4
  277. package/time-panel/index.js +2 -2
  278. package/time-panel/vue.js +1 -1
  279. package/time-picker-mobile/index.js +30 -0
  280. package/time-picker-mobile/vue.js +30 -0
  281. package/time-range/index.js +1 -1
  282. package/time-range/vue.js +1 -1
  283. package/time-spinner/index.js +2 -2
  284. package/time-spinner/vue.js +1 -1
  285. package/toggle-menu/index.js +2 -2
  286. package/toggle-menu/vue.js +1 -1
  287. package/tooltip/index.js +30 -3
  288. package/tooltip/vue.js +33 -12
  289. package/top-box/index.js +3 -3
  290. package/transfer/index.js +1 -1
  291. package/transfer-panel/index.js +2 -2
  292. package/tree/index.js +6 -6
  293. package/tree/vue.js +1 -1
  294. package/tree-node/index.js +1 -1
  295. package/upload/index.js +1 -2
  296. package/upload/vue.js +2 -2
  297. package/upload-dragger/index.js +5 -1
  298. package/upload-dragger/vue.js +9 -3
  299. package/upload-list/index.js +158 -8
  300. package/upload-list/vue.js +77 -25
  301. package/user/index.js +86 -70
  302. package/user/vue.js +15 -5
  303. package/user-account/vue.js +1 -1
  304. package/user-contact/index.js +49 -3
  305. package/user-contact/vue.js +17 -8
  306. package/user-head-group/vue.js +17 -0
  307. package/user-link/index.js +10 -2
  308. package/user-link/vue.js +11 -6
  309. package/wheel/index.js +1 -1
  310. package/wizard/index.js +3 -3
  311. package/year-range/index.js +125 -0
  312. package/year-range/vue.js +88 -0
  313. package/year-table/index.js +175 -11
  314. package/year-table/vue.js +17 -5
@@ -0,0 +1,111 @@
1
+ import "../chunk-PKUHTIDK.js";
2
+ const hide = ({ state, emit }) => () => {
3
+ state.search.show = false;
4
+ emit("update:visible", false);
5
+ emit("close", false);
6
+ };
7
+ const watchVisible = ({ emit, state, props, api }) => (bool) => {
8
+ const { multiple, modelValue } = props;
9
+ if (bool && multiple) {
10
+ api.watchModelValue(modelValue);
11
+ }
12
+ setTimeout(() => {
13
+ state.toggle = bool;
14
+ }, 0);
15
+ emit("update:visible", bool);
16
+ };
17
+ const watchModelValue = ({ props, state, emit }) => (value) => {
18
+ const { multiple, menus, valueField, textField, textSplit } = props;
19
+ if (multiple) {
20
+ const ids = menus.map((option) => option[valueField]);
21
+ state.checkList = (value || []).map((id) => {
22
+ return ids.indexOf(id) > -1 ? menus[ids.indexOf(id)] : { [valueField]: id, [textField]: id };
23
+ });
24
+ }
25
+ const text = multiple ? state.checkList.map((item) => item[textField]) : menus.filter((item) => item[valueField] === value).map((item) => item[textField]);
26
+ emit("update:text", text.join(textSplit));
27
+ };
28
+ const includeOptionIndex = (props) => (list, option) => {
29
+ const { valueField } = props;
30
+ let index = -1;
31
+ list.some((item, i) => {
32
+ const isEqual = item[valueField] === option[valueField];
33
+ isEqual && (index = i);
34
+ return isEqual;
35
+ });
36
+ return index;
37
+ };
38
+ const selectOption = ({ emit, state, props, api }) => (option) => {
39
+ const { valueField, multiple } = props;
40
+ if (multiple) {
41
+ const index = api.includeOptionIndex(state.checkList, option);
42
+ index > -1 ? state.checkList.splice(index, 1) : state.checkList.push(option);
43
+ } else {
44
+ emit("update:visible", false);
45
+ emit("update:modelValue", option[valueField]);
46
+ }
47
+ emit("click", option);
48
+ };
49
+ const confirm = ({ emit, state, props, api }) => () => {
50
+ if (state.search.show) {
51
+ api.searchBoxToggle(false);
52
+ } else {
53
+ emit("confirm", state);
54
+ emit("update:visible", false);
55
+ props.multiple && emit("update:modelValue", state.checkIds);
56
+ }
57
+ };
58
+ const searchMethod = ({ state, props }) => () => {
59
+ const { searchConfig, textField } = props;
60
+ const { input, options } = state.search;
61
+ let list;
62
+ if (searchConfig && searchConfig.searchMethod) {
63
+ list = searchConfig.searchMethod({ input, options }) || [];
64
+ } else {
65
+ list = options.filter((item) => item[textField].indexOf(input) > -1);
66
+ }
67
+ if (list.then === "function") {
68
+ list.then((data) => state.search.filterOptions = data);
69
+ } else {
70
+ state.search.filterOptions = list;
71
+ }
72
+ };
73
+ const searchBoxToggle = ({ state, props, api }) => (bool) => {
74
+ const { menus, searchConfig } = props;
75
+ state.search.show = bool;
76
+ state.search.input = "";
77
+ if (bool) {
78
+ state.search.options = !searchConfig.options || !searchConfig.options.length ? menus : searchConfig.options;
79
+ api.searchMethod();
80
+ }
81
+ };
82
+ const allCheckHandler = ({ state, props }) => () => {
83
+ if (state.checkList.length === props.menus.length) {
84
+ state.checkList = [];
85
+ } else {
86
+ state.checkList = props.menus.slice();
87
+ }
88
+ };
89
+ const searchSelectHandler = ({ state, emit, api, props }) => (option) => {
90
+ const { valueField, multiple } = props;
91
+ if (multiple) {
92
+ const index = api.includeOptionIndex(state.checkList, option);
93
+ index > -1 ? state.checkList.splice(index, 1) : state.checkList.push(option);
94
+ } else {
95
+ api.searchBoxToggle(false);
96
+ emit("update:modelValue", option[valueField]);
97
+ }
98
+ emit("search-click", option);
99
+ };
100
+ export {
101
+ allCheckHandler,
102
+ confirm,
103
+ hide,
104
+ includeOptionIndex,
105
+ searchBoxToggle,
106
+ searchMethod,
107
+ searchSelectHandler,
108
+ selectOption,
109
+ watchModelValue,
110
+ watchVisible
111
+ };
@@ -0,0 +1,58 @@
1
+ import "../chunk-PKUHTIDK.js";
2
+ import {
3
+ hide,
4
+ watchVisible,
5
+ selectOption,
6
+ confirm,
7
+ searchMethod,
8
+ searchSelectHandler,
9
+ searchBoxToggle,
10
+ watchModelValue,
11
+ includeOptionIndex,
12
+ allCheckHandler
13
+ } from "./index";
14
+ const api = [
15
+ "state",
16
+ "hide",
17
+ "selectOption",
18
+ "confirm",
19
+ "searchMethod",
20
+ "searchSelectHandler",
21
+ "searchBoxToggle",
22
+ "includeOptionIndex",
23
+ "allCheckHandler"
24
+ ];
25
+ const renderless = (props, { computed, reactive, watch }, { emit }) => {
26
+ const api2 = {};
27
+ const state = reactive({
28
+ toggle: false,
29
+ checkList: [],
30
+ search: {
31
+ show: false,
32
+ input: "",
33
+ options: [],
34
+ filterOptions: []
35
+ },
36
+ checkIds: computed(() => state.checkList.map((option) => option[props.valueField]))
37
+ });
38
+ Object.assign(api2, {
39
+ state,
40
+ confirm: confirm({ state, emit, props, api: api2 }),
41
+ selectOption: selectOption({ state, emit, props, api: api2 }),
42
+ hide: hide({ state, emit }),
43
+ watchVisible: watchVisible({ emit, state, props, api: api2 }),
44
+ watchModelValue: watchModelValue({ props, state, emit }),
45
+ searchMethod: searchMethod({ state, props, api: api2 }),
46
+ searchSelectHandler: searchSelectHandler({ state, emit, api: api2, props }),
47
+ searchBoxToggle: searchBoxToggle({ state, props, api: api2 }),
48
+ allCheckHandler: allCheckHandler({ state, props }),
49
+ includeOptionIndex: includeOptionIndex(props)
50
+ });
51
+ watch(() => props.visible, api2.watchVisible);
52
+ watch(() => props.modelValue, api2.watchModelValue, { immediate: true });
53
+ return api2;
54
+ };
55
+ export {
56
+ api,
57
+ renderless
58
+ };
@@ -0,0 +1,170 @@
1
+ import "../chunk-PKUHTIDK.js";
2
+ const close = ({ state, emit, vm }) => () => {
3
+ state.search.input = "";
4
+ vm.$refs.actionSheet.close();
5
+ emit("close", false);
6
+ };
7
+ const watchVisible = ({ emit, state, props, api }) => (bool) => {
8
+ const { multiple, modelValue, menus } = props;
9
+ if (bool) {
10
+ if (!state.lazy) {
11
+ state.search.options = menus;
12
+ }
13
+ api.searchMethod();
14
+ multiple && api.watchModelValue(modelValue);
15
+ }
16
+ emit("update:visible", bool);
17
+ setTimeout(() => {
18
+ state.toggle = bool;
19
+ }, 0);
20
+ };
21
+ const watchModelValue = ({ props, state, emit }) => (value) => {
22
+ const { multiple, menus, valueField, textField, textSplit } = props;
23
+ if (multiple) {
24
+ const ids = menus.map((option) => option[valueField]);
25
+ state.checkList = (value || []).map((id) => {
26
+ return ids.indexOf(id) > -1 ? menus[ids.indexOf(id)] : { [valueField]: id, [textField]: id };
27
+ });
28
+ }
29
+ const textStr = multiple ? state.checkList.map((data) => data[textField]) : menus.filter((data) => data[valueField] === value).map((data) => data[textField]);
30
+ emit("update:text", textStr.join(textSplit));
31
+ };
32
+ const includeOptionIndex = (props) => (list, option) => {
33
+ const { valueField } = props;
34
+ let OptionIndex = -1;
35
+ list.some((data, i) => {
36
+ const isEqual = data[valueField] === option[valueField];
37
+ isEqual && (OptionIndex = i);
38
+ return isEqual;
39
+ });
40
+ return OptionIndex;
41
+ };
42
+ const selectOption = ({ emit, state, props, api }) => (data) => {
43
+ const { valueField, multiple } = props;
44
+ if (multiple) {
45
+ const index = api.includeOptionIndex(state.checkList, data);
46
+ index > -1 ? state.checkList.splice(index, 1) : state.checkList.push(data);
47
+ } else {
48
+ emit("update:visible", false);
49
+ emit("update:modelValue", data[valueField]);
50
+ }
51
+ emit("click", data);
52
+ };
53
+ const confirm = ({ state, props, api, emit }) => () => {
54
+ const { search, checkIds } = state;
55
+ if (!search.show) {
56
+ emit("confirm", state);
57
+ emit("update:visible", false);
58
+ props.multiple && emit("update:modelValue", checkIds);
59
+ } else {
60
+ api.searchBoxToggle(false);
61
+ }
62
+ };
63
+ const searchMethod = ({ state, props }) => () => {
64
+ const { input, options } = state.search;
65
+ const { searchConfig, textField, valueField, topConfig } = props;
66
+ const topOptionIds = (topConfig.options || []).map((item) => item[valueField]);
67
+ let list;
68
+ if (searchConfig && searchConfig.searchMethod) {
69
+ list = searchConfig.searchMethod({ input, options }) || [];
70
+ } else {
71
+ list = options.filter(
72
+ (item) => item[textField].indexOf(input) > -1 && topOptionIds.indexOf(item[valueField]) === -1
73
+ );
74
+ }
75
+ if (typeof list.then === "function") {
76
+ list.then((data) => state.search.filterOptions = data);
77
+ } else {
78
+ state.search.filterOptions = list;
79
+ }
80
+ };
81
+ const searchBoxToggle = ({ state, props, api }) => (bool) => {
82
+ const { menus } = props;
83
+ state.search.input = "";
84
+ if (bool) {
85
+ if (!state.lazy) {
86
+ state.search.options = menus;
87
+ }
88
+ api.searchMethod();
89
+ } else {
90
+ api.close();
91
+ }
92
+ };
93
+ const allCheckHandler = ({ state, props }) => () => {
94
+ state.checkList = state.checkList.length === props.menus.length ? [] : props.menus.slice();
95
+ };
96
+ const searchSelectHandler = ({ state, emit, api, props }) => (option) => {
97
+ const { valueField, multiple, requiredSelectedList } = props;
98
+ if (multiple) {
99
+ const index = api.includeOptionIndex(state.checkList, option);
100
+ if (index > -1 && requiredSelectedList.indexOf(option[valueField]) !== -1) {
101
+ emit("search-click", option, false);
102
+ return;
103
+ }
104
+ index > -1 ? state.checkList.splice(index, 1) : state.checkList.push(option);
105
+ } else {
106
+ api.searchBoxToggle(false);
107
+ emit("update:modelValue", option[valueField]);
108
+ }
109
+ emit("search-click", option, true);
110
+ };
111
+ const toggleCheckList = ({ state }) => (value) => {
112
+ if (!state.checkList.length) {
113
+ return;
114
+ }
115
+ state.selected.show = value;
116
+ if (value) {
117
+ state.selected.options = state.checkList.slice();
118
+ } else {
119
+ state.checkList = state.selected.options.slice();
120
+ }
121
+ };
122
+ const clean = ({ state, props }) => () => {
123
+ const { valueField, requiredSelectedList } = props;
124
+ state.selected.options = state.selected.options.filter(
125
+ (item) => requiredSelectedList.indexOf(item[valueField]) !== -1
126
+ );
127
+ };
128
+ const selectedOptionHandler = ({ state, api }) => (option) => {
129
+ const index = api.includeOptionIndex(state.selected.options, option);
130
+ if (index > -1) {
131
+ state.selected.options.splice(index, 1);
132
+ }
133
+ };
134
+ const load = ({ state, props, api }) => () => {
135
+ const { infiniteScroll } = props;
136
+ const { search } = state;
137
+ if (!infiniteScroll.load || state.search.loading) {
138
+ return;
139
+ }
140
+ const list = infiniteScroll.load({ input: search.input, options: search.options });
141
+ if (!list) {
142
+ return;
143
+ } else if (typeof list.then === "function") {
144
+ state.search.loading = true;
145
+ list.then((data) => {
146
+ state.search.loading = false;
147
+ state.search.options = search.options.concat(data);
148
+ api.searchMethod();
149
+ });
150
+ } else {
151
+ state.search.options = search.options.concat(list);
152
+ api.searchMethod();
153
+ }
154
+ };
155
+ export {
156
+ allCheckHandler,
157
+ clean,
158
+ close,
159
+ confirm,
160
+ includeOptionIndex,
161
+ load,
162
+ searchBoxToggle,
163
+ searchMethod,
164
+ searchSelectHandler,
165
+ selectOption,
166
+ selectedOptionHandler,
167
+ toggleCheckList,
168
+ watchModelValue,
169
+ watchVisible
170
+ };
@@ -0,0 +1,82 @@
1
+ import "../chunk-PKUHTIDK.js";
2
+ import {
3
+ close,
4
+ watchVisible,
5
+ selectOption,
6
+ confirm,
7
+ searchMethod,
8
+ searchSelectHandler,
9
+ searchBoxToggle,
10
+ watchModelValue,
11
+ includeOptionIndex,
12
+ allCheckHandler,
13
+ toggleCheckList,
14
+ clean,
15
+ load,
16
+ selectedOptionHandler
17
+ } from "./index";
18
+ const api = [
19
+ "state",
20
+ "allCheckHandler",
21
+ "close",
22
+ "selectOption",
23
+ "confirm",
24
+ "searchMethod",
25
+ "searchSelectHandler",
26
+ "searchBoxToggle",
27
+ "includeOptionIndex",
28
+ "clean",
29
+ "load",
30
+ "selectedOptionHandler",
31
+ "toggleCheckList"
32
+ ];
33
+ const renderless = (props, { computed, reactive, watch }, { emit, vm }) => {
34
+ const api2 = {};
35
+ const state = reactive({
36
+ toggle: false,
37
+ checkList: [],
38
+ selected: {
39
+ show: false,
40
+ options: []
41
+ },
42
+ search: {
43
+ filterOptions: [],
44
+ input: "",
45
+ options: props.menus || [],
46
+ loading: false
47
+ },
48
+ checkIds: computed(() => state.checkList.map((option) => option[props.valueField])),
49
+ lazy: computed(() => !props.infiniteScroll.disabled && typeof props.infiniteScroll.load === "function")
50
+ });
51
+ Object.assign(api2, {
52
+ state,
53
+ confirm: confirm({ state, emit, props, api: api2 }),
54
+ selectOption: selectOption({ state, emit, props, api: api2 }),
55
+ close: close({ state, emit, vm }),
56
+ watchVisible: watchVisible({ emit, state, props, api: api2 }),
57
+ watchModelValue: watchModelValue({ props, state, emit }),
58
+ searchMethod: searchMethod({ state, props, api: api2 }),
59
+ searchSelectHandler: searchSelectHandler({ state, emit, api: api2, props }),
60
+ searchBoxToggle: searchBoxToggle({ state, props, api: api2 }),
61
+ allCheckHandler: allCheckHandler({ state, props }),
62
+ toggleCheckList: toggleCheckList({ state }),
63
+ clean: clean({ state, props }),
64
+ load: load({ state, props, api: api2 }),
65
+ selectedOptionHandler: selectedOptionHandler({ state, api: api2 }),
66
+ includeOptionIndex: includeOptionIndex(props)
67
+ });
68
+ watch(() => props.visible, api2.watchVisible, { immediate: true });
69
+ watch(() => props.modelValue, api2.watchModelValue, { immediate: true });
70
+ watch(
71
+ () => props.menus,
72
+ (value) => {
73
+ state.search.options = value;
74
+ api2.searchMethod();
75
+ }
76
+ );
77
+ return api2;
78
+ };
79
+ export {
80
+ api,
81
+ renderless
82
+ };
@@ -0,0 +1,216 @@
1
+ import "../chunk-PKUHTIDK.js";
2
+ import { omitText } from "../common/string";
3
+ const normal = (n) => n < 0 ? 0 : n;
4
+ const init = ({ props, state }) => () => {
5
+ const { inverse, total, select } = props;
6
+ state.inverse = !!inverse;
7
+ state.total = state.inverse ? normal(total - select.length) : select.length;
8
+ state.select = select.slice(0);
9
+ };
10
+ const submitSelection = ({ api, state }) => (option, oper = "add") => {
11
+ const { inverse, total, select } = state;
12
+ if (oper === "add") {
13
+ const index = select.findIndex((opt) => api.keyOption(opt) === api.keyOption(option));
14
+ if (index === -1) {
15
+ state.select = [...select, option];
16
+ state.total = total + (inverse ? -1 : 1);
17
+ api.emitChange();
18
+ }
19
+ } else if (oper === "remove") {
20
+ const index = select.findIndex((opt) => api.keyOption(opt) === api.keyOption(option));
21
+ if (index > -1) {
22
+ state.select = [...select.slice(0, index), ...select.slice(index + 1)];
23
+ state.total = total + (inverse ? 1 : -1);
24
+ api.emitChange();
25
+ }
26
+ }
27
+ };
28
+ const validArray = (arr) => Array.isArray(arr) && arr.length;
29
+ const arrayMinus = (api) => (arr1, arr2) => {
30
+ let res = [];
31
+ if (validArray(arr1) && validArray(arr2)) {
32
+ arr1.forEach((item1) => {
33
+ if (arr2.findIndex((item2) => api.keyOption(item1) === api.keyOption(item2)) === -1) {
34
+ res.push(item1);
35
+ }
36
+ });
37
+ } else if (validArray(arr1) && !validArray(arr2)) {
38
+ res = [...arr1];
39
+ }
40
+ return res;
41
+ };
42
+ const batchSubmit = ({ api, state }) => (options, oper = "add") => {
43
+ const { inverse, total, select } = state;
44
+ if (oper === "add") {
45
+ const toPlus = api.arrayMinus(options, select);
46
+ if (validArray(toPlus)) {
47
+ state.select = [...select, ...toPlus];
48
+ state.total = total + (inverse ? -1 : 1) * toPlus.length;
49
+ api.emitChange();
50
+ }
51
+ } else if (oper === "remove") {
52
+ const toMinus = api.arrayMinus(select, api.arrayMinus(select, options));
53
+ if (validArray(toMinus)) {
54
+ let tmpSelect = select;
55
+ toMinus.map((opt1) => select.findIndex((opt2) => api.keyOption(opt1) === api.keyOption(opt2))).sort((a, b) => a - b).reverse().forEach((i) => tmpSelect = [...tmpSelect.slice(0, i), ...tmpSelect.slice(i + 1)]);
56
+ state.select = [...tmpSelect];
57
+ state.total = total + (inverse ? 1 : -1) * toMinus.length;
58
+ api.emitChange();
59
+ }
60
+ }
61
+ };
62
+ const coverSubmit = ({ api, props, state }) => (options) => {
63
+ const { total } = props;
64
+ const { inverse, select } = state;
65
+ if (Array.isArray(options)) {
66
+ const t0 = api.arrayMinus(select, api.arrayMinus(select, options));
67
+ const t1 = api.arrayMinus(options, select);
68
+ state.select = [...t0, ...t1];
69
+ state.total = inverse ? normal(total - options.length) : options.length;
70
+ api.emitChange();
71
+ }
72
+ };
73
+ const getSelection = ({ api, state }) => () => {
74
+ const { inverse, select } = state;
75
+ return { flag: !inverse, selection: select, state: api.getParams() };
76
+ };
77
+ const i18nSelected = ({ state, t }) => () => {
78
+ const { inverse, total } = state;
79
+ const template = inverse ? t("ui.selectedBox.allSelect") : t("ui.selectedBox.select");
80
+ return template.replace("%s", total);
81
+ };
82
+ const computedShowAuxi = (props) => () => {
83
+ const { config } = props;
84
+ const { showField } = config || {};
85
+ return Array.isArray(showField) && showField.length > 1;
86
+ };
87
+ const textPrimary = (props) => (option) => {
88
+ const { config } = props;
89
+ const { showField } = config || {};
90
+ let primaryText = "";
91
+ if (typeof showField === "string") {
92
+ primaryText = option[showField];
93
+ } else if (Array.isArray(showField) && typeof showField[0] === "string") {
94
+ primaryText = option[showField[0]];
95
+ }
96
+ return primaryText;
97
+ };
98
+ const textAuxi = (props) => (option) => {
99
+ const { config } = props;
100
+ const { showField } = config || {};
101
+ let auxiText = "";
102
+ if (Array.isArray(showField) && typeof showField[1] === "string") {
103
+ auxiText = option[showField[1]];
104
+ }
105
+ return auxiText;
106
+ };
107
+ const handleMouseenter = ({ state, vm }) => (e) => {
108
+ const dom = e.target;
109
+ const text = dom.textContent;
110
+ const font = window.getComputedStyle(dom).font;
111
+ const rect = dom.getBoundingClientRect();
112
+ const res = omitText(text, font, rect.width);
113
+ const popover = vm.$refs.popover;
114
+ if (res.o) {
115
+ popover.state.referenceElm = dom;
116
+ popover.state.popperElm && (popover.state.popperElm.style.display = "none");
117
+ popover.doDestroy();
118
+ state.popoverContent = text;
119
+ state.popoverVisible = true;
120
+ setTimeout(popover.updatePopper, 20);
121
+ }
122
+ };
123
+ const handleMouseleave = (state) => () => {
124
+ state.popoverContent = "";
125
+ state.popoverVisible = false;
126
+ };
127
+ const handleClear = ({ api, emit, props, state }) => () => {
128
+ const { total } = props;
129
+ const { inverse, select } = state;
130
+ if (Array.isArray(select) && select.length) {
131
+ state.select = [];
132
+ state.total = inverse ? normal(total) : 0;
133
+ api.emitChange();
134
+ emit("clear", { state: api.getParams() });
135
+ }
136
+ };
137
+ const handleDelete = ({ api, emit, state }) => (option) => {
138
+ const { inverse, total, select } = state;
139
+ const index = select.findIndex((opt) => api.keyOption(opt) === api.keyOption(option));
140
+ if (index > -1) {
141
+ state.select = [...select.slice(0, index), ...select.slice(index + 1)];
142
+ state.total = total + (inverse ? 1 : -1);
143
+ api.emitChange();
144
+ emit("delete", { option, state: api.getParams() });
145
+ }
146
+ };
147
+ const getParams = (state) => () => {
148
+ const { inverse, total, select } = state;
149
+ return { inverse, total, select };
150
+ };
151
+ const emitChange = ({ api, emit }) => () => emit("change", api.getSelection());
152
+ const keyOption = ({ api, props }) => (option) => {
153
+ const { config } = props;
154
+ const { pkField = "id" } = config || {};
155
+ return api.keyType(option[pkField]);
156
+ };
157
+ const keyType = (props) => (keyValue) => {
158
+ const { config } = props;
159
+ const { pkFieldType = "number" } = config || {};
160
+ const typeFn = pkFieldType === "number" ? Number : String;
161
+ return typeFn(keyValue);
162
+ };
163
+ const initDrag = ({ api, emit, markRaw, props, state, vm }) => () => {
164
+ const { config } = props;
165
+ const { plugin } = config || {};
166
+ const { optionSelector, dragAnimation } = state;
167
+ const handleUpdate = (e) => {
168
+ const { from, to, oldIndex, newIndex } = e;
169
+ const { select } = state;
170
+ if (from === to && oldIndex !== newIndex) {
171
+ const optDoms = Array.from(vm.$el.querySelectorAll(optionSelector));
172
+ const slct = optDoms.map((optDom) => select.find((opt) => api.keyOption(opt) === api.keyType(optDom.dataset.key)));
173
+ state.select = slct;
174
+ state.refresh += 1;
175
+ api.emitChange();
176
+ emit("drag", { state: api.getParams() });
177
+ }
178
+ };
179
+ if (!plugin)
180
+ return;
181
+ const dragInstance = plugin.create(vm.$refs.list, {
182
+ animation: dragAnimation,
183
+ draggable: optionSelector,
184
+ onUpdate: handleUpdate
185
+ });
186
+ state.dragInstance = markRaw(dragInstance);
187
+ };
188
+ const unmount = (state) => () => {
189
+ const { dragInstance } = state;
190
+ if (dragInstance && typeof dragInstance.destroy === "function") {
191
+ dragInstance.destroy();
192
+ state.dragInstance = null;
193
+ }
194
+ };
195
+ export {
196
+ arrayMinus,
197
+ batchSubmit,
198
+ computedShowAuxi,
199
+ coverSubmit,
200
+ emitChange,
201
+ getParams,
202
+ getSelection,
203
+ handleClear,
204
+ handleDelete,
205
+ handleMouseenter,
206
+ handleMouseleave,
207
+ i18nSelected,
208
+ init,
209
+ initDrag,
210
+ keyOption,
211
+ keyType,
212
+ submitSelection,
213
+ textAuxi,
214
+ textPrimary,
215
+ unmount
216
+ };