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