@opentiny/vue-renderless 3.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (397) hide show
  1. package/action-sheet/index.js +28 -0
  2. package/action-sheet/vue.js +29 -0
  3. package/alert/index.js +23 -0
  4. package/alert/vue.js +37 -0
  5. package/autocomplete/index.js +175 -0
  6. package/autocomplete/vue.js +171 -0
  7. package/avatar/index.js +29 -0
  8. package/avatar/vue.js +24 -0
  9. package/badge/index.js +16 -0
  10. package/badge/vue.js +30 -0
  11. package/breadcrumb/vue.js +4 -0
  12. package/breadcrumb-item/vue.js +24 -0
  13. package/bulletin-board/index.js +21 -0
  14. package/bulletin-board/vue.js +36 -0
  15. package/button/index.js +19 -0
  16. package/button/vue.js +43 -0
  17. package/button-group/index.js +25 -0
  18. package/button-group/vue.js +51 -0
  19. package/calendar/index.js +279 -0
  20. package/calendar/vue.js +124 -0
  21. package/card-template/index.js +39 -0
  22. package/card-template/vue.js +34 -0
  23. package/carousel/index.js +206 -0
  24. package/carousel/vue.js +222 -0
  25. package/carousel-item/index.js +93 -0
  26. package/carousel-item/vue.js +57 -0
  27. package/cascader/index.js +511 -0
  28. package/cascader/vue.js +342 -0
  29. package/cascader-menu/index.js +41 -0
  30. package/cascader-menu/vue.js +36 -0
  31. package/cascader-node/index.js +63 -0
  32. package/cascader-node/vue.js +62 -0
  33. package/cascader-panel/index.js +359 -0
  34. package/cascader-panel/node.js +199 -0
  35. package/cascader-panel/store.js +80 -0
  36. package/cascader-panel/vue.js +217 -0
  37. package/checkbox/index.js +145 -0
  38. package/checkbox/vue.js +139 -0
  39. package/checkbox-button/index.js +102 -0
  40. package/checkbox-button/vue.js +150 -0
  41. package/checkbox-group/index.js +12 -0
  42. package/checkbox-group/vue.js +33 -0
  43. package/col/index.js +132 -0
  44. package/col/vue.js +34 -0
  45. package/collapse/index.js +45 -0
  46. package/collapse/vue.js +35 -0
  47. package/collapse-item/index.js +38 -0
  48. package/collapse-item/vue.js +48 -0
  49. package/common/array.js +120 -0
  50. package/common/bigInt.js +352 -0
  51. package/common/browser.js +69 -0
  52. package/common/dataset/index.js +135 -0
  53. package/common/date.js +352 -0
  54. package/common/decimal.js +203 -0
  55. package/common/deps/ResizeObserver.js +474 -0
  56. package/common/deps/after-leave.js +25 -0
  57. package/common/deps/clickoutside.js +61 -0
  58. package/common/deps/date-util.js +262 -0
  59. package/common/deps/date.js +308 -0
  60. package/common/deps/debounce.js +4 -0
  61. package/common/deps/dom.js +190 -0
  62. package/common/deps/fullscreen/apis.js +157 -0
  63. package/common/deps/fullscreen/screenfull.js +106 -0
  64. package/common/deps/letter-only.js +15 -0
  65. package/common/deps/memorize.js +149 -0
  66. package/common/deps/number-only.js +16 -0
  67. package/common/deps/popper.js +713 -0
  68. package/common/deps/popup-manager.js +179 -0
  69. package/common/deps/repeat-click.js +24 -0
  70. package/common/deps/requestAnimationFrame.js +25 -0
  71. package/common/deps/resize-event.js +29 -0
  72. package/common/deps/scroll-into-view.js +29 -0
  73. package/common/deps/scrollbar-width.js +25 -0
  74. package/common/deps/throttle.js +34 -0
  75. package/common/deps/touch.js +33 -0
  76. package/common/deps/tree-model/node.js +586 -0
  77. package/common/deps/tree-model/tree-store.js +377 -0
  78. package/common/deps/tree-model/util.js +14 -0
  79. package/common/deps/upload-ajax.js +71 -0
  80. package/common/deps/vue-emitter.js +30 -0
  81. package/common/deps/vue-popper.js +291 -0
  82. package/common/deps/vue-popup.js +211 -0
  83. package/common/event.js +17 -0
  84. package/common/index.js +288 -0
  85. package/common/object.js +228 -0
  86. package/common/runtime.js +52 -0
  87. package/common/string.js +446 -0
  88. package/common/type.js +65 -0
  89. package/common/validate/index.js +6 -0
  90. package/common/validate/messages.js +68 -0
  91. package/common/validate/rules/enum.js +8 -0
  92. package/common/validate/rules/index.js +14 -0
  93. package/common/validate/rules/pattern.js +16 -0
  94. package/common/validate/rules/range.js +62 -0
  95. package/common/validate/rules/required.js +13 -0
  96. package/common/validate/rules/type.js +110 -0
  97. package/common/validate/rules/whitespace.js +6 -0
  98. package/common/validate/schema.js +323 -0
  99. package/common/validate/util.js +198 -0
  100. package/common/validate/validations/array.js +25 -0
  101. package/common/validate/validations/date.js +35 -0
  102. package/common/validate/validations/enum.js +24 -0
  103. package/common/validate/validations/float.js +24 -0
  104. package/common/validate/validations/index.js +42 -0
  105. package/common/validate/validations/integer.js +24 -0
  106. package/common/validate/validations/method.js +23 -0
  107. package/common/validate/validations/number.js +27 -0
  108. package/common/validate/validations/pattern.js +23 -0
  109. package/common/validate/validations/required.js +15 -0
  110. package/common/validate/validations/string.js +29 -0
  111. package/common/validate/validations/type.js +25 -0
  112. package/common/xss.js +325 -0
  113. package/container/index.js +110 -0
  114. package/container/vue.js +63 -0
  115. package/credit-card/index.js +107 -0
  116. package/credit-card/vue.js +117 -0
  117. package/credit-card-form/index.js +143 -0
  118. package/credit-card-form/vue.js +150 -0
  119. package/crop/index.js +297 -0
  120. package/crop/vue.js +191 -0
  121. package/date-panel/index.js +584 -0
  122. package/date-panel/vue.js +319 -0
  123. package/date-picker/index.js +301 -0
  124. package/date-picker/vue.js +169 -0
  125. package/date-range/index.js +463 -0
  126. package/date-range/vue.js +297 -0
  127. package/date-table/index.js +457 -0
  128. package/date-table/vue.js +151 -0
  129. package/detail-page/index.js +135 -0
  130. package/detail-page/vue.js +145 -0
  131. package/dialog-box/index.js +268 -0
  132. package/dialog-box/vue.js +226 -0
  133. package/drop-times/index.js +23 -0
  134. package/drop-times/vue.js +28 -0
  135. package/dropdown/index.js +259 -0
  136. package/dropdown/vue.js +107 -0
  137. package/dropdown-item/index.js +155 -0
  138. package/dropdown-item/vue.js +124 -0
  139. package/dropdown-menu/index.js +148 -0
  140. package/dropdown-menu/vue.js +44 -0
  141. package/exception/index.js +13 -0
  142. package/exception/vue.js +25 -0
  143. package/fall-menu/index.js +121 -0
  144. package/fall-menu/vue.js +90 -0
  145. package/file-upload/index.js +1940 -0
  146. package/file-upload/vue.js +458 -0
  147. package/floatbar/index.js +10 -0
  148. package/floatbar/vue.js +17 -0
  149. package/form/index.js +186 -0
  150. package/form/vue.js +69 -0
  151. package/form-item/index.js +364 -0
  152. package/form-item/vue.js +210 -0
  153. package/fullscreen/index.js +138 -0
  154. package/fullscreen/vue.js +77 -0
  155. package/grid/core/index.js +3 -0
  156. package/grid/core/interceptor.js +38 -0
  157. package/grid/core/storeMap.js +19 -0
  158. package/grid/plugins/export.js +169 -0
  159. package/grid/plugins/exportExcel.js +749 -0
  160. package/grid/plugins/header.js +58 -0
  161. package/grid/plugins/resize.js +82 -0
  162. package/grid/static/array/arrayEach.js +12 -0
  163. package/grid/static/array/arrayIndexOf.js +11 -0
  164. package/grid/static/array/eachTree.js +32 -0
  165. package/grid/static/array/every.js +2 -0
  166. package/grid/static/array/filterTree.js +16 -0
  167. package/grid/static/array/find.js +3 -0
  168. package/grid/static/array/findTree.js +46 -0
  169. package/grid/static/array/helperCreateIterateHandle.js +59 -0
  170. package/grid/static/array/helperCreateTreeFunc.js +18 -0
  171. package/grid/static/array/includes.js +5 -0
  172. package/grid/static/array/lastArrayEach.js +6 -0
  173. package/grid/static/array/map.js +23 -0
  174. package/grid/static/array/mapTree.js +33 -0
  175. package/grid/static/array/slice.js +10 -0
  176. package/grid/static/array/sortBy.js +69 -0
  177. package/grid/static/array/sum.js +28 -0
  178. package/grid/static/array/toArray.js +7 -0
  179. package/grid/static/array/toTreeArray.js +24 -0
  180. package/grid/static/base/clear.js +44 -0
  181. package/grid/static/base/clone.js +18 -0
  182. package/grid/static/base/destructuring.js +18 -0
  183. package/grid/static/base/each.js +9 -0
  184. package/grid/static/base/eqNull.js +6 -0
  185. package/grid/static/base/findIndexOf.js +10 -0
  186. package/grid/static/base/get.js +42 -0
  187. package/grid/static/base/has.js +60 -0
  188. package/grid/static/base/hasOwnProp.js +4 -0
  189. package/grid/static/base/helperCreateGetObjects.js +26 -0
  190. package/grid/static/base/helperCreateInInObjectString.js +7 -0
  191. package/grid/static/base/helperCreateInTypeof.js +6 -0
  192. package/grid/static/base/helperCreateIndexOf.js +21 -0
  193. package/grid/static/base/helperCreateiterateIndexOf.js +21 -0
  194. package/grid/static/base/helperDefaultCompare.js +4 -0
  195. package/grid/static/base/helperDeleteProperty.js +8 -0
  196. package/grid/static/base/helperEqualCompare.js +60 -0
  197. package/grid/static/base/helperGetHGSKeys.js +4 -0
  198. package/grid/static/base/indexOf.js +3 -0
  199. package/grid/static/base/isArray.js +3 -0
  200. package/grid/static/base/isBoolean.js +4 -0
  201. package/grid/static/base/isDate.js +3 -0
  202. package/grid/static/base/isEmpty.js +8 -0
  203. package/grid/static/base/isEqual.js +11 -0
  204. package/grid/static/base/isFunction.js +4 -0
  205. package/grid/static/base/isNaN.js +5 -0
  206. package/grid/static/base/isNull.js +4 -0
  207. package/grid/static/base/isNumber.js +4 -0
  208. package/grid/static/base/isObject.js +5 -0
  209. package/grid/static/base/isPlainObject.js +2 -0
  210. package/grid/static/base/isRegExp.js +3 -0
  211. package/grid/static/base/isSet.js +5 -0
  212. package/grid/static/base/isString.js +4 -0
  213. package/grid/static/base/isUndefined.js +4 -0
  214. package/grid/static/base/keys.js +3 -0
  215. package/grid/static/base/lastEach.js +9 -0
  216. package/grid/static/base/remove.js +44 -0
  217. package/grid/static/base/set.js +43 -0
  218. package/grid/static/base/toJSONString.js +4 -0
  219. package/grid/static/base/toStringJSON.js +13 -0
  220. package/grid/static/base/uniqueId.js +5 -0
  221. package/grid/static/browse/browse.js +54 -0
  222. package/grid/static/function/property.js +7 -0
  223. package/grid/static/function/throttle.js +43 -0
  224. package/grid/static/index.js +55 -0
  225. package/grid/static/number/helperCreateToNumber.js +12 -0
  226. package/grid/static/number/toNumber.js +3 -0
  227. package/grid/static/object/assign.js +41 -0
  228. package/grid/static/object/extend.js +3 -0
  229. package/grid/static/object/lastObjectEach.js +8 -0
  230. package/grid/static/object/objectEach.js +11 -0
  231. package/grid/static/object/objectMap.js +20 -0
  232. package/grid/static/object/values.js +9 -0
  233. package/grid/static/static/staticDocument.js +4 -0
  234. package/grid/static/static/staticHGKeyRE.js +2 -0
  235. package/grid/static/static/staticParseInt.js +2 -0
  236. package/grid/static/static/staticStrUndefined.js +2 -0
  237. package/grid/static/static/staticWindow.js +4 -0
  238. package/grid/static/string/template.js +12 -0
  239. package/grid/static/string/toString.js +12 -0
  240. package/grid/utils/column.js +72 -0
  241. package/grid/utils/common.js +155 -0
  242. package/grid/utils/dom.js +213 -0
  243. package/grid/utils/event.js +40 -0
  244. package/grid/utils/index.js +5 -0
  245. package/image/index.js +187 -0
  246. package/image/vue.js +142 -0
  247. package/image-viewer/index.js +469 -0
  248. package/image-viewer/vue.js +243 -0
  249. package/input/index.js +319 -0
  250. package/input/vue.js +319 -0
  251. package/ip-address/index.js +370 -0
  252. package/ip-address/vue.js +185 -0
  253. package/layout/vue.js +4 -0
  254. package/link/index.js +10 -0
  255. package/link/vue.js +26 -0
  256. package/link-menu/index.js +146 -0
  257. package/link-menu/vue.js +138 -0
  258. package/list/index.js +13 -0
  259. package/list/vue.js +17 -0
  260. package/loading/index.js +29 -0
  261. package/loading/vue.js +28 -0
  262. package/milestone/index.js +92 -0
  263. package/milestone/vue.js +31 -0
  264. package/mini-picker/index.js +227 -0
  265. package/mini-picker/vue.js +142 -0
  266. package/modal/index.js +866 -0
  267. package/modal/vue.js +130 -0
  268. package/month-range/index.js +169 -0
  269. package/month-range/vue.js +104 -0
  270. package/month-table/index.js +232 -0
  271. package/month-table/vue.js +72 -0
  272. package/nav-menu/index.js +457 -0
  273. package/nav-menu/vue.js +187 -0
  274. package/notify/index.js +91 -0
  275. package/notify/vue.js +67 -0
  276. package/numeric/index.js +419 -0
  277. package/numeric/vue.js +218 -0
  278. package/option/index.js +79 -0
  279. package/option/vue.js +219 -0
  280. package/option-group/index.js +18 -0
  281. package/option-group/vue.js +37 -0
  282. package/package.json +179 -0
  283. package/pager-item/index.js +122 -0
  284. package/pager-item/vue.js +52 -0
  285. package/panel/index.js +30 -0
  286. package/panel/vue.js +26 -0
  287. package/picker/index.js +1039 -0
  288. package/picker/timezone.js +974 -0
  289. package/picker/vue.js +415 -0
  290. package/picker-column/index.js +261 -0
  291. package/picker-column/vue.js +163 -0
  292. package/pop-upload/index.js +324 -0
  293. package/pop-upload/vue.js +292 -0
  294. package/popeditor/index.js +884 -0
  295. package/popeditor/vue.js +368 -0
  296. package/popover/index.js +203 -0
  297. package/popover/vue.js +174 -0
  298. package/popup/index.js +139 -0
  299. package/popup/vue.js +129 -0
  300. package/progress/index.js +174 -0
  301. package/progress/vue.js +118 -0
  302. package/pull-refresh/index.js +104 -0
  303. package/pull-refresh/vue.js +64 -0
  304. package/radio/index.js +83 -0
  305. package/radio/vue.js +99 -0
  306. package/radio-button/index.js +58 -0
  307. package/radio-button/vue.js +70 -0
  308. package/radio-group/index.js +51 -0
  309. package/radio-group/vue.js +34 -0
  310. package/rate/index.js +254 -0
  311. package/rate/vue.js +158 -0
  312. package/row/index.js +19 -0
  313. package/row/vue.js +24 -0
  314. package/scroll-text/index.js +24 -0
  315. package/scroll-text/vue.js +31 -0
  316. package/scrollbar/index.js +127 -0
  317. package/scrollbar/vue-bar.js +49 -0
  318. package/scrollbar/vue.js +43 -0
  319. package/search/index.js +110 -0
  320. package/search/vue.js +110 -0
  321. package/select/index.js +1766 -0
  322. package/select/vue.js +693 -0
  323. package/select-dropdown/index.js +23 -0
  324. package/select-dropdown/vue.js +122 -0
  325. package/slide-bar/index.js +94 -0
  326. package/slide-bar/vue.js +58 -0
  327. package/slider/index.js +434 -0
  328. package/slider/vue.js +172 -0
  329. package/split/index.js +122 -0
  330. package/split/vue.js +131 -0
  331. package/steps/vue.js +4 -0
  332. package/switch/index.js +45 -0
  333. package/switch/vue.js +62 -0
  334. package/tab-bar/index.js +51 -0
  335. package/tab-bar/vue.js +16 -0
  336. package/tab-dropdown/index.js +11 -0
  337. package/tab-dropdown/vue.js +17 -0
  338. package/tab-item/index.js +37 -0
  339. package/tab-item/vue.js +49 -0
  340. package/tab-nav/index.js +247 -0
  341. package/tab-nav/vue.js +106 -0
  342. package/tabbar/index.js +32 -0
  343. package/tabbar/vue.js +54 -0
  344. package/tabbar-item/index.js +55 -0
  345. package/tabbar-item/vue.js +53 -0
  346. package/table/index.js +111 -0
  347. package/table/vue.js +66 -0
  348. package/tabs/index.js +174 -0
  349. package/tabs/vue.js +141 -0
  350. package/tag/index.js +14 -0
  351. package/tag/vue.js +13 -0
  352. package/tall-storage/index.js +161 -0
  353. package/tall-storage/vue-storage-box.js +25 -0
  354. package/tall-storage/vue.js +38 -0
  355. package/text-popup/index.js +75 -0
  356. package/text-popup/vue.js +64 -0
  357. package/time/index.js +121 -0
  358. package/time/vue.js +124 -0
  359. package/time-line/index.js +60 -0
  360. package/time-line/vue.js +49 -0
  361. package/time-panel/index.js +189 -0
  362. package/time-panel/scrollIntoView.js +23 -0
  363. package/time-panel/vue.js +110 -0
  364. package/time-range/index.js +199 -0
  365. package/time-range/vue.js +129 -0
  366. package/time-spinner/index.js +175 -0
  367. package/time-spinner/vue.js +122 -0
  368. package/toggle-menu/index.js +104 -0
  369. package/toggle-menu/vue.js +74 -0
  370. package/tooltip/index.js +171 -0
  371. package/tooltip/vue.js +133 -0
  372. package/top-box/index.js +81 -0
  373. package/top-box/vue.js +77 -0
  374. package/transfer/index.js +296 -0
  375. package/transfer/vue.js +138 -0
  376. package/transfer-panel/index.js +364 -0
  377. package/transfer-panel/vue.js +258 -0
  378. package/tree/index.js +642 -0
  379. package/tree/vue.js +268 -0
  380. package/tree-menu/index.js +124 -0
  381. package/tree-menu/vue.js +60 -0
  382. package/tree-node/index.js +271 -0
  383. package/tree-node/vue.js +211 -0
  384. package/upload/index.js +324 -0
  385. package/upload/vue.js +93 -0
  386. package/upload-dragger/index.js +50 -0
  387. package/upload-dragger/vue.js +27 -0
  388. package/upload-list/index.js +55 -0
  389. package/upload-list/vue.js +48 -0
  390. package/user-contact/index.js +13 -0
  391. package/user-contact/vue.js +20 -0
  392. package/user-head/index.js +71 -0
  393. package/user-head/vue.js +47 -0
  394. package/wizard/index.js +123 -0
  395. package/wizard/vue.js +45 -0
  396. package/year-table/index.js +40 -0
  397. package/year-table/vue.js +23 -0
@@ -0,0 +1,1766 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+ import { find } from '@opentiny/vue-renderless/common/array';
7
+ import { getObj, isEqual } from '@opentiny/vue-renderless/common/object';
8
+ import { isKorean } from '@opentiny/vue-renderless/common/string';
9
+ import scrollIntoView from '@opentiny/vue-renderless/common/deps/scroll-into-view';
10
+ import PopupManager from '@opentiny/vue-renderless/common/deps/popup-manager';
11
+ import debounce from '@opentiny/vue-renderless/common/deps/debounce';
12
+ import { getDataset } from '@opentiny/vue-renderless/common/dataset';
13
+ import Memorize from '@opentiny/vue-renderless/common/deps/memorize';
14
+ import { isEmptyObject } from '@opentiny/vue-renderless/common/type';
15
+ import { addResizeListener, removeResizeListener } from '@opentiny/vue-renderless/common/deps/resize-event';
16
+ import { extend } from '@opentiny/vue-renderless/common/object';
17
+ export var handleComposition = function handleComposition(_ref) {
18
+ var api = _ref.api,
19
+ nextTick = _ref.nextTick,
20
+ state = _ref.state;
21
+ return function (event) {
22
+ var text = event.target.value;
23
+ if (event.type === 'compositionend') {
24
+ state.isOnComposition = false;
25
+ nextTick(function () {
26
+ return api.handleQueryChange(text);
27
+ });
28
+ } else {
29
+ var lastCharacter = text[text.length - 1] || '';
30
+ state.isOnComposition = !isKorean(lastCharacter);
31
+ }
32
+ };
33
+ };
34
+ export var showTip = function showTip(_ref2) {
35
+ var props = _ref2.props,
36
+ state = _ref2.state,
37
+ refs = _ref2.refs;
38
+ return function (show) {
39
+ if (!props.showOverflowTooltip) {
40
+ return;
41
+ }
42
+ var overflow;
43
+ if (!show) {
44
+ clearTimeout(state.tipTimer);
45
+ state.tipTimer = setTimeout(function () {
46
+ state.showTip = state.tipHover;
47
+ }, refs.popover.closeDelay);
48
+ } else {
49
+ if (!props.multiple) {
50
+ var reference = refs.reference.$el;
51
+ overflow = reference.querySelector('input').scrollWidth > reference.scrollWidth;
52
+ } else {
53
+ overflow = refs.tags.scrollHeight > refs.tags.getBoundingClientRect().height;
54
+ }
55
+ state.showTip = show && overflow && !!state.tips && !state.visible;
56
+ }
57
+ };
58
+ };
59
+ export var gridOnQueryChange = function gridOnQueryChange(_ref3) {
60
+ var props = _ref3.props,
61
+ refs = _ref3.refs,
62
+ constants = _ref3.constants,
63
+ state = _ref3.state;
64
+ return function (value) {
65
+ var multiple = props.multiple,
66
+ valueField = props.valueField,
67
+ filterMethod = props.filterMethod,
68
+ filterable = props.filterable,
69
+ remote = props.remote,
70
+ remoteMethod = props.remoteMethod;
71
+ if (filterable && typeof filterMethod === 'function') {
72
+ var table = refs.selectGrid.$refs.tinyTable;
73
+ var fullData = table.afterFullData;
74
+ refs.selectGrid.scrollTo(null, 0);
75
+ table.afterFullData = filterMethod(value, fullData) || [];
76
+ refs.selectGrid.handleTableData(!value).then(function () {
77
+ return state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
78
+ });
79
+ state.previousQuery = value;
80
+ } else if (remote && typeof remoteMethod === 'function') {
81
+ state.previousQuery = value;
82
+ remoteMethod(value).then(function (data) {
83
+ if (multiple) {
84
+ var selectedIds = state.selected.map(function (sel) {
85
+ return sel[valueField];
86
+ });
87
+ refs.selectGrid.clearSelection();
88
+ refs.selectGrid.setSelection(data.filter(function (row) {
89
+ return ~selectedIds.indexOf(row[valueField]);
90
+ }), true);
91
+ state.remoteData = data.filter(function (row) {
92
+ return !~selectedIds.indexOf(row[valueField]);
93
+ }).concat(state.selected);
94
+ } else {
95
+ refs.selectGrid.clearRadioRow();
96
+ refs.selectGrid.setRadioRow(find(data, function (item) {
97
+ return props.modelValue == item[props.valueField];
98
+ }));
99
+ state.remoteData = data;
100
+ }
101
+ refs.selectGrid.$refs.tinyTable.lastScrollTop = 0;
102
+ refs.selectGrid.loadData(data);
103
+ refs.selectGrid.handleTableData(!value).then(function () {
104
+ return state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
105
+ });
106
+ });
107
+ }
108
+ };
109
+ };
110
+ export var defaultOnQueryChange = function defaultOnQueryChange(_ref4) {
111
+ var props = _ref4.props,
112
+ state = _ref4.state,
113
+ constants = _ref4.constants,
114
+ api = _ref4.api;
115
+ return function (value) {
116
+ if (props.remote && typeof props.remoteMethod === 'function') {
117
+ state.hoverIndex = -1;
118
+ props.remoteMethod(value);
119
+ } else if (typeof props.filterMethod === 'function') {
120
+ props.filterMethod(value);
121
+ state.selectEmitter.emit(constants.COMPONENT_NAME.OptionGroup, constants.EVENT_NAME.queryChange);
122
+ } else {
123
+ state.filteredOptionsCount = state.optionsCount;
124
+ state.selectEmitter.emit(constants.EVENT_NAME.queryChange, value);
125
+ }
126
+ if (props.defaultFirstOption && (props.filterable || props.remote) && state.filteredOptionsCount) {
127
+ api.checkDefaultFirstOption();
128
+ }
129
+ };
130
+ };
131
+ export var handleQueryChange = function handleQueryChange(_ref5) {
132
+ var api = _ref5.api,
133
+ constants = _ref5.constants,
134
+ nextTick = _ref5.nextTick,
135
+ props = _ref5.props,
136
+ vm = _ref5.vm,
137
+ state = _ref5.state;
138
+ return function (value) {
139
+ var refs = vm.$refs;
140
+ if (state.previousQuery === value || state.isOnComposition) {
141
+ return;
142
+ }
143
+ if (state.previousQuery === null && (typeof props.filterMethod === 'function' || typeof props.remoteMethod === 'function')) {
144
+ state.previousQuery = value;
145
+ return;
146
+ }
147
+ if (props.renderType === constants.TYPE.Grid) {
148
+ api.gridOnQueryChange(value);
149
+ return;
150
+ }
151
+ if (props.renderType === constants.TYPE.Tree) {
152
+ state.previousQuery = value;
153
+ if (props.filterable && typeof props.filterMethod === 'function') {
154
+ refs.selectTree && refs.selectTree.filter(value);
155
+ }
156
+ }
157
+ state.previousQuery = value;
158
+ nextTick(function () {
159
+ if (state.visible) {
160
+ state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
161
+ state.showWarper = true;
162
+ }
163
+ });
164
+ state.hoverIndex = -1;
165
+ if (props.multiple && props.filterable) {
166
+ nextTick(function () {
167
+ var length = refs.input.value.length * 15 + 20;
168
+ state.inputLength = state.collapseTags ? Math.min(50, length) : length;
169
+ api.managePlaceholder();
170
+ api.resetInputHeight();
171
+ });
172
+ }
173
+ if (props.renderType === constants.TYPE.Tree) {
174
+ return;
175
+ }
176
+ api.defaultOnQueryChange(value);
177
+ };
178
+ };
179
+ export var scrollToOption = function scrollToOption(_ref6) {
180
+ var refs = _ref6.refs,
181
+ constants = _ref6.constants;
182
+ return function (option) {
183
+ var target = Array.isArray(option) && option[0] ? option[0].el : option.el;
184
+ if (refs.popper && target) {
185
+ var menu = refs.popper.$el.querySelector(constants.CLASS.SelectDropdownWrap);
186
+ scrollIntoView(menu, target);
187
+ }
188
+ refs.scrollbar && refs.scrollbar.handleScroll();
189
+ };
190
+ };
191
+ export var handleMenuEnter = function handleMenuEnter(_ref7) {
192
+ var api = _ref7.api,
193
+ nextTick = _ref7.nextTick,
194
+ state = _ref7.state;
195
+ return function () {
196
+ nextTick(function () {
197
+ return api.scrollToOption(state.selected);
198
+ });
199
+ };
200
+ };
201
+ export var emitChange = function emitChange(_ref8) {
202
+ var emit = _ref8.emit,
203
+ props = _ref8.props,
204
+ state = _ref8.state,
205
+ constants = _ref8.constants;
206
+ return function (value) {
207
+ var seekItem = function seekItem(val, arr, items, flag) {
208
+ if (constants.TYPE.Tree === flag) {
209
+ var recurNode = function recurNode(node) {
210
+ val === node[props.valueField] && items.push(node);
211
+ val !== node[props.valueField] && Array.isArray(node.children) && node.children.forEach(recurNode);
212
+ };
213
+ arr.forEach(recurNode);
214
+ } else if (constants.TYPE.Grid === flag) {
215
+ for (var i = 0; i < arr.length; i++) {
216
+ if (val === arr[i][props.valueField]) {
217
+ items.push(arr[i]);
218
+ break;
219
+ }
220
+ }
221
+ }
222
+ };
223
+ if (!isEqual(props.modelValue, value)) {
224
+ if (props.renderType === constants.TYPE.Grid && props.multiple) {
225
+ value = value || [];
226
+ var gridData = state.gridData || [];
227
+ var items = [];
228
+ value.forEach(function (valueItem) {
229
+ seekItem(valueItem, gridData, items, constants.TYPE.Grid);
230
+ });
231
+ emit('change', value, items);
232
+ } else if (props.renderType === constants.TYPE.Tree && props.multiple) {
233
+ value = value || [];
234
+ var treeData = state.treeData || [];
235
+ var _items = [];
236
+ value.forEach(function (valueItem) {
237
+ seekItem(valueItem, treeData, _items, constants.TYPE.Tree);
238
+ });
239
+ emit('change', value, _items);
240
+ } else {
241
+ emit('change', value);
242
+ }
243
+ }
244
+ };
245
+ };
246
+ export var getOption = function getOption(_ref9) {
247
+ var props = _ref9.props,
248
+ state = _ref9.state;
249
+ return function (value) {
250
+ var option;
251
+ var isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]';
252
+ var isNull = Object.prototype.toString.call(value).toLowerCase() === '[object null]';
253
+ var isUndefined = Object.prototype.toString.call(value).toLowerCase() === '[object undefined]';
254
+ for (var i = state.cachedOptions.length - 1; i >= 0; i--) {
255
+ var cachedOption = state.cachedOptions[i];
256
+ var _isEqual = isObject ? getObj(cachedOption.value, props.valueKey) === getObj(value, props.valueKey) : cachedOption.value === value;
257
+ if (_isEqual) {
258
+ option = cachedOption;
259
+ break;
260
+ }
261
+ }
262
+ if (option) {
263
+ return option;
264
+ }
265
+ var label = !isObject && !isNull && !isUndefined ? value : '';
266
+ var newOption = {
267
+ value: value,
268
+ currentLabel: label
269
+ };
270
+ if (props.multiple) {
271
+ newOption.hitState = false;
272
+ }
273
+ return newOption;
274
+ };
275
+ };
276
+ var getOptionOfSetSelected = function getOptionOfSetSelected(_ref10) {
277
+ var api = _ref10.api,
278
+ props = _ref10.props;
279
+ var option = api.getOption(props.modelValue) || {};
280
+ if (!option.state) {
281
+ option.state = {};
282
+ }
283
+ if (option.created) {
284
+ option.createdLabel = option.state.currentLabel;
285
+ option.createdSelected = true;
286
+ } else {
287
+ option.createdSelected = false;
288
+ }
289
+ return option;
290
+ };
291
+ var getResultOfSetSelected = function getResultOfSetSelected(_ref11) {
292
+ var props = _ref11.props,
293
+ isGrid = _ref11.isGrid,
294
+ isTree = _ref11.isTree,
295
+ api = _ref11.api;
296
+ var result = [];
297
+ if (Array.isArray(props.modelValue)) {
298
+ props.modelValue.forEach(function (value) {
299
+ if (isGrid || isTree) {
300
+ var option = api.getPluginOption(value, isTree);
301
+ result = result.concat(option);
302
+ } else {
303
+ result.push(api.getOption(value));
304
+ }
305
+ });
306
+ }
307
+ return result;
308
+ };
309
+ export var setSelected = function setSelected(_ref12) {
310
+ var api = _ref12.api,
311
+ constants = _ref12.constants,
312
+ nextTick = _ref12.nextTick,
313
+ props = _ref12.props,
314
+ refs = _ref12.refs,
315
+ state = _ref12.state;
316
+ return function () {
317
+ var isTree = props.renderType === constants.TYPE.Tree;
318
+ var isGrid = props.renderType === constants.TYPE.Grid;
319
+ if (!props.multiple) {
320
+ if (isGrid || isTree) {
321
+ if (!props.modelValue) {
322
+ state.selectedLabel = '';
323
+ state.selected = {};
324
+ state.currentKey = '';
325
+ refs.selectGrid && refs.selectGrid.clearRadioRow();
326
+ refs.selectTree && refs.selectTree.setCurrentKey && refs.selectTree.setCurrentKey(null);
327
+ return;
328
+ }
329
+ var isRemote = props.filterable && props.remote && typeof props.remoteMethod === 'function';
330
+ var nestdata = isRemote ? state.remoteData : isTree ? api.getTreeData(state.treeData) : state.gridData;
331
+ var data = find(nestdata, function (item) {
332
+ return props.modelValue == item[props.valueField];
333
+ });
334
+ if (isEmptyObject(data)) {
335
+ return;
336
+ }
337
+ var obj = _objectSpread({}, data);
338
+ var label = data[props.textField];
339
+ obj.currentLabel = label;
340
+ state.selectedLabel = label;
341
+ state.selected = obj;
342
+ state.currentKey = data[props.valueField];
343
+ } else {
344
+ var option = getOptionOfSetSelected({
345
+ api: api,
346
+ props: props
347
+ });
348
+ nextTick(function () {
349
+ state.selected = option;
350
+ state.selectedLabel = option.state.currentLabel || option.currentLabel;
351
+ props.filterable && (state.query = state.selectedLabel);
352
+ });
353
+ }
354
+ return;
355
+ }
356
+ var result = getResultOfSetSelected({
357
+ props: props,
358
+ isGrid: isGrid,
359
+ isTree: isTree,
360
+ api: api
361
+ });
362
+ state.selectCls = result.length ? result.length === state.options.length ? 'checked-sur' : 'halfselect' : 'check';
363
+ state.selected = result;
364
+ refs.selectTree && refs.selectTree.setCheckedNodes && refs.selectTree.setCheckedNodes(state.selected);
365
+ state.tips = state.selected.map(function (item) {
366
+ return item.state ? item.state.currentLabel : item.currentLabel;
367
+ }).join(',');
368
+ nextTick(api.resetInputHeight);
369
+ };
370
+ };
371
+ export var getPluginOption = function getPluginOption(_ref13) {
372
+ var api = _ref13.api,
373
+ props = _ref13.props,
374
+ state = _ref13.state;
375
+ return function (value, isTree) {
376
+ var isRemote = props.filterable && props.remote && typeof props.remoteMethod === 'function';
377
+ var textField = props.textField,
378
+ valueField = props.valueField;
379
+ var sourceData = isRemote ? state.remoteData : isTree ? api.getTreeData(state.treeData) : state.gridData;
380
+ var selNode = find(sourceData, function (item) {
381
+ return item[valueField] == value;
382
+ });
383
+ var items = [];
384
+ if (selNode) {
385
+ selNode.currentLabel = selNode[textField];
386
+ items.push(selNode);
387
+ }
388
+ return items;
389
+ };
390
+ };
391
+ export var toggleCheckAll = function toggleCheckAll(_ref14) {
392
+ var api = _ref14.api,
393
+ emit = _ref14.emit,
394
+ state = _ref14.state;
395
+ return function () {
396
+ var getEnabledValues = function getEnabledValues(options) {
397
+ var values = [];
398
+ for (var i = 0; i < options.length; i++) {
399
+ if (!options[i].state.disabled && !options[i].state.groupDisabled) {
400
+ values.push(options[i].value);
401
+ }
402
+ }
403
+ return values;
404
+ };
405
+ var value;
406
+ if (state.selectCls === 'check') {
407
+ value = getEnabledValues(state.options);
408
+ } else if (state.selectCls === 'halfselect') {
409
+ var unchecked = state.options.filter(function (item) {
410
+ return !item.disabled && item.state.selectCls === 'check';
411
+ });
412
+ unchecked.length ? value = getEnabledValues(state.options) : value = [];
413
+ } else if (state.selectCls === 'checked-sur') {
414
+ value = [];
415
+ }
416
+ api.setSoftFocus();
417
+ emit('update:modelValue', value);
418
+ emit('change', value);
419
+ };
420
+ };
421
+ export var handleFocus = function handleFocus(_ref15) {
422
+ var emit = _ref15.emit,
423
+ props = _ref15.props,
424
+ state = _ref15.state,
425
+ api = _ref15.api;
426
+ return function (event) {
427
+ if (!state.softFocus) {
428
+ if (props.automaticDropdown || props.filterable) {
429
+ state.visible = true;
430
+ state.softFocus = true;
431
+ }
432
+ emit('focus', event);
433
+ } else {
434
+ state.softFocus = false;
435
+ }
436
+ if (props.remote && props.filterable && state.firstAutoSeach) {
437
+ state.firstAutoSeach = false;
438
+ state.query = '';
439
+ state.previousQuery = undefined;
440
+ api.handleQueryChange(state.query);
441
+ }
442
+ };
443
+ };
444
+ export var focus = function focus(_ref16) {
445
+ var refs = _ref16.refs,
446
+ state = _ref16.state;
447
+ return function () {
448
+ if (!state.softFocus) {
449
+ refs.reference.focus();
450
+ }
451
+ };
452
+ };
453
+ export var blur = function blur(_ref17) {
454
+ var refs = _ref17.refs,
455
+ state = _ref17.state;
456
+ return function () {
457
+ state.visible = false;
458
+ refs.reference.blur();
459
+ };
460
+ };
461
+ export var handleBlur = function handleBlur(_ref18) {
462
+ var constants = _ref18.constants,
463
+ dispatch = _ref18.dispatch,
464
+ emit = _ref18.emit,
465
+ state = _ref18.state;
466
+ return function (event) {
467
+ setTimeout(function () {
468
+ if (state.isSilentBlur) {
469
+ state.isSilentBlur = false;
470
+ } else {
471
+ emit('blur', event);
472
+ }
473
+ dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.formBlur, event.target.value);
474
+ }, 100);
475
+ state.softFocus = false;
476
+ };
477
+ };
478
+ export var handleClearClick = function handleClearClick(api) {
479
+ return function (event) {
480
+ api.deleteSelected(event);
481
+ };
482
+ };
483
+ export var doDestroy = function doDestroy(refs) {
484
+ return function () {
485
+ refs.popper && refs.popper.doDestroy();
486
+ };
487
+ };
488
+ export var handleClose = function handleClose(state) {
489
+ return function () {
490
+ state.visible = false;
491
+ };
492
+ };
493
+ export var toggleLastOptionHitState = function toggleLastOptionHitState(_ref19) {
494
+ var state = _ref19.state;
495
+ return function (hit) {
496
+ if (!Array.isArray(state.selected)) {
497
+ return;
498
+ }
499
+ var option = state.selected[state.selected.length - 1];
500
+ if (!option) {
501
+ return;
502
+ }
503
+ var hitTarget = option.state || option;
504
+ if (hit === true || hit === false) {
505
+ hitTarget.hitState = hit;
506
+ return hit;
507
+ }
508
+ hitTarget.hitState = !hitTarget.hitState;
509
+ return hitTarget.hitState;
510
+ };
511
+ };
512
+ export var deletePrevTag = function deletePrevTag(_ref20) {
513
+ var api = _ref20.api,
514
+ constants = _ref20.constants,
515
+ emit = _ref20.emit,
516
+ props = _ref20.props,
517
+ state = _ref20.state,
518
+ vm = _ref20.vm;
519
+ return function (event) {
520
+ var refs = vm.$refs;
521
+ if (event.target.value.length <= 0 && !api.toggleLastOptionHitState()) {
522
+ var value = props.modelValue.slice();
523
+ value.pop();
524
+ emit('update:modelValue', value);
525
+ api.emitChange(value);
526
+ if (props.renderType === constants.TYPE.Grid) {
527
+ var rows = state.selected.slice().filter(function (item) {
528
+ return value.indexOf(item[props.valueField]) > -1;
529
+ });
530
+ refs.selectGrid.clearSelection();
531
+ refs.selectGrid.setSelection(rows, true);
532
+ }
533
+ }
534
+ };
535
+ };
536
+ export var managePlaceholder = function managePlaceholder(_ref21) {
537
+ var refs = _ref21.refs,
538
+ state = _ref21.state;
539
+ return function () {
540
+ if (state.currentPlaceholder !== '') {
541
+ state.currentPlaceholder = refs.input.value ? '' : state.cachedPlaceHolder;
542
+ }
543
+ };
544
+ };
545
+ export var resetInputState = function resetInputState(_ref22) {
546
+ var api = _ref22.api,
547
+ refs = _ref22.refs,
548
+ state = _ref22.state;
549
+ return function (event) {
550
+ if (event.keyCode !== 8) {
551
+ api.toggleLastOptionHitState(false);
552
+ }
553
+ state.inputLength = refs.input.value.length * 15 + 20;
554
+ api.resetInputHeight();
555
+ };
556
+ };
557
+ export var resetInputHeight = function resetInputHeight(_ref23) {
558
+ var constants = _ref23.constants,
559
+ nextTick = _ref23.nextTick,
560
+ props = _ref23.props,
561
+ refs = _ref23.refs,
562
+ state = _ref23.state;
563
+ return function () {
564
+ if (state.collapseTags && !props.filterable) {
565
+ return;
566
+ }
567
+ nextTick(function () {
568
+ if (!refs.reference) {
569
+ return;
570
+ }
571
+ var inputChildNodes = refs.reference.$el.childNodes;
572
+ var input = [].filter.call(inputChildNodes, function (item) {
573
+ return item.tagName === 'INPUT';
574
+ })[0];
575
+ var tags = refs.tags;
576
+ if (!input) {
577
+ return;
578
+ }
579
+ var sizeInMap = state.initialInputHeight || 30;
580
+ var noSelected = state.selected.length === 0;
581
+ input.style.height = noSelected ? sizeInMap + 'px' : Math.max(tags ? tags.clientHeight + (tags.clientHeight > sizeInMap ? 6 : 0) : 0, sizeInMap) + 'px';
582
+ if (state.visible && state.emptyText !== false) {
583
+ state.selectEmitter.emit(constants.EVENT_NAME.updatePopper, true);
584
+ }
585
+ });
586
+ };
587
+ };
588
+ export var resetHoverIndex = function resetHoverIndex(_ref24) {
589
+ var props = _ref24.props,
590
+ state = _ref24.state;
591
+ return function () {
592
+ if (!props.showOverflowTooltip) {
593
+ state.hoverIndex = -1;
594
+ } else if (!props.multiple) {
595
+ state.hoverIndex = state.options.indexOf(state.selected);
596
+ } else {
597
+ if (state.selected.length > 0) {
598
+ state.hoverIndex = Math.min.apply(null, state.selected.map(function (item) {
599
+ return state.options.indexOf(item);
600
+ }));
601
+ } else {
602
+ state.hoverIndex = -1;
603
+ }
604
+ }
605
+ };
606
+ };
607
+ export var handleOptionSelect = function handleOptionSelect(_ref25) {
608
+ var api = _ref25.api,
609
+ emit = _ref25.emit,
610
+ nextTick = _ref25.nextTick,
611
+ props = _ref25.props,
612
+ refs = _ref25.refs,
613
+ state = _ref25.state;
614
+ return function (option, byClick) {
615
+ state.memorize && state.memorize.updateByKey(option[state.memorize._dataKey] || option.value);
616
+ if (props.multiple) {
617
+ var value = (props.modelValue || []).slice();
618
+ var optionIndex = api.getValueIndex(value, option.value);
619
+ if (optionIndex > -1) {
620
+ value.splice(optionIndex, 1);
621
+ } else if (state.multipleLimit <= 0 || value.length < state.multipleLimit) {
622
+ value.push(option.value);
623
+ }
624
+ emit('update:modelValue', value);
625
+ api.emitChange(value);
626
+ if (option.created) {
627
+ state.query = '';
628
+ api.handleQueryChange('');
629
+ state.inputLength = 20;
630
+ }
631
+ if (props.filterable) {
632
+ refs.input.focus();
633
+ }
634
+ if (props.autoClose) {
635
+ state.visible = false;
636
+ }
637
+ } else {
638
+ emit('update:modelValue', option.value);
639
+ api.emitChange(option.value);
640
+ state.visible = false;
641
+ }
642
+ state.isSilentBlur = byClick;
643
+ api.setSoftFocus();
644
+ if (state.visible) {
645
+ return;
646
+ }
647
+ nextTick(function () {
648
+ api.scrollToOption(option);
649
+ });
650
+ };
651
+ };
652
+ export var setSoftFocus = function setSoftFocus(_ref26) {
653
+ var refs = _ref26.refs,
654
+ state = _ref26.state;
655
+ return function () {
656
+ state.softFocus = true;
657
+ var input = refs.input || refs.reference;
658
+ if (input) {
659
+ input.focus();
660
+ }
661
+ };
662
+ };
663
+ export var getValueIndex = function getValueIndex(props) {
664
+ return function () {
665
+ var arr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
666
+ var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
667
+ var isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]';
668
+ if (!isObject) {
669
+ return arr.indexOf(value);
670
+ } else {
671
+ var valueKey = props.valueKey;
672
+ var index = -1;
673
+ arr.some(function (item, i) {
674
+ if (getObj(item, valueKey) === getObj(value, valueKey)) {
675
+ index = i;
676
+ return true;
677
+ }
678
+ return false;
679
+ });
680
+ return index;
681
+ }
682
+ };
683
+ };
684
+ export var toggleMenu = function toggleMenu(_ref27) {
685
+ var refs = _ref27.refs,
686
+ state = _ref27.state,
687
+ props = _ref27.props;
688
+ return function () {
689
+ if (!state.selectDisabled) {
690
+ !props.ignoreEnter && (state.visible = !state.visible);
691
+ if (state.softFocus) {
692
+ !props.ignoreEnter && (state.visible = !state.visible);
693
+ state.softFocus = false;
694
+ }
695
+ if (state.visible) {
696
+ var dom = refs.input || refs.reference;
697
+ dom.focus();
698
+ }
699
+ }
700
+ };
701
+ };
702
+ export var selectOption = function selectOption(_ref28) {
703
+ var api = _ref28.api,
704
+ state = _ref28.state,
705
+ props = _ref28.props;
706
+ return function () {
707
+ if (!state.visible || props.hideDrop) {
708
+ api.toggleMenu();
709
+ } else {
710
+ if (state.options[state.hoverIndex]) {
711
+ api.handleOptionSelect(state.options[state.hoverIndex]);
712
+ }
713
+ }
714
+ };
715
+ };
716
+ export var deleteSelected = function deleteSelected(_ref29) {
717
+ var api = _ref29.api,
718
+ constants = _ref29.constants,
719
+ emit = _ref29.emit,
720
+ props = _ref29.props,
721
+ vm = _ref29.vm,
722
+ state = _ref29.state;
723
+ return function (event) {
724
+ event.stopPropagation();
725
+ var value = props.multiple ? [] : '';
726
+ var refs = vm.$refs;
727
+ if (props.renderType === constants.TYPE.Tree) {
728
+ state.selected = {};
729
+ state.selectedLabel = '';
730
+ refs.selectTree.setCurrentKey(null);
731
+ } else if (props.renderType === constants.TYPE.Grid) {
732
+ state.selected = {};
733
+ state.selectedLabel = '';
734
+ refs.selectGrid.clearRadioRow();
735
+ }
736
+ state.showTip = false;
737
+ emit('update:modelValue', value);
738
+ api.emitChange(value);
739
+ state.visible = false;
740
+ emit('clear');
741
+ };
742
+ };
743
+ export var deleteTag = function deleteTag(_ref30) {
744
+ var api = _ref30.api,
745
+ constants = _ref30.constants,
746
+ emit = _ref30.emit,
747
+ props = _ref30.props,
748
+ state = _ref30.state,
749
+ vm = _ref30.vm;
750
+ return function (event, tag) {
751
+ var refs = vm.$refs;
752
+ var isTree = props.renderType === constants.TYPE.Tree;
753
+ var index = state.selected.indexOf(tag);
754
+ var treeValue = [];
755
+ var treeIds = [tag[props.valueField]];
756
+ if (isTree && !props.treeOp.checkStrictly) {
757
+ var node = refs.selectTree.getNode(tag[props.valueField]);
758
+ if (!node.isLeaf) {
759
+ treeIds.push.apply(treeIds, _toConsumableArray(api.getChildValue(node.childNodes, props.valueField)));
760
+ }
761
+ while (node.parent && !Array.isArray(node.parent.data)) {
762
+ treeIds.push(node.parent.data[props.valueField]);
763
+ node = node.parent;
764
+ }
765
+ state.selected.slice().map(function (node) {
766
+ return treeIds.indexOf(node[props.valueField]) === -1 && treeValue.push(node[props.valueField]);
767
+ });
768
+ }
769
+ if (index > -1 && !state.selectDisabled) {
770
+ var value = props.modelValue.slice();
771
+ value.splice(index, 1);
772
+ if (props.renderType === constants.TYPE.Tree) {
773
+ props.treeOp.checkStrictly && treeValue.push.apply(treeValue, _toConsumableArray(value));
774
+ refs.selectTree.setCheckedKeys(treeValue);
775
+ } else if (props.renderType === constants.TYPE.Grid) {
776
+ var rows = state.selected.slice().filter(function (item) {
777
+ return value.indexOf(item[props.valueField]) > -1;
778
+ });
779
+ refs.selectGrid.clearSelection();
780
+ refs.selectGrid.setSelection(rows, true);
781
+ }
782
+ emit('update:modelValue', isTree ? treeValue : value);
783
+ api.emitChange(value);
784
+ emit(constants.EVENT_NAME.removeTag, tag[props.valueField]);
785
+ }
786
+ event.stopPropagation();
787
+ };
788
+ };
789
+ export var onInputChange = function onInputChange(_ref31) {
790
+ var api = _ref31.api,
791
+ props = _ref31.props,
792
+ state = _ref31.state,
793
+ constants = _ref31.constants,
794
+ nextTick = _ref31.nextTick;
795
+ return function () {
796
+ if (!props.delay) {
797
+ if (props.filterable && state.query !== state.selectedLabel) {
798
+ state.query = state.selectedLabel;
799
+ api.handleQueryChange(state.query);
800
+ nextTick(function () {
801
+ state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
802
+ });
803
+ }
804
+ } else {
805
+ api.debouncRquest();
806
+ }
807
+ nextTick(function () {
808
+ state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
809
+ });
810
+ };
811
+ };
812
+ export var onOptionDestroy = function onOptionDestroy(state) {
813
+ return function (index) {
814
+ if (index > -1) {
815
+ state.optionsCount--;
816
+ state.filteredOptionsCount--;
817
+ state.options.splice(index, 1);
818
+ }
819
+ };
820
+ };
821
+ export var resetInputWidth = function resetInputWidth(_ref32) {
822
+ var refs = _ref32.refs,
823
+ state = _ref32.state;
824
+ return function () {
825
+ state.inputWidth = refs.reference.$el.getBoundingClientRect().width;
826
+ };
827
+ };
828
+ export var handleResize = function handleResize(_ref33) {
829
+ var api = _ref33.api,
830
+ props = _ref33.props;
831
+ return function () {
832
+ api.resetInputWidth();
833
+ if (props.multiple) {
834
+ api.resetInputHeight();
835
+ }
836
+ };
837
+ };
838
+ export var checkDefaultFirstOption = function checkDefaultFirstOption(state) {
839
+ return function () {
840
+ state.hoverIndex = -1;
841
+ var hasCreated = false;
842
+ for (var i = state.options.length - 1; i >= 0; i--) {
843
+ if (state.options[i].created) {
844
+ hasCreated = true;
845
+ state.hoverIndex = i;
846
+ break;
847
+ }
848
+ }
849
+ if (hasCreated) {
850
+ return;
851
+ }
852
+ for (var _i = 0; _i !== state.options.length; ++_i) {
853
+ var option = state.options[_i];
854
+ if (state.query) {
855
+ if (!option.disabled && !option.groupDisabled && option.visible) {
856
+ state.hoverIndex = _i;
857
+ break;
858
+ }
859
+ } else {
860
+ if (option.itemSelected) {
861
+ state.hoverIndex = _i;
862
+ break;
863
+ }
864
+ }
865
+ }
866
+ };
867
+ };
868
+ export var getValueKey = function getValueKey(props) {
869
+ return function (item) {
870
+ if (Object.prototype.toString.call(item.value).toLowerCase() !== '[object object]') {
871
+ return item.value;
872
+ }
873
+ return getObj(item.value, props.valueKey);
874
+ };
875
+ };
876
+ export var navigateOptions = function navigateOptions(_ref34) {
877
+ var api = _ref34.api,
878
+ nextTick = _ref34.nextTick,
879
+ state = _ref34.state;
880
+ return function (direction) {
881
+ var len = state.options.length;
882
+ if (!state.visible) {
883
+ state.visible = true;
884
+ return;
885
+ }
886
+ if (len === 0 || state.filteredOptionsCount === 0) {
887
+ return;
888
+ }
889
+ if (!state.optionsAllDisabled) {
890
+ if (direction === 'next') {
891
+ state.hoverIndex++;
892
+ if (state.hoverIndex === len) {
893
+ state.hoverIndex = 0;
894
+ }
895
+ } else if (direction === 'prev') {
896
+ state.hoverIndex--;
897
+ if (state.hoverIndex < 0) {
898
+ state.hoverIndex = len - 1;
899
+ }
900
+ }
901
+ var option = state.options[state.hoverIndex];
902
+ if (option.disabled === true || option.groupDisabled === true || !option.visible) {
903
+ api.navigateOptions(direction);
904
+ }
905
+ nextTick(function () {
906
+ return api.scrollToOption(state.hoverOption);
907
+ });
908
+ }
909
+ };
910
+ };
911
+ export var emptyText = function emptyText(_ref35) {
912
+ var I18N = _ref35.I18N,
913
+ props = _ref35.props,
914
+ state = _ref35.state,
915
+ t = _ref35.t;
916
+ return function () {
917
+ if (props.loading) {
918
+ return props.loadingText || t(I18N.loading);
919
+ } else {
920
+ if (props.remote && state.query === '' && props.renderType) {
921
+ if (props.multiple) {
922
+ return state.selected.length > 0 || state.remoteData.length > 0;
923
+ }
924
+ return state.selected[props.valueField] || state.remoteData.length > 0;
925
+ }
926
+ if (props.remote && state.query === '' && state.options.length === 0) {
927
+ return false;
928
+ }
929
+ if (props.filterable && state.query && state.options.length > 0 && state.filteredOptionsCount === 0) {
930
+ return props.noMatchText || t(I18N.noMatch);
931
+ }
932
+ if (!state.options.some(function (option) {
933
+ return option.visible;
934
+ })) {
935
+ return props.noDataText || t(I18N.noData);
936
+ }
937
+ }
938
+ return null;
939
+ };
940
+ };
941
+ var optmzApis = {
942
+ exist: function exist(val, multiple) {
943
+ return multiple ? Array.isArray(val) && val.length : val;
944
+ },
945
+ getValueIndex: function getValueIndex(props) {
946
+ var options = props.options,
947
+ valueField = props.valueField,
948
+ modelValue = props.modelValue,
949
+ multiple = props.multiple;
950
+ var contain = function contain(val, arr) {
951
+ return Array.isArray(arr) && ~arr.indexOf(val);
952
+ };
953
+ var equal = function equal(val, opt) {
954
+ return multiple ? contain(opt[valueField], [val]) : opt[valueField] === val;
955
+ };
956
+ var start = 0;
957
+ if (optmzApis.exist(modelValue, multiple)) {
958
+ var lastVal = multiple ? modelValue[modelValue.length - 1] : modelValue;
959
+ for (var i = 0; i < options.length; i++) {
960
+ if (!equal(lastVal, options[i])) continue;
961
+ return i;
962
+ }
963
+ }
964
+ return start;
965
+ },
966
+ getStartIndex: function getStartIndex(_ref36) {
967
+ var props = _ref36.props,
968
+ state = _ref36.state;
969
+ var options = props.options;
970
+ var optimizeOpts = state.optimizeOpts,
971
+ optimizeStore = state.optimizeStore;
972
+ var rSize = optimizeOpts.rSize;
973
+ var valueIndex = optimizeStore.valueIndex;
974
+ return valueIndex + rSize > options.length ? options.length - rSize : valueIndex;
975
+ },
976
+ getViewStyle: function getViewStyle(_ref37) {
977
+ var props = _ref37.props,
978
+ state = _ref37.state;
979
+ var options = props.options;
980
+ var optimizeOpts = state.optimizeOpts;
981
+ var optionHeight = optimizeOpts.optionHeight;
982
+ return "height:".concat(optionHeight * options.length, "px");
983
+ },
984
+ getStoreDatas: function getStoreDatas(_ref38) {
985
+ var props = _ref38.props,
986
+ state = _ref38.state;
987
+ var options = props.options,
988
+ valueField = props.valueField,
989
+ modelValue = props.modelValue,
990
+ multiple = props.multiple;
991
+ var datas = state.datas,
992
+ optimizeOpts = state.optimizeOpts,
993
+ optimizeStore = state.optimizeStore;
994
+ var startIndex = optimizeStore.startIndex;
995
+ var rSize = optimizeOpts.rSize;
996
+ var sliced = datas.slice(startIndex, startIndex + rSize);
997
+ var hiddenOptions = optimizeStore.hiddenOptions = [];
998
+ var findPush = function findPush(val) {
999
+ var opt = options.find(function (option) {
1000
+ return option[valueField] === val;
1001
+ });
1002
+ if (opt && !~sliced.indexOf(opt)) {
1003
+ sliced.push(opt);
1004
+ hiddenOptions.push(opt);
1005
+ }
1006
+ };
1007
+ if (optmzApis.exist(modelValue, multiple)) {
1008
+ if (multiple) {
1009
+ modelValue.forEach(findPush);
1010
+ } else {
1011
+ findPush(modelValue);
1012
+ }
1013
+ }
1014
+ return sliced;
1015
+ },
1016
+ queryWrap: function queryWrap(refs) {
1017
+ return refs.scrollbar.$el.querySelector('.tiny-scrollbar__wrap.virtual');
1018
+ },
1019
+ queryItems: function queryItems(refs) {
1020
+ return refs.scrollbar.$el.querySelectorAll('.tiny-select-dropdown__item.virtual');
1021
+ },
1022
+ createMacro: function createMacro(cb) {
1023
+ return setTimeout(cb);
1024
+ },
1025
+ setScrollTop: function setScrollTop(_ref39) {
1026
+ var refs = _ref39.refs,
1027
+ state = _ref39.state;
1028
+ var optimizeOpts = state.optimizeOpts,
1029
+ optimizeStore = state.optimizeStore;
1030
+ var optionHeight = optimizeOpts.optionHeight;
1031
+ var wrap = optmzApis.queryWrap(refs);
1032
+ wrap.scrollTop = optionHeight * optimizeStore.valueIndex;
1033
+ },
1034
+ setValueIndex: function setValueIndex(_ref40) {
1035
+ var props = _ref40.props,
1036
+ state = _ref40.state;
1037
+ return state.optimizeStore.valueIndex = optmzApis.getValueIndex(props);
1038
+ },
1039
+ addScrollListener: function addScrollListener(_ref41) {
1040
+ var api = _ref41.api,
1041
+ refs = _ref41.refs,
1042
+ state = _ref41.state;
1043
+ var optimizeStore = state.optimizeStore;
1044
+ var wrap = optmzApis.queryWrap(refs);
1045
+ !optimizeStore.bind && wrap.addEventListener('scroll', api.getScrollListener) && (optimizeStore.bind = true);
1046
+ },
1047
+ removeScrollListener: function removeScrollListener(_ref42) {
1048
+ var api = _ref42.api,
1049
+ refs = _ref42.refs,
1050
+ state = _ref42.state;
1051
+ var optimizeStore = state.optimizeStore;
1052
+ var wrap = optmzApis.queryWrap(refs);
1053
+ optimizeStore.bind && wrap.removeEventListener('scroll', api.getScrollListener) && (optimizeStore.bind = false);
1054
+ },
1055
+ isFirstPage: function isFirstPage(_ref43) {
1056
+ var props = _ref43.props,
1057
+ state = _ref43.state;
1058
+ var optimizeStore = state.optimizeStore;
1059
+ var datas = optimizeStore.datas;
1060
+ var options = props.options;
1061
+ return Array.isArray(datas) && Array.isArray(options) && datas[0] === options[0];
1062
+ },
1063
+ natural: function natural(val) {
1064
+ return val < 0 ? 0 : val;
1065
+ },
1066
+ updateItems: function updateItems(_ref44) {
1067
+ var refs = _ref44.refs,
1068
+ state = _ref44.state,
1069
+ itemFn = _ref44.itemFn;
1070
+ var optimizeOpts = state.optimizeOpts;
1071
+ var optionHeight = optimizeOpts.optionHeight;
1072
+ var items = optmzApis.queryItems(refs);
1073
+ for (var i = 0; i < items.length; i++) {
1074
+ var item = items[i];
1075
+ var flag = item.classList.contains('virtual-hidden');
1076
+ item.style.top = flag ? "-".concat(optionHeight, "px") : "".concat(itemFn(i), "px");
1077
+ }
1078
+ },
1079
+ process: function process(_ref45) {
1080
+ var props = _ref45.props,
1081
+ start = _ref45.start,
1082
+ state = _ref45.state;
1083
+ var optimizeStore = state.optimizeStore;
1084
+ optimizeStore.startIndex = typeof start !== 'undefined' ? start : optmzApis.getStartIndex({
1085
+ props: props,
1086
+ state: state
1087
+ });
1088
+ optimizeStore.datas = optmzApis.getStoreDatas({
1089
+ props: props,
1090
+ state: state
1091
+ });
1092
+ optimizeStore.firstPage = optmzApis.isFirstPage({
1093
+ props: props,
1094
+ state: state
1095
+ });
1096
+ }
1097
+ };
1098
+ export var watchValue = function watchValue(_ref46) {
1099
+ var api = _ref46.api,
1100
+ constants = _ref46.constants,
1101
+ dispatch = _ref46.dispatch,
1102
+ props = _ref46.props,
1103
+ refs = _ref46.refs,
1104
+ state = _ref46.state;
1105
+ return function (value, oldValue) {
1106
+ if (props.multiple) {
1107
+ api.resetInputHeight();
1108
+ if (value && value.length > 0 || refs.input && state.query !== '') {
1109
+ state.currentPlaceholder = '';
1110
+ } else {
1111
+ state.currentPlaceholder = state.cachedPlaceHolder;
1112
+ }
1113
+ if (props.filterable && !props.reserveKeyword) {
1114
+ props.renderType !== constants.TYPE.Grid && (state.query = '');
1115
+ api.handleQueryChange(state.query);
1116
+ }
1117
+ }
1118
+ api.setSelected();
1119
+ if (props.filterable && !props.multiple) {
1120
+ state.inputLength = 20;
1121
+ }
1122
+ if (state.completed && !isEqual(value, oldValue)) {
1123
+ dispatch(constants.COMPONENT_NAME.FormItem, constants.EVENT_NAME.formChange, value);
1124
+ }
1125
+ state.optimizeStore.flag && optmzApis.setValueIndex({
1126
+ props: props,
1127
+ state: state
1128
+ });
1129
+ };
1130
+ };
1131
+ export var calcOverFlow = function calcOverFlow(_ref47) {
1132
+ var refs = _ref47.refs,
1133
+ props = _ref47.props,
1134
+ state = _ref47.state;
1135
+ return function (height) {
1136
+ if (!props.multiple || !props.showOverflowTooltip) {
1137
+ return;
1138
+ }
1139
+ state.overflow = false;
1140
+ var tagDom = refs.tags;
1141
+ var tags = tagDom.querySelectorAll('.tiny-tag');
1142
+ if (tags.length) {
1143
+ tagDom.scrollTo && tagDom.scrollTo({
1144
+ top: 0
1145
+ });
1146
+ var _tags$0$getBoundingCl = tags[0].getBoundingClientRect(),
1147
+ x = _tags$0$getBoundingCl.x,
1148
+ width = _tags$0$getBoundingCl.width;
1149
+ if (width >= tagDom.getBoundingClientRect().width) {
1150
+ state.overflow = 0;
1151
+ } else {
1152
+ for (var i = 1; i < tags.length; i++) {
1153
+ var tx = tags[i].getBoundingClientRect().x;
1154
+ if (tx == x) {
1155
+ state.overflow = i - 1;
1156
+ break;
1157
+ }
1158
+ }
1159
+ }
1160
+ }
1161
+ refs.select.style.height = refs.select.style.height || height;
1162
+ refs.reference.$el.style.position = 'absolute';
1163
+ var inputWidth = refs.select.getBoundingClientRect().width;
1164
+ var position = state.visible ? 'absolute' : '';
1165
+ state.selectFiexd = {
1166
+ height: height,
1167
+ position: position,
1168
+ width: inputWidth + 'px',
1169
+ zIndex: PopupManager.nextZIndex()
1170
+ };
1171
+ state.inputWidth = inputWidth;
1172
+ };
1173
+ };
1174
+ var postOperOfToVisible = function postOperOfToVisible(_ref48) {
1175
+ var props = _ref48.props,
1176
+ state = _ref48.state,
1177
+ constants = _ref48.constants;
1178
+ if (props.multiple) {
1179
+ return;
1180
+ }
1181
+ if (state.selected) {
1182
+ if (props.renderType === constants.TYPE.Grid || props.renderType === constants.TYPE.Tree) {
1183
+ state.selectedLabel = state.selected.currentLabel;
1184
+ } else {
1185
+ if (props.filterable && props.allowCreate && state.createdSelected && state.createdLabel) {
1186
+ state.selectedLabel = state.createdLabel;
1187
+ } else {
1188
+ state.selectedLabel = state.selected.state.currentLabel || state.selected.currentLabel;
1189
+ }
1190
+ if (props.filterable) {
1191
+ state.query = state.selectedLabel;
1192
+ }
1193
+ }
1194
+ if (props.filterable) {
1195
+ state.currentPlaceholder = state.cachedPlaceHolder;
1196
+ }
1197
+ }
1198
+ };
1199
+ export var toVisible = function toVisible(_ref49) {
1200
+ var constants = _ref49.constants,
1201
+ state = _ref49.state,
1202
+ props = _ref49.props,
1203
+ vm = _ref49.vm,
1204
+ api = _ref49.api,
1205
+ nextTick = _ref49.nextTick;
1206
+ return function () {
1207
+ var refs = vm.$refs;
1208
+ state.selectEmitter.emit(constants.EVENT_NAME.destroyPopper);
1209
+ props.remote && props.dropOnlySearch && (state.showWarper = false);
1210
+ if (refs.input) {
1211
+ refs.input.blur();
1212
+ }
1213
+ state.query = '';
1214
+ state.selectedLabel = '';
1215
+ state.inputLength = 20;
1216
+ if (props.renderType !== constants.TYPE.Tree) {
1217
+ state.previousQuery = props.remoteConfig.clearData && state.previousQuery !== state.query ? undefined : null;
1218
+ }
1219
+ api.resetHoverIndex();
1220
+ nextTick(function () {
1221
+ if (refs.input && refs.input.value === '' && state.selected.length === 0) {
1222
+ state.currentPlaceholder = state.cachedPlaceHolder;
1223
+ }
1224
+ if (refs.selectGrid) {
1225
+ refs.selectGrid.clearScroll();
1226
+ }
1227
+ });
1228
+ postOperOfToVisible({
1229
+ props: props,
1230
+ state: state,
1231
+ constants: constants
1232
+ });
1233
+ };
1234
+ };
1235
+ export var toHide = function toHide(_ref50) {
1236
+ var constants = _ref50.constants,
1237
+ state = _ref50.state,
1238
+ props = _ref50.props,
1239
+ vm = _ref50.vm,
1240
+ api = _ref50.api;
1241
+ return function () {
1242
+ var refs = vm.$refs;
1243
+ state.selectEmitter.emit(constants.COMPONENT_NAME.SelectDropdown, constants.EVENT_NAME.updatePopper);
1244
+ if (props.filterable) {
1245
+ state.query = props.remote ? '' : props.renderType !== constants.TYPE.Tree ? state.selectedLabel : '';
1246
+ state.previousQuery !== state.query && api.handleQueryChange(state.query);
1247
+ if (props.multiple) {
1248
+ refs.input.focus();
1249
+ } else {
1250
+ if (!props.remote) {
1251
+ state.selectEmitter.emit(constants.EVENT_NAME.queryChange, '');
1252
+ state.selectEmitter.emit(constants.COMPONENT_NAME.OptionGroup, constants.EVENT_NAME.queryChange);
1253
+ }
1254
+ if (state.selectedLabel) {
1255
+ state.currentPlaceholder = state.selectedLabel;
1256
+ state.selectedLabel = '';
1257
+ }
1258
+ }
1259
+ }
1260
+ if (refs.selectGrid) {
1261
+ refs.selectGrid.clearSelection();
1262
+ refs.selectGrid.setSelection(state.selected, true);
1263
+ if (props.filterable && typeof props.filterMethod === 'function') {
1264
+ refs.selectGrid.handleTableData(true);
1265
+ } else if (props.filterable && props.remote && typeof props.remoteMethod === 'function') {
1266
+ refs.selectGrid.handleTableData();
1267
+ }
1268
+ }
1269
+ };
1270
+ };
1271
+ export var watchVisible = function watchVisible(_ref51) {
1272
+ var api = _ref51.api,
1273
+ constants = _ref51.constants,
1274
+ emit = _ref51.emit,
1275
+ state = _ref51.state,
1276
+ refs = _ref51.refs;
1277
+ return function (value) {
1278
+ if (api.onCopying()) {
1279
+ return;
1280
+ }
1281
+ value ? api.toHide() : api.toVisible();
1282
+ emit(constants.EVENT_NAME.visibleChange, value);
1283
+ setTimeout(function () {
1284
+ state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
1285
+ });
1286
+ if (value && state.optimizeStore.flag) {
1287
+ optmzApis.createMacro(function () {
1288
+ optmzApis.setScrollTop({
1289
+ refs: refs,
1290
+ state: state
1291
+ });
1292
+ api.getScrollListener();
1293
+ });
1294
+ }
1295
+ };
1296
+ };
1297
+ export var watchOptions = function watchOptions(_ref52) {
1298
+ var api = _ref52.api,
1299
+ constants = _ref52.constants,
1300
+ nextTick = _ref52.nextTick,
1301
+ parent = _ref52.parent,
1302
+ props = _ref52.props,
1303
+ state = _ref52.state;
1304
+ return function () {
1305
+ if (typeof window === 'undefined') {
1306
+ return;
1307
+ }
1308
+ nextTick(function () {
1309
+ state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
1310
+ });
1311
+ if (props.multiple) {
1312
+ api.resetInputHeight();
1313
+ }
1314
+ nextTick(function () {
1315
+ if (parent.$el.querySelector('input') !== document.activeElement) {
1316
+ api.setSelected();
1317
+ }
1318
+ });
1319
+ if (props.defaultFirstOption && (props.filterable || props.remote) && state.filteredOptionsCount) {
1320
+ api.checkDefaultFirstOption();
1321
+ }
1322
+ };
1323
+ };
1324
+ export var handleCopyClick = function handleCopyClick(_ref53) {
1325
+ var parent = _ref53.parent,
1326
+ props = _ref53.props,
1327
+ state = _ref53.state;
1328
+ return function () {
1329
+ var input = document.createElement('input');
1330
+ input.style.height = 0;
1331
+ input.style.border = 'none';
1332
+ input.style.position = 'absolute';
1333
+ parent.$el.appendChild(input);
1334
+ input.value = state.selected.map(function (item) {
1335
+ return item.state ? item.state.currentLabel : item.currentLabel;
1336
+ }).join(props.textSplit);
1337
+ input.select();
1338
+ document.execCommand('copy');
1339
+ parent.$el.removeChild(input);
1340
+ };
1341
+ };
1342
+ export var selectChange = function selectChange(_ref54) {
1343
+ var emit = _ref54.emit,
1344
+ props = _ref54.props,
1345
+ state = _ref54.state;
1346
+ return function (_ref55) {
1347
+ var $table = _ref55.$table,
1348
+ selection = _ref55.selection,
1349
+ checked = _ref55.checked,
1350
+ row = _ref55.row;
1351
+ var textField = props.textField,
1352
+ valueField = props.valueField;
1353
+ var remoteItem = function remoteItem(row) {
1354
+ var removeItem = find(state.selected, function (item) {
1355
+ return item[valueField] === row[valueField];
1356
+ });
1357
+ removeItem && state.selected.splice(state.selected.indexOf(removeItem), 1);
1358
+ };
1359
+ if (row) {
1360
+ checked ? state.selected.push(_objectSpread(_objectSpread({}, row), {}, {
1361
+ value: row[valueField],
1362
+ currentLabel: row[textField]
1363
+ })) : remoteItem(row);
1364
+ } else {
1365
+ checked ? state.selected = state.selected.concat(selection.filter(function (row) {
1366
+ return !~props.modelValue.indexOf(row[valueField]);
1367
+ })) : $table.tableData.forEach(function (row) {
1368
+ return remoteItem(row);
1369
+ });
1370
+ }
1371
+ var keys = state.selected.map(function (item) {
1372
+ return item[valueField];
1373
+ });
1374
+ emit('update:modelValue', keys);
1375
+ emit('change', keys, state.selected);
1376
+ };
1377
+ };
1378
+ export var getcheckedData = function getcheckedData(_ref56) {
1379
+ var props = _ref56.props,
1380
+ state = _ref56.state;
1381
+ return function () {
1382
+ var checkedKey = [];
1383
+ if (!Array.isArray(state.selected)) {
1384
+ return props.modelValue ? [props.modelValue] : [state.selected[props.valueField]];
1385
+ } else {
1386
+ state.selected.length > 0 && state.selected.forEach(function (item) {
1387
+ checkedKey.push(item[props.valueField]);
1388
+ });
1389
+ return checkedKey;
1390
+ }
1391
+ };
1392
+ };
1393
+ export var radioChange = function radioChange(_ref57) {
1394
+ var emit = _ref57.emit,
1395
+ props = _ref57.props,
1396
+ state = _ref57.state;
1397
+ return function (_ref58) {
1398
+ var row = _ref58.row;
1399
+ row.value = row[props.valueField];
1400
+ row.currentLabel = row[props.textField];
1401
+ state.selected = row;
1402
+ state.visible = false;
1403
+ state.currentKey = row[props.valueField];
1404
+ emit('update:modelValue', row.value);
1405
+ emit('change', row);
1406
+ };
1407
+ };
1408
+ export var getTreeData = function getTreeData(props) {
1409
+ return function (data) {
1410
+ var nodes = [];
1411
+ var getChild = function getChild(data, pId) {
1412
+ data.forEach(function (node) {
1413
+ node.pId = pId;
1414
+ nodes.push(node);
1415
+ if (node.children && node.children.length > 0) {
1416
+ getChild(node.children, node[props.valueField]);
1417
+ }
1418
+ });
1419
+ };
1420
+ getChild(data, null);
1421
+ return nodes;
1422
+ };
1423
+ };
1424
+ export var treeNodeClick = function treeNodeClick(_ref59) {
1425
+ var emit = _ref59.emit,
1426
+ props = _ref59.props,
1427
+ state = _ref59.state;
1428
+ return function (data) {
1429
+ if (!props.multiple) {
1430
+ data.currentLabel = data[props.textField];
1431
+ data.value = data[props.valueField];
1432
+ state.selected = data;
1433
+ state.visible = false;
1434
+ emit('update:modelValue', data.value);
1435
+ emit('change', data);
1436
+ }
1437
+ };
1438
+ };
1439
+ export var nodeCheckClick = function nodeCheckClick(_ref60) {
1440
+ var emit = _ref60.emit,
1441
+ props = _ref60.props,
1442
+ state = _ref60.state;
1443
+ return function (data, _ref61) {
1444
+ var checkedKeys = _ref61.checkedKeys,
1445
+ checkedNodes = _ref61.checkedNodes;
1446
+ checkedNodes.forEach(function (node) {
1447
+ node.currentLabel = node[props.textField];
1448
+ node.value = node[props.valueField];
1449
+ });
1450
+ emit('update:modelValue', checkedKeys);
1451
+ emit('change', checkedKeys, checkedNodes);
1452
+ };
1453
+ };
1454
+ export var nodeCollapse = function nodeCollapse(_ref62) {
1455
+ var state = _ref62.state,
1456
+ constants = _ref62.constants;
1457
+ return function () {
1458
+ setTimeout(function () {
1459
+ state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
1460
+ }, 310);
1461
+ };
1462
+ };
1463
+ export var nodeExpand = function nodeExpand(_ref63) {
1464
+ var state = _ref63.state,
1465
+ constants = _ref63.constants;
1466
+ return function () {
1467
+ setTimeout(function () {
1468
+ state.selectEmitter.emit(constants.EVENT_NAME.updatePopper);
1469
+ }, 310);
1470
+ };
1471
+ };
1472
+ export var debouncRquest = function debouncRquest(_ref64) {
1473
+ var api = _ref64.api,
1474
+ state = _ref64.state,
1475
+ props = _ref64.props;
1476
+ return debounce(props.delay, function () {
1477
+ if (props.filterable && state.query !== state.selectedLabel) {
1478
+ state.query = state.selectedLabel;
1479
+ api.handleQueryChange(state.query);
1480
+ }
1481
+ });
1482
+ };
1483
+ export var getChildValue = function getChildValue() {
1484
+ return function (data, key) {
1485
+ var ids = [];
1486
+ var getChild = function getChild(nodes) {
1487
+ nodes.forEach(function (node) {
1488
+ ids.push(node.data[key]);
1489
+ if (node.childNodes.length > 0) {
1490
+ getChild(node.childNodes);
1491
+ }
1492
+ });
1493
+ };
1494
+ getChild(data);
1495
+ return ids;
1496
+ };
1497
+ };
1498
+ export var watchPropsOption = function watchPropsOption(_ref65) {
1499
+ var constants = _ref65.constants,
1500
+ parent = _ref65.parent,
1501
+ props = _ref65.props,
1502
+ state = _ref65.state;
1503
+ return function () {
1504
+ var renderType = props.renderType;
1505
+ var _props$treeOp = props.treeOp,
1506
+ key = _props$treeOp.key,
1507
+ parentKey = _props$treeOp.parentKey;
1508
+ var dataset = {
1509
+ dataset: props.options || props.dataset,
1510
+ service: parent.$service,
1511
+ tree: {
1512
+ key: key,
1513
+ parentKey: parentKey
1514
+ }
1515
+ };
1516
+ getDataset(dataset).then(function (data) {
1517
+ if (renderType === constants.TYPE.Tree) {
1518
+ state.treeData = data;
1519
+ } else if (renderType === constants.TYPE.Grid) {
1520
+ state.gridData = data;
1521
+ } else {
1522
+ if (props.cacheOp && props.cacheOp.key) {
1523
+ state.memorize = new Memorize(props.cacheOp);
1524
+ state.datas = state.memorize.assemble(data.slice());
1525
+ } else {
1526
+ state.datas = data;
1527
+ }
1528
+ }
1529
+ });
1530
+ };
1531
+ };
1532
+ export var buildSelectConfig = function buildSelectConfig(_ref66) {
1533
+ var props = _ref66.props,
1534
+ state = _ref66.state;
1535
+ return function () {
1536
+ var checkRowKeys = state.gridCheckedData;
1537
+ var selectConfig = props.selectConfig;
1538
+ return _objectSpread(_objectSpread({}, selectConfig), {}, {
1539
+ checkRowKeys: checkRowKeys
1540
+ });
1541
+ };
1542
+ };
1543
+ export var buildRadioConfig = function buildRadioConfig(_ref67) {
1544
+ var props = _ref67.props,
1545
+ state = _ref67.state;
1546
+ return function () {
1547
+ var checkRowKey = state.currentKey;
1548
+ var highlight = true;
1549
+ var radioConfig = props.radioConfig;
1550
+ return _objectSpread(_objectSpread({}, radioConfig), {
1551
+ checkRowKey: checkRowKey,
1552
+ highlight: highlight
1553
+ });
1554
+ };
1555
+ };
1556
+ export var onMouseenterNative = function onMouseenterNative(_ref68) {
1557
+ var state = _ref68.state;
1558
+ return function () {
1559
+ state.inputHovering = true;
1560
+ if (state.searchSingleCopy && state.selectedLabel) {
1561
+ state.softFocus = true;
1562
+ }
1563
+ };
1564
+ };
1565
+ export var onMouseleaveNative = function onMouseleaveNative(_ref69) {
1566
+ var state = _ref69.state;
1567
+ return function () {
1568
+ state.inputHovering = false;
1569
+ if (state.searchSingleCopy && state.selectedLabel) {
1570
+ state.softFocus = false;
1571
+ }
1572
+ };
1573
+ };
1574
+ export var onCopying = function onCopying(_ref70) {
1575
+ var state = _ref70.state,
1576
+ refs = _ref70.refs;
1577
+ return function () {
1578
+ return state.searchSingleCopy && state.selectedLabel && refs.reference && refs.reference.hasSelection && refs.reference.hasSelection();
1579
+ };
1580
+ };
1581
+ export var watchHoverIndex = function watchHoverIndex(_ref71) {
1582
+ var state = _ref71.state;
1583
+ return function (value) {
1584
+ if (typeof value === 'number' && value > -1) {
1585
+ state.hoverOption = state.options[value] || {};
1586
+ } else if (value === -9) {
1587
+ state.hoverOption = {};
1588
+ }
1589
+ state.options.forEach(function (option) {
1590
+ option.hover = state.hoverOption === option;
1591
+ });
1592
+ };
1593
+ };
1594
+ export var mounted = function mounted(_ref72) {
1595
+ var api = _ref72.api,
1596
+ parent = _ref72.parent,
1597
+ state = _ref72.state,
1598
+ props = _ref72.props,
1599
+ refs = _ref72.refs;
1600
+ return function () {
1601
+ var parentEl = parent.$el;
1602
+ var inputEl = parentEl.querySelector('input.tiny-input__inner');
1603
+ var inputClientRect = inputEl.getBoundingClientRect();
1604
+ if (inputEl === document.activeElement) {
1605
+ document.activeElement.blur();
1606
+ }
1607
+ state.completed = true;
1608
+ var sizeMap = {
1609
+ mini: 28,
1610
+ small: 32,
1611
+ medium: 36
1612
+ };
1613
+ if (props.multiple && Array.isArray(props.modelValue) && props.modelValue.length > 0) {
1614
+ state.currentPlaceholder = '';
1615
+ }
1616
+ state.initialInputHeight = inputClientRect.height || sizeMap[state.selectSize];
1617
+ addResizeListener(parentEl, api.handleResize);
1618
+ if (refs.tags) {
1619
+ addResizeListener(refs.tags, api.resetInputHeight);
1620
+ }
1621
+ if (props.remote && props.multiple) {
1622
+ api.resetInputHeight();
1623
+ }
1624
+ state.inputWidth = inputClientRect.width;
1625
+ api.setSelected();
1626
+ if (props.dataset) {
1627
+ api.watchPropsOption();
1628
+ }
1629
+ };
1630
+ };
1631
+ export var unMount = function unMount(_ref73) {
1632
+ var api = _ref73.api,
1633
+ parent = _ref73.parent,
1634
+ refs = _ref73.refs,
1635
+ state = _ref73.state;
1636
+ return function () {
1637
+ if (parent.$el && api.handleResize) {
1638
+ removeResizeListener(parent.$el, api.handleResize);
1639
+ }
1640
+ if (refs.tags) {
1641
+ removeResizeListener(refs.tags, api.resetInputHeight);
1642
+ }
1643
+ state.popperElm = null;
1644
+ state.optimizeStore.flag && optmzApis.removeScrollListener({
1645
+ api: api,
1646
+ refs: refs,
1647
+ state: state
1648
+ });
1649
+ };
1650
+ };
1651
+ export var computeOptimizeOpts = function computeOptimizeOpts(_ref74) {
1652
+ var props = _ref74.props,
1653
+ state = _ref74.state;
1654
+ return function () {
1655
+ var optimization = props.optimization;
1656
+ var baseOpts = {
1657
+ gt: 20,
1658
+ rSize: 10,
1659
+ optionHeight: 30,
1660
+ limit: 20
1661
+ };
1662
+ var optOpts;
1663
+ if (optimization) {
1664
+ if (typeof optimization === 'boolean') {
1665
+ optOpts = extend(true, {}, baseOpts);
1666
+ } else {
1667
+ optOpts = extend(true, {}, baseOpts, optimization);
1668
+ }
1669
+ optOpts.virtualScroll = optOpts.gt > 0 && optOpts.gt <= state.datas.length;
1670
+ return optOpts;
1671
+ }
1672
+ };
1673
+ };
1674
+ export var watchOptimizeOpts = function watchOptimizeOpts(_ref75) {
1675
+ var api = _ref75.api,
1676
+ props = _ref75.props,
1677
+ refs = _ref75.refs,
1678
+ state = _ref75.state;
1679
+ return function () {
1680
+ var optimizeOpts = state.optimizeOpts,
1681
+ optimizeStore = state.optimizeStore;
1682
+ if (optimizeOpts) {
1683
+ var virtualScroll = optimizeOpts.virtualScroll,
1684
+ optionHeight = optimizeOpts.optionHeight;
1685
+ optimizeStore.flag = virtualScroll;
1686
+ if (virtualScroll) {
1687
+ optimizeStore.viewStyle = optmzApis.getViewStyle({
1688
+ props: props,
1689
+ state: state
1690
+ });
1691
+ optimizeStore.valueIndex = optmzApis.getValueIndex(props);
1692
+ optmzApis.process({
1693
+ props: props,
1694
+ state: state
1695
+ });
1696
+ optmzApis.createMacro(function () {
1697
+ var itemFn = function itemFn(i) {
1698
+ return optionHeight * (optimizeStore.startIndex + i);
1699
+ };
1700
+ optmzApis.addScrollListener({
1701
+ api: api,
1702
+ refs: refs,
1703
+ state: state
1704
+ });
1705
+ optmzApis.updateItems({
1706
+ refs: refs,
1707
+ state: state,
1708
+ itemFn: itemFn
1709
+ });
1710
+ });
1711
+ }
1712
+ }
1713
+ };
1714
+ };
1715
+ export var getScrollListener = function getScrollListener(_ref76) {
1716
+ var props = _ref76.props,
1717
+ refs = _ref76.refs,
1718
+ state = _ref76.state;
1719
+ var listener = function listener() {
1720
+ var options = props.options;
1721
+ var optimizeOpts = state.optimizeOpts;
1722
+ var optionHeight = optimizeOpts.optionHeight;
1723
+ var viewHeight = optionHeight * options.length;
1724
+ var _optmzApis$queryWrap = optmzApis.queryWrap(refs),
1725
+ clientHeight = _optmzApis$queryWrap.clientHeight,
1726
+ scrollTop = _optmzApis$queryWrap.scrollTop;
1727
+ var maxScrollTop = viewHeight - clientHeight;
1728
+ var start = Math.floor(scrollTop / optionHeight);
1729
+ if (scrollTop <= maxScrollTop) {
1730
+ optmzApis.process({
1731
+ props: props,
1732
+ start: start,
1733
+ state: state
1734
+ });
1735
+ optmzApis.createMacro(function () {
1736
+ var itemFn = function itemFn(i) {
1737
+ return scrollTop + optionHeight * i - scrollTop % optionHeight;
1738
+ };
1739
+ optmzApis.updateItems({
1740
+ refs: refs,
1741
+ state: state,
1742
+ itemFn: itemFn
1743
+ });
1744
+ });
1745
+ }
1746
+ };
1747
+ var optimization = props.optimization;
1748
+ var delay = optmzApis.natural((optimization && _typeof(optimization) === 'object' ? optimization.delay : null) || 10);
1749
+ return debounce(delay, listener);
1750
+ };
1751
+ export var computeCollapseTags = function computeCollapseTags(props) {
1752
+ return function () {
1753
+ return props.collapseTags;
1754
+ };
1755
+ };
1756
+ export var computeMultipleLimit = function computeMultipleLimit(_ref77) {
1757
+ var props = _ref77.props,
1758
+ state = _ref77.state;
1759
+ return function () {
1760
+ var multipleLimit = props.multipleLimit,
1761
+ multiple = props.multiple;
1762
+ var optimizeOpts = state.optimizeOpts,
1763
+ optimizeStore = state.optimizeStore;
1764
+ return optmzApis.natural(multiple && optimizeStore.flag ? multipleLimit || optimizeOpts.limit : multipleLimit);
1765
+ };
1766
+ };