vue-treeselect.cjs.js 122 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904
  1. /*!
  2. * vue-treeselect v0.4.0 | (c) 2017-2019 Riophae Lee
  3. * Released under the MIT License.
  4. * https://vue-treeselect.js.org/
  5. */
  6. module.exports =
  7. /******/ (function(modules) { // webpackBootstrap
  8. /******/ // The module cache
  9. /******/ var installedModules = {};
  10. /******/
  11. /******/ // The require function
  12. /******/ function __webpack_require__(moduleId) {
  13. /******/
  14. /******/ // Check if module is in cache
  15. /******/ if(installedModules[moduleId]) {
  16. /******/ return installedModules[moduleId].exports;
  17. /******/ }
  18. /******/ // Create a new module (and put it into the cache)
  19. /******/ var module = installedModules[moduleId] = {
  20. /******/ i: moduleId,
  21. /******/ l: false,
  22. /******/ exports: {}
  23. /******/ };
  24. /******/
  25. /******/ // Execute the module function
  26. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  27. /******/
  28. /******/ // Flag the module as loaded
  29. /******/ module.l = true;
  30. /******/
  31. /******/ // Return the exports of the module
  32. /******/ return module.exports;
  33. /******/ }
  34. /******/
  35. /******/
  36. /******/ // expose the modules object (__webpack_modules__)
  37. /******/ __webpack_require__.m = modules;
  38. /******/
  39. /******/ // expose the module cache
  40. /******/ __webpack_require__.c = installedModules;
  41. /******/
  42. /******/ // define getter function for harmony exports
  43. /******/ __webpack_require__.d = function(exports, name, getter) {
  44. /******/ if(!__webpack_require__.o(exports, name)) {
  45. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  46. /******/ }
  47. /******/ };
  48. /******/
  49. /******/ // define __esModule on exports
  50. /******/ __webpack_require__.r = function(exports) {
  51. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  52. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  53. /******/ }
  54. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  55. /******/ };
  56. /******/
  57. /******/ // create a fake namespace object
  58. /******/ // mode & 1: value is a module id, require it
  59. /******/ // mode & 2: merge all properties of value into the ns
  60. /******/ // mode & 4: return value when already ns object
  61. /******/ // mode & 8|1: behave like require
  62. /******/ __webpack_require__.t = function(value, mode) {
  63. /******/ if(mode & 1) value = __webpack_require__(value);
  64. /******/ if(mode & 8) return value;
  65. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  66. /******/ var ns = Object.create(null);
  67. /******/ __webpack_require__.r(ns);
  68. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  69. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  70. /******/ return ns;
  71. /******/ };
  72. /******/
  73. /******/ // getDefaultExport function for compatibility with non-harmony modules
  74. /******/ __webpack_require__.n = function(module) {
  75. /******/ var getter = module && module.__esModule ?
  76. /******/ function getDefault() { return module['default']; } :
  77. /******/ function getModuleExports() { return module; };
  78. /******/ __webpack_require__.d(getter, 'a', getter);
  79. /******/ return getter;
  80. /******/ };
  81. /******/
  82. /******/ // Object.prototype.hasOwnProperty.call
  83. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  84. /******/
  85. /******/ // __webpack_public_path__
  86. /******/ __webpack_require__.p = "/";
  87. /******/
  88. /******/
  89. /******/ // Load entry module and return exports
  90. /******/ return __webpack_require__(__webpack_require__.s = 16);
  91. /******/ })
  92. /************************************************************************/
  93. /******/ ([
  94. /* 0 */
  95. /***/ (function(module, exports) {
  96. module.exports = require("@babel/runtime/helpers/slicedToArray");
  97. /***/ }),
  98. /* 1 */
  99. /***/ (function(module, exports) {
  100. module.exports = require("@babel/runtime/helpers/toConsumableArray");
  101. /***/ }),
  102. /* 2 */
  103. /***/ (function(module, exports) {
  104. module.exports = require("@babel/runtime/helpers/defineProperty");
  105. /***/ }),
  106. /* 3 */
  107. /***/ (function(module, exports) {
  108. module.exports = require("fuzzysearch");
  109. /***/ }),
  110. /* 4 */
  111. /***/ (function(module, exports) {
  112. module.exports = require("lodash/noop");
  113. /***/ }),
  114. /* 5 */
  115. /***/ (function(module, exports) {
  116. module.exports = require("lodash/debounce");
  117. /***/ }),
  118. /* 6 */
  119. /***/ (function(module, exports) {
  120. module.exports = require("watch-size");
  121. /***/ }),
  122. /* 7 */
  123. /***/ (function(module, exports) {
  124. module.exports = require("is-promise");
  125. /***/ }),
  126. /* 8 */
  127. /***/ (function(module, exports) {
  128. module.exports = require("lodash/once");
  129. /***/ }),
  130. /* 9 */
  131. /***/ (function(module, exports) {
  132. module.exports = require("lodash/identity");
  133. /***/ }),
  134. /* 10 */
  135. /***/ (function(module, exports) {
  136. module.exports = require("lodash/constant");
  137. /***/ }),
  138. /* 11 */
  139. /***/ (function(module, exports) {
  140. module.exports = require("@babel/runtime/helpers/typeof");
  141. /***/ }),
  142. /* 12 */
  143. /***/ (function(module, exports) {
  144. module.exports = require("lodash/last");
  145. /***/ }),
  146. /* 13 */
  147. /***/ (function(module, exports) {
  148. module.exports = require("babel-helper-vue-jsx-merge-props");
  149. /***/ }),
  150. /* 14 */
  151. /***/ (function(module, exports) {
  152. module.exports = require("vue");
  153. /***/ }),
  154. /* 15 */
  155. /***/ (function(module, exports, __webpack_require__) {
  156. // extracted by mini-css-extract-plugin
  157. /***/ }),
  158. /* 16 */
  159. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  160. "use strict";
  161. __webpack_require__.r(__webpack_exports__);
  162. // EXTERNAL MODULE: external "@babel/runtime/helpers/slicedToArray"
  163. var slicedToArray_ = __webpack_require__(0);
  164. var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray_);
  165. // EXTERNAL MODULE: external "@babel/runtime/helpers/toConsumableArray"
  166. var toConsumableArray_ = __webpack_require__(1);
  167. var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray_);
  168. // EXTERNAL MODULE: external "@babel/runtime/helpers/defineProperty"
  169. var defineProperty_ = __webpack_require__(2);
  170. var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty_);
  171. // EXTERNAL MODULE: external "fuzzysearch"
  172. var external_fuzzysearch_ = __webpack_require__(3);
  173. var external_fuzzysearch_default = /*#__PURE__*/__webpack_require__.n(external_fuzzysearch_);
  174. // EXTERNAL MODULE: external "lodash/noop"
  175. var noop_ = __webpack_require__(4);
  176. var noop_default = /*#__PURE__*/__webpack_require__.n(noop_);
  177. // CONCATENATED MODULE: ./src/utils/noop.js
  178. // CONCATENATED MODULE: ./src/utils/warning.js
  179. var warning_warning = process.env.NODE_ENV === 'production' ? noop_default.a : function warning(checker, complainer) {
  180. if (!checker()) {
  181. var _console;
  182. var message = ['[Vue-Treeselect Warning]'].concat(complainer());
  183. (_console = console).error.apply(_console, toConsumableArray_default()(message));
  184. }
  185. };
  186. // CONCATENATED MODULE: ./src/utils/onLeftClick.js
  187. function onLeftClick(mouseDownHandler) {
  188. return function onMouseDown(evt) {
  189. if (evt.type === 'mousedown' && evt.button === 0) {
  190. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  191. args[_key - 1] = arguments[_key];
  192. }
  193. mouseDownHandler.call.apply(mouseDownHandler, [this, evt].concat(args));
  194. }
  195. };
  196. }
  197. // CONCATENATED MODULE: ./src/utils/scrollIntoView.js
  198. function scrollIntoView($scrollingEl, $focusedEl) {
  199. var scrollingReact = $scrollingEl.getBoundingClientRect();
  200. var focusedRect = $focusedEl.getBoundingClientRect();
  201. var overScroll = $focusedEl.offsetHeight / 3;
  202. if (focusedRect.bottom + overScroll > scrollingReact.bottom) {
  203. $scrollingEl.scrollTop = Math.min($focusedEl.offsetTop + $focusedEl.clientHeight - $scrollingEl.offsetHeight + overScroll, $scrollingEl.scrollHeight);
  204. } else if (focusedRect.top - overScroll < scrollingReact.top) {
  205. $scrollingEl.scrollTop = Math.max($focusedEl.offsetTop - overScroll, 0);
  206. }
  207. }
  208. // EXTERNAL MODULE: external "lodash/debounce"
  209. var debounce_ = __webpack_require__(5);
  210. var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce_);
  211. // CONCATENATED MODULE: ./src/utils/debounce.js
  212. // EXTERNAL MODULE: external "watch-size"
  213. var external_watch_size_ = __webpack_require__(6);
  214. var external_watch_size_default = /*#__PURE__*/__webpack_require__.n(external_watch_size_);
  215. // CONCATENATED MODULE: ./src/utils/removeFromArray.js
  216. function removeFromArray(arr, elem) {
  217. var idx = arr.indexOf(elem);
  218. if (idx !== -1) arr.splice(idx, 1);
  219. }
  220. // CONCATENATED MODULE: ./src/utils/watchSize.js
  221. var intervalId;
  222. var registered = [];
  223. var INTERVAL_DURATION = 100;
  224. function run() {
  225. intervalId = setInterval(function () {
  226. registered.forEach(test);
  227. }, INTERVAL_DURATION);
  228. }
  229. function stop() {
  230. clearInterval(intervalId);
  231. intervalId = null;
  232. }
  233. function test(item) {
  234. var $el = item.$el,
  235. listener = item.listener,
  236. lastWidth = item.lastWidth,
  237. lastHeight = item.lastHeight;
  238. var width = $el.offsetWidth;
  239. var height = $el.offsetHeight;
  240. if (lastWidth !== width || lastHeight !== height) {
  241. item.lastWidth = width;
  242. item.lastHeight = height;
  243. listener({
  244. width: width,
  245. height: height
  246. });
  247. }
  248. }
  249. function watchSizeForIE9($el, listener) {
  250. var item = {
  251. $el: $el,
  252. listener: listener,
  253. lastWidth: null,
  254. lastHeight: null
  255. };
  256. var unwatch = function unwatch() {
  257. removeFromArray(registered, item);
  258. if (!registered.length) stop();
  259. };
  260. registered.push(item);
  261. test(item);
  262. run();
  263. return unwatch;
  264. }
  265. function watchSize($el, listener) {
  266. var isIE9 = document.documentMode === 9;
  267. var locked = true;
  268. var wrappedListener = function wrappedListener() {
  269. return locked || listener.apply(void 0, arguments);
  270. };
  271. var implementation = isIE9 ? watchSizeForIE9 : external_watch_size_default.a;
  272. var removeSizeWatcher = implementation($el, wrappedListener);
  273. locked = false;
  274. return removeSizeWatcher;
  275. }
  276. // CONCATENATED MODULE: ./src/utils/setupResizeAndScrollEventListeners.js
  277. function findScrollParents($el) {
  278. var $scrollParents = [];
  279. var $parent = $el.parentNode;
  280. while ($parent && $parent.nodeName !== 'BODY' && $parent.nodeType === document.ELEMENT_NODE) {
  281. if (isScrollElment($parent)) $scrollParents.push($parent);
  282. $parent = $parent.parentNode;
  283. }
  284. $scrollParents.push(window);
  285. return $scrollParents;
  286. }
  287. function isScrollElment($el) {
  288. var _getComputedStyle = getComputedStyle($el),
  289. overflow = _getComputedStyle.overflow,
  290. overflowX = _getComputedStyle.overflowX,
  291. overflowY = _getComputedStyle.overflowY;
  292. return /(auto|scroll|overlay)/.test(overflow + overflowY + overflowX);
  293. }
  294. function setupResizeAndScrollEventListeners($el, listener) {
  295. var $scrollParents = findScrollParents($el);
  296. window.addEventListener('resize', listener, {
  297. passive: true
  298. });
  299. $scrollParents.forEach(function (scrollParent) {
  300. scrollParent.addEventListener('scroll', listener, {
  301. passive: true
  302. });
  303. });
  304. return function removeEventListeners() {
  305. window.removeEventListener('resize', listener, {
  306. passive: true
  307. });
  308. $scrollParents.forEach(function ($scrollParent) {
  309. $scrollParent.removeEventListener('scroll', listener, {
  310. passive: true
  311. });
  312. });
  313. };
  314. }
  315. // CONCATENATED MODULE: ./src/utils/isNaN.js
  316. function isNaN_isNaN(x) {
  317. return x !== x;
  318. }
  319. // EXTERNAL MODULE: external "is-promise"
  320. var external_is_promise_ = __webpack_require__(7);
  321. var external_is_promise_default = /*#__PURE__*/__webpack_require__.n(external_is_promise_);
  322. // CONCATENATED MODULE: ./src/utils/isPromise.js
  323. // EXTERNAL MODULE: external "lodash/once"
  324. var once_ = __webpack_require__(8);
  325. var once_default = /*#__PURE__*/__webpack_require__.n(once_);
  326. // CONCATENATED MODULE: ./src/utils/once.js
  327. // EXTERNAL MODULE: external "lodash/identity"
  328. var identity_ = __webpack_require__(9);
  329. var identity_default = /*#__PURE__*/__webpack_require__.n(identity_);
  330. // CONCATENATED MODULE: ./src/utils/identity.js
  331. // EXTERNAL MODULE: external "lodash/constant"
  332. var constant_ = __webpack_require__(10);
  333. var constant_default = /*#__PURE__*/__webpack_require__.n(constant_);
  334. // CONCATENATED MODULE: ./src/utils/constant.js
  335. // CONCATENATED MODULE: ./src/utils/createMap.js
  336. var createMap = function createMap() {
  337. return Object.create(null);
  338. };
  339. // EXTERNAL MODULE: external "@babel/runtime/helpers/typeof"
  340. var typeof_ = __webpack_require__(11);
  341. var typeof_default = /*#__PURE__*/__webpack_require__.n(typeof_);
  342. // CONCATENATED MODULE: ./src/utils/deepExtend.js
  343. function isPlainObject(value) {
  344. if (value == null || typeof_default()(value) !== 'object') return false;
  345. return Object.getPrototypeOf(value) === Object.prototype;
  346. }
  347. function copy(obj, key, value) {
  348. if (isPlainObject(value)) {
  349. obj[key] || (obj[key] = {});
  350. deepExtend(obj[key], value);
  351. } else {
  352. obj[key] = value;
  353. }
  354. }
  355. function deepExtend(target, source) {
  356. if (isPlainObject(source)) {
  357. var keys = Object.keys(source);
  358. for (var i = 0, len = keys.length; i < len; i++) {
  359. copy(target, keys[i], source[keys[i]]);
  360. }
  361. }
  362. return target;
  363. }
  364. // EXTERNAL MODULE: external "lodash/last"
  365. var last_ = __webpack_require__(12);
  366. var last_default = /*#__PURE__*/__webpack_require__.n(last_);
  367. // CONCATENATED MODULE: ./src/utils/last.js
  368. // CONCATENATED MODULE: ./src/utils/includes.js
  369. function includes(arrOrStr, elem) {
  370. return arrOrStr.indexOf(elem) !== -1;
  371. }
  372. // CONCATENATED MODULE: ./src/utils/find.js
  373. function find(arr, predicate, ctx) {
  374. for (var i = 0, len = arr.length; i < len; i++) {
  375. if (predicate.call(ctx, arr[i], i, arr)) return arr[i];
  376. }
  377. return undefined;
  378. }
  379. // CONCATENATED MODULE: ./src/utils/quickDiff.js
  380. function quickDiff(arrA, arrB) {
  381. if (arrA.length !== arrB.length) return true;
  382. for (var i = 0; i < arrA.length; i++) {
  383. if (arrA[i] !== arrB[i]) return true;
  384. }
  385. return false;
  386. }
  387. // CONCATENATED MODULE: ./src/utils/index.js
  388. // CONCATENATED MODULE: ./src/constants.js
  389. var NO_PARENT_NODE = null;
  390. var UNCHECKED = 0;
  391. var INDETERMINATE = 1;
  392. var CHECKED = 2;
  393. var ALL_CHILDREN = 'ALL_CHILDREN';
  394. var ALL_DESCENDANTS = 'ALL_DESCENDANTS';
  395. var LEAF_CHILDREN = 'LEAF_CHILDREN';
  396. var LEAF_DESCENDANTS = 'LEAF_DESCENDANTS';
  397. var LOAD_ROOT_OPTIONS = 'LOAD_ROOT_OPTIONS';
  398. var LOAD_CHILDREN_OPTIONS = 'LOAD_CHILDREN_OPTIONS';
  399. var ASYNC_SEARCH = 'ASYNC_SEARCH';
  400. var ALL = 'ALL';
  401. var BRANCH_PRIORITY = 'BRANCH_PRIORITY';
  402. var LEAF_PRIORITY = 'LEAF_PRIORITY';
  403. var ALL_WITH_INDETERMINATE = 'ALL_WITH_INDETERMINATE';
  404. var ORDER_SELECTED = 'ORDER_SELECTED';
  405. var LEVEL = 'LEVEL';
  406. var INDEX = 'INDEX';
  407. var KEY_CODES = {
  408. BACKSPACE: 8,
  409. ENTER: 13,
  410. ESCAPE: 27,
  411. END: 35,
  412. HOME: 36,
  413. ARROW_LEFT: 37,
  414. ARROW_UP: 38,
  415. ARROW_RIGHT: 39,
  416. ARROW_DOWN: 40,
  417. DELETE: 46
  418. };
  419. var INPUT_DEBOUNCE_DELAY = process.env.NODE_ENV === 'testing' ? 10 : 200;
  420. var MIN_INPUT_WIDTH = 5;
  421. var MENU_BUFFER = 40;
  422. // CONCATENATED MODULE: ./src/mixins/treeselectMixin.js
  423. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  424. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  425. function sortValueByIndex(a, b) {
  426. var i = 0;
  427. do {
  428. if (a.level < i) return -1;
  429. if (b.level < i) return 1;
  430. if (a.index[i] !== b.index[i]) return a.index[i] - b.index[i];
  431. i++;
  432. } while (true);
  433. }
  434. function sortValueByLevel(a, b) {
  435. return a.level === b.level ? sortValueByIndex(a, b) : a.level - b.level;
  436. }
  437. function createAsyncOptionsStates() {
  438. return {
  439. isLoaded: false,
  440. isLoading: false,
  441. loadingError: ''
  442. };
  443. }
  444. function stringifyOptionPropValue(value) {
  445. if (typeof value === 'string') return value;
  446. if (typeof value === 'number' && !isNaN_isNaN(value)) return value + '';
  447. return '';
  448. }
  449. function match(enableFuzzyMatch, needle, haystack) {
  450. return enableFuzzyMatch ? external_fuzzysearch_default()(needle, haystack) : includes(haystack, needle);
  451. }
  452. function getErrorMessage(err) {
  453. return err.message || String(err);
  454. }
  455. var instanceId = 0;
  456. /* harmony default export */ var treeselectMixin = ({
  457. provide: function provide() {
  458. return {
  459. instance: this
  460. };
  461. },
  462. props: {
  463. allowClearingDisabled: {
  464. type: Boolean,
  465. default: false
  466. },
  467. allowSelectingDisabledDescendants: {
  468. type: Boolean,
  469. default: false
  470. },
  471. alwaysOpen: {
  472. type: Boolean,
  473. default: false
  474. },
  475. appendToBody: {
  476. type: Boolean,
  477. default: false
  478. },
  479. async: {
  480. type: Boolean,
  481. default: false
  482. },
  483. autoFocus: {
  484. type: Boolean,
  485. default: false
  486. },
  487. autoLoadRootOptions: {
  488. type: Boolean,
  489. default: true
  490. },
  491. autoDeselectAncestors: {
  492. type: Boolean,
  493. default: false
  494. },
  495. autoDeselectDescendants: {
  496. type: Boolean,
  497. default: false
  498. },
  499. autoSelectAncestors: {
  500. type: Boolean,
  501. default: false
  502. },
  503. autoSelectDescendants: {
  504. type: Boolean,
  505. default: false
  506. },
  507. backspaceRemoves: {
  508. type: Boolean,
  509. default: true
  510. },
  511. beforeClearAll: {
  512. type: Function,
  513. default: constant_default()(true)
  514. },
  515. branchNodesFirst: {
  516. type: Boolean,
  517. default: false
  518. },
  519. cacheOptions: {
  520. type: Boolean,
  521. default: true
  522. },
  523. clearable: {
  524. type: Boolean,
  525. default: true
  526. },
  527. clearAllText: {
  528. type: String,
  529. default: 'Clear all'
  530. },
  531. clearOnSelect: {
  532. type: Boolean,
  533. default: false
  534. },
  535. clearValueText: {
  536. type: String,
  537. default: 'Clear value'
  538. },
  539. closeOnSelect: {
  540. type: Boolean,
  541. default: true
  542. },
  543. defaultExpandLevel: {
  544. type: Number,
  545. default: 0
  546. },
  547. defaultOptions: {
  548. default: false
  549. },
  550. deleteRemoves: {
  551. type: Boolean,
  552. default: true
  553. },
  554. delimiter: {
  555. type: String,
  556. default: ','
  557. },
  558. flattenSearchResults: {
  559. type: Boolean,
  560. default: false
  561. },
  562. disableBranchNodes: {
  563. type: Boolean,
  564. default: false
  565. },
  566. disabled: {
  567. type: Boolean,
  568. default: false
  569. },
  570. disableFuzzyMatching: {
  571. type: Boolean,
  572. default: false
  573. },
  574. flat: {
  575. type: Boolean,
  576. default: false
  577. },
  578. instanceId: {
  579. default: function _default() {
  580. return "".concat(instanceId++, "$$");
  581. },
  582. type: [String, Number]
  583. },
  584. joinValues: {
  585. type: Boolean,
  586. default: false
  587. },
  588. limit: {
  589. type: Number,
  590. default: Infinity
  591. },
  592. limitText: {
  593. type: Function,
  594. default: function limitTextDefault(count) {
  595. return "and ".concat(count, " more");
  596. }
  597. },
  598. loadingText: {
  599. type: String,
  600. default: 'Loading...'
  601. },
  602. loadOptions: {
  603. type: Function
  604. },
  605. matchKeys: {
  606. type: Array,
  607. default: constant_default()(['label'])
  608. },
  609. maxHeight: {
  610. type: Number,
  611. default: 300
  612. },
  613. multiple: {
  614. type: Boolean,
  615. default: false
  616. },
  617. name: {
  618. type: String
  619. },
  620. noChildrenText: {
  621. type: String,
  622. default: 'No sub-options.'
  623. },
  624. noOptionsText: {
  625. type: String,
  626. default: 'No options available.'
  627. },
  628. noResultsText: {
  629. type: String,
  630. default: 'No results found...'
  631. },
  632. normalizer: {
  633. type: Function,
  634. default: identity_default.a
  635. },
  636. openDirection: {
  637. type: String,
  638. default: 'auto',
  639. validator: function validator(value) {
  640. var acceptableValues = ['auto', 'top', 'bottom', 'above', 'below'];
  641. return includes(acceptableValues, value);
  642. }
  643. },
  644. openOnClick: {
  645. type: Boolean,
  646. default: true
  647. },
  648. openOnFocus: {
  649. type: Boolean,
  650. default: false
  651. },
  652. options: {
  653. type: Array
  654. },
  655. placeholder: {
  656. type: String,
  657. default: 'Select...'
  658. },
  659. required: {
  660. type: Boolean,
  661. default: false
  662. },
  663. retryText: {
  664. type: String,
  665. default: 'Retry?'
  666. },
  667. retryTitle: {
  668. type: String,
  669. default: 'Click to retry'
  670. },
  671. searchable: {
  672. type: Boolean,
  673. default: true
  674. },
  675. searchNested: {
  676. type: Boolean,
  677. default: false
  678. },
  679. searchPromptText: {
  680. type: String,
  681. default: 'Type to search...'
  682. },
  683. showCount: {
  684. type: Boolean,
  685. default: false
  686. },
  687. showCountOf: {
  688. type: String,
  689. default: ALL_CHILDREN,
  690. validator: function validator(value) {
  691. var acceptableValues = [ALL_CHILDREN, ALL_DESCENDANTS, LEAF_CHILDREN, LEAF_DESCENDANTS];
  692. return includes(acceptableValues, value);
  693. }
  694. },
  695. showCountOnSearch: null,
  696. sortValueBy: {
  697. type: String,
  698. default: ORDER_SELECTED,
  699. validator: function validator(value) {
  700. var acceptableValues = [ORDER_SELECTED, LEVEL, INDEX];
  701. return includes(acceptableValues, value);
  702. }
  703. },
  704. tabIndex: {
  705. type: Number,
  706. default: 0
  707. },
  708. value: null,
  709. valueConsistsOf: {
  710. type: String,
  711. default: BRANCH_PRIORITY,
  712. validator: function validator(value) {
  713. var acceptableValues = [ALL, BRANCH_PRIORITY, LEAF_PRIORITY, ALL_WITH_INDETERMINATE];
  714. return includes(acceptableValues, value);
  715. }
  716. },
  717. valueFormat: {
  718. type: String,
  719. default: 'id'
  720. },
  721. zIndex: {
  722. type: [Number, String],
  723. default: 999
  724. }
  725. },
  726. data: function data() {
  727. return {
  728. trigger: {
  729. isFocused: false,
  730. searchQuery: ''
  731. },
  732. menu: {
  733. isOpen: false,
  734. current: null,
  735. lastScrollPosition: 0,
  736. placement: 'bottom'
  737. },
  738. forest: {
  739. normalizedOptions: [],
  740. nodeMap: createMap(),
  741. checkedStateMap: createMap(),
  742. selectedNodeIds: this.extractCheckedNodeIdsFromValue(),
  743. selectedNodeMap: createMap()
  744. },
  745. rootOptionsStates: createAsyncOptionsStates(),
  746. localSearch: {
  747. active: false,
  748. noResults: true,
  749. countMap: createMap()
  750. },
  751. remoteSearch: createMap()
  752. };
  753. },
  754. computed: {
  755. selectedNodes: function selectedNodes() {
  756. return this.forest.selectedNodeIds.map(this.getNode);
  757. },
  758. internalValue: function internalValue() {
  759. var _this = this;
  760. var internalValue;
  761. if (this.single || this.flat || this.disableBranchNodes || this.valueConsistsOf === ALL) {
  762. internalValue = this.forest.selectedNodeIds.slice();
  763. } else if (this.valueConsistsOf === BRANCH_PRIORITY) {
  764. internalValue = this.forest.selectedNodeIds.filter(function (id) {
  765. var node = _this.getNode(id);
  766. if (node.isRootNode) return true;
  767. return !_this.isSelected(node.parentNode);
  768. });
  769. } else if (this.valueConsistsOf === LEAF_PRIORITY) {
  770. internalValue = this.forest.selectedNodeIds.filter(function (id) {
  771. var node = _this.getNode(id);
  772. if (node.isLeaf) return true;
  773. return node.children.length === 0;
  774. });
  775. } else if (this.valueConsistsOf === ALL_WITH_INDETERMINATE) {
  776. var _internalValue;
  777. var indeterminateNodeIds = [];
  778. internalValue = this.forest.selectedNodeIds.slice();
  779. this.selectedNodes.forEach(function (selectedNode) {
  780. selectedNode.ancestors.forEach(function (ancestor) {
  781. if (includes(indeterminateNodeIds, ancestor.id)) return;
  782. if (includes(internalValue, ancestor.id)) return;
  783. indeterminateNodeIds.push(ancestor.id);
  784. });
  785. });
  786. (_internalValue = internalValue).push.apply(_internalValue, indeterminateNodeIds);
  787. }
  788. if (this.sortValueBy === LEVEL) {
  789. internalValue.sort(function (a, b) {
  790. return sortValueByLevel(_this.getNode(a), _this.getNode(b));
  791. });
  792. } else if (this.sortValueBy === INDEX) {
  793. internalValue.sort(function (a, b) {
  794. return sortValueByIndex(_this.getNode(a), _this.getNode(b));
  795. });
  796. }
  797. return internalValue;
  798. },
  799. hasValue: function hasValue() {
  800. return this.internalValue.length > 0;
  801. },
  802. single: function single() {
  803. return !this.multiple;
  804. },
  805. visibleOptionIds: function visibleOptionIds() {
  806. var _this2 = this;
  807. var visibleOptionIds = [];
  808. this.traverseAllNodesByIndex(function (node) {
  809. if (!_this2.localSearch.active || _this2.shouldOptionBeIncludedInSearchResult(node)) {
  810. visibleOptionIds.push(node.id);
  811. }
  812. if (node.isBranch && !_this2.shouldExpand(node)) {
  813. return false;
  814. }
  815. });
  816. return visibleOptionIds;
  817. },
  818. hasVisibleOptions: function hasVisibleOptions() {
  819. return this.visibleOptionIds.length !== 0;
  820. },
  821. showCountOnSearchComputed: function showCountOnSearchComputed() {
  822. return typeof this.showCountOnSearch === 'boolean' ? this.showCountOnSearch : this.showCount;
  823. },
  824. hasBranchNodes: function hasBranchNodes() {
  825. return this.forest.normalizedOptions.some(function (rootNode) {
  826. return rootNode.isBranch;
  827. });
  828. },
  829. shouldFlattenOptions: function shouldFlattenOptions() {
  830. return this.localSearch.active && this.flattenSearchResults;
  831. }
  832. },
  833. watch: {
  834. alwaysOpen: function alwaysOpen(newValue) {
  835. if (newValue) this.openMenu();else this.closeMenu();
  836. },
  837. branchNodesFirst: function branchNodesFirst() {
  838. this.initialize();
  839. },
  840. disabled: function disabled(newValue) {
  841. if (newValue && this.menu.isOpen) this.closeMenu();else if (!newValue && !this.menu.isOpen && this.alwaysOpen) this.openMenu();
  842. },
  843. flat: function flat() {
  844. this.initialize();
  845. },
  846. internalValue: function internalValue(newValue, oldValue) {
  847. var hasChanged = quickDiff(newValue, oldValue);
  848. if (hasChanged) this.$emit('input', this.getValue(), this.getInstanceId());
  849. },
  850. matchKeys: function matchKeys() {
  851. this.initialize();
  852. },
  853. multiple: function multiple(newValue) {
  854. if (newValue) this.buildForestState();
  855. },
  856. options: {
  857. handler: function handler() {
  858. if (this.async) return;
  859. this.initialize();
  860. this.rootOptionsStates.isLoaded = Array.isArray(this.options);
  861. },
  862. deep: true,
  863. immediate: true
  864. },
  865. 'trigger.searchQuery': function triggerSearchQuery() {
  866. if (this.async) {
  867. this.handleRemoteSearch();
  868. } else {
  869. this.handleLocalSearch();
  870. }
  871. this.$emit('search-change', this.trigger.searchQuery, this.getInstanceId());
  872. },
  873. value: function value() {
  874. var nodeIdsFromValue = this.extractCheckedNodeIdsFromValue();
  875. var hasChanged = quickDiff(nodeIdsFromValue, this.internalValue);
  876. if (hasChanged) this.fixSelectedNodeIds(nodeIdsFromValue);
  877. }
  878. },
  879. methods: {
  880. verifyProps: function verifyProps() {
  881. var _this3 = this;
  882. warning_warning(function () {
  883. return _this3.async ? _this3.searchable : true;
  884. }, function () {
  885. return 'For async search mode, the value of "searchable" prop must be true.';
  886. });
  887. if (this.options == null && !this.loadOptions) {
  888. warning_warning(function () {
  889. return false;
  890. }, function () {
  891. return 'Are you meant to dynamically load options? You need to use "loadOptions" prop.';
  892. });
  893. }
  894. if (this.flat) {
  895. warning_warning(function () {
  896. return _this3.multiple;
  897. }, function () {
  898. return 'You are using flat mode. But you forgot to add "multiple=true"?';
  899. });
  900. }
  901. if (!this.flat) {
  902. var propNames = ['autoSelectAncestors', 'autoSelectDescendants', 'autoDeselectAncestors', 'autoDeselectDescendants'];
  903. propNames.forEach(function (propName) {
  904. warning_warning(function () {
  905. return !_this3[propName];
  906. }, function () {
  907. return "\"".concat(propName, "\" only applies to flat mode.");
  908. });
  909. });
  910. }
  911. },
  912. resetFlags: function resetFlags() {
  913. this._blurOnSelect = false;
  914. },
  915. initialize: function initialize() {
  916. var options = this.async ? this.getRemoteSearchEntry().options : this.options;
  917. if (Array.isArray(options)) {
  918. var prevNodeMap = this.forest.nodeMap;
  919. this.forest.nodeMap = createMap();
  920. this.keepDataOfSelectedNodes(prevNodeMap);
  921. this.forest.normalizedOptions = this.normalize(NO_PARENT_NODE, options, prevNodeMap);
  922. this.fixSelectedNodeIds(this.internalValue);
  923. } else {
  924. this.forest.normalizedOptions = [];
  925. }
  926. },
  927. getInstanceId: function getInstanceId() {
  928. return this.instanceId == null ? this.id : this.instanceId;
  929. },
  930. getValue: function getValue() {
  931. var _this4 = this;
  932. if (this.valueFormat === 'id') {
  933. return this.multiple ? this.internalValue.slice() : this.internalValue[0];
  934. }
  935. var rawNodes = this.internalValue.map(function (id) {
  936. return _this4.getNode(id).raw;
  937. });
  938. return this.multiple ? rawNodes : rawNodes[0];
  939. },
  940. getNode: function getNode(nodeId) {
  941. warning_warning(function () {
  942. return nodeId != null;
  943. }, function () {
  944. return "Invalid node id: ".concat(nodeId);
  945. });
  946. if (nodeId == null) return null;
  947. return nodeId in this.forest.nodeMap ? this.forest.nodeMap[nodeId] : this.createFallbackNode(nodeId);
  948. },
  949. createFallbackNode: function createFallbackNode(id) {
  950. var raw = this.extractNodeFromValue(id);
  951. var label = this.enhancedNormalizer(raw).label || "".concat(id, " (unknown)");
  952. var fallbackNode = {
  953. id: id,
  954. label: label,
  955. ancestors: [],
  956. parentNode: NO_PARENT_NODE,
  957. isFallbackNode: true,
  958. isRootNode: true,
  959. isLeaf: true,
  960. isBranch: false,
  961. isDisabled: false,
  962. isNew: false,
  963. index: [-1],
  964. level: 0,
  965. raw: raw
  966. };
  967. return this.$set(this.forest.nodeMap, id, fallbackNode);
  968. },
  969. extractCheckedNodeIdsFromValue: function extractCheckedNodeIdsFromValue() {
  970. var _this5 = this;
  971. if (this.value == null) return [];
  972. if (this.valueFormat === 'id') {
  973. return this.multiple ? this.value.slice() : [this.value];
  974. }
  975. return (this.multiple ? this.value : [this.value]).map(function (node) {
  976. return _this5.enhancedNormalizer(node);
  977. }).map(function (node) {
  978. return node.id;
  979. });
  980. },
  981. extractNodeFromValue: function extractNodeFromValue(id) {
  982. var _this6 = this;
  983. var defaultNode = {
  984. id: id
  985. };
  986. if (this.valueFormat === 'id') {
  987. return defaultNode;
  988. }
  989. var valueArray = this.multiple ? Array.isArray(this.value) ? this.value : [] : this.value ? [this.value] : [];
  990. var matched = find(valueArray, function (node) {
  991. return node && _this6.enhancedNormalizer(node).id === id;
  992. });
  993. return matched || defaultNode;
  994. },
  995. fixSelectedNodeIds: function fixSelectedNodeIds(nodeIdListOfPrevValue) {
  996. var _this7 = this;
  997. var nextSelectedNodeIds = [];
  998. if (this.single || this.flat || this.disableBranchNodes || this.valueConsistsOf === ALL) {
  999. nextSelectedNodeIds = nodeIdListOfPrevValue;
  1000. } else if (this.valueConsistsOf === BRANCH_PRIORITY) {
  1001. nodeIdListOfPrevValue.forEach(function (nodeId) {
  1002. nextSelectedNodeIds.push(nodeId);
  1003. var node = _this7.getNode(nodeId);
  1004. if (node.isBranch) _this7.traverseDescendantsBFS(node, function (descendant) {
  1005. nextSelectedNodeIds.push(descendant.id);
  1006. });
  1007. });
  1008. } else if (this.valueConsistsOf === LEAF_PRIORITY) {
  1009. var map = createMap();
  1010. var queue = nodeIdListOfPrevValue.slice();
  1011. while (queue.length) {
  1012. var nodeId = queue.shift();
  1013. var node = this.getNode(nodeId);
  1014. nextSelectedNodeIds.push(nodeId);
  1015. if (node.isRootNode) continue;
  1016. if (!(node.parentNode.id in map)) map[node.parentNode.id] = node.parentNode.children.length;
  1017. if (--map[node.parentNode.id] === 0) queue.push(node.parentNode.id);
  1018. }
  1019. } else if (this.valueConsistsOf === ALL_WITH_INDETERMINATE) {
  1020. var _map = createMap();
  1021. var _queue = nodeIdListOfPrevValue.filter(function (nodeId) {
  1022. var node = _this7.getNode(nodeId);
  1023. return node.isLeaf || node.children.length === 0;
  1024. });
  1025. while (_queue.length) {
  1026. var _nodeId = _queue.shift();
  1027. var _node = this.getNode(_nodeId);
  1028. nextSelectedNodeIds.push(_nodeId);
  1029. if (_node.isRootNode) continue;
  1030. if (!(_node.parentNode.id in _map)) _map[_node.parentNode.id] = _node.parentNode.children.length;
  1031. if (--_map[_node.parentNode.id] === 0) _queue.push(_node.parentNode.id);
  1032. }
  1033. }
  1034. var hasChanged = quickDiff(this.forest.selectedNodeIds, nextSelectedNodeIds);
  1035. if (hasChanged) this.forest.selectedNodeIds = nextSelectedNodeIds;
  1036. this.buildForestState();
  1037. },
  1038. keepDataOfSelectedNodes: function keepDataOfSelectedNodes(prevNodeMap) {
  1039. var _this8 = this;
  1040. this.forest.selectedNodeIds.forEach(function (id) {
  1041. if (!prevNodeMap[id]) return;
  1042. var node = _objectSpread({}, prevNodeMap[id], {
  1043. isFallbackNode: true
  1044. });
  1045. _this8.$set(_this8.forest.nodeMap, id, node);
  1046. });
  1047. },
  1048. isSelected: function isSelected(node) {
  1049. return this.forest.selectedNodeMap[node.id] === true;
  1050. },
  1051. traverseDescendantsBFS: function traverseDescendantsBFS(parentNode, callback) {
  1052. if (!parentNode.isBranch) return;
  1053. var queue = parentNode.children.slice();
  1054. while (queue.length) {
  1055. var currNode = queue[0];
  1056. if (currNode.isBranch) queue.push.apply(queue, toConsumableArray_default()(currNode.children));
  1057. callback(currNode);
  1058. queue.shift();
  1059. }
  1060. },
  1061. traverseDescendantsDFS: function traverseDescendantsDFS(parentNode, callback) {
  1062. var _this9 = this;
  1063. if (!parentNode.isBranch) return;
  1064. parentNode.children.forEach(function (child) {
  1065. _this9.traverseDescendantsDFS(child, callback);
  1066. callback(child);
  1067. });
  1068. },
  1069. traverseAllNodesDFS: function traverseAllNodesDFS(callback) {
  1070. var _this10 = this;
  1071. this.forest.normalizedOptions.forEach(function (rootNode) {
  1072. _this10.traverseDescendantsDFS(rootNode, callback);
  1073. callback(rootNode);
  1074. });
  1075. },
  1076. traverseAllNodesByIndex: function traverseAllNodesByIndex(callback) {
  1077. var walk = function walk(parentNode) {
  1078. parentNode.children.forEach(function (child) {
  1079. if (callback(child) !== false && child.isBranch) {
  1080. walk(child);
  1081. }
  1082. });
  1083. };
  1084. walk({
  1085. children: this.forest.normalizedOptions
  1086. });
  1087. },
  1088. toggleClickOutsideEvent: function toggleClickOutsideEvent(enabled) {
  1089. if (enabled) {
  1090. document.addEventListener('mousedown', this.handleClickOutside, false);
  1091. } else {
  1092. document.removeEventListener('mousedown', this.handleClickOutside, false);
  1093. }
  1094. },
  1095. getValueContainer: function getValueContainer() {
  1096. return this.$refs.control.$refs['value-container'];
  1097. },
  1098. getInput: function getInput() {
  1099. return this.getValueContainer().$refs.input;
  1100. },
  1101. focusInput: function focusInput() {
  1102. this.getInput().focus();
  1103. },
  1104. blurInput: function blurInput() {
  1105. this.getInput().blur();
  1106. },
  1107. handleMouseDown: onLeftClick(function handleMouseDown(evt) {
  1108. evt.preventDefault();
  1109. evt.stopPropagation();
  1110. if (this.disabled) return;
  1111. var isClickedOnValueContainer = this.getValueContainer().$el.contains(evt.target);
  1112. if (isClickedOnValueContainer && !this.menu.isOpen && (this.openOnClick || this.trigger.isFocused)) {
  1113. this.openMenu();
  1114. }
  1115. if (this._blurOnSelect) {
  1116. this.blurInput();
  1117. } else {
  1118. this.focusInput();
  1119. }
  1120. this.resetFlags();
  1121. }),
  1122. handleClickOutside: function handleClickOutside(evt) {
  1123. if (this.$refs.wrapper && !this.$refs.wrapper.contains(evt.target)) {
  1124. this.blurInput();
  1125. this.closeMenu();
  1126. }
  1127. },
  1128. handleLocalSearch: function handleLocalSearch() {
  1129. var _this11 = this;
  1130. var searchQuery = this.trigger.searchQuery;
  1131. var done = function done() {
  1132. return _this11.resetHighlightedOptionWhenNecessary(true);
  1133. };
  1134. if (!searchQuery) {
  1135. this.localSearch.active = false;
  1136. return done();
  1137. }
  1138. this.localSearch.active = true;
  1139. this.localSearch.noResults = true;
  1140. this.traverseAllNodesDFS(function (node) {
  1141. if (node.isBranch) {
  1142. var _this11$$set;
  1143. node.isExpandedOnSearch = false;
  1144. node.showAllChildrenOnSearch = false;
  1145. node.isMatched = false;
  1146. node.hasMatchedDescendants = false;
  1147. _this11.$set(_this11.localSearch.countMap, node.id, (_this11$$set = {}, defineProperty_default()(_this11$$set, ALL_CHILDREN, 0), defineProperty_default()(_this11$$set, ALL_DESCENDANTS, 0), defineProperty_default()(_this11$$set, LEAF_CHILDREN, 0), defineProperty_default()(_this11$$set, LEAF_DESCENDANTS, 0), _this11$$set));
  1148. }
  1149. });
  1150. var lowerCasedSearchQuery = searchQuery.trim().toLocaleLowerCase();
  1151. var splitSearchQuery = lowerCasedSearchQuery.replace(/\s+/g, ' ').split(' ');
  1152. this.traverseAllNodesDFS(function (node) {
  1153. if (_this11.searchNested && splitSearchQuery.length > 1) {
  1154. node.isMatched = splitSearchQuery.every(function (filterValue) {
  1155. return match(false, filterValue, node.nestedSearchLabel);
  1156. });
  1157. } else {
  1158. node.isMatched = _this11.matchKeys.some(function (matchKey) {
  1159. return match(!_this11.disableFuzzyMatching, lowerCasedSearchQuery, node.lowerCased[matchKey]);
  1160. });
  1161. }
  1162. if (node.isMatched) {
  1163. _this11.localSearch.noResults = false;
  1164. node.ancestors.forEach(function (ancestor) {
  1165. return _this11.localSearch.countMap[ancestor.id][ALL_DESCENDANTS]++;
  1166. });
  1167. if (node.isLeaf) node.ancestors.forEach(function (ancestor) {
  1168. return _this11.localSearch.countMap[ancestor.id][LEAF_DESCENDANTS]++;
  1169. });
  1170. if (node.parentNode !== NO_PARENT_NODE) {
  1171. _this11.localSearch.countMap[node.parentNode.id][ALL_CHILDREN] += 1;
  1172. if (node.isLeaf) _this11.localSearch.countMap[node.parentNode.id][LEAF_CHILDREN] += 1;
  1173. }
  1174. }
  1175. if ((node.isMatched || node.isBranch && node.isExpandedOnSearch) && node.parentNode !== NO_PARENT_NODE) {
  1176. node.parentNode.isExpandedOnSearch = true;
  1177. node.parentNode.hasMatchedDescendants = true;
  1178. }
  1179. });
  1180. done();
  1181. },
  1182. handleRemoteSearch: function handleRemoteSearch() {
  1183. var _this12 = this;
  1184. var searchQuery = this.trigger.searchQuery;
  1185. var entry = this.getRemoteSearchEntry();
  1186. var done = function done() {
  1187. _this12.initialize();
  1188. _this12.resetHighlightedOptionWhenNecessary(true);
  1189. };
  1190. if ((searchQuery === '' || this.cacheOptions) && entry.isLoaded) {
  1191. return done();
  1192. }
  1193. this.callLoadOptionsProp({
  1194. action: ASYNC_SEARCH,
  1195. args: {
  1196. searchQuery: searchQuery
  1197. },
  1198. isPending: function isPending() {
  1199. return entry.isLoading;
  1200. },
  1201. start: function start() {
  1202. entry.isLoading = true;
  1203. entry.isLoaded = false;
  1204. entry.loadingError = '';
  1205. },
  1206. succeed: function succeed(options) {
  1207. entry.isLoaded = true;
  1208. entry.options = options;
  1209. if (_this12.trigger.searchQuery === searchQuery) done();
  1210. },
  1211. fail: function fail(err) {
  1212. entry.loadingError = getErrorMessage(err);
  1213. },
  1214. end: function end() {
  1215. entry.isLoading = false;
  1216. }
  1217. });
  1218. },
  1219. getRemoteSearchEntry: function getRemoteSearchEntry() {
  1220. var _this13 = this;
  1221. var searchQuery = this.trigger.searchQuery;
  1222. var entry = this.remoteSearch[searchQuery] || _objectSpread({}, createAsyncOptionsStates(), {
  1223. options: []
  1224. });
  1225. this.$watch(function () {
  1226. return entry.options;
  1227. }, function () {
  1228. if (_this13.trigger.searchQuery === searchQuery) _this13.initialize();
  1229. }, {
  1230. deep: true
  1231. });
  1232. if (searchQuery === '') {
  1233. if (Array.isArray(this.defaultOptions)) {
  1234. entry.options = this.defaultOptions;
  1235. entry.isLoaded = true;
  1236. return entry;
  1237. } else if (this.defaultOptions !== true) {
  1238. entry.isLoaded = true;
  1239. return entry;
  1240. }
  1241. }
  1242. if (!this.remoteSearch[searchQuery]) {
  1243. this.$set(this.remoteSearch, searchQuery, entry);
  1244. }
  1245. return entry;
  1246. },
  1247. shouldExpand: function shouldExpand(node) {
  1248. return this.localSearch.active ? node.isExpandedOnSearch : node.isExpanded;
  1249. },
  1250. shouldOptionBeIncludedInSearchResult: function shouldOptionBeIncludedInSearchResult(node) {
  1251. if (node.isMatched) return true;
  1252. if (node.isBranch && node.hasMatchedDescendants && !this.flattenSearchResults) return true;
  1253. if (!node.isRootNode && node.parentNode.showAllChildrenOnSearch) return true;
  1254. return false;
  1255. },
  1256. shouldShowOptionInMenu: function shouldShowOptionInMenu(node) {
  1257. if (this.localSearch.active && !this.shouldOptionBeIncludedInSearchResult(node)) {
  1258. return false;
  1259. }
  1260. return true;
  1261. },
  1262. getControl: function getControl() {
  1263. return this.$refs.control.$el;
  1264. },
  1265. getMenu: function getMenu() {
  1266. var ref = this.appendToBody ? this.$refs.portal.portalTarget : this;
  1267. var $menu = ref.$refs.menu.$refs.menu;
  1268. return $menu && $menu.nodeName !== '#comment' ? $menu : null;
  1269. },
  1270. setCurrentHighlightedOption: function setCurrentHighlightedOption(node) {
  1271. var _this14 = this;
  1272. var scroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  1273. var prev = this.menu.current;
  1274. if (prev != null && prev in this.forest.nodeMap) {
  1275. this.forest.nodeMap[prev].isHighlighted = false;
  1276. }
  1277. this.menu.current = node.id;
  1278. node.isHighlighted = true;
  1279. if (this.menu.isOpen && scroll) {
  1280. var scrollToOption = function scrollToOption() {
  1281. var $menu = _this14.getMenu();
  1282. var $option = $menu.querySelector(".vue-treeselect__option[data-id=\"".concat(node.id, "\"]"));
  1283. if ($option) scrollIntoView($menu, $option);
  1284. };
  1285. if (this.getMenu()) {
  1286. scrollToOption();
  1287. } else {
  1288. this.$nextTick(scrollToOption);
  1289. }
  1290. }
  1291. },
  1292. resetHighlightedOptionWhenNecessary: function resetHighlightedOptionWhenNecessary() {
  1293. var forceReset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1294. var current = this.menu.current;
  1295. if (forceReset || current == null || !(current in this.forest.nodeMap) || !this.shouldShowOptionInMenu(this.getNode(current))) {
  1296. this.highlightFirstOption();
  1297. }
  1298. },
  1299. highlightFirstOption: function highlightFirstOption() {
  1300. if (!this.hasVisibleOptions) return;
  1301. var first = this.visibleOptionIds[0];
  1302. this.setCurrentHighlightedOption(this.getNode(first));
  1303. },
  1304. highlightPrevOption: function highlightPrevOption() {
  1305. if (!this.hasVisibleOptions) return;
  1306. var prev = this.visibleOptionIds.indexOf(this.menu.current) - 1;
  1307. if (prev === -1) return this.highlightLastOption();
  1308. this.setCurrentHighlightedOption(this.getNode(this.visibleOptionIds[prev]));
  1309. },
  1310. highlightNextOption: function highlightNextOption() {
  1311. if (!this.hasVisibleOptions) return;
  1312. var next = this.visibleOptionIds.indexOf(this.menu.current) + 1;
  1313. if (next === this.visibleOptionIds.length) return this.highlightFirstOption();
  1314. this.setCurrentHighlightedOption(this.getNode(this.visibleOptionIds[next]));
  1315. },
  1316. highlightLastOption: function highlightLastOption() {
  1317. if (!this.hasVisibleOptions) return;
  1318. var last = last_default()(this.visibleOptionIds);
  1319. this.setCurrentHighlightedOption(this.getNode(last));
  1320. },
  1321. resetSearchQuery: function resetSearchQuery() {
  1322. this.trigger.searchQuery = '';
  1323. },
  1324. closeMenu: function closeMenu() {
  1325. if (!this.menu.isOpen || !this.disabled && this.alwaysOpen) return;
  1326. this.saveMenuScrollPosition();
  1327. this.menu.isOpen = false;
  1328. this.toggleClickOutsideEvent(false);
  1329. this.resetSearchQuery();
  1330. this.$emit('close', this.getValue(), this.getInstanceId());
  1331. },
  1332. openMenu: function openMenu() {
  1333. if (this.disabled || this.menu.isOpen) return;
  1334. this.menu.isOpen = true;
  1335. this.$nextTick(this.resetHighlightedOptionWhenNecessary);
  1336. this.$nextTick(this.restoreMenuScrollPosition);
  1337. if (!this.options && !this.async) this.loadRootOptions();
  1338. this.toggleClickOutsideEvent(true);
  1339. this.$emit('open', this.getInstanceId());
  1340. },
  1341. toggleMenu: function toggleMenu() {
  1342. if (this.menu.isOpen) {
  1343. this.closeMenu();
  1344. } else {
  1345. this.openMenu();
  1346. }
  1347. },
  1348. toggleExpanded: function toggleExpanded(node) {
  1349. var nextState;
  1350. if (this.localSearch.active) {
  1351. nextState = node.isExpandedOnSearch = !node.isExpandedOnSearch;
  1352. if (nextState) node.showAllChildrenOnSearch = true;
  1353. } else {
  1354. nextState = node.isExpanded = !node.isExpanded;
  1355. }
  1356. if (nextState && !node.childrenStates.isLoaded) {
  1357. this.loadChildrenOptions(node);
  1358. }
  1359. },
  1360. buildForestState: function buildForestState() {
  1361. var _this15 = this;
  1362. var selectedNodeMap = createMap();
  1363. this.forest.selectedNodeIds.forEach(function (selectedNodeId) {
  1364. selectedNodeMap[selectedNodeId] = true;
  1365. });
  1366. this.forest.selectedNodeMap = selectedNodeMap;
  1367. var checkedStateMap = createMap();
  1368. if (this.multiple) {
  1369. this.traverseAllNodesByIndex(function (node) {
  1370. checkedStateMap[node.id] = UNCHECKED;
  1371. });
  1372. this.selectedNodes.forEach(function (selectedNode) {
  1373. checkedStateMap[selectedNode.id] = CHECKED;
  1374. if (!_this15.flat && !_this15.disableBranchNodes) {
  1375. selectedNode.ancestors.forEach(function (ancestorNode) {
  1376. if (!_this15.isSelected(ancestorNode)) {
  1377. checkedStateMap[ancestorNode.id] = INDETERMINATE;
  1378. }
  1379. });
  1380. }
  1381. });
  1382. }
  1383. this.forest.checkedStateMap = checkedStateMap;
  1384. },
  1385. enhancedNormalizer: function enhancedNormalizer(raw) {
  1386. return _objectSpread({}, raw, {}, this.normalizer(raw, this.getInstanceId()));
  1387. },
  1388. normalize: function normalize(parentNode, nodes, prevNodeMap) {
  1389. var _this16 = this;
  1390. var normalizedOptions = nodes.map(function (node) {
  1391. return [_this16.enhancedNormalizer(node), node];
  1392. }).map(function (_ref, index) {
  1393. var _ref2 = slicedToArray_default()(_ref, 2),
  1394. node = _ref2[0],
  1395. raw = _ref2[1];
  1396. _this16.checkDuplication(node);
  1397. _this16.verifyNodeShape(node);
  1398. var id = node.id,
  1399. label = node.label,
  1400. children = node.children,
  1401. isDefaultExpanded = node.isDefaultExpanded;
  1402. var isRootNode = parentNode === NO_PARENT_NODE;
  1403. var level = isRootNode ? 0 : parentNode.level + 1;
  1404. var isBranch = Array.isArray(children) || children === null;
  1405. var isLeaf = !isBranch;
  1406. var isDisabled = !!node.isDisabled || !_this16.flat && !isRootNode && parentNode.isDisabled;
  1407. var isNew = !!node.isNew;
  1408. var lowerCased = _this16.matchKeys.reduce(function (prev, key) {
  1409. return _objectSpread({}, prev, defineProperty_default()({}, key, stringifyOptionPropValue(node[key]).toLocaleLowerCase()));
  1410. }, {});
  1411. var nestedSearchLabel = isRootNode ? lowerCased.label : parentNode.nestedSearchLabel + ' ' + lowerCased.label;
  1412. var normalized = _this16.$set(_this16.forest.nodeMap, id, createMap());
  1413. _this16.$set(normalized, 'id', id);
  1414. _this16.$set(normalized, 'label', label);
  1415. _this16.$set(normalized, 'level', level);
  1416. _this16.$set(normalized, 'ancestors', isRootNode ? [] : [parentNode].concat(parentNode.ancestors));
  1417. _this16.$set(normalized, 'index', (isRootNode ? [] : parentNode.index).concat(index));
  1418. _this16.$set(normalized, 'parentNode', parentNode);
  1419. _this16.$set(normalized, 'lowerCased', lowerCased);
  1420. _this16.$set(normalized, 'nestedSearchLabel', nestedSearchLabel);
  1421. _this16.$set(normalized, 'isDisabled', isDisabled);
  1422. _this16.$set(normalized, 'isNew', isNew);
  1423. _this16.$set(normalized, 'isMatched', false);
  1424. _this16.$set(normalized, 'isHighlighted', false);
  1425. _this16.$set(normalized, 'isBranch', isBranch);
  1426. _this16.$set(normalized, 'isLeaf', isLeaf);
  1427. _this16.$set(normalized, 'isRootNode', isRootNode);
  1428. _this16.$set(normalized, 'raw', raw);
  1429. if (isBranch) {
  1430. var _this16$$set;
  1431. var isLoaded = Array.isArray(children);
  1432. _this16.$set(normalized, 'childrenStates', _objectSpread({}, createAsyncOptionsStates(), {
  1433. isLoaded: isLoaded
  1434. }));
  1435. _this16.$set(normalized, 'isExpanded', typeof isDefaultExpanded === 'boolean' ? isDefaultExpanded : level < _this16.defaultExpandLevel);
  1436. _this16.$set(normalized, 'hasMatchedDescendants', false);
  1437. _this16.$set(normalized, 'hasDisabledDescendants', false);
  1438. _this16.$set(normalized, 'isExpandedOnSearch', false);
  1439. _this16.$set(normalized, 'showAllChildrenOnSearch', false);
  1440. _this16.$set(normalized, 'count', (_this16$$set = {}, defineProperty_default()(_this16$$set, ALL_CHILDREN, 0), defineProperty_default()(_this16$$set, ALL_DESCENDANTS, 0), defineProperty_default()(_this16$$set, LEAF_CHILDREN, 0), defineProperty_default()(_this16$$set, LEAF_DESCENDANTS, 0), _this16$$set));
  1441. _this16.$set(normalized, 'children', isLoaded ? _this16.normalize(normalized, children, prevNodeMap) : []);
  1442. if (isDefaultExpanded === true) normalized.ancestors.forEach(function (ancestor) {
  1443. ancestor.isExpanded = true;
  1444. });
  1445. if (!isLoaded && typeof _this16.loadOptions !== 'function') {
  1446. warning_warning(function () {
  1447. return false;
  1448. }, function () {
  1449. return 'Unloaded branch node detected. "loadOptions" prop is required to load its children.';
  1450. });
  1451. } else if (!isLoaded && normalized.isExpanded) {
  1452. _this16.loadChildrenOptions(normalized);
  1453. }
  1454. }
  1455. normalized.ancestors.forEach(function (ancestor) {
  1456. return ancestor.count[ALL_DESCENDANTS]++;
  1457. });
  1458. if (isLeaf) normalized.ancestors.forEach(function (ancestor) {
  1459. return ancestor.count[LEAF_DESCENDANTS]++;
  1460. });
  1461. if (!isRootNode) {
  1462. parentNode.count[ALL_CHILDREN] += 1;
  1463. if (isLeaf) parentNode.count[LEAF_CHILDREN] += 1;
  1464. if (isDisabled) parentNode.hasDisabledDescendants = true;
  1465. }
  1466. if (prevNodeMap && prevNodeMap[id]) {
  1467. var prev = prevNodeMap[id];
  1468. normalized.isMatched = prev.isMatched;
  1469. normalized.showAllChildrenOnSearch = prev.showAllChildrenOnSearch;
  1470. normalized.isHighlighted = prev.isHighlighted;
  1471. if (prev.isBranch && normalized.isBranch) {
  1472. normalized.isExpanded = prev.isExpanded;
  1473. normalized.isExpandedOnSearch = prev.isExpandedOnSearch;
  1474. if (prev.childrenStates.isLoaded && !normalized.childrenStates.isLoaded) {
  1475. normalized.isExpanded = false;
  1476. } else {
  1477. normalized.childrenStates = _objectSpread({}, prev.childrenStates);
  1478. }
  1479. }
  1480. }
  1481. return normalized;
  1482. });
  1483. if (this.branchNodesFirst) {
  1484. var branchNodes = normalizedOptions.filter(function (option) {
  1485. return option.isBranch;
  1486. });
  1487. var leafNodes = normalizedOptions.filter(function (option) {
  1488. return option.isLeaf;
  1489. });
  1490. normalizedOptions = branchNodes.concat(leafNodes);
  1491. }
  1492. return normalizedOptions;
  1493. },
  1494. loadRootOptions: function loadRootOptions() {
  1495. var _this17 = this;
  1496. this.callLoadOptionsProp({
  1497. action: LOAD_ROOT_OPTIONS,
  1498. isPending: function isPending() {
  1499. return _this17.rootOptionsStates.isLoading;
  1500. },
  1501. start: function start() {
  1502. _this17.rootOptionsStates.isLoading = true;
  1503. _this17.rootOptionsStates.loadingError = '';
  1504. },
  1505. succeed: function succeed() {
  1506. _this17.rootOptionsStates.isLoaded = true;
  1507. _this17.$nextTick(function () {
  1508. _this17.resetHighlightedOptionWhenNecessary(true);
  1509. });
  1510. },
  1511. fail: function fail(err) {
  1512. _this17.rootOptionsStates.loadingError = getErrorMessage(err);
  1513. },
  1514. end: function end() {
  1515. _this17.rootOptionsStates.isLoading = false;
  1516. }
  1517. });
  1518. },
  1519. loadChildrenOptions: function loadChildrenOptions(parentNode) {
  1520. var _this18 = this;
  1521. var id = parentNode.id,
  1522. raw = parentNode.raw;
  1523. this.callLoadOptionsProp({
  1524. action: LOAD_CHILDREN_OPTIONS,
  1525. args: {
  1526. parentNode: raw
  1527. },
  1528. isPending: function isPending() {
  1529. return _this18.getNode(id).childrenStates.isLoading;
  1530. },
  1531. start: function start() {
  1532. _this18.getNode(id).childrenStates.isLoading = true;
  1533. _this18.getNode(id).childrenStates.loadingError = '';
  1534. },
  1535. succeed: function succeed() {
  1536. _this18.getNode(id).childrenStates.isLoaded = true;
  1537. },
  1538. fail: function fail(err) {
  1539. _this18.getNode(id).childrenStates.loadingError = getErrorMessage(err);
  1540. },
  1541. end: function end() {
  1542. _this18.getNode(id).childrenStates.isLoading = false;
  1543. }
  1544. });
  1545. },
  1546. callLoadOptionsProp: function callLoadOptionsProp(_ref3) {
  1547. var action = _ref3.action,
  1548. args = _ref3.args,
  1549. isPending = _ref3.isPending,
  1550. start = _ref3.start,
  1551. succeed = _ref3.succeed,
  1552. fail = _ref3.fail,
  1553. end = _ref3.end;
  1554. if (!this.loadOptions || isPending()) {
  1555. return;
  1556. }
  1557. start();
  1558. var callback = once_default()(function (err, result) {
  1559. if (err) {
  1560. fail(err);
  1561. } else {
  1562. succeed(result);
  1563. }
  1564. end();
  1565. });
  1566. var result = this.loadOptions(_objectSpread({
  1567. id: this.getInstanceId(),
  1568. instanceId: this.getInstanceId(),
  1569. action: action
  1570. }, args, {
  1571. callback: callback
  1572. }));
  1573. if (external_is_promise_default()(result)) {
  1574. result.then(function () {
  1575. callback();
  1576. }, function (err) {
  1577. callback(err);
  1578. }).catch(function (err) {
  1579. console.error(err);
  1580. });
  1581. }
  1582. },
  1583. checkDuplication: function checkDuplication(node) {
  1584. var _this19 = this;
  1585. warning_warning(function () {
  1586. return !(node.id in _this19.forest.nodeMap && !_this19.forest.nodeMap[node.id].isFallbackNode);
  1587. }, function () {
  1588. return "Detected duplicate presence of node id ".concat(JSON.stringify(node.id), ". ") + "Their labels are \"".concat(_this19.forest.nodeMap[node.id].label, "\" and \"").concat(node.label, "\" respectively.");
  1589. });
  1590. },
  1591. verifyNodeShape: function verifyNodeShape(node) {
  1592. warning_warning(function () {
  1593. return !(node.children === undefined && node.isBranch === true);
  1594. }, function () {
  1595. return 'Are you meant to declare an unloaded branch node? ' + '`isBranch: true` is no longer supported, please use `children: null` instead.';
  1596. });
  1597. },
  1598. select: function select(node) {
  1599. if (this.disabled || node.isDisabled) {
  1600. return;
  1601. }
  1602. if (this.single) {
  1603. this.clear();
  1604. }
  1605. var nextState = this.multiple && !this.flat ? this.forest.checkedStateMap[node.id] === UNCHECKED : !this.isSelected(node);
  1606. if (nextState) {
  1607. this._selectNode(node);
  1608. } else {
  1609. this._deselectNode(node);
  1610. }
  1611. this.buildForestState();
  1612. if (nextState) {
  1613. this.$emit('select', node.raw, this.getInstanceId());
  1614. } else {
  1615. this.$emit('deselect', node.raw, this.getInstanceId());
  1616. }
  1617. if (this.localSearch.active && nextState && (this.single || this.clearOnSelect)) {
  1618. this.resetSearchQuery();
  1619. }
  1620. if (this.single && this.closeOnSelect) {
  1621. this.closeMenu();
  1622. if (this.searchable) {
  1623. this._blurOnSelect = true;
  1624. }
  1625. }
  1626. },
  1627. clear: function clear() {
  1628. var _this20 = this;
  1629. if (this.hasValue) {
  1630. if (this.single || this.allowClearingDisabled) {
  1631. this.forest.selectedNodeIds = [];
  1632. } else {
  1633. this.forest.selectedNodeIds = this.forest.selectedNodeIds.filter(function (nodeId) {
  1634. return _this20.getNode(nodeId).isDisabled;
  1635. });
  1636. }
  1637. this.buildForestState();
  1638. }
  1639. },
  1640. _selectNode: function _selectNode(node) {
  1641. var _this21 = this;
  1642. if (this.single || this.disableBranchNodes) {
  1643. return this.addValue(node);
  1644. }
  1645. if (this.flat) {
  1646. this.addValue(node);
  1647. if (this.autoSelectAncestors) {
  1648. node.ancestors.forEach(function (ancestor) {
  1649. if (!_this21.isSelected(ancestor) && !ancestor.isDisabled) _this21.addValue(ancestor);
  1650. });
  1651. } else if (this.autoSelectDescendants) {
  1652. this.traverseDescendantsBFS(node, function (descendant) {
  1653. if (!_this21.isSelected(descendant) && !descendant.isDisabled) _this21.addValue(descendant);
  1654. });
  1655. }
  1656. return;
  1657. }
  1658. var isFullyChecked = node.isLeaf || !node.hasDisabledDescendants || this.allowSelectingDisabledDescendants;
  1659. if (isFullyChecked) {
  1660. this.addValue(node);
  1661. }
  1662. if (node.isBranch) {
  1663. this.traverseDescendantsBFS(node, function (descendant) {
  1664. if (!descendant.isDisabled || _this21.allowSelectingDisabledDescendants) {
  1665. _this21.addValue(descendant);
  1666. }
  1667. });
  1668. }
  1669. if (isFullyChecked) {
  1670. var curr = node;
  1671. while ((curr = curr.parentNode) !== NO_PARENT_NODE) {
  1672. if (curr.children.every(this.isSelected)) this.addValue(curr);else break;
  1673. }
  1674. }
  1675. },
  1676. _deselectNode: function _deselectNode(node) {
  1677. var _this22 = this;
  1678. if (this.disableBranchNodes) {
  1679. return this.removeValue(node);
  1680. }
  1681. if (this.flat) {
  1682. this.removeValue(node);
  1683. if (this.autoDeselectAncestors) {
  1684. node.ancestors.forEach(function (ancestor) {
  1685. if (_this22.isSelected(ancestor) && !ancestor.isDisabled) _this22.removeValue(ancestor);
  1686. });
  1687. } else if (this.autoDeselectDescendants) {
  1688. this.traverseDescendantsBFS(node, function (descendant) {
  1689. if (_this22.isSelected(descendant) && !descendant.isDisabled) _this22.removeValue(descendant);
  1690. });
  1691. }
  1692. return;
  1693. }
  1694. var hasUncheckedSomeDescendants = false;
  1695. if (node.isBranch) {
  1696. this.traverseDescendantsDFS(node, function (descendant) {
  1697. if (!descendant.isDisabled || _this22.allowSelectingDisabledDescendants) {
  1698. _this22.removeValue(descendant);
  1699. hasUncheckedSomeDescendants = true;
  1700. }
  1701. });
  1702. }
  1703. if (node.isLeaf || hasUncheckedSomeDescendants || node.children.length === 0) {
  1704. this.removeValue(node);
  1705. var curr = node;
  1706. while ((curr = curr.parentNode) !== NO_PARENT_NODE) {
  1707. if (this.isSelected(curr)) this.removeValue(curr);else break;
  1708. }
  1709. }
  1710. },
  1711. addValue: function addValue(node) {
  1712. this.forest.selectedNodeIds.push(node.id);
  1713. this.forest.selectedNodeMap[node.id] = true;
  1714. },
  1715. removeValue: function removeValue(node) {
  1716. removeFromArray(this.forest.selectedNodeIds, node.id);
  1717. delete this.forest.selectedNodeMap[node.id];
  1718. },
  1719. removeLastValue: function removeLastValue() {
  1720. if (!this.hasValue) return;
  1721. if (this.single) return this.clear();
  1722. var lastValue = last_default()(this.internalValue);
  1723. var lastSelectedNode = this.getNode(lastValue);
  1724. this.select(lastSelectedNode);
  1725. },
  1726. saveMenuScrollPosition: function saveMenuScrollPosition() {
  1727. var $menu = this.getMenu();
  1728. if ($menu) this.menu.lastScrollPosition = $menu.scrollTop;
  1729. },
  1730. restoreMenuScrollPosition: function restoreMenuScrollPosition() {
  1731. var $menu = this.getMenu();
  1732. if ($menu) $menu.scrollTop = this.menu.lastScrollPosition;
  1733. }
  1734. },
  1735. created: function created() {
  1736. this.verifyProps();
  1737. this.resetFlags();
  1738. },
  1739. mounted: function mounted() {
  1740. if (this.autoFocus) this.focusInput();
  1741. if (!this.options && !this.async && this.autoLoadRootOptions) this.loadRootOptions();
  1742. if (this.alwaysOpen) this.openMenu();
  1743. if (this.async && this.defaultOptions) this.handleRemoteSearch();
  1744. },
  1745. destroyed: function destroyed() {
  1746. this.toggleClickOutsideEvent(false);
  1747. }
  1748. });
  1749. // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/HiddenFields.vue?vue&type=script&lang=js&
  1750. function stringifyValue(value) {
  1751. if (typeof value === 'string') return value;
  1752. if (value != null && !isNaN_isNaN(value)) return JSON.stringify(value);
  1753. return '';
  1754. }
  1755. /* harmony default export */ var HiddenFieldsvue_type_script_lang_js_ = ({
  1756. name: 'vue-treeselect--hidden-fields',
  1757. inject: ['instance'],
  1758. functional: true,
  1759. render: function render(_, context) {
  1760. var h = arguments[0];
  1761. var instance = context.injections.instance;
  1762. if (!instance.name || instance.disabled || !instance.hasValue) return null;
  1763. var stringifiedValues = instance.internalValue.map(stringifyValue);
  1764. if (instance.multiple && instance.joinValues) stringifiedValues = [stringifiedValues.join(instance.delimiter)];
  1765. return stringifiedValues.map(function (stringifiedValue, i) {
  1766. return h("input", {
  1767. attrs: {
  1768. type: "hidden",
  1769. name: instance.name
  1770. },
  1771. domProps: {
  1772. "value": stringifiedValue
  1773. },
  1774. key: 'hidden-field-' + i
  1775. });
  1776. });
  1777. }
  1778. });
  1779. // CONCATENATED MODULE: ./src/components/HiddenFields.vue?vue&type=script&lang=js&
  1780. /* harmony default export */ var components_HiddenFieldsvue_type_script_lang_js_ = (HiddenFieldsvue_type_script_lang_js_);
  1781. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  1782. /* globals __VUE_SSR_CONTEXT__ */
  1783. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  1784. // This module is a runtime utility for cleaner component module output and will
  1785. // be included in the final webpack user bundle.
  1786. function normalizeComponent (
  1787. scriptExports,
  1788. render,
  1789. staticRenderFns,
  1790. functionalTemplate,
  1791. injectStyles,
  1792. scopeId,
  1793. moduleIdentifier, /* server only */
  1794. shadowMode /* vue-cli only */
  1795. ) {
  1796. // Vue.extend constructor export interop
  1797. var options = typeof scriptExports === 'function'
  1798. ? scriptExports.options
  1799. : scriptExports
  1800. // render functions
  1801. if (render) {
  1802. options.render = render
  1803. options.staticRenderFns = staticRenderFns
  1804. options._compiled = true
  1805. }
  1806. // functional template
  1807. if (functionalTemplate) {
  1808. options.functional = true
  1809. }
  1810. // scopedId
  1811. if (scopeId) {
  1812. options._scopeId = 'data-v-' + scopeId
  1813. }
  1814. var hook
  1815. if (moduleIdentifier) { // server build
  1816. hook = function (context) {
  1817. // 2.3 injection
  1818. context =
  1819. context || // cached call
  1820. (this.$vnode && this.$vnode.ssrContext) || // stateful
  1821. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  1822. // 2.2 with runInNewContext: true
  1823. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  1824. context = __VUE_SSR_CONTEXT__
  1825. }
  1826. // inject component styles
  1827. if (injectStyles) {
  1828. injectStyles.call(this, context)
  1829. }
  1830. // register component module identifier for async chunk inferrence
  1831. if (context && context._registeredComponents) {
  1832. context._registeredComponents.add(moduleIdentifier)
  1833. }
  1834. }
  1835. // used by ssr in case component is cached and beforeCreate
  1836. // never gets called
  1837. options._ssrRegister = hook
  1838. } else if (injectStyles) {
  1839. hook = shadowMode
  1840. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  1841. : injectStyles
  1842. }
  1843. if (hook) {
  1844. if (options.functional) {
  1845. // for template-only hot-reload because in that case the render fn doesn't
  1846. // go through the normalizer
  1847. options._injectStyles = hook
  1848. // register for functioal component in vue file
  1849. var originalRender = options.render
  1850. options.render = function renderWithStyleInjection (h, context) {
  1851. hook.call(context)
  1852. return originalRender(h, context)
  1853. }
  1854. } else {
  1855. // inject component registration as beforeCreate hook
  1856. var existing = options.beforeCreate
  1857. options.beforeCreate = existing
  1858. ? [].concat(existing, hook)
  1859. : [hook]
  1860. }
  1861. }
  1862. return {
  1863. exports: scriptExports,
  1864. options: options
  1865. }
  1866. }
  1867. // CONCATENATED MODULE: ./src/components/HiddenFields.vue
  1868. var HiddenFields_render, staticRenderFns
  1869. /* normalize component */
  1870. var component = normalizeComponent(
  1871. components_HiddenFieldsvue_type_script_lang_js_,
  1872. HiddenFields_render,
  1873. staticRenderFns,
  1874. false,
  1875. null,
  1876. null,
  1877. null
  1878. )
  1879. /* hot reload */
  1880. if (false) { var api; }
  1881. component.options.__file = "src/components/HiddenFields.vue"
  1882. /* harmony default export */ var HiddenFields = (component.exports);
  1883. // EXTERNAL MODULE: external "babel-helper-vue-jsx-merge-props"
  1884. var external_babel_helper_vue_jsx_merge_props_ = __webpack_require__(13);
  1885. var external_babel_helper_vue_jsx_merge_props_default = /*#__PURE__*/__webpack_require__.n(external_babel_helper_vue_jsx_merge_props_);
  1886. // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Input.vue?vue&type=script&lang=js&
  1887. var keysThatRequireMenuBeingOpen = [KEY_CODES.ENTER, KEY_CODES.END, KEY_CODES.HOME, KEY_CODES.ARROW_LEFT, KEY_CODES.ARROW_UP, KEY_CODES.ARROW_RIGHT, KEY_CODES.ARROW_DOWN];
  1888. /* harmony default export */ var Inputvue_type_script_lang_js_ = ({
  1889. name: 'vue-treeselect--input',
  1890. inject: ['instance'],
  1891. data: function data() {
  1892. return {
  1893. inputWidth: MIN_INPUT_WIDTH,
  1894. value: ''
  1895. };
  1896. },
  1897. computed: {
  1898. needAutoSize: function needAutoSize() {
  1899. var instance = this.instance;
  1900. return instance.searchable && !instance.disabled && instance.multiple;
  1901. },
  1902. inputStyle: function inputStyle() {
  1903. return {
  1904. width: this.needAutoSize ? "".concat(this.inputWidth, "px") : null
  1905. };
  1906. }
  1907. },
  1908. watch: {
  1909. 'instance.trigger.searchQuery': function instanceTriggerSearchQuery(newValue) {
  1910. this.value = newValue;
  1911. },
  1912. value: function value() {
  1913. if (this.needAutoSize) this.$nextTick(this.updateInputWidth);
  1914. }
  1915. },
  1916. created: function created() {
  1917. this.debouncedCallback = debounce_default()(this.updateSearchQuery, INPUT_DEBOUNCE_DELAY, {
  1918. leading: true,
  1919. trailing: true
  1920. });
  1921. },
  1922. methods: {
  1923. clear: function clear() {
  1924. this.onInput({
  1925. target: {
  1926. value: ''
  1927. }
  1928. });
  1929. },
  1930. focus: function focus() {
  1931. var instance = this.instance;
  1932. if (!instance.disabled) {
  1933. this.$refs.input && this.$refs.input.focus();
  1934. }
  1935. },
  1936. blur: function blur() {
  1937. this.$refs.input && this.$refs.input.blur();
  1938. },
  1939. onFocus: function onFocus() {
  1940. var instance = this.instance;
  1941. instance.trigger.isFocused = true;
  1942. if (instance.openOnFocus) instance.openMenu();
  1943. },
  1944. onBlur: function onBlur() {
  1945. var instance = this.instance;
  1946. var menu = instance.getMenu();
  1947. if (menu && document.activeElement === menu) {
  1948. return this.focus();
  1949. }
  1950. instance.trigger.isFocused = false;
  1951. instance.closeMenu();
  1952. },
  1953. onInput: function onInput(evt) {
  1954. var value = evt.target.value;
  1955. this.value = value;
  1956. if (value) {
  1957. this.debouncedCallback();
  1958. } else {
  1959. this.debouncedCallback.cancel();
  1960. this.updateSearchQuery();
  1961. }
  1962. },
  1963. onKeyDown: function onKeyDown(evt) {
  1964. var instance = this.instance;
  1965. var key = 'which' in evt ? evt.which : evt.keyCode;
  1966. if (evt.ctrlKey || evt.shiftKey || evt.altKey || evt.metaKey) return;
  1967. if (!instance.menu.isOpen && includes(keysThatRequireMenuBeingOpen, key)) {
  1968. evt.preventDefault();
  1969. return instance.openMenu();
  1970. }
  1971. switch (key) {
  1972. case KEY_CODES.BACKSPACE:
  1973. {
  1974. if (instance.backspaceRemoves && !this.value.length) {
  1975. instance.removeLastValue();
  1976. }
  1977. break;
  1978. }
  1979. case KEY_CODES.ENTER:
  1980. {
  1981. evt.preventDefault();
  1982. if (instance.menu.current === null) return;
  1983. var current = instance.getNode(instance.menu.current);
  1984. if (current.isBranch && instance.disableBranchNodes) return;
  1985. instance.select(current);
  1986. break;
  1987. }
  1988. case KEY_CODES.ESCAPE:
  1989. {
  1990. if (this.value.length) {
  1991. this.clear();
  1992. } else if (instance.menu.isOpen) {
  1993. instance.closeMenu();
  1994. }
  1995. break;
  1996. }
  1997. case KEY_CODES.END:
  1998. {
  1999. evt.preventDefault();
  2000. instance.highlightLastOption();
  2001. break;
  2002. }
  2003. case KEY_CODES.HOME:
  2004. {
  2005. evt.preventDefault();
  2006. instance.highlightFirstOption();
  2007. break;
  2008. }
  2009. case KEY_CODES.ARROW_LEFT:
  2010. {
  2011. var _current = instance.getNode(instance.menu.current);
  2012. if (_current.isBranch && instance.shouldExpand(_current)) {
  2013. evt.preventDefault();
  2014. instance.toggleExpanded(_current);
  2015. } else if (!_current.isRootNode && (_current.isLeaf || _current.isBranch && !instance.shouldExpand(_current))) {
  2016. evt.preventDefault();
  2017. instance.setCurrentHighlightedOption(_current.parentNode);
  2018. }
  2019. break;
  2020. }
  2021. case KEY_CODES.ARROW_UP:
  2022. {
  2023. evt.preventDefault();
  2024. instance.highlightPrevOption();
  2025. break;
  2026. }
  2027. case KEY_CODES.ARROW_RIGHT:
  2028. {
  2029. var _current2 = instance.getNode(instance.menu.current);
  2030. if (_current2.isBranch && !instance.shouldExpand(_current2)) {
  2031. evt.preventDefault();
  2032. instance.toggleExpanded(_current2);
  2033. }
  2034. break;
  2035. }
  2036. case KEY_CODES.ARROW_DOWN:
  2037. {
  2038. evt.preventDefault();
  2039. instance.highlightNextOption();
  2040. break;
  2041. }
  2042. case KEY_CODES.DELETE:
  2043. {
  2044. if (instance.deleteRemoves && !this.value.length) {
  2045. instance.removeLastValue();
  2046. }
  2047. break;
  2048. }
  2049. default:
  2050. {
  2051. instance.openMenu();
  2052. }
  2053. }
  2054. },
  2055. onMouseDown: function onMouseDown(evt) {
  2056. if (this.value.length) {
  2057. evt.stopPropagation();
  2058. }
  2059. },
  2060. renderInputContainer: function renderInputContainer() {
  2061. var h = this.$createElement;
  2062. var instance = this.instance;
  2063. var props = {};
  2064. var children = [];
  2065. if (instance.searchable && !instance.disabled) {
  2066. children.push(this.renderInput());
  2067. if (this.needAutoSize) children.push(this.renderSizer());
  2068. }
  2069. if (!instance.searchable) {
  2070. deepExtend(props, {
  2071. on: {
  2072. focus: this.onFocus,
  2073. blur: this.onBlur,
  2074. keydown: this.onKeyDown
  2075. },
  2076. ref: 'input'
  2077. });
  2078. }
  2079. if (!instance.searchable && !instance.disabled) {
  2080. deepExtend(props, {
  2081. attrs: {
  2082. tabIndex: instance.tabIndex
  2083. }
  2084. });
  2085. }
  2086. return h("div", external_babel_helper_vue_jsx_merge_props_default()([{
  2087. "class": "vue-treeselect__input-container"
  2088. }, props]), [children]);
  2089. },
  2090. renderInput: function renderInput() {
  2091. var h = this.$createElement;
  2092. var instance = this.instance;
  2093. return h("input", {
  2094. ref: "input",
  2095. "class": "vue-treeselect__input",
  2096. attrs: {
  2097. type: "text",
  2098. autocomplete: "off",
  2099. tabIndex: instance.tabIndex,
  2100. required: instance.required && !instance.hasValue
  2101. },
  2102. domProps: {
  2103. "value": this.value
  2104. },
  2105. style: this.inputStyle,
  2106. on: {
  2107. "focus": this.onFocus,
  2108. "input": this.onInput,
  2109. "blur": this.onBlur,
  2110. "keydown": this.onKeyDown,
  2111. "mousedown": this.onMouseDown
  2112. }
  2113. });
  2114. },
  2115. renderSizer: function renderSizer() {
  2116. var h = this.$createElement;
  2117. return h("div", {
  2118. ref: "sizer",
  2119. "class": "vue-treeselect__sizer"
  2120. }, [this.value]);
  2121. },
  2122. updateInputWidth: function updateInputWidth() {
  2123. this.inputWidth = Math.max(MIN_INPUT_WIDTH, this.$refs.sizer.scrollWidth + 15);
  2124. },
  2125. updateSearchQuery: function updateSearchQuery() {
  2126. var instance = this.instance;
  2127. instance.trigger.searchQuery = this.value;
  2128. }
  2129. },
  2130. render: function render() {
  2131. return this.renderInputContainer();
  2132. }
  2133. });
  2134. // CONCATENATED MODULE: ./src/components/Input.vue?vue&type=script&lang=js&
  2135. /* harmony default export */ var components_Inputvue_type_script_lang_js_ = (Inputvue_type_script_lang_js_);
  2136. // CONCATENATED MODULE: ./src/components/Input.vue
  2137. var Input_render, Input_staticRenderFns
  2138. /* normalize component */
  2139. var Input_component = normalizeComponent(
  2140. components_Inputvue_type_script_lang_js_,
  2141. Input_render,
  2142. Input_staticRenderFns,
  2143. false,
  2144. null,
  2145. null,
  2146. null
  2147. )
  2148. /* hot reload */
  2149. if (false) { var Input_api; }
  2150. Input_component.options.__file = "src/components/Input.vue"
  2151. /* harmony default export */ var Input = (Input_component.exports);
  2152. // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Placeholder.vue?vue&type=script&lang=js&
  2153. /* harmony default export */ var Placeholdervue_type_script_lang_js_ = ({
  2154. name: 'vue-treeselect--placeholder',
  2155. inject: ['instance'],
  2156. render: function render() {
  2157. var h = arguments[0];
  2158. var instance = this.instance;
  2159. var placeholderClass = {
  2160. 'vue-treeselect__placeholder': true,
  2161. 'vue-treeselect-helper-zoom-effect-off': true,
  2162. 'vue-treeselect-helper-hide': instance.hasValue || instance.trigger.searchQuery
  2163. };
  2164. return h("div", {
  2165. "class": placeholderClass
  2166. }, [instance.placeholder]);
  2167. }
  2168. });
  2169. // CONCATENATED MODULE: ./src/components/Placeholder.vue?vue&type=script&lang=js&
  2170. /* harmony default export */ var components_Placeholdervue_type_script_lang_js_ = (Placeholdervue_type_script_lang_js_);
  2171. // CONCATENATED MODULE: ./src/components/Placeholder.vue
  2172. var Placeholder_render, Placeholder_staticRenderFns
  2173. /* normalize component */
  2174. var Placeholder_component = normalizeComponent(
  2175. components_Placeholdervue_type_script_lang_js_,
  2176. Placeholder_render,
  2177. Placeholder_staticRenderFns,
  2178. false,
  2179. null,
  2180. null,
  2181. null
  2182. )
  2183. /* hot reload */
  2184. if (false) { var Placeholder_api; }
  2185. Placeholder_component.options.__file = "src/components/Placeholder.vue"
  2186. /* harmony default export */ var Placeholder = (Placeholder_component.exports);
  2187. // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/SingleValue.vue?vue&type=script&lang=js&
  2188. /* harmony default export */ var SingleValuevue_type_script_lang_js_ = ({
  2189. name: 'vue-treeselect--single-value',
  2190. inject: ['instance'],
  2191. methods: {
  2192. renderSingleValueLabel: function renderSingleValueLabel() {
  2193. var instance = this.instance;
  2194. var node = instance.selectedNodes[0];
  2195. var customValueLabelRenderer = instance.$scopedSlots['value-label'];
  2196. return customValueLabelRenderer ? customValueLabelRenderer({
  2197. node: node
  2198. }) : node.label;
  2199. }
  2200. },
  2201. render: function render() {
  2202. var h = arguments[0];
  2203. var instance = this.instance,
  2204. renderValueContainer = this.$parent.renderValueContainer;
  2205. var shouldShowValue = instance.hasValue && !instance.trigger.searchQuery;
  2206. return renderValueContainer([shouldShowValue && h("div", {
  2207. "class": "vue-treeselect__single-value"
  2208. }, [this.renderSingleValueLabel()]), h(Placeholder), h(Input, {
  2209. ref: "input"
  2210. })]);
  2211. }
  2212. });
  2213. // CONCATENATED MODULE: ./src/components/SingleValue.vue?vue&type=script&lang=js&
  2214. /* harmony default export */ var components_SingleValuevue_type_script_lang_js_ = (SingleValuevue_type_script_lang_js_);
  2215. // CONCATENATED MODULE: ./src/components/SingleValue.vue
  2216. var SingleValue_render, SingleValue_staticRenderFns
  2217. /* normalize component */
  2218. var SingleValue_component = normalizeComponent(
  2219. components_SingleValuevue_type_script_lang_js_,
  2220. SingleValue_render,
  2221. SingleValue_staticRenderFns,
  2222. false,
  2223. null,
  2224. null,
  2225. null
  2226. )
  2227. /* hot reload */
  2228. if (false) { var SingleValue_api; }
  2229. SingleValue_component.options.__file = "src/components/SingleValue.vue"
  2230. /* harmony default export */ var SingleValue = (SingleValue_component.exports);
  2231. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js!./node_modules/vue-loader/lib??vue-loader-options!./src/components/icons/Delete.vue?vue&type=template&id=364b6320&
  2232. var Deletevue_type_template_id_364b6320_render = function() {
  2233. var _vm = this
  2234. var _h = _vm.$createElement
  2235. var _c = _vm._self._c || _h
  2236. return _c(
  2237. "svg",
  2238. {
  2239. attrs: {
  2240. xmlns: "http://www.w3.org/2000/svg",
  2241. viewBox: "0 0 348.333 348.333"
  2242. }
  2243. },
  2244. [
  2245. _c("path", {
  2246. attrs: {
  2247. d:
  2248. "M336.559 68.611L231.016 174.165l105.543 105.549c15.699 15.705 15.699 41.145 0 56.85-7.844 7.844-18.128 11.769-28.407 11.769-10.296 0-20.581-3.919-28.419-11.769L174.167 231.003 68.609 336.563c-7.843 7.844-18.128 11.769-28.416 11.769-10.285 0-20.563-3.919-28.413-11.769-15.699-15.698-15.699-41.139 0-56.85l105.54-105.549L11.774 68.611c-15.699-15.699-15.699-41.145 0-56.844 15.696-15.687 41.127-15.687 56.829 0l105.563 105.554L279.721 11.767c15.705-15.687 41.139-15.687 56.832 0 15.705 15.699 15.705 41.145.006 56.844z"
  2249. }
  2250. })
  2251. ]
  2252. )
  2253. }
  2254. var Deletevue_type_template_id_364b6320_staticRenderFns = []
  2255. Deletevue_type_template_id_364b6320_render._withStripped = true
  2256. // CONCATENATED MODULE: ./src/components/icons/Delete.vue?vue&type=template&id=364b6320&
  2257. // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/icons/Delete.vue?vue&type=script&lang=js&
  2258. /* harmony default export */ var Deletevue_type_script_lang_js_ = ({
  2259. name: 'vue-treeselect--x'
  2260. });
  2261. // CONCATENATED MODULE: ./src/components/icons/Delete.vue?vue&type=script&lang=js&
  2262. /* harmony default export */ var icons_Deletevue_type_script_lang_js_ = (Deletevue_type_script_lang_js_);
  2263. // CONCATENATED MODULE: ./src/components/icons/Delete.vue
  2264. /* normalize component */
  2265. var Delete_component = normalizeComponent(
  2266. icons_Deletevue_type_script_lang_js_,
  2267. Deletevue_type_template_id_364b6320_render,
  2268. Deletevue_type_template_id_364b6320_staticRenderFns,
  2269. false,
  2270. null,
  2271. null,
  2272. null
  2273. )
  2274. /* hot reload */
  2275. if (false) { var Delete_api; }
  2276. Delete_component.options.__file = "src/components/icons/Delete.vue"
  2277. /* harmony default export */ var Delete = (Delete_component.exports);
  2278. // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/MultiValueItem.vue?vue&type=script&lang=js&
  2279. /* harmony default export */ var MultiValueItemvue_type_script_lang_js_ = ({
  2280. name: 'vue-treeselect--multi-value-item',
  2281. inject: ['instance'],
  2282. props: {
  2283. node: {
  2284. type: Object,
  2285. required: true
  2286. }
  2287. },
  2288. methods: {
  2289. handleMouseDown: onLeftClick(function handleMouseDown() {
  2290. var instance = this.instance,
  2291. node = this.node;
  2292. instance.select(node);
  2293. })
  2294. },
  2295. render: function render() {
  2296. var h = arguments[0];
  2297. var instance = this.instance,
  2298. node = this.node;
  2299. var itemClass = {
  2300. 'vue-treeselect__multi-value-item': true,
  2301. 'vue-treeselect__multi-value-item-disabled': node.isDisabled,
  2302. 'vue-treeselect__multi-value-item-new': node.isNew
  2303. };
  2304. var customValueLabelRenderer = instance.$scopedSlots['value-label'];
  2305. var labelRenderer = customValueLabelRenderer ? customValueLabelRenderer({
  2306. node: node
  2307. }) : node.label;
  2308. return h("div", {
  2309. "class": "vue-treeselect__multi-value-item-container"
  2310. }, [h("div", {
  2311. "class": itemClass,
  2312. on: {
  2313. "mousedown": this.handleMouseDown
  2314. }
  2315. }, [h("span", {
  2316. "class": "vue-treeselect__multi-value-label"
  2317. }, [labelRenderer]), h("span", {
  2318. "class": "vue-treeselect__icon vue-treeselect__value-remove"
  2319. }, [h(Delete)])])]);
  2320. }
  2321. });
  2322. // CONCATENATED MODULE: ./src/components/MultiValueItem.vue?vue&type=script&lang=js&
  2323. /* harmony default export */ var components_MultiValueItemvue_type_script_lang_js_ = (MultiValueItemvue_type_script_lang_js_);
  2324. // CONCATENATED MODULE: ./src/components/MultiValueItem.vue
  2325. var MultiValueItem_render, MultiValueItem_staticRenderFns
  2326. /* normalize component */
  2327. var MultiValueItem_component = normalizeComponent(
  2328. components_MultiValueItemvue_type_script_lang_js_,
  2329. MultiValueItem_render,
  2330. MultiValueItem_staticRenderFns,
  2331. false,
  2332. null,
  2333. null,
  2334. null
  2335. )
  2336. /* hot reload */
  2337. if (false) { var MultiValueItem_api; }
  2338. MultiValueItem_component.options.__file = "src/components/MultiValueItem.vue"
  2339. /* harmony default export */ var MultiValueItem = (MultiValueItem_component.exports);
  2340. // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/MultiValue.vue?vue&type=script&lang=js&
  2341. /* harmony default export */ var MultiValuevue_type_script_lang_js_ = ({
  2342. name: 'vue-treeselect--multi-value',
  2343. inject: ['instance'],
  2344. methods: {
  2345. renderMultiValueItems: function renderMultiValueItems() {
  2346. var h = this.$createElement;
  2347. var instance = this.instance;
  2348. return instance.internalValue.slice(0, instance.limit).map(instance.getNode).map(function (node) {
  2349. return h(MultiValueItem, {
  2350. key: "multi-value-item-".concat(node.id),
  2351. attrs: {
  2352. node: node
  2353. }
  2354. });
  2355. });
  2356. },
  2357. renderExceedLimitTip: function renderExceedLimitTip() {
  2358. var h = this.$createElement;
  2359. var instance = this.instance;
  2360. var count = instance.internalValue.length - instance.limit;
  2361. if (count <= 0) return null;
  2362. return h("div", {
  2363. "class": "vue-treeselect__limit-tip vue-treeselect-helper-zoom-effect-off",
  2364. key: "exceed-limit-tip"
  2365. }, [h("span", {
  2366. "class": "vue-treeselect__limit-tip-text"
  2367. }, [instance.limitText(count)])]);
  2368. }
  2369. },
  2370. render: function render() {
  2371. var h = arguments[0];
  2372. var renderValueContainer = this.$parent.renderValueContainer;
  2373. var transitionGroupProps = {
  2374. props: {
  2375. tag: 'div',
  2376. name: 'vue-treeselect__multi-value-item--transition',
  2377. appear: true
  2378. }
  2379. };
  2380. return renderValueContainer(h("transition-group", external_babel_helper_vue_jsx_merge_props_default()([{
  2381. "class": "vue-treeselect__multi-value"
  2382. }, transitionGroupProps]), [this.renderMultiValueItems(), this.renderExceedLimitTip(), h(Placeholder, {
  2383. key: "placeholder"
  2384. }), h(Input, {
  2385. ref: "input",
  2386. key: "input"
  2387. })]));
  2388. }
  2389. });
  2390. // CONCATENATED MODULE: ./src/components/MultiValue.vue?vue&type=script&lang=js&
  2391. /* harmony default export */ var components_MultiValuevue_type_script_lang_js_ = (MultiValuevue_type_script_lang_js_);
  2392. // CONCATENATED MODULE: ./src/components/MultiValue.vue
  2393. var MultiValue_render, MultiValue_staticRenderFns
  2394. /* normalize component */
  2395. var MultiValue_component = normalizeComponent(
  2396. components_MultiValuevue_type_script_lang_js_,
  2397. MultiValue_render,
  2398. MultiValue_staticRenderFns,
  2399. false,
  2400. null,
  2401. null,
  2402. null
  2403. )
  2404. /* hot reload */
  2405. if (false) { var MultiValue_api; }
  2406. MultiValue_component.options.__file = "src/components/MultiValue.vue"
  2407. /* harmony default export */ var MultiValue = (MultiValue_component.exports);
  2408. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js!./node_modules/vue-loader/lib??vue-loader-options!./src/components/icons/Arrow.vue?vue&type=template&id=11186cd4&
  2409. var Arrowvue_type_template_id_11186cd4_render = function() {
  2410. var _vm = this
  2411. var _h = _vm.$createElement
  2412. var _c = _vm._self._c || _h
  2413. return _c(
  2414. "svg",
  2415. {
  2416. attrs: {
  2417. xmlns: "http://www.w3.org/2000/svg",
  2418. viewBox: "0 0 292.362 292.362"
  2419. }
  2420. },
  2421. [
  2422. _c("path", {
  2423. attrs: {
  2424. d:
  2425. "M286.935 69.377c-3.614-3.617-7.898-5.424-12.848-5.424H18.274c-4.952 0-9.233 1.807-12.85 5.424C1.807 72.998 0 77.279 0 82.228c0 4.948 1.807 9.229 5.424 12.847l127.907 127.907c3.621 3.617 7.902 5.428 12.85 5.428s9.233-1.811 12.847-5.428L286.935 95.074c3.613-3.617 5.427-7.898 5.427-12.847 0-4.948-1.814-9.229-5.427-12.85z"
  2426. }
  2427. })
  2428. ]
  2429. )
  2430. }
  2431. var Arrowvue_type_template_id_11186cd4_staticRenderFns = []
  2432. Arrowvue_type_template_id_11186cd4_render._withStripped = true
  2433. // CONCATENATED MODULE: ./src/components/icons/Arrow.vue?vue&type=template&id=11186cd4&
  2434. // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/icons/Arrow.vue?vue&type=script&lang=js&
  2435. /* harmony default export */ var Arrowvue_type_script_lang_js_ = ({
  2436. name: 'vue-treeselect--arrow'
  2437. });
  2438. // CONCATENATED MODULE: ./src/components/icons/Arrow.vue?vue&type=script&lang=js&
  2439. /* harmony default export */ var icons_Arrowvue_type_script_lang_js_ = (Arrowvue_type_script_lang_js_);
  2440. // CONCATENATED MODULE: ./src/components/icons/Arrow.vue
  2441. /* normalize component */
  2442. var Arrow_component = normalizeComponent(
  2443. icons_Arrowvue_type_script_lang_js_,
  2444. Arrowvue_type_template_id_11186cd4_render,
  2445. Arrowvue_type_template_id_11186cd4_staticRenderFns,
  2446. false,
  2447. null,
  2448. null,
  2449. null
  2450. )
  2451. /* hot reload */
  2452. if (false) { var Arrow_api; }
  2453. Arrow_component.options.__file = "src/components/icons/Arrow.vue"
  2454. /* harmony default export */ var Arrow = (Arrow_component.exports);
  2455. // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Control.vue?vue&type=script&lang=js&
  2456. /* harmony default export */ var Controlvue_type_script_lang_js_ = ({
  2457. name: 'vue-treeselect--control',
  2458. inject: ['instance'],
  2459. computed: {
  2460. shouldShowX: function shouldShowX() {
  2461. var instance = this.instance;
  2462. return instance.clearable && !instance.disabled && instance.hasValue && (this.hasUndisabledValue || instance.allowClearingDisabled);
  2463. },
  2464. shouldShowArrow: function shouldShowArrow() {
  2465. var instance = this.instance;
  2466. if (!instance.alwaysOpen) return true;
  2467. return !instance.menu.isOpen;
  2468. },
  2469. hasUndisabledValue: function hasUndisabledValue() {
  2470. var instance = this.instance;
  2471. return instance.hasValue && instance.internalValue.some(function (id) {
  2472. return !instance.getNode(id).isDisabled;
  2473. });
  2474. }
  2475. },
  2476. methods: {
  2477. renderX: function renderX() {
  2478. var h = this.$createElement;
  2479. var instance = this.instance;
  2480. var title = instance.multiple ? instance.clearAllText : instance.clearValueText;
  2481. if (!this.shouldShowX) return null;
  2482. return h("div", {
  2483. "class": "vue-treeselect__x-container",
  2484. attrs: {
  2485. title: title
  2486. },
  2487. on: {
  2488. "mousedown": this.handleMouseDownOnX
  2489. }
  2490. }, [h(Delete, {
  2491. "class": "vue-treeselect__x"
  2492. })]);
  2493. },
  2494. renderArrow: function renderArrow() {
  2495. var h = this.$createElement;
  2496. var instance = this.instance;
  2497. var arrowClass = {
  2498. 'vue-treeselect__control-arrow': true,
  2499. 'vue-treeselect__control-arrow--rotated': instance.menu.isOpen
  2500. };
  2501. if (!this.shouldShowArrow) return null;
  2502. return h("div", {
  2503. "class": "vue-treeselect__control-arrow-container",
  2504. on: {
  2505. "mousedown": this.handleMouseDownOnArrow
  2506. }
  2507. }, [h(Arrow, {
  2508. "class": arrowClass
  2509. })]);
  2510. },
  2511. handleMouseDownOnX: onLeftClick(function handleMouseDownOnX(evt) {
  2512. evt.stopPropagation();
  2513. evt.preventDefault();
  2514. var instance = this.instance;
  2515. var result = instance.beforeClearAll();
  2516. var handler = function handler(shouldClear) {
  2517. if (shouldClear) instance.clear();
  2518. };
  2519. if (external_is_promise_default()(result)) {
  2520. result.then(handler);
  2521. } else {
  2522. setTimeout(function () {
  2523. return handler(result);
  2524. }, 0);
  2525. }
  2526. }),
  2527. handleMouseDownOnArrow: onLeftClick(function handleMouseDownOnArrow(evt) {
  2528. evt.preventDefault();
  2529. evt.stopPropagation();
  2530. var instance = this.instance;
  2531. instance.focusInput();
  2532. instance.toggleMenu();
  2533. }),
  2534. renderValueContainer: function renderValueContainer(children) {
  2535. var h = this.$createElement;
  2536. return h("div", {
  2537. "class": "vue-treeselect__value-container"
  2538. }, [children]);
  2539. }
  2540. },
  2541. render: function render() {
  2542. var h = arguments[0];
  2543. var instance = this.instance;
  2544. var ValueContainer = instance.single ? SingleValue : MultiValue;
  2545. return h("div", {
  2546. "class": "vue-treeselect__control",
  2547. on: {
  2548. "mousedown": instance.handleMouseDown
  2549. }
  2550. }, [h(ValueContainer, {
  2551. ref: "value-container"
  2552. }), this.renderX(), this.renderArrow()]);
  2553. }
  2554. });
  2555. // CONCATENATED MODULE: ./src/components/Control.vue?vue&type=script&lang=js&
  2556. /* harmony default export */ var components_Controlvue_type_script_lang_js_ = (Controlvue_type_script_lang_js_);
  2557. // CONCATENATED MODULE: ./src/components/Control.vue
  2558. var Control_render, Control_staticRenderFns
  2559. /* normalize component */
  2560. var Control_component = normalizeComponent(
  2561. components_Controlvue_type_script_lang_js_,
  2562. Control_render,
  2563. Control_staticRenderFns,
  2564. false,
  2565. null,
  2566. null,
  2567. null
  2568. )
  2569. /* hot reload */
  2570. if (false) { var Control_api; }
  2571. Control_component.options.__file = "src/components/Control.vue"
  2572. /* harmony default export */ var Control = (Control_component.exports);
  2573. // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Tip.vue?vue&type=script&lang=js&
  2574. /* harmony default export */ var Tipvue_type_script_lang_js_ = ({
  2575. name: 'vue-treeselect--tip',
  2576. functional: true,
  2577. props: {
  2578. type: {
  2579. type: String,
  2580. required: true
  2581. },
  2582. icon: {
  2583. type: String,
  2584. required: true
  2585. }
  2586. },
  2587. render: function render(_, context) {
  2588. var h = arguments[0];
  2589. var props = context.props,
  2590. children = context.children;
  2591. return h("div", {
  2592. "class": "vue-treeselect__tip vue-treeselect__".concat(props.type, "-tip")
  2593. }, [h("div", {
  2594. "class": "vue-treeselect__icon-container"
  2595. }, [h("span", {
  2596. "class": "vue-treeselect__icon-".concat(props.icon)
  2597. })]), h("span", {
  2598. "class": "vue-treeselect__tip-text vue-treeselect__".concat(props.type, "-tip-text")
  2599. }, [children])]);
  2600. }
  2601. });
  2602. // CONCATENATED MODULE: ./src/components/Tip.vue?vue&type=script&lang=js&
  2603. /* harmony default export */ var components_Tipvue_type_script_lang_js_ = (Tipvue_type_script_lang_js_);
  2604. // CONCATENATED MODULE: ./src/components/Tip.vue
  2605. var Tip_render, Tip_staticRenderFns
  2606. /* normalize component */
  2607. var Tip_component = normalizeComponent(
  2608. components_Tipvue_type_script_lang_js_,
  2609. Tip_render,
  2610. Tip_staticRenderFns,
  2611. false,
  2612. null,
  2613. null,
  2614. null
  2615. )
  2616. /* hot reload */
  2617. if (false) { var Tip_api; }
  2618. Tip_component.options.__file = "src/components/Tip.vue"
  2619. /* harmony default export */ var Tip = (Tip_component.exports);
  2620. // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Option.vue?vue&type=script&lang=js&
  2621. var arrowPlaceholder, checkMark, minusMark;
  2622. var Option = {
  2623. name: 'vue-treeselect--option',
  2624. inject: ['instance'],
  2625. props: {
  2626. node: {
  2627. type: Object,
  2628. required: true
  2629. }
  2630. },
  2631. computed: {
  2632. shouldExpand: function shouldExpand() {
  2633. var instance = this.instance,
  2634. node = this.node;
  2635. return node.isBranch && instance.shouldExpand(node);
  2636. },
  2637. shouldShow: function shouldShow() {
  2638. var instance = this.instance,
  2639. node = this.node;
  2640. return instance.shouldShowOptionInMenu(node);
  2641. }
  2642. },
  2643. methods: {
  2644. renderOption: function renderOption() {
  2645. var h = this.$createElement;
  2646. var instance = this.instance,
  2647. node = this.node;
  2648. var optionClass = {
  2649. 'vue-treeselect__option': true,
  2650. 'vue-treeselect__option--disabled': node.isDisabled,
  2651. 'vue-treeselect__option--selected': instance.isSelected(node),
  2652. 'vue-treeselect__option--highlight': node.isHighlighted,
  2653. 'vue-treeselect__option--matched': instance.localSearch.active && node.isMatched,
  2654. 'vue-treeselect__option--hide': !this.shouldShow
  2655. };
  2656. return h("div", {
  2657. "class": optionClass,
  2658. on: {
  2659. "mouseenter": this.handleMouseEnterOption
  2660. },
  2661. attrs: {
  2662. "data-id": node.id
  2663. }
  2664. }, [this.renderArrow(), this.renderLabelContainer([this.renderCheckboxContainer([this.renderCheckbox()]), this.renderLabel()])]);
  2665. },
  2666. renderSubOptionsList: function renderSubOptionsList() {
  2667. var h = this.$createElement;
  2668. if (!this.shouldExpand) return null;
  2669. return h("div", {
  2670. "class": "vue-treeselect__list"
  2671. }, [this.renderSubOptions(), this.renderNoChildrenTip(), this.renderLoadingChildrenTip(), this.renderLoadingChildrenErrorTip()]);
  2672. },
  2673. renderArrow: function renderArrow() {
  2674. var h = this.$createElement;
  2675. var instance = this.instance,
  2676. node = this.node;
  2677. if (instance.shouldFlattenOptions && this.shouldShow) return null;
  2678. if (node.isBranch) {
  2679. var transitionProps = {
  2680. props: {
  2681. name: 'vue-treeselect__option-arrow--prepare',
  2682. appear: true
  2683. }
  2684. };
  2685. var arrowClass = {
  2686. 'vue-treeselect__option-arrow': true,
  2687. 'vue-treeselect__option-arrow--rotated': this.shouldExpand
  2688. };
  2689. return h("div", {
  2690. "class": "vue-treeselect__option-arrow-container",
  2691. on: {
  2692. "mousedown": this.handleMouseDownOnArrow
  2693. }
  2694. }, [h("transition", transitionProps, [h(Arrow, {
  2695. "class": arrowClass
  2696. })])]);
  2697. }
  2698. if (instance.hasBranchNodes) {
  2699. if (!arrowPlaceholder) arrowPlaceholder = h("div", {
  2700. "class": "vue-treeselect__option-arrow-placeholder"
  2701. }, ["\xA0"]);
  2702. return arrowPlaceholder;
  2703. }
  2704. return null;
  2705. },
  2706. renderLabelContainer: function renderLabelContainer(children) {
  2707. var h = this.$createElement;
  2708. return h("div", {
  2709. "class": "vue-treeselect__label-container",
  2710. on: {
  2711. "mousedown": this.handleMouseDownOnLabelContainer
  2712. }
  2713. }, [children]);
  2714. },
  2715. renderCheckboxContainer: function renderCheckboxContainer(children) {
  2716. var h = this.$createElement;
  2717. var instance = this.instance,
  2718. node = this.node;
  2719. if (instance.single) return null;
  2720. if (instance.disableBranchNodes && node.isBranch) return null;
  2721. return h("div", {
  2722. "class": "vue-treeselect__checkbox-container"
  2723. }, [children]);
  2724. },
  2725. renderCheckbox: function renderCheckbox() {
  2726. var h = this.$createElement;
  2727. var instance = this.instance,
  2728. node = this.node;
  2729. var checkedState = instance.forest.checkedStateMap[node.id];
  2730. var checkboxClass = {
  2731. 'vue-treeselect__checkbox': true,
  2732. 'vue-treeselect__checkbox--checked': checkedState === CHECKED,
  2733. 'vue-treeselect__checkbox--indeterminate': checkedState === INDETERMINATE,
  2734. 'vue-treeselect__checkbox--unchecked': checkedState === UNCHECKED,
  2735. 'vue-treeselect__checkbox--disabled': node.isDisabled
  2736. };
  2737. if (!checkMark) checkMark = h("span", {
  2738. "class": "vue-treeselect__check-mark"
  2739. });
  2740. if (!minusMark) minusMark = h("span", {
  2741. "class": "vue-treeselect__minus-mark"
  2742. });
  2743. return h("span", {
  2744. "class": checkboxClass
  2745. }, [checkMark, minusMark]);
  2746. },
  2747. renderLabel: function renderLabel() {
  2748. var h = this.$createElement;
  2749. var instance = this.instance,
  2750. node = this.node;
  2751. var shouldShowCount = node.isBranch && (instance.localSearch.active ? instance.showCountOnSearchComputed : instance.showCount);
  2752. var count = shouldShowCount ? instance.localSearch.active ? instance.localSearch.countMap[node.id][instance.showCountOf] : node.count[instance.showCountOf] : NaN;
  2753. var labelClassName = 'vue-treeselect__label';
  2754. var countClassName = 'vue-treeselect__count';
  2755. var customLabelRenderer = instance.$scopedSlots['option-label'];
  2756. if (customLabelRenderer) return customLabelRenderer({
  2757. node: node,
  2758. shouldShowCount: shouldShowCount,
  2759. count: count,
  2760. labelClassName: labelClassName,
  2761. countClassName: countClassName
  2762. });
  2763. return h("label", {
  2764. "class": labelClassName
  2765. }, [node.label, shouldShowCount && h("span", {
  2766. "class": countClassName
  2767. }, ["(", count, ")"])]);
  2768. },
  2769. renderSubOptions: function renderSubOptions() {
  2770. var h = this.$createElement;
  2771. var node = this.node;
  2772. if (!node.childrenStates.isLoaded) return null;
  2773. return node.children.map(function (childNode) {
  2774. return h(Option, {
  2775. attrs: {
  2776. node: childNode
  2777. },
  2778. key: childNode.id
  2779. });
  2780. });
  2781. },
  2782. renderNoChildrenTip: function renderNoChildrenTip() {
  2783. var h = this.$createElement;
  2784. var instance = this.instance,
  2785. node = this.node;
  2786. if (!node.childrenStates.isLoaded || node.children.length) return null;
  2787. return h(Tip, {
  2788. attrs: {
  2789. type: "no-children",
  2790. icon: "warning"
  2791. }
  2792. }, [instance.noChildrenText]);
  2793. },
  2794. renderLoadingChildrenTip: function renderLoadingChildrenTip() {
  2795. var h = this.$createElement;
  2796. var instance = this.instance,
  2797. node = this.node;
  2798. if (!node.childrenStates.isLoading) return null;
  2799. return h(Tip, {
  2800. attrs: {
  2801. type: "loading",
  2802. icon: "loader"
  2803. }
  2804. }, [instance.loadingText]);
  2805. },
  2806. renderLoadingChildrenErrorTip: function renderLoadingChildrenErrorTip() {
  2807. var h = this.$createElement;
  2808. var instance = this.instance,
  2809. node = this.node;
  2810. if (!node.childrenStates.loadingError) return null;
  2811. return h(Tip, {
  2812. attrs: {
  2813. type: "error",
  2814. icon: "error"
  2815. }
  2816. }, [node.childrenStates.loadingError, h("a", {
  2817. "class": "vue-treeselect__retry",
  2818. attrs: {
  2819. title: instance.retryTitle
  2820. },
  2821. on: {
  2822. "mousedown": this.handleMouseDownOnRetry
  2823. }
  2824. }, [instance.retryText])]);
  2825. },
  2826. handleMouseEnterOption: function handleMouseEnterOption(evt) {
  2827. var instance = this.instance,
  2828. node = this.node;
  2829. if (evt.target !== evt.currentTarget) return;
  2830. instance.setCurrentHighlightedOption(node, false);
  2831. },
  2832. handleMouseDownOnArrow: onLeftClick(function handleMouseDownOnOptionArrow() {
  2833. var instance = this.instance,
  2834. node = this.node;
  2835. instance.toggleExpanded(node);
  2836. }),
  2837. handleMouseDownOnLabelContainer: onLeftClick(function handleMouseDownOnLabelContainer() {
  2838. var instance = this.instance,
  2839. node = this.node;
  2840. if (node.isBranch && instance.disableBranchNodes) {
  2841. instance.toggleExpanded(node);
  2842. } else {
  2843. instance.select(node);
  2844. }
  2845. }),
  2846. handleMouseDownOnRetry: onLeftClick(function handleMouseDownOnRetry() {
  2847. var instance = this.instance,
  2848. node = this.node;
  2849. instance.loadChildrenOptions(node);
  2850. })
  2851. },
  2852. render: function render() {
  2853. var h = arguments[0];
  2854. var node = this.node;
  2855. var indentLevel = this.instance.shouldFlattenOptions ? 0 : node.level;
  2856. var listItemClass = defineProperty_default()({
  2857. 'vue-treeselect__list-item': true
  2858. }, "vue-treeselect__indent-level-".concat(indentLevel), true);
  2859. var transitionProps = {
  2860. props: {
  2861. name: 'vue-treeselect__list--transition'
  2862. }
  2863. };
  2864. return h("div", {
  2865. "class": listItemClass
  2866. }, [this.renderOption(), node.isBranch && h("transition", transitionProps, [this.renderSubOptionsList()])]);
  2867. }
  2868. };
  2869. /* harmony default export */ var Optionvue_type_script_lang_js_ = (Option);
  2870. // CONCATENATED MODULE: ./src/components/Option.vue?vue&type=script&lang=js&
  2871. /* harmony default export */ var components_Optionvue_type_script_lang_js_ = (Optionvue_type_script_lang_js_);
  2872. // CONCATENATED MODULE: ./src/components/Option.vue
  2873. var Option_render, Option_staticRenderFns
  2874. /* normalize component */
  2875. var Option_component = normalizeComponent(
  2876. components_Optionvue_type_script_lang_js_,
  2877. Option_render,
  2878. Option_staticRenderFns,
  2879. false,
  2880. null,
  2881. null,
  2882. null
  2883. )
  2884. /* hot reload */
  2885. if (false) { var Option_api; }
  2886. Option_component.options.__file = "src/components/Option.vue"
  2887. /* harmony default export */ var components_Option = (Option_component.exports);
  2888. // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Menu.vue?vue&type=script&lang=js&
  2889. var directionMap = {
  2890. top: 'top',
  2891. bottom: 'bottom',
  2892. above: 'top',
  2893. below: 'bottom'
  2894. };
  2895. /* harmony default export */ var Menuvue_type_script_lang_js_ = ({
  2896. name: 'vue-treeselect--menu',
  2897. inject: ['instance'],
  2898. computed: {
  2899. menuStyle: function menuStyle() {
  2900. var instance = this.instance;
  2901. return {
  2902. maxHeight: instance.maxHeight + 'px'
  2903. };
  2904. },
  2905. menuContainerStyle: function menuContainerStyle() {
  2906. var instance = this.instance;
  2907. return {
  2908. zIndex: instance.appendToBody ? null : instance.zIndex
  2909. };
  2910. }
  2911. },
  2912. watch: {
  2913. 'instance.menu.isOpen': function instanceMenuIsOpen(newValue) {
  2914. if (newValue) {
  2915. this.$nextTick(this.onMenuOpen);
  2916. } else {
  2917. this.onMenuClose();
  2918. }
  2919. }
  2920. },
  2921. created: function created() {
  2922. this.menuSizeWatcher = null;
  2923. this.menuResizeAndScrollEventListeners = null;
  2924. },
  2925. mounted: function mounted() {
  2926. var instance = this.instance;
  2927. if (instance.menu.isOpen) this.$nextTick(this.onMenuOpen);
  2928. },
  2929. destroyed: function destroyed() {
  2930. this.onMenuClose();
  2931. },
  2932. methods: {
  2933. renderMenu: function renderMenu() {
  2934. var h = this.$createElement;
  2935. var instance = this.instance;
  2936. if (!instance.menu.isOpen) return null;
  2937. return h("div", {
  2938. ref: "menu",
  2939. "class": "vue-treeselect__menu",
  2940. on: {
  2941. "mousedown": instance.handleMouseDown
  2942. },
  2943. style: this.menuStyle
  2944. }, [this.renderBeforeList(), instance.async ? this.renderAsyncSearchMenuInner() : instance.localSearch.active ? this.renderLocalSearchMenuInner() : this.renderNormalMenuInner(), this.renderAfterList()]);
  2945. },
  2946. renderBeforeList: function renderBeforeList() {
  2947. var instance = this.instance;
  2948. var beforeListRenderer = instance.$scopedSlots['before-list'];
  2949. return beforeListRenderer ? beforeListRenderer() : null;
  2950. },
  2951. renderAfterList: function renderAfterList() {
  2952. var instance = this.instance;
  2953. var afterListRenderer = instance.$scopedSlots['after-list'];
  2954. return afterListRenderer ? afterListRenderer() : null;
  2955. },
  2956. renderNormalMenuInner: function renderNormalMenuInner() {
  2957. var instance = this.instance;
  2958. if (instance.rootOptionsStates.isLoading) {
  2959. return this.renderLoadingOptionsTip();
  2960. } else if (instance.rootOptionsStates.loadingError) {
  2961. return this.renderLoadingRootOptionsErrorTip();
  2962. } else if (instance.rootOptionsStates.isLoaded && instance.forest.normalizedOptions.length === 0) {
  2963. return this.renderNoAvailableOptionsTip();
  2964. } else {
  2965. return this.renderOptionList();
  2966. }
  2967. },
  2968. renderLocalSearchMenuInner: function renderLocalSearchMenuInner() {
  2969. var instance = this.instance;
  2970. if (instance.rootOptionsStates.isLoading) {
  2971. return this.renderLoadingOptionsTip();
  2972. } else if (instance.rootOptionsStates.loadingError) {
  2973. return this.renderLoadingRootOptionsErrorTip();
  2974. } else if (instance.rootOptionsStates.isLoaded && instance.forest.normalizedOptions.length === 0) {
  2975. return this.renderNoAvailableOptionsTip();
  2976. } else if (instance.localSearch.noResults) {
  2977. return this.renderNoResultsTip();
  2978. } else {
  2979. return this.renderOptionList();
  2980. }
  2981. },
  2982. renderAsyncSearchMenuInner: function renderAsyncSearchMenuInner() {
  2983. var instance = this.instance;
  2984. var entry = instance.getRemoteSearchEntry();
  2985. var shouldShowSearchPromptTip = instance.trigger.searchQuery === '' && !instance.defaultOptions;
  2986. var shouldShowNoResultsTip = shouldShowSearchPromptTip ? false : entry.isLoaded && entry.options.length === 0;
  2987. if (shouldShowSearchPromptTip) {
  2988. return this.renderSearchPromptTip();
  2989. } else if (entry.isLoading) {
  2990. return this.renderLoadingOptionsTip();
  2991. } else if (entry.loadingError) {
  2992. return this.renderAsyncSearchLoadingErrorTip();
  2993. } else if (shouldShowNoResultsTip) {
  2994. return this.renderNoResultsTip();
  2995. } else {
  2996. return this.renderOptionList();
  2997. }
  2998. },
  2999. renderOptionList: function renderOptionList() {
  3000. var h = this.$createElement;
  3001. var instance = this.instance;
  3002. return h("div", {
  3003. "class": "vue-treeselect__list"
  3004. }, [instance.forest.normalizedOptions.map(function (rootNode) {
  3005. return h(components_Option, {
  3006. attrs: {
  3007. node: rootNode
  3008. },
  3009. key: rootNode.id
  3010. });
  3011. })]);
  3012. },
  3013. renderSearchPromptTip: function renderSearchPromptTip() {
  3014. var h = this.$createElement;
  3015. var instance = this.instance;
  3016. return h(Tip, {
  3017. attrs: {
  3018. type: "search-prompt",
  3019. icon: "warning"
  3020. }
  3021. }, [instance.searchPromptText]);
  3022. },
  3023. renderLoadingOptionsTip: function renderLoadingOptionsTip() {
  3024. var h = this.$createElement;
  3025. var instance = this.instance;
  3026. return h(Tip, {
  3027. attrs: {
  3028. type: "loading",
  3029. icon: "loader"
  3030. }
  3031. }, [instance.loadingText]);
  3032. },
  3033. renderLoadingRootOptionsErrorTip: function renderLoadingRootOptionsErrorTip() {
  3034. var h = this.$createElement;
  3035. var instance = this.instance;
  3036. return h(Tip, {
  3037. attrs: {
  3038. type: "error",
  3039. icon: "error"
  3040. }
  3041. }, [instance.rootOptionsStates.loadingError, h("a", {
  3042. "class": "vue-treeselect__retry",
  3043. on: {
  3044. "click": instance.loadRootOptions
  3045. },
  3046. attrs: {
  3047. title: instance.retryTitle
  3048. }
  3049. }, [instance.retryText])]);
  3050. },
  3051. renderAsyncSearchLoadingErrorTip: function renderAsyncSearchLoadingErrorTip() {
  3052. var h = this.$createElement;
  3053. var instance = this.instance;
  3054. var entry = instance.getRemoteSearchEntry();
  3055. return h(Tip, {
  3056. attrs: {
  3057. type: "error",
  3058. icon: "error"
  3059. }
  3060. }, [entry.loadingError, h("a", {
  3061. "class": "vue-treeselect__retry",
  3062. on: {
  3063. "click": instance.handleRemoteSearch
  3064. },
  3065. attrs: {
  3066. title: instance.retryTitle
  3067. }
  3068. }, [instance.retryText])]);
  3069. },
  3070. renderNoAvailableOptionsTip: function renderNoAvailableOptionsTip() {
  3071. var h = this.$createElement;
  3072. var instance = this.instance;
  3073. return h(Tip, {
  3074. attrs: {
  3075. type: "no-options",
  3076. icon: "warning"
  3077. }
  3078. }, [instance.noOptionsText]);
  3079. },
  3080. renderNoResultsTip: function renderNoResultsTip() {
  3081. var h = this.$createElement;
  3082. var instance = this.instance;
  3083. return h(Tip, {
  3084. attrs: {
  3085. type: "no-results",
  3086. icon: "warning"
  3087. }
  3088. }, [instance.noResultsText]);
  3089. },
  3090. onMenuOpen: function onMenuOpen() {
  3091. this.adjustMenuOpenDirection();
  3092. this.setupMenuSizeWatcher();
  3093. this.setupMenuResizeAndScrollEventListeners();
  3094. },
  3095. onMenuClose: function onMenuClose() {
  3096. this.removeMenuSizeWatcher();
  3097. this.removeMenuResizeAndScrollEventListeners();
  3098. },
  3099. adjustMenuOpenDirection: function adjustMenuOpenDirection() {
  3100. var instance = this.instance;
  3101. if (!instance.menu.isOpen) return;
  3102. var $menu = instance.getMenu();
  3103. var $control = instance.getControl();
  3104. var menuRect = $menu.getBoundingClientRect();
  3105. var controlRect = $control.getBoundingClientRect();
  3106. var menuHeight = menuRect.height;
  3107. var viewportHeight = window.innerHeight;
  3108. var spaceAbove = controlRect.top;
  3109. var spaceBelow = window.innerHeight - controlRect.bottom;
  3110. var isControlInViewport = controlRect.top >= 0 && controlRect.top <= viewportHeight || controlRect.top < 0 && controlRect.bottom > 0;
  3111. var hasEnoughSpaceBelow = spaceBelow > menuHeight + MENU_BUFFER;
  3112. var hasEnoughSpaceAbove = spaceAbove > menuHeight + MENU_BUFFER;
  3113. if (!isControlInViewport) {
  3114. instance.closeMenu();
  3115. } else if (instance.openDirection !== 'auto') {
  3116. instance.menu.placement = directionMap[instance.openDirection];
  3117. } else if (hasEnoughSpaceBelow || !hasEnoughSpaceAbove) {
  3118. instance.menu.placement = 'bottom';
  3119. } else {
  3120. instance.menu.placement = 'top';
  3121. }
  3122. },
  3123. setupMenuSizeWatcher: function setupMenuSizeWatcher() {
  3124. var instance = this.instance;
  3125. var $menu = instance.getMenu();
  3126. if (this.menuSizeWatcher) return;
  3127. this.menuSizeWatcher = {
  3128. remove: watchSize($menu, this.adjustMenuOpenDirection)
  3129. };
  3130. },
  3131. setupMenuResizeAndScrollEventListeners: function setupMenuResizeAndScrollEventListeners() {
  3132. var instance = this.instance;
  3133. var $control = instance.getControl();
  3134. if (this.menuResizeAndScrollEventListeners) return;
  3135. this.menuResizeAndScrollEventListeners = {
  3136. remove: setupResizeAndScrollEventListeners($control, this.adjustMenuOpenDirection)
  3137. };
  3138. },
  3139. removeMenuSizeWatcher: function removeMenuSizeWatcher() {
  3140. if (!this.menuSizeWatcher) return;
  3141. this.menuSizeWatcher.remove();
  3142. this.menuSizeWatcher = null;
  3143. },
  3144. removeMenuResizeAndScrollEventListeners: function removeMenuResizeAndScrollEventListeners() {
  3145. if (!this.menuResizeAndScrollEventListeners) return;
  3146. this.menuResizeAndScrollEventListeners.remove();
  3147. this.menuResizeAndScrollEventListeners = null;
  3148. }
  3149. },
  3150. render: function render() {
  3151. var h = arguments[0];
  3152. return h("div", {
  3153. ref: "menu-container",
  3154. "class": "vue-treeselect__menu-container",
  3155. style: this.menuContainerStyle
  3156. }, [h("transition", {
  3157. attrs: {
  3158. name: "vue-treeselect__menu--transition"
  3159. }
  3160. }, [this.renderMenu()])]);
  3161. }
  3162. });
  3163. // CONCATENATED MODULE: ./src/components/Menu.vue?vue&type=script&lang=js&
  3164. /* harmony default export */ var components_Menuvue_type_script_lang_js_ = (Menuvue_type_script_lang_js_);
  3165. // CONCATENATED MODULE: ./src/components/Menu.vue
  3166. var Menu_render, Menu_staticRenderFns
  3167. /* normalize component */
  3168. var Menu_component = normalizeComponent(
  3169. components_Menuvue_type_script_lang_js_,
  3170. Menu_render,
  3171. Menu_staticRenderFns,
  3172. false,
  3173. null,
  3174. null,
  3175. null
  3176. )
  3177. /* hot reload */
  3178. if (false) { var Menu_api; }
  3179. Menu_component.options.__file = "src/components/Menu.vue"
  3180. /* harmony default export */ var Menu = (Menu_component.exports);
  3181. // EXTERNAL MODULE: external "vue"
  3182. var external_vue_ = __webpack_require__(14);
  3183. var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
  3184. // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/MenuPortal.vue?vue&type=script&lang=js&
  3185. function MenuPortalvue_type_script_lang_js_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  3186. function MenuPortalvue_type_script_lang_js_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { MenuPortalvue_type_script_lang_js_ownKeys(source, true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { MenuPortalvue_type_script_lang_js_ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  3187. var PortalTarget = {
  3188. name: 'vue-treeselect--portal-target',
  3189. inject: ['instance'],
  3190. watch: {
  3191. 'instance.menu.isOpen': function instanceMenuIsOpen(newValue) {
  3192. if (newValue) {
  3193. this.setupHandlers();
  3194. } else {
  3195. this.removeHandlers();
  3196. }
  3197. },
  3198. 'instance.menu.placement': function instanceMenuPlacement() {
  3199. this.updateMenuContainerOffset();
  3200. }
  3201. },
  3202. created: function created() {
  3203. this.controlResizeAndScrollEventListeners = null;
  3204. this.controlSizeWatcher = null;
  3205. },
  3206. mounted: function mounted() {
  3207. var instance = this.instance;
  3208. if (instance.menu.isOpen) this.setupHandlers();
  3209. },
  3210. methods: {
  3211. setupHandlers: function setupHandlers() {
  3212. this.updateWidth();
  3213. this.updateMenuContainerOffset();
  3214. this.setupControlResizeAndScrollEventListeners();
  3215. this.setupControlSizeWatcher();
  3216. },
  3217. removeHandlers: function removeHandlers() {
  3218. this.removeControlResizeAndScrollEventListeners();
  3219. this.removeControlSizeWatcher();
  3220. },
  3221. setupControlResizeAndScrollEventListeners: function setupControlResizeAndScrollEventListeners() {
  3222. var instance = this.instance;
  3223. var $control = instance.getControl();
  3224. if (this.controlResizeAndScrollEventListeners) return;
  3225. this.controlResizeAndScrollEventListeners = {
  3226. remove: setupResizeAndScrollEventListeners($control, this.updateMenuContainerOffset)
  3227. };
  3228. },
  3229. setupControlSizeWatcher: function setupControlSizeWatcher() {
  3230. var _this = this;
  3231. var instance = this.instance;
  3232. var $control = instance.getControl();
  3233. if (this.controlSizeWatcher) return;
  3234. this.controlSizeWatcher = {
  3235. remove: watchSize($control, function () {
  3236. _this.updateWidth();
  3237. _this.updateMenuContainerOffset();
  3238. })
  3239. };
  3240. },
  3241. removeControlResizeAndScrollEventListeners: function removeControlResizeAndScrollEventListeners() {
  3242. if (!this.controlResizeAndScrollEventListeners) return;
  3243. this.controlResizeAndScrollEventListeners.remove();
  3244. this.controlResizeAndScrollEventListeners = null;
  3245. },
  3246. removeControlSizeWatcher: function removeControlSizeWatcher() {
  3247. if (!this.controlSizeWatcher) return;
  3248. this.controlSizeWatcher.remove();
  3249. this.controlSizeWatcher = null;
  3250. },
  3251. updateWidth: function updateWidth() {
  3252. var instance = this.instance;
  3253. var $portalTarget = this.$el;
  3254. var $control = instance.getControl();
  3255. var controlRect = $control.getBoundingClientRect();
  3256. $portalTarget.style.width = controlRect.width + 'px';
  3257. },
  3258. updateMenuContainerOffset: function updateMenuContainerOffset() {
  3259. var instance = this.instance;
  3260. var $control = instance.getControl();
  3261. var $portalTarget = this.$el;
  3262. var controlRect = $control.getBoundingClientRect();
  3263. var portalTargetRect = $portalTarget.getBoundingClientRect();
  3264. var offsetY = instance.menu.placement === 'bottom' ? controlRect.height : 0;
  3265. var left = Math.round(controlRect.left - portalTargetRect.left) + 'px';
  3266. var top = Math.round(controlRect.top - portalTargetRect.top + offsetY) + 'px';
  3267. var menuContainerStyle = this.$refs.menu.$refs['menu-container'].style;
  3268. var transformVariations = ['transform', 'webkitTransform', 'MozTransform', 'msTransform'];
  3269. var transform = find(transformVariations, function (t) {
  3270. return t in document.body.style;
  3271. });
  3272. menuContainerStyle[transform] = "translate(".concat(left, ", ").concat(top, ")");
  3273. }
  3274. },
  3275. render: function render() {
  3276. var h = arguments[0];
  3277. var instance = this.instance;
  3278. var portalTargetClass = ['vue-treeselect__portal-target', instance.wrapperClass];
  3279. var portalTargetStyle = {
  3280. zIndex: instance.zIndex
  3281. };
  3282. return h("div", {
  3283. "class": portalTargetClass,
  3284. style: portalTargetStyle,
  3285. attrs: {
  3286. "data-instance-id": instance.getInstanceId()
  3287. }
  3288. }, [h(Menu, {
  3289. ref: "menu"
  3290. })]);
  3291. },
  3292. destroyed: function destroyed() {
  3293. this.removeHandlers();
  3294. }
  3295. };
  3296. var placeholder;
  3297. /* harmony default export */ var MenuPortalvue_type_script_lang_js_ = ({
  3298. name: 'vue-treeselect--menu-portal',
  3299. created: function created() {
  3300. this.portalTarget = null;
  3301. },
  3302. mounted: function mounted() {
  3303. this.setup();
  3304. },
  3305. destroyed: function destroyed() {
  3306. this.teardown();
  3307. },
  3308. methods: {
  3309. setup: function setup() {
  3310. var el = document.createElement('div');
  3311. document.body.appendChild(el);
  3312. this.portalTarget = new external_vue_default.a(MenuPortalvue_type_script_lang_js_objectSpread({
  3313. el: el,
  3314. parent: this
  3315. }, PortalTarget));
  3316. },
  3317. teardown: function teardown() {
  3318. document.body.removeChild(this.portalTarget.$el);
  3319. this.portalTarget.$el.innerHTML = '';
  3320. this.portalTarget.$destroy();
  3321. this.portalTarget = null;
  3322. }
  3323. },
  3324. render: function render() {
  3325. var h = arguments[0];
  3326. if (!placeholder) placeholder = h("div", {
  3327. "class": "vue-treeselect__menu-placeholder"
  3328. });
  3329. return placeholder;
  3330. }
  3331. });
  3332. // CONCATENATED MODULE: ./src/components/MenuPortal.vue?vue&type=script&lang=js&
  3333. /* harmony default export */ var components_MenuPortalvue_type_script_lang_js_ = (MenuPortalvue_type_script_lang_js_);
  3334. // CONCATENATED MODULE: ./src/components/MenuPortal.vue
  3335. var MenuPortal_render, MenuPortal_staticRenderFns
  3336. /* normalize component */
  3337. var MenuPortal_component = normalizeComponent(
  3338. components_MenuPortalvue_type_script_lang_js_,
  3339. MenuPortal_render,
  3340. MenuPortal_staticRenderFns,
  3341. false,
  3342. null,
  3343. null,
  3344. null
  3345. )
  3346. /* hot reload */
  3347. if (false) { var MenuPortal_api; }
  3348. MenuPortal_component.options.__file = "src/components/MenuPortal.vue"
  3349. /* harmony default export */ var MenuPortal = (MenuPortal_component.exports);
  3350. // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Treeselect.vue?vue&type=script&lang=js&
  3351. /* harmony default export */ var Treeselectvue_type_script_lang_js_ = ({
  3352. name: 'vue-treeselect',
  3353. mixins: [treeselectMixin],
  3354. computed: {
  3355. wrapperClass: function wrapperClass() {
  3356. return {
  3357. 'vue-treeselect': true,
  3358. 'vue-treeselect--single': this.single,
  3359. 'vue-treeselect--multi': this.multiple,
  3360. 'vue-treeselect--searchable': this.searchable,
  3361. 'vue-treeselect--disabled': this.disabled,
  3362. 'vue-treeselect--focused': this.trigger.isFocused,
  3363. 'vue-treeselect--has-value': this.hasValue,
  3364. 'vue-treeselect--open': this.menu.isOpen,
  3365. 'vue-treeselect--open-above': this.menu.placement === 'top',
  3366. 'vue-treeselect--open-below': this.menu.placement === 'bottom',
  3367. 'vue-treeselect--branch-nodes-disabled': this.disableBranchNodes,
  3368. 'vue-treeselect--append-to-body': this.appendToBody
  3369. };
  3370. }
  3371. },
  3372. render: function render() {
  3373. var h = arguments[0];
  3374. return h("div", {
  3375. ref: "wrapper",
  3376. "class": this.wrapperClass
  3377. }, [h(HiddenFields), h(Control, {
  3378. ref: "control"
  3379. }), this.appendToBody ? h(MenuPortal, {
  3380. ref: "portal"
  3381. }) : h(Menu, {
  3382. ref: "menu"
  3383. })]);
  3384. }
  3385. });
  3386. // CONCATENATED MODULE: ./src/components/Treeselect.vue?vue&type=script&lang=js&
  3387. /* harmony default export */ var components_Treeselectvue_type_script_lang_js_ = (Treeselectvue_type_script_lang_js_);
  3388. // CONCATENATED MODULE: ./src/components/Treeselect.vue
  3389. var Treeselect_render, Treeselect_staticRenderFns
  3390. /* normalize component */
  3391. var Treeselect_component = normalizeComponent(
  3392. components_Treeselectvue_type_script_lang_js_,
  3393. Treeselect_render,
  3394. Treeselect_staticRenderFns,
  3395. false,
  3396. null,
  3397. null,
  3398. null
  3399. )
  3400. /* hot reload */
  3401. if (false) { var Treeselect_api; }
  3402. Treeselect_component.options.__file = "src/components/Treeselect.vue"
  3403. /* harmony default export */ var Treeselect = (Treeselect_component.exports);
  3404. // EXTERNAL MODULE: ./src/style.less
  3405. var style = __webpack_require__(15);
  3406. // CONCATENATED MODULE: ./src/index.js
  3407. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VERSION", function() { return VERSION; });
  3408. /* concated harmony reexport Treeselect */__webpack_require__.d(__webpack_exports__, "Treeselect", function() { return Treeselect; });
  3409. /* concated harmony reexport treeselectMixin */__webpack_require__.d(__webpack_exports__, "treeselectMixin", function() { return treeselectMixin; });
  3410. /* concated harmony reexport LOAD_ROOT_OPTIONS */__webpack_require__.d(__webpack_exports__, "LOAD_ROOT_OPTIONS", function() { return LOAD_ROOT_OPTIONS; });
  3411. /* concated harmony reexport LOAD_CHILDREN_OPTIONS */__webpack_require__.d(__webpack_exports__, "LOAD_CHILDREN_OPTIONS", function() { return LOAD_CHILDREN_OPTIONS; });
  3412. /* concated harmony reexport ASYNC_SEARCH */__webpack_require__.d(__webpack_exports__, "ASYNC_SEARCH", function() { return ASYNC_SEARCH; });
  3413. /* harmony default export */ var src = __webpack_exports__["default"] = (Treeselect);
  3414. var VERSION = "0.4.0";
  3415. /***/ })
  3416. /******/ ]);
  3417. //# sourceMappingURL=vue-treeselect.cjs.js.map