5007 lines
148 KiB
JavaScript
5007 lines
148 KiB
JavaScript
/*!
|
|
* vue-treeselect v0.4.0 | (c) 2017-2019 Riophae Lee
|
|
* Released under the MIT License.
|
|
* https://vue-treeselect.js.org/
|
|
*/
|
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
module.exports = factory(require("Vue"));
|
|
else if(typeof define === 'function' && define.amd)
|
|
define(["Vue"], factory);
|
|
else if(typeof exports === 'object')
|
|
exports["VueTreeselect"] = factory(require("Vue"));
|
|
else
|
|
root["VueTreeselect"] = factory(root["Vue"]);
|
|
})(window, function(__WEBPACK_EXTERNAL_MODULE__34__) {
|
|
return /******/ (function(modules) { // webpackBootstrap
|
|
/******/ // The module cache
|
|
/******/ var installedModules = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __webpack_require__(moduleId) {
|
|
/******/
|
|
/******/ // Check if module is in cache
|
|
/******/ if(installedModules[moduleId]) {
|
|
/******/ return installedModules[moduleId].exports;
|
|
/******/ }
|
|
/******/ // Create a new module (and put it into the cache)
|
|
/******/ var module = installedModules[moduleId] = {
|
|
/******/ i: moduleId,
|
|
/******/ l: false,
|
|
/******/ exports: {}
|
|
/******/ };
|
|
/******/
|
|
/******/ // Execute the module function
|
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
/******/
|
|
/******/ // Flag the module as loaded
|
|
/******/ module.l = true;
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/******/
|
|
/******/ // expose the modules object (__webpack_modules__)
|
|
/******/ __webpack_require__.m = modules;
|
|
/******/
|
|
/******/ // expose the module cache
|
|
/******/ __webpack_require__.c = installedModules;
|
|
/******/
|
|
/******/ // define getter function for harmony exports
|
|
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
/******/ }
|
|
/******/ };
|
|
/******/
|
|
/******/ // define __esModule on exports
|
|
/******/ __webpack_require__.r = function(exports) {
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
/******/ }
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
/******/ };
|
|
/******/
|
|
/******/ // create a fake namespace object
|
|
/******/ // mode & 1: value is a module id, require it
|
|
/******/ // mode & 2: merge all properties of value into the ns
|
|
/******/ // mode & 4: return value when already ns object
|
|
/******/ // mode & 8|1: behave like require
|
|
/******/ __webpack_require__.t = function(value, mode) {
|
|
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
/******/ if(mode & 8) return value;
|
|
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
/******/ var ns = Object.create(null);
|
|
/******/ __webpack_require__.r(ns);
|
|
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
/******/ return ns;
|
|
/******/ };
|
|
/******/
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
/******/ __webpack_require__.n = function(module) {
|
|
/******/ var getter = module && module.__esModule ?
|
|
/******/ function getDefault() { return module['default']; } :
|
|
/******/ function getModuleExports() { return module; };
|
|
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
/******/ return getter;
|
|
/******/ };
|
|
/******/
|
|
/******/ // Object.prototype.hasOwnProperty.call
|
|
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
/******/
|
|
/******/ // __webpack_public_path__
|
|
/******/ __webpack_require__.p = "/";
|
|
/******/
|
|
/******/
|
|
/******/ // Load entry module and return exports
|
|
/******/ return __webpack_require__(__webpack_require__.s = 36);
|
|
/******/ })
|
|
/************************************************************************/
|
|
/******/ ([
|
|
/* 0 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var arrayWithHoles = __webpack_require__(1);
|
|
|
|
var iterableToArrayLimit = __webpack_require__(2);
|
|
|
|
var nonIterableRest = __webpack_require__(3);
|
|
|
|
function _slicedToArray(arr, i) {
|
|
return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest();
|
|
}
|
|
|
|
module.exports = _slicedToArray;
|
|
|
|
/***/ }),
|
|
/* 1 */
|
|
/***/ (function(module, exports) {
|
|
|
|
function _arrayWithHoles(arr) {
|
|
if (Array.isArray(arr)) return arr;
|
|
}
|
|
|
|
module.exports = _arrayWithHoles;
|
|
|
|
/***/ }),
|
|
/* 2 */
|
|
/***/ (function(module, exports) {
|
|
|
|
function _iterableToArrayLimit(arr, i) {
|
|
if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
|
|
return;
|
|
}
|
|
|
|
var _arr = [];
|
|
var _n = true;
|
|
var _d = false;
|
|
var _e = undefined;
|
|
|
|
try {
|
|
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
_arr.push(_s.value);
|
|
|
|
if (i && _arr.length === i) break;
|
|
}
|
|
} catch (err) {
|
|
_d = true;
|
|
_e = err;
|
|
} finally {
|
|
try {
|
|
if (!_n && _i["return"] != null) _i["return"]();
|
|
} finally {
|
|
if (_d) throw _e;
|
|
}
|
|
}
|
|
|
|
return _arr;
|
|
}
|
|
|
|
module.exports = _iterableToArrayLimit;
|
|
|
|
/***/ }),
|
|
/* 3 */
|
|
/***/ (function(module, exports) {
|
|
|
|
function _nonIterableRest() {
|
|
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
}
|
|
|
|
module.exports = _nonIterableRest;
|
|
|
|
/***/ }),
|
|
/* 4 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var arrayWithoutHoles = __webpack_require__(5);
|
|
|
|
var iterableToArray = __webpack_require__(6);
|
|
|
|
var nonIterableSpread = __webpack_require__(7);
|
|
|
|
function _toConsumableArray(arr) {
|
|
return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();
|
|
}
|
|
|
|
module.exports = _toConsumableArray;
|
|
|
|
/***/ }),
|
|
/* 5 */
|
|
/***/ (function(module, exports) {
|
|
|
|
function _arrayWithoutHoles(arr) {
|
|
if (Array.isArray(arr)) {
|
|
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
|
|
arr2[i] = arr[i];
|
|
}
|
|
|
|
return arr2;
|
|
}
|
|
}
|
|
|
|
module.exports = _arrayWithoutHoles;
|
|
|
|
/***/ }),
|
|
/* 6 */
|
|
/***/ (function(module, exports) {
|
|
|
|
function _iterableToArray(iter) {
|
|
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
|
}
|
|
|
|
module.exports = _iterableToArray;
|
|
|
|
/***/ }),
|
|
/* 7 */
|
|
/***/ (function(module, exports) {
|
|
|
|
function _nonIterableSpread() {
|
|
throw new TypeError("Invalid attempt to spread non-iterable instance");
|
|
}
|
|
|
|
module.exports = _nonIterableSpread;
|
|
|
|
/***/ }),
|
|
/* 8 */
|
|
/***/ (function(module, exports) {
|
|
|
|
function _defineProperty(obj, key, value) {
|
|
if (key in obj) {
|
|
Object.defineProperty(obj, key, {
|
|
value: value,
|
|
enumerable: true,
|
|
configurable: true,
|
|
writable: true
|
|
});
|
|
} else {
|
|
obj[key] = value;
|
|
}
|
|
|
|
return obj;
|
|
}
|
|
|
|
module.exports = _defineProperty;
|
|
|
|
/***/ }),
|
|
/* 9 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
function fuzzysearch (needle, haystack) {
|
|
var tlen = haystack.length;
|
|
var qlen = needle.length;
|
|
if (qlen > tlen) {
|
|
return false;
|
|
}
|
|
if (qlen === tlen) {
|
|
return needle === haystack;
|
|
}
|
|
outer: for (var i = 0, j = 0; i < qlen; i++) {
|
|
var nch = needle.charCodeAt(i);
|
|
while (j < tlen) {
|
|
if (haystack.charCodeAt(j++) === nch) {
|
|
continue outer;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
module.exports = fuzzysearch;
|
|
|
|
|
|
/***/ }),
|
|
/* 10 */
|
|
/***/ (function(module, exports) {
|
|
|
|
/**
|
|
* This method returns `undefined`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @since 2.3.0
|
|
* @category Util
|
|
* @example
|
|
*
|
|
* _.times(2, _.noop);
|
|
* // => [undefined, undefined]
|
|
*/
|
|
function noop() {
|
|
// No operation performed.
|
|
}
|
|
|
|
module.exports = noop;
|
|
|
|
|
|
/***/ }),
|
|
/* 11 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var isObject = __webpack_require__(12),
|
|
now = __webpack_require__(13),
|
|
toNumber = __webpack_require__(17);
|
|
|
|
/** Error message constants. */
|
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
|
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
var nativeMax = Math.max,
|
|
nativeMin = Math.min;
|
|
|
|
/**
|
|
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
* milliseconds have elapsed since the last time the debounced function was
|
|
* invoked. The debounced function comes with a `cancel` method to cancel
|
|
* delayed `func` invocations and a `flush` method to immediately invoke them.
|
|
* Provide `options` to indicate whether `func` should be invoked on the
|
|
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
|
|
* with the last arguments provided to the debounced function. Subsequent
|
|
* calls to the debounced function return the result of the last `func`
|
|
* invocation.
|
|
*
|
|
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
* invoked on the trailing edge of the timeout only if the debounced function
|
|
* is invoked more than once during the `wait` timeout.
|
|
*
|
|
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
*
|
|
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
* for details over the differences between `_.debounce` and `_.throttle`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @since 0.1.0
|
|
* @category Function
|
|
* @param {Function} func The function to debounce.
|
|
* @param {number} [wait=0] The number of milliseconds to delay.
|
|
* @param {Object} [options={}] The options object.
|
|
* @param {boolean} [options.leading=false]
|
|
* Specify invoking on the leading edge of the timeout.
|
|
* @param {number} [options.maxWait]
|
|
* The maximum time `func` is allowed to be delayed before it's invoked.
|
|
* @param {boolean} [options.trailing=true]
|
|
* Specify invoking on the trailing edge of the timeout.
|
|
* @returns {Function} Returns the new debounced function.
|
|
* @example
|
|
*
|
|
* // Avoid costly calculations while the window size is in flux.
|
|
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
|
|
*
|
|
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
|
* jQuery(element).on('click', _.debounce(sendMail, 300, {
|
|
* 'leading': true,
|
|
* 'trailing': false
|
|
* }));
|
|
*
|
|
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
|
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
|
|
* var source = new EventSource('/stream');
|
|
* jQuery(source).on('message', debounced);
|
|
*
|
|
* // Cancel the trailing debounced invocation.
|
|
* jQuery(window).on('popstate', debounced.cancel);
|
|
*/
|
|
function debounce(func, wait, options) {
|
|
var lastArgs,
|
|
lastThis,
|
|
maxWait,
|
|
result,
|
|
timerId,
|
|
lastCallTime,
|
|
lastInvokeTime = 0,
|
|
leading = false,
|
|
maxing = false,
|
|
trailing = true;
|
|
|
|
if (typeof func != 'function') {
|
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
}
|
|
wait = toNumber(wait) || 0;
|
|
if (isObject(options)) {
|
|
leading = !!options.leading;
|
|
maxing = 'maxWait' in options;
|
|
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
}
|
|
|
|
function invokeFunc(time) {
|
|
var args = lastArgs,
|
|
thisArg = lastThis;
|
|
|
|
lastArgs = lastThis = undefined;
|
|
lastInvokeTime = time;
|
|
result = func.apply(thisArg, args);
|
|
return result;
|
|
}
|
|
|
|
function leadingEdge(time) {
|
|
// Reset any `maxWait` timer.
|
|
lastInvokeTime = time;
|
|
// Start the timer for the trailing edge.
|
|
timerId = setTimeout(timerExpired, wait);
|
|
// Invoke the leading edge.
|
|
return leading ? invokeFunc(time) : result;
|
|
}
|
|
|
|
function remainingWait(time) {
|
|
var timeSinceLastCall = time - lastCallTime,
|
|
timeSinceLastInvoke = time - lastInvokeTime,
|
|
timeWaiting = wait - timeSinceLastCall;
|
|
|
|
return maxing
|
|
? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
|
|
: timeWaiting;
|
|
}
|
|
|
|
function shouldInvoke(time) {
|
|
var timeSinceLastCall = time - lastCallTime,
|
|
timeSinceLastInvoke = time - lastInvokeTime;
|
|
|
|
// Either this is the first call, activity has stopped and we're at the
|
|
// trailing edge, the system time has gone backwards and we're treating
|
|
// it as the trailing edge, or we've hit the `maxWait` limit.
|
|
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
|
|
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
|
|
}
|
|
|
|
function timerExpired() {
|
|
var time = now();
|
|
if (shouldInvoke(time)) {
|
|
return trailingEdge(time);
|
|
}
|
|
// Restart the timer.
|
|
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
}
|
|
|
|
function trailingEdge(time) {
|
|
timerId = undefined;
|
|
|
|
// Only invoke if we have `lastArgs` which means `func` has been
|
|
// debounced at least once.
|
|
if (trailing && lastArgs) {
|
|
return invokeFunc(time);
|
|
}
|
|
lastArgs = lastThis = undefined;
|
|
return result;
|
|
}
|
|
|
|
function cancel() {
|
|
if (timerId !== undefined) {
|
|
clearTimeout(timerId);
|
|
}
|
|
lastInvokeTime = 0;
|
|
lastArgs = lastCallTime = lastThis = timerId = undefined;
|
|
}
|
|
|
|
function flush() {
|
|
return timerId === undefined ? result : trailingEdge(now());
|
|
}
|
|
|
|
function debounced() {
|
|
var time = now(),
|
|
isInvoking = shouldInvoke(time);
|
|
|
|
lastArgs = arguments;
|
|
lastThis = this;
|
|
lastCallTime = time;
|
|
|
|
if (isInvoking) {
|
|
if (timerId === undefined) {
|
|
return leadingEdge(lastCallTime);
|
|
}
|
|
if (maxing) {
|
|
// Handle invocations in a tight loop.
|
|
clearTimeout(timerId);
|
|
timerId = setTimeout(timerExpired, wait);
|
|
return invokeFunc(lastCallTime);
|
|
}
|
|
}
|
|
if (timerId === undefined) {
|
|
timerId = setTimeout(timerExpired, wait);
|
|
}
|
|
return result;
|
|
}
|
|
debounced.cancel = cancel;
|
|
debounced.flush = flush;
|
|
return debounced;
|
|
}
|
|
|
|
module.exports = debounce;
|
|
|
|
|
|
/***/ }),
|
|
/* 12 */
|
|
/***/ (function(module, exports) {
|
|
|
|
/**
|
|
* Checks if `value` is the
|
|
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @since 0.1.0
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
* @example
|
|
*
|
|
* _.isObject({});
|
|
* // => true
|
|
*
|
|
* _.isObject([1, 2, 3]);
|
|
* // => true
|
|
*
|
|
* _.isObject(_.noop);
|
|
* // => true
|
|
*
|
|
* _.isObject(null);
|
|
* // => false
|
|
*/
|
|
function isObject(value) {
|
|
var type = typeof value;
|
|
return value != null && (type == 'object' || type == 'function');
|
|
}
|
|
|
|
module.exports = isObject;
|
|
|
|
|
|
/***/ }),
|
|
/* 13 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var root = __webpack_require__(14);
|
|
|
|
/**
|
|
* Gets the timestamp of the number of milliseconds that have elapsed since
|
|
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @since 2.4.0
|
|
* @category Date
|
|
* @returns {number} Returns the timestamp.
|
|
* @example
|
|
*
|
|
* _.defer(function(stamp) {
|
|
* console.log(_.now() - stamp);
|
|
* }, _.now());
|
|
* // => Logs the number of milliseconds it took for the deferred invocation.
|
|
*/
|
|
var now = function() {
|
|
return root.Date.now();
|
|
};
|
|
|
|
module.exports = now;
|
|
|
|
|
|
/***/ }),
|
|
/* 14 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var freeGlobal = __webpack_require__(15);
|
|
|
|
/** Detect free variable `self`. */
|
|
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
|
|
/** Used as a reference to the global object. */
|
|
var root = freeGlobal || freeSelf || Function('return this')();
|
|
|
|
module.exports = root;
|
|
|
|
|
|
/***/ }),
|
|
/* 15 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
/* WEBPACK VAR INJECTION */(function(global) {/** Detect free variable `global` from Node.js. */
|
|
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
|
|
module.exports = freeGlobal;
|
|
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(16)))
|
|
|
|
/***/ }),
|
|
/* 16 */
|
|
/***/ (function(module, exports) {
|
|
|
|
var g;
|
|
|
|
// This works in non-strict mode
|
|
g = (function() {
|
|
return this;
|
|
})();
|
|
|
|
try {
|
|
// This works if eval is allowed (see CSP)
|
|
g = g || new Function("return this")();
|
|
} catch (e) {
|
|
// This works if the window reference is available
|
|
if (typeof window === "object") g = window;
|
|
}
|
|
|
|
// g can still be undefined, but nothing to do about it...
|
|
// We return undefined, instead of nothing here, so it's
|
|
// easier to handle this case. if(!global) { ...}
|
|
|
|
module.exports = g;
|
|
|
|
|
|
/***/ }),
|
|
/* 17 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var isObject = __webpack_require__(12),
|
|
isSymbol = __webpack_require__(18);
|
|
|
|
/** Used as references for various `Number` constants. */
|
|
var NAN = 0 / 0;
|
|
|
|
/** Used to match leading and trailing whitespace. */
|
|
var reTrim = /^\s+|\s+$/g;
|
|
|
|
/** Used to detect bad signed hexadecimal string values. */
|
|
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
|
|
/** Used to detect binary string values. */
|
|
var reIsBinary = /^0b[01]+$/i;
|
|
|
|
/** Used to detect octal string values. */
|
|
var reIsOctal = /^0o[0-7]+$/i;
|
|
|
|
/** Built-in method references without a dependency on `root`. */
|
|
var freeParseInt = parseInt;
|
|
|
|
/**
|
|
* Converts `value` to a number.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @since 4.0.0
|
|
* @category Lang
|
|
* @param {*} value The value to process.
|
|
* @returns {number} Returns the number.
|
|
* @example
|
|
*
|
|
* _.toNumber(3.2);
|
|
* // => 3.2
|
|
*
|
|
* _.toNumber(Number.MIN_VALUE);
|
|
* // => 5e-324
|
|
*
|
|
* _.toNumber(Infinity);
|
|
* // => Infinity
|
|
*
|
|
* _.toNumber('3.2');
|
|
* // => 3.2
|
|
*/
|
|
function toNumber(value) {
|
|
if (typeof value == 'number') {
|
|
return value;
|
|
}
|
|
if (isSymbol(value)) {
|
|
return NAN;
|
|
}
|
|
if (isObject(value)) {
|
|
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
|
value = isObject(other) ? (other + '') : other;
|
|
}
|
|
if (typeof value != 'string') {
|
|
return value === 0 ? value : +value;
|
|
}
|
|
value = value.replace(reTrim, '');
|
|
var isBinary = reIsBinary.test(value);
|
|
return (isBinary || reIsOctal.test(value))
|
|
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
|
: (reIsBadHex.test(value) ? NAN : +value);
|
|
}
|
|
|
|
module.exports = toNumber;
|
|
|
|
|
|
/***/ }),
|
|
/* 18 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var baseGetTag = __webpack_require__(19),
|
|
isObjectLike = __webpack_require__(23);
|
|
|
|
/** `Object#toString` result references. */
|
|
var symbolTag = '[object Symbol]';
|
|
|
|
/**
|
|
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @since 4.0.0
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
* @example
|
|
*
|
|
* _.isSymbol(Symbol.iterator);
|
|
* // => true
|
|
*
|
|
* _.isSymbol('abc');
|
|
* // => false
|
|
*/
|
|
function isSymbol(value) {
|
|
return typeof value == 'symbol' ||
|
|
(isObjectLike(value) && baseGetTag(value) == symbolTag);
|
|
}
|
|
|
|
module.exports = isSymbol;
|
|
|
|
|
|
/***/ }),
|
|
/* 19 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var Symbol = __webpack_require__(20),
|
|
getRawTag = __webpack_require__(21),
|
|
objectToString = __webpack_require__(22);
|
|
|
|
/** `Object#toString` result references. */
|
|
var nullTag = '[object Null]',
|
|
undefinedTag = '[object Undefined]';
|
|
|
|
/** Built-in value references. */
|
|
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
|
|
|
/**
|
|
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to query.
|
|
* @returns {string} Returns the `toStringTag`.
|
|
*/
|
|
function baseGetTag(value) {
|
|
if (value == null) {
|
|
return value === undefined ? undefinedTag : nullTag;
|
|
}
|
|
return (symToStringTag && symToStringTag in Object(value))
|
|
? getRawTag(value)
|
|
: objectToString(value);
|
|
}
|
|
|
|
module.exports = baseGetTag;
|
|
|
|
|
|
/***/ }),
|
|
/* 20 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var root = __webpack_require__(14);
|
|
|
|
/** Built-in value references. */
|
|
var Symbol = root.Symbol;
|
|
|
|
module.exports = Symbol;
|
|
|
|
|
|
/***/ }),
|
|
/* 21 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var Symbol = __webpack_require__(20);
|
|
|
|
/** Used for built-in method references. */
|
|
var objectProto = Object.prototype;
|
|
|
|
/** Used to check objects for own properties. */
|
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
|
|
/**
|
|
* Used to resolve the
|
|
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
* of values.
|
|
*/
|
|
var nativeObjectToString = objectProto.toString;
|
|
|
|
/** Built-in value references. */
|
|
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
|
|
|
/**
|
|
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to query.
|
|
* @returns {string} Returns the raw `toStringTag`.
|
|
*/
|
|
function getRawTag(value) {
|
|
var isOwn = hasOwnProperty.call(value, symToStringTag),
|
|
tag = value[symToStringTag];
|
|
|
|
try {
|
|
value[symToStringTag] = undefined;
|
|
var unmasked = true;
|
|
} catch (e) {}
|
|
|
|
var result = nativeObjectToString.call(value);
|
|
if (unmasked) {
|
|
if (isOwn) {
|
|
value[symToStringTag] = tag;
|
|
} else {
|
|
delete value[symToStringTag];
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
module.exports = getRawTag;
|
|
|
|
|
|
/***/ }),
|
|
/* 22 */
|
|
/***/ (function(module, exports) {
|
|
|
|
/** Used for built-in method references. */
|
|
var objectProto = Object.prototype;
|
|
|
|
/**
|
|
* Used to resolve the
|
|
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
* of values.
|
|
*/
|
|
var nativeObjectToString = objectProto.toString;
|
|
|
|
/**
|
|
* Converts `value` to a string using `Object.prototype.toString`.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to convert.
|
|
* @returns {string} Returns the converted string.
|
|
*/
|
|
function objectToString(value) {
|
|
return nativeObjectToString.call(value);
|
|
}
|
|
|
|
module.exports = objectToString;
|
|
|
|
|
|
/***/ }),
|
|
/* 23 */
|
|
/***/ (function(module, exports) {
|
|
|
|
/**
|
|
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
* and has a `typeof` result of "object".
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @since 4.0.0
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
* @example
|
|
*
|
|
* _.isObjectLike({});
|
|
* // => true
|
|
*
|
|
* _.isObjectLike([1, 2, 3]);
|
|
* // => true
|
|
*
|
|
* _.isObjectLike(_.noop);
|
|
* // => false
|
|
*
|
|
* _.isObjectLike(null);
|
|
* // => false
|
|
*/
|
|
function isObjectLike(value) {
|
|
return value != null && typeof value == 'object';
|
|
}
|
|
|
|
module.exports = isObjectLike;
|
|
|
|
|
|
/***/ }),
|
|
/* 24 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = isPromise;
|
|
|
|
function isPromise(obj) {
|
|
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
/* 25 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var before = __webpack_require__(26);
|
|
|
|
/**
|
|
* Creates a function that is restricted to invoking `func` once. Repeat calls
|
|
* to the function return the value of the first invocation. The `func` is
|
|
* invoked with the `this` binding and arguments of the created function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @since 0.1.0
|
|
* @category Function
|
|
* @param {Function} func The function to restrict.
|
|
* @returns {Function} Returns the new restricted function.
|
|
* @example
|
|
*
|
|
* var initialize = _.once(createApplication);
|
|
* initialize();
|
|
* initialize();
|
|
* // => `createApplication` is invoked once
|
|
*/
|
|
function once(func) {
|
|
return before(2, func);
|
|
}
|
|
|
|
module.exports = once;
|
|
|
|
|
|
/***/ }),
|
|
/* 26 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var toInteger = __webpack_require__(27);
|
|
|
|
/** Error message constants. */
|
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
|
|
/**
|
|
* Creates a function that invokes `func`, with the `this` binding and arguments
|
|
* of the created function, while it's called less than `n` times. Subsequent
|
|
* calls to the created function return the result of the last `func` invocation.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @since 3.0.0
|
|
* @category Function
|
|
* @param {number} n The number of calls at which `func` is no longer invoked.
|
|
* @param {Function} func The function to restrict.
|
|
* @returns {Function} Returns the new restricted function.
|
|
* @example
|
|
*
|
|
* jQuery(element).on('click', _.before(5, addContactToList));
|
|
* // => Allows adding up to 4 contacts to the list.
|
|
*/
|
|
function before(n, func) {
|
|
var result;
|
|
if (typeof func != 'function') {
|
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
}
|
|
n = toInteger(n);
|
|
return function() {
|
|
if (--n > 0) {
|
|
result = func.apply(this, arguments);
|
|
}
|
|
if (n <= 1) {
|
|
func = undefined;
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
|
|
module.exports = before;
|
|
|
|
|
|
/***/ }),
|
|
/* 27 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var toFinite = __webpack_require__(28);
|
|
|
|
/**
|
|
* Converts `value` to an integer.
|
|
*
|
|
* **Note:** This method is loosely based on
|
|
* [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @since 4.0.0
|
|
* @category Lang
|
|
* @param {*} value The value to convert.
|
|
* @returns {number} Returns the converted integer.
|
|
* @example
|
|
*
|
|
* _.toInteger(3.2);
|
|
* // => 3
|
|
*
|
|
* _.toInteger(Number.MIN_VALUE);
|
|
* // => 0
|
|
*
|
|
* _.toInteger(Infinity);
|
|
* // => 1.7976931348623157e+308
|
|
*
|
|
* _.toInteger('3.2');
|
|
* // => 3
|
|
*/
|
|
function toInteger(value) {
|
|
var result = toFinite(value),
|
|
remainder = result % 1;
|
|
|
|
return result === result ? (remainder ? result - remainder : result) : 0;
|
|
}
|
|
|
|
module.exports = toInteger;
|
|
|
|
|
|
/***/ }),
|
|
/* 28 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var toNumber = __webpack_require__(17);
|
|
|
|
/** Used as references for various `Number` constants. */
|
|
var INFINITY = 1 / 0,
|
|
MAX_INTEGER = 1.7976931348623157e+308;
|
|
|
|
/**
|
|
* Converts `value` to a finite number.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @since 4.12.0
|
|
* @category Lang
|
|
* @param {*} value The value to convert.
|
|
* @returns {number} Returns the converted number.
|
|
* @example
|
|
*
|
|
* _.toFinite(3.2);
|
|
* // => 3.2
|
|
*
|
|
* _.toFinite(Number.MIN_VALUE);
|
|
* // => 5e-324
|
|
*
|
|
* _.toFinite(Infinity);
|
|
* // => 1.7976931348623157e+308
|
|
*
|
|
* _.toFinite('3.2');
|
|
* // => 3.2
|
|
*/
|
|
function toFinite(value) {
|
|
if (!value) {
|
|
return value === 0 ? value : 0;
|
|
}
|
|
value = toNumber(value);
|
|
if (value === INFINITY || value === -INFINITY) {
|
|
var sign = (value < 0 ? -1 : 1);
|
|
return sign * MAX_INTEGER;
|
|
}
|
|
return value === value ? value : 0;
|
|
}
|
|
|
|
module.exports = toFinite;
|
|
|
|
|
|
/***/ }),
|
|
/* 29 */
|
|
/***/ (function(module, exports) {
|
|
|
|
/**
|
|
* This method returns the first argument it receives.
|
|
*
|
|
* @static
|
|
* @since 0.1.0
|
|
* @memberOf _
|
|
* @category Util
|
|
* @param {*} value Any value.
|
|
* @returns {*} Returns `value`.
|
|
* @example
|
|
*
|
|
* var object = { 'a': 1 };
|
|
*
|
|
* console.log(_.identity(object) === object);
|
|
* // => true
|
|
*/
|
|
function identity(value) {
|
|
return value;
|
|
}
|
|
|
|
module.exports = identity;
|
|
|
|
|
|
/***/ }),
|
|
/* 30 */
|
|
/***/ (function(module, exports) {
|
|
|
|
/**
|
|
* Creates a function that returns `value`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @since 2.4.0
|
|
* @category Util
|
|
* @param {*} value The value to return from the new function.
|
|
* @returns {Function} Returns the new constant function.
|
|
* @example
|
|
*
|
|
* var objects = _.times(2, _.constant({ 'a': 1 }));
|
|
*
|
|
* console.log(objects);
|
|
* // => [{ 'a': 1 }, { 'a': 1 }]
|
|
*
|
|
* console.log(objects[0] === objects[1]);
|
|
* // => true
|
|
*/
|
|
function constant(value) {
|
|
return function() {
|
|
return value;
|
|
};
|
|
}
|
|
|
|
module.exports = constant;
|
|
|
|
|
|
/***/ }),
|
|
/* 31 */
|
|
/***/ (function(module, exports) {
|
|
|
|
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }
|
|
|
|
function _typeof(obj) {
|
|
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
|
|
module.exports = _typeof = function _typeof(obj) {
|
|
return _typeof2(obj);
|
|
};
|
|
} else {
|
|
module.exports = _typeof = function _typeof(obj) {
|
|
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
|
|
};
|
|
}
|
|
|
|
return _typeof(obj);
|
|
}
|
|
|
|
module.exports = _typeof;
|
|
|
|
/***/ }),
|
|
/* 32 */
|
|
/***/ (function(module, exports) {
|
|
|
|
/**
|
|
* Gets the last element of `array`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @since 0.1.0
|
|
* @category Array
|
|
* @param {Array} array The array to query.
|
|
* @returns {*} Returns the last element of `array`.
|
|
* @example
|
|
*
|
|
* _.last([1, 2, 3]);
|
|
* // => 3
|
|
*/
|
|
function last(array) {
|
|
var length = array == null ? 0 : array.length;
|
|
return length ? array[length - 1] : undefined;
|
|
}
|
|
|
|
module.exports = last;
|
|
|
|
|
|
/***/ }),
|
|
/* 33 */
|
|
/***/ (function(module, exports) {
|
|
|
|
var nestRE = /^(attrs|props|on|nativeOn|class|style|hook)$/
|
|
|
|
module.exports = function mergeJSXProps (objs) {
|
|
return objs.reduce(function (a, b) {
|
|
var aa, bb, key, nestedKey, temp
|
|
for (key in b) {
|
|
aa = a[key]
|
|
bb = b[key]
|
|
if (aa && nestRE.test(key)) {
|
|
// normalize class
|
|
if (key === 'class') {
|
|
if (typeof aa === 'string') {
|
|
temp = aa
|
|
a[key] = aa = {}
|
|
aa[temp] = true
|
|
}
|
|
if (typeof bb === 'string') {
|
|
temp = bb
|
|
b[key] = bb = {}
|
|
bb[temp] = true
|
|
}
|
|
}
|
|
if (key === 'on' || key === 'nativeOn' || key === 'hook') {
|
|
// merge functions
|
|
for (nestedKey in bb) {
|
|
aa[nestedKey] = mergeFn(aa[nestedKey], bb[nestedKey])
|
|
}
|
|
} else if (Array.isArray(aa)) {
|
|
a[key] = aa.concat(bb)
|
|
} else if (Array.isArray(bb)) {
|
|
a[key] = [aa].concat(bb)
|
|
} else {
|
|
for (nestedKey in bb) {
|
|
aa[nestedKey] = bb[nestedKey]
|
|
}
|
|
}
|
|
} else {
|
|
a[key] = b[key]
|
|
}
|
|
}
|
|
return a
|
|
}, {})
|
|
}
|
|
|
|
function mergeFn (a, b) {
|
|
return function () {
|
|
a && a.apply(this, arguments)
|
|
b && b.apply(this, arguments)
|
|
}
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
/* 34 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = __WEBPACK_EXTERNAL_MODULE__34__;
|
|
|
|
/***/ }),
|
|
/* 35 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
|
/***/ }),
|
|
/* 36 */
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/slicedToArray.js
|
|
var slicedToArray = __webpack_require__(0);
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/toConsumableArray.js
|
|
var toConsumableArray = __webpack_require__(4);
|
|
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
|
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/defineProperty.js
|
|
var defineProperty = __webpack_require__(8);
|
|
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);
|
|
|
|
// EXTERNAL MODULE: ./node_modules/fuzzysearch/index.js
|
|
var fuzzysearch = __webpack_require__(9);
|
|
var fuzzysearch_default = /*#__PURE__*/__webpack_require__.n(fuzzysearch);
|
|
|
|
// EXTERNAL MODULE: ./node_modules/lodash/noop.js
|
|
var noop = __webpack_require__(10);
|
|
|
|
// CONCATENATED MODULE: ./src/utils/noop.js
|
|
|
|
// CONCATENATED MODULE: ./src/utils/warning.js
|
|
|
|
|
|
var warning_warning = false ? undefined : function warning(checker, complainer) {
|
|
if (!checker()) {
|
|
var _console;
|
|
|
|
var message = ['[Vue-Treeselect Warning]'].concat(complainer());
|
|
|
|
(_console = console).error.apply(_console, toConsumableArray_default()(message));
|
|
}
|
|
};
|
|
// CONCATENATED MODULE: ./src/utils/onLeftClick.js
|
|
function onLeftClick(mouseDownHandler) {
|
|
return function onMouseDown(evt) {
|
|
if (evt.type === 'mousedown' && evt.button === 0) {
|
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
args[_key - 1] = arguments[_key];
|
|
}
|
|
|
|
mouseDownHandler.call.apply(mouseDownHandler, [this, evt].concat(args));
|
|
}
|
|
};
|
|
}
|
|
// CONCATENATED MODULE: ./src/utils/scrollIntoView.js
|
|
function scrollIntoView($scrollingEl, $focusedEl) {
|
|
var scrollingReact = $scrollingEl.getBoundingClientRect();
|
|
var focusedRect = $focusedEl.getBoundingClientRect();
|
|
var overScroll = $focusedEl.offsetHeight / 3;
|
|
|
|
if (focusedRect.bottom + overScroll > scrollingReact.bottom) {
|
|
$scrollingEl.scrollTop = Math.min($focusedEl.offsetTop + $focusedEl.clientHeight - $scrollingEl.offsetHeight + overScroll, $scrollingEl.scrollHeight);
|
|
} else if (focusedRect.top - overScroll < scrollingReact.top) {
|
|
$scrollingEl.scrollTop = Math.max($focusedEl.offsetTop - overScroll, 0);
|
|
}
|
|
}
|
|
// EXTERNAL MODULE: ./node_modules/lodash/debounce.js
|
|
var debounce = __webpack_require__(11);
|
|
var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce);
|
|
|
|
// CONCATENATED MODULE: ./src/utils/debounce.js
|
|
|
|
// CONCATENATED MODULE: ./node_modules/watch-size/index.es.mjs
|
|
var index_es_index = (function (element, listener) {
|
|
var expand = document.createElement('_');
|
|
var shrink = expand.appendChild(document.createElement('_'));
|
|
var expandChild = expand.appendChild(document.createElement('_'));
|
|
var shrinkChild = shrink.appendChild(document.createElement('_'));
|
|
|
|
var lastWidth = void 0,
|
|
lastHeight = void 0;
|
|
|
|
shrink.style.cssText = expand.style.cssText = 'height:100%;left:0;opacity:0;overflow:hidden;pointer-events:none;position:absolute;top:0;transition:0s;width:100%;z-index:-1';
|
|
shrinkChild.style.cssText = expandChild.style.cssText = 'display:block;height:100%;transition:0s;width:100%';
|
|
shrinkChild.style.width = shrinkChild.style.height = '200%';
|
|
|
|
element.appendChild(expand);
|
|
|
|
test();
|
|
|
|
return stop;
|
|
|
|
function test() {
|
|
unbind();
|
|
|
|
var width = element.offsetWidth;
|
|
var height = element.offsetHeight;
|
|
|
|
if (width !== lastWidth || height !== lastHeight) {
|
|
lastWidth = width;
|
|
lastHeight = height;
|
|
|
|
expandChild.style.width = width * 2 + 'px';
|
|
expandChild.style.height = height * 2 + 'px';
|
|
|
|
expand.scrollLeft = expand.scrollWidth;
|
|
expand.scrollTop = expand.scrollHeight;
|
|
shrink.scrollLeft = shrink.scrollWidth;
|
|
shrink.scrollTop = shrink.scrollHeight;
|
|
|
|
listener({ width: width, height: height });
|
|
}
|
|
|
|
shrink.addEventListener('scroll', test);
|
|
expand.addEventListener('scroll', test);
|
|
}
|
|
|
|
function unbind() {
|
|
shrink.removeEventListener('scroll', test);
|
|
expand.removeEventListener('scroll', test);
|
|
}
|
|
|
|
function stop() {
|
|
unbind();
|
|
|
|
element.removeChild(expand);
|
|
}
|
|
});
|
|
|
|
/* harmony default export */ var index_es = (index_es_index);
|
|
|
|
// CONCATENATED MODULE: ./src/utils/removeFromArray.js
|
|
function removeFromArray(arr, elem) {
|
|
var idx = arr.indexOf(elem);
|
|
if (idx !== -1) arr.splice(idx, 1);
|
|
}
|
|
// CONCATENATED MODULE: ./src/utils/watchSize.js
|
|
|
|
|
|
var intervalId;
|
|
var registered = [];
|
|
var INTERVAL_DURATION = 100;
|
|
|
|
function run() {
|
|
intervalId = setInterval(function () {
|
|
registered.forEach(test);
|
|
}, INTERVAL_DURATION);
|
|
}
|
|
|
|
function stop() {
|
|
clearInterval(intervalId);
|
|
intervalId = null;
|
|
}
|
|
|
|
function test(item) {
|
|
var $el = item.$el,
|
|
listener = item.listener,
|
|
lastWidth = item.lastWidth,
|
|
lastHeight = item.lastHeight;
|
|
var width = $el.offsetWidth;
|
|
var height = $el.offsetHeight;
|
|
|
|
if (lastWidth !== width || lastHeight !== height) {
|
|
item.lastWidth = width;
|
|
item.lastHeight = height;
|
|
listener({
|
|
width: width,
|
|
height: height
|
|
});
|
|
}
|
|
}
|
|
|
|
function watchSizeForIE9($el, listener) {
|
|
var item = {
|
|
$el: $el,
|
|
listener: listener,
|
|
lastWidth: null,
|
|
lastHeight: null
|
|
};
|
|
|
|
var unwatch = function unwatch() {
|
|
removeFromArray(registered, item);
|
|
if (!registered.length) stop();
|
|
};
|
|
|
|
registered.push(item);
|
|
test(item);
|
|
run();
|
|
return unwatch;
|
|
}
|
|
|
|
function watchSize($el, listener) {
|
|
var isIE9 = document.documentMode === 9;
|
|
var locked = true;
|
|
|
|
var wrappedListener = function wrappedListener() {
|
|
return locked || listener.apply(void 0, arguments);
|
|
};
|
|
|
|
var implementation = isIE9 ? watchSizeForIE9 : index_es;
|
|
var removeSizeWatcher = implementation($el, wrappedListener);
|
|
locked = false;
|
|
return removeSizeWatcher;
|
|
}
|
|
// CONCATENATED MODULE: ./src/utils/setupResizeAndScrollEventListeners.js
|
|
function findScrollParents($el) {
|
|
var $scrollParents = [];
|
|
var $parent = $el.parentNode;
|
|
|
|
while ($parent && $parent.nodeName !== 'BODY' && $parent.nodeType === document.ELEMENT_NODE) {
|
|
if (isScrollElment($parent)) $scrollParents.push($parent);
|
|
$parent = $parent.parentNode;
|
|
}
|
|
|
|
$scrollParents.push(window);
|
|
return $scrollParents;
|
|
}
|
|
|
|
function isScrollElment($el) {
|
|
var _getComputedStyle = getComputedStyle($el),
|
|
overflow = _getComputedStyle.overflow,
|
|
overflowX = _getComputedStyle.overflowX,
|
|
overflowY = _getComputedStyle.overflowY;
|
|
|
|
return /(auto|scroll|overlay)/.test(overflow + overflowY + overflowX);
|
|
}
|
|
|
|
function setupResizeAndScrollEventListeners($el, listener) {
|
|
var $scrollParents = findScrollParents($el);
|
|
window.addEventListener('resize', listener, {
|
|
passive: true
|
|
});
|
|
$scrollParents.forEach(function (scrollParent) {
|
|
scrollParent.addEventListener('scroll', listener, {
|
|
passive: true
|
|
});
|
|
});
|
|
return function removeEventListeners() {
|
|
window.removeEventListener('resize', listener, {
|
|
passive: true
|
|
});
|
|
$scrollParents.forEach(function ($scrollParent) {
|
|
$scrollParent.removeEventListener('scroll', listener, {
|
|
passive: true
|
|
});
|
|
});
|
|
};
|
|
}
|
|
// CONCATENATED MODULE: ./src/utils/isNaN.js
|
|
function isNaN_isNaN(x) {
|
|
return x !== x;
|
|
}
|
|
// EXTERNAL MODULE: ./node_modules/is-promise/index.js
|
|
var is_promise = __webpack_require__(24);
|
|
var is_promise_default = /*#__PURE__*/__webpack_require__.n(is_promise);
|
|
|
|
// CONCATENATED MODULE: ./src/utils/isPromise.js
|
|
|
|
// EXTERNAL MODULE: ./node_modules/lodash/once.js
|
|
var once = __webpack_require__(25);
|
|
var once_default = /*#__PURE__*/__webpack_require__.n(once);
|
|
|
|
// CONCATENATED MODULE: ./src/utils/once.js
|
|
|
|
// EXTERNAL MODULE: ./node_modules/lodash/identity.js
|
|
var identity = __webpack_require__(29);
|
|
var identity_default = /*#__PURE__*/__webpack_require__.n(identity);
|
|
|
|
// CONCATENATED MODULE: ./src/utils/identity.js
|
|
|
|
// EXTERNAL MODULE: ./node_modules/lodash/constant.js
|
|
var constant = __webpack_require__(30);
|
|
var constant_default = /*#__PURE__*/__webpack_require__.n(constant);
|
|
|
|
// CONCATENATED MODULE: ./src/utils/constant.js
|
|
|
|
// CONCATENATED MODULE: ./src/utils/createMap.js
|
|
var createMap = function createMap() {
|
|
return Object.create(null);
|
|
};
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/typeof.js
|
|
var helpers_typeof = __webpack_require__(31);
|
|
var typeof_default = /*#__PURE__*/__webpack_require__.n(helpers_typeof);
|
|
|
|
// CONCATENATED MODULE: ./src/utils/deepExtend.js
|
|
|
|
|
|
function isPlainObject(value) {
|
|
if (value == null || typeof_default()(value) !== 'object') return false;
|
|
return Object.getPrototypeOf(value) === Object.prototype;
|
|
}
|
|
|
|
function copy(obj, key, value) {
|
|
if (isPlainObject(value)) {
|
|
obj[key] || (obj[key] = {});
|
|
deepExtend(obj[key], value);
|
|
} else {
|
|
obj[key] = value;
|
|
}
|
|
}
|
|
|
|
function deepExtend(target, source) {
|
|
if (isPlainObject(source)) {
|
|
var keys = Object.keys(source);
|
|
|
|
for (var i = 0, len = keys.length; i < len; i++) {
|
|
copy(target, keys[i], source[keys[i]]);
|
|
}
|
|
}
|
|
|
|
return target;
|
|
}
|
|
// EXTERNAL MODULE: ./node_modules/lodash/last.js
|
|
var lodash_last = __webpack_require__(32);
|
|
var last_default = /*#__PURE__*/__webpack_require__.n(lodash_last);
|
|
|
|
// CONCATENATED MODULE: ./src/utils/last.js
|
|
|
|
// CONCATENATED MODULE: ./src/utils/includes.js
|
|
function includes(arrOrStr, elem) {
|
|
return arrOrStr.indexOf(elem) !== -1;
|
|
}
|
|
// CONCATENATED MODULE: ./src/utils/find.js
|
|
function find(arr, predicate, ctx) {
|
|
for (var i = 0, len = arr.length; i < len; i++) {
|
|
if (predicate.call(ctx, arr[i], i, arr)) return arr[i];
|
|
}
|
|
|
|
return undefined;
|
|
}
|
|
// CONCATENATED MODULE: ./src/utils/quickDiff.js
|
|
function quickDiff(arrA, arrB) {
|
|
if (arrA.length !== arrB.length) return true;
|
|
|
|
for (var i = 0; i < arrA.length; i++) {
|
|
if (arrA[i] !== arrB[i]) return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
// CONCATENATED MODULE: ./src/utils/index.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CONCATENATED MODULE: ./src/constants.js
|
|
var NO_PARENT_NODE = null;
|
|
var UNCHECKED = 0;
|
|
var INDETERMINATE = 1;
|
|
var CHECKED = 2;
|
|
var ALL_CHILDREN = 'ALL_CHILDREN';
|
|
var ALL_DESCENDANTS = 'ALL_DESCENDANTS';
|
|
var LEAF_CHILDREN = 'LEAF_CHILDREN';
|
|
var LEAF_DESCENDANTS = 'LEAF_DESCENDANTS';
|
|
var LOAD_ROOT_OPTIONS = 'LOAD_ROOT_OPTIONS';
|
|
var LOAD_CHILDREN_OPTIONS = 'LOAD_CHILDREN_OPTIONS';
|
|
var ASYNC_SEARCH = 'ASYNC_SEARCH';
|
|
var ALL = 'ALL';
|
|
var BRANCH_PRIORITY = 'BRANCH_PRIORITY';
|
|
var LEAF_PRIORITY = 'LEAF_PRIORITY';
|
|
var ALL_WITH_INDETERMINATE = 'ALL_WITH_INDETERMINATE';
|
|
var ORDER_SELECTED = 'ORDER_SELECTED';
|
|
var LEVEL = 'LEVEL';
|
|
var INDEX = 'INDEX';
|
|
var KEY_CODES = {
|
|
BACKSPACE: 8,
|
|
ENTER: 13,
|
|
ESCAPE: 27,
|
|
END: 35,
|
|
HOME: 36,
|
|
ARROW_LEFT: 37,
|
|
ARROW_UP: 38,
|
|
ARROW_RIGHT: 39,
|
|
ARROW_DOWN: 40,
|
|
DELETE: 46
|
|
};
|
|
var INPUT_DEBOUNCE_DELAY = false ? undefined : 200;
|
|
var MIN_INPUT_WIDTH = 5;
|
|
var MENU_BUFFER = 40;
|
|
// CONCATENATED MODULE: ./src/mixins/treeselectMixin.js
|
|
|
|
|
|
|
|
|
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
|
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
|
|
|
|
|
|
|
|
|
|
function sortValueByIndex(a, b) {
|
|
var i = 0;
|
|
|
|
do {
|
|
if (a.level < i) return -1;
|
|
if (b.level < i) return 1;
|
|
if (a.index[i] !== b.index[i]) return a.index[i] - b.index[i];
|
|
i++;
|
|
} while (true);
|
|
}
|
|
|
|
function sortValueByLevel(a, b) {
|
|
return a.level === b.level ? sortValueByIndex(a, b) : a.level - b.level;
|
|
}
|
|
|
|
function createAsyncOptionsStates() {
|
|
return {
|
|
isLoaded: false,
|
|
isLoading: false,
|
|
loadingError: ''
|
|
};
|
|
}
|
|
|
|
function stringifyOptionPropValue(value) {
|
|
if (typeof value === 'string') return value;
|
|
if (typeof value === 'number' && !isNaN_isNaN(value)) return value + '';
|
|
return '';
|
|
}
|
|
|
|
function match(enableFuzzyMatch, needle, haystack) {
|
|
return enableFuzzyMatch ? fuzzysearch_default()(needle, haystack) : includes(haystack, needle);
|
|
}
|
|
|
|
function getErrorMessage(err) {
|
|
return err.message || String(err);
|
|
}
|
|
|
|
var instanceId = 0;
|
|
/* harmony default export */ var treeselectMixin = ({
|
|
provide: function provide() {
|
|
return {
|
|
instance: this
|
|
};
|
|
},
|
|
props: {
|
|
allowClearingDisabled: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
allowSelectingDisabledDescendants: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
alwaysOpen: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
appendToBody: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
async: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
autoFocus: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
autoLoadRootOptions: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
autoDeselectAncestors: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
autoDeselectDescendants: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
autoSelectAncestors: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
autoSelectDescendants: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
backspaceRemoves: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
beforeClearAll: {
|
|
type: Function,
|
|
default: constant_default()(true)
|
|
},
|
|
branchNodesFirst: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
cacheOptions: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
clearable: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
clearAllText: {
|
|
type: String,
|
|
default: 'Clear all'
|
|
},
|
|
clearOnSelect: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
clearValueText: {
|
|
type: String,
|
|
default: 'Clear value'
|
|
},
|
|
closeOnSelect: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
defaultExpandLevel: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
defaultOptions: {
|
|
default: false
|
|
},
|
|
deleteRemoves: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
delimiter: {
|
|
type: String,
|
|
default: ','
|
|
},
|
|
flattenSearchResults: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
disableBranchNodes: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
disabled: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
disableFuzzyMatching: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
flat: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
instanceId: {
|
|
default: function _default() {
|
|
return "".concat(instanceId++, "$$");
|
|
},
|
|
type: [String, Number]
|
|
},
|
|
joinValues: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
limit: {
|
|
type: Number,
|
|
default: Infinity
|
|
},
|
|
limitText: {
|
|
type: Function,
|
|
default: function limitTextDefault(count) {
|
|
return "and ".concat(count, " more");
|
|
}
|
|
},
|
|
loadingText: {
|
|
type: String,
|
|
default: 'Loading...'
|
|
},
|
|
loadOptions: {
|
|
type: Function
|
|
},
|
|
matchKeys: {
|
|
type: Array,
|
|
default: constant_default()(['label'])
|
|
},
|
|
maxHeight: {
|
|
type: Number,
|
|
default: 300
|
|
},
|
|
multiple: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
name: {
|
|
type: String
|
|
},
|
|
noChildrenText: {
|
|
type: String,
|
|
default: 'No sub-options.'
|
|
},
|
|
noOptionsText: {
|
|
type: String,
|
|
default: 'No options available.'
|
|
},
|
|
noResultsText: {
|
|
type: String,
|
|
default: 'No results found...'
|
|
},
|
|
normalizer: {
|
|
type: Function,
|
|
default: identity_default.a
|
|
},
|
|
openDirection: {
|
|
type: String,
|
|
default: 'auto',
|
|
validator: function validator(value) {
|
|
var acceptableValues = ['auto', 'top', 'bottom', 'above', 'below'];
|
|
return includes(acceptableValues, value);
|
|
}
|
|
},
|
|
openOnClick: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
openOnFocus: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
options: {
|
|
type: Array
|
|
},
|
|
placeholder: {
|
|
type: String,
|
|
default: 'Select...'
|
|
},
|
|
required: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
retryText: {
|
|
type: String,
|
|
default: 'Retry?'
|
|
},
|
|
retryTitle: {
|
|
type: String,
|
|
default: 'Click to retry'
|
|
},
|
|
searchable: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
searchNested: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
searchPromptText: {
|
|
type: String,
|
|
default: 'Type to search...'
|
|
},
|
|
showCount: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
showCountOf: {
|
|
type: String,
|
|
default: ALL_CHILDREN,
|
|
validator: function validator(value) {
|
|
var acceptableValues = [ALL_CHILDREN, ALL_DESCENDANTS, LEAF_CHILDREN, LEAF_DESCENDANTS];
|
|
return includes(acceptableValues, value);
|
|
}
|
|
},
|
|
showCountOnSearch: null,
|
|
sortValueBy: {
|
|
type: String,
|
|
default: ORDER_SELECTED,
|
|
validator: function validator(value) {
|
|
var acceptableValues = [ORDER_SELECTED, LEVEL, INDEX];
|
|
return includes(acceptableValues, value);
|
|
}
|
|
},
|
|
tabIndex: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
value: null,
|
|
valueConsistsOf: {
|
|
type: String,
|
|
default: BRANCH_PRIORITY,
|
|
validator: function validator(value) {
|
|
var acceptableValues = [ALL, BRANCH_PRIORITY, LEAF_PRIORITY, ALL_WITH_INDETERMINATE];
|
|
return includes(acceptableValues, value);
|
|
}
|
|
},
|
|
valueFormat: {
|
|
type: String,
|
|
default: 'id'
|
|
},
|
|
zIndex: {
|
|
type: [Number, String],
|
|
default: 999
|
|
}
|
|
},
|
|
data: function data() {
|
|
return {
|
|
trigger: {
|
|
isFocused: false,
|
|
searchQuery: ''
|
|
},
|
|
menu: {
|
|
isOpen: false,
|
|
current: null,
|
|
lastScrollPosition: 0,
|
|
placement: 'bottom'
|
|
},
|
|
forest: {
|
|
normalizedOptions: [],
|
|
nodeMap: createMap(),
|
|
checkedStateMap: createMap(),
|
|
selectedNodeIds: this.extractCheckedNodeIdsFromValue(),
|
|
selectedNodeMap: createMap()
|
|
},
|
|
rootOptionsStates: createAsyncOptionsStates(),
|
|
localSearch: {
|
|
active: false,
|
|
noResults: true,
|
|
countMap: createMap()
|
|
},
|
|
remoteSearch: createMap()
|
|
};
|
|
},
|
|
computed: {
|
|
selectedNodes: function selectedNodes() {
|
|
return this.forest.selectedNodeIds.map(this.getNode);
|
|
},
|
|
internalValue: function internalValue() {
|
|
var _this = this;
|
|
|
|
var internalValue;
|
|
|
|
if (this.single || this.flat || this.disableBranchNodes || this.valueConsistsOf === ALL) {
|
|
internalValue = this.forest.selectedNodeIds.slice();
|
|
} else if (this.valueConsistsOf === BRANCH_PRIORITY) {
|
|
internalValue = this.forest.selectedNodeIds.filter(function (id) {
|
|
var node = _this.getNode(id);
|
|
|
|
if (node.isRootNode) return true;
|
|
return !_this.isSelected(node.parentNode);
|
|
});
|
|
} else if (this.valueConsistsOf === LEAF_PRIORITY) {
|
|
internalValue = this.forest.selectedNodeIds.filter(function (id) {
|
|
var node = _this.getNode(id);
|
|
|
|
if (node.isLeaf) return true;
|
|
return node.children.length === 0;
|
|
});
|
|
} else if (this.valueConsistsOf === ALL_WITH_INDETERMINATE) {
|
|
var _internalValue;
|
|
|
|
var indeterminateNodeIds = [];
|
|
internalValue = this.forest.selectedNodeIds.slice();
|
|
this.selectedNodes.forEach(function (selectedNode) {
|
|
selectedNode.ancestors.forEach(function (ancestor) {
|
|
if (includes(indeterminateNodeIds, ancestor.id)) return;
|
|
if (includes(internalValue, ancestor.id)) return;
|
|
indeterminateNodeIds.push(ancestor.id);
|
|
});
|
|
});
|
|
|
|
(_internalValue = internalValue).push.apply(_internalValue, indeterminateNodeIds);
|
|
}
|
|
|
|
if (this.sortValueBy === LEVEL) {
|
|
internalValue.sort(function (a, b) {
|
|
return sortValueByLevel(_this.getNode(a), _this.getNode(b));
|
|
});
|
|
} else if (this.sortValueBy === INDEX) {
|
|
internalValue.sort(function (a, b) {
|
|
return sortValueByIndex(_this.getNode(a), _this.getNode(b));
|
|
});
|
|
}
|
|
|
|
return internalValue;
|
|
},
|
|
hasValue: function hasValue() {
|
|
return this.internalValue.length > 0;
|
|
},
|
|
single: function single() {
|
|
return !this.multiple;
|
|
},
|
|
visibleOptionIds: function visibleOptionIds() {
|
|
var _this2 = this;
|
|
|
|
var visibleOptionIds = [];
|
|
this.traverseAllNodesByIndex(function (node) {
|
|
if (!_this2.localSearch.active || _this2.shouldOptionBeIncludedInSearchResult(node)) {
|
|
visibleOptionIds.push(node.id);
|
|
}
|
|
|
|
if (node.isBranch && !_this2.shouldExpand(node)) {
|
|
return false;
|
|
}
|
|
});
|
|
return visibleOptionIds;
|
|
},
|
|
hasVisibleOptions: function hasVisibleOptions() {
|
|
return this.visibleOptionIds.length !== 0;
|
|
},
|
|
showCountOnSearchComputed: function showCountOnSearchComputed() {
|
|
return typeof this.showCountOnSearch === 'boolean' ? this.showCountOnSearch : this.showCount;
|
|
},
|
|
hasBranchNodes: function hasBranchNodes() {
|
|
return this.forest.normalizedOptions.some(function (rootNode) {
|
|
return rootNode.isBranch;
|
|
});
|
|
},
|
|
shouldFlattenOptions: function shouldFlattenOptions() {
|
|
return this.localSearch.active && this.flattenSearchResults;
|
|
}
|
|
},
|
|
watch: {
|
|
alwaysOpen: function alwaysOpen(newValue) {
|
|
if (newValue) this.openMenu();else this.closeMenu();
|
|
},
|
|
branchNodesFirst: function branchNodesFirst() {
|
|
this.initialize();
|
|
},
|
|
disabled: function disabled(newValue) {
|
|
if (newValue && this.menu.isOpen) this.closeMenu();else if (!newValue && !this.menu.isOpen && this.alwaysOpen) this.openMenu();
|
|
},
|
|
flat: function flat() {
|
|
this.initialize();
|
|
},
|
|
internalValue: function internalValue(newValue, oldValue) {
|
|
var hasChanged = quickDiff(newValue, oldValue);
|
|
if (hasChanged) this.$emit('input', this.getValue(), this.getInstanceId());
|
|
},
|
|
matchKeys: function matchKeys() {
|
|
this.initialize();
|
|
},
|
|
multiple: function multiple(newValue) {
|
|
if (newValue) this.buildForestState();
|
|
},
|
|
options: {
|
|
handler: function handler() {
|
|
if (this.async) return;
|
|
this.initialize();
|
|
this.rootOptionsStates.isLoaded = Array.isArray(this.options);
|
|
},
|
|
deep: true,
|
|
immediate: true
|
|
},
|
|
'trigger.searchQuery': function triggerSearchQuery() {
|
|
if (this.async) {
|
|
this.handleRemoteSearch();
|
|
} else {
|
|
this.handleLocalSearch();
|
|
}
|
|
|
|
this.$emit('search-change', this.trigger.searchQuery, this.getInstanceId());
|
|
},
|
|
value: function value() {
|
|
var nodeIdsFromValue = this.extractCheckedNodeIdsFromValue();
|
|
var hasChanged = quickDiff(nodeIdsFromValue, this.internalValue);
|
|
if (hasChanged) this.fixSelectedNodeIds(nodeIdsFromValue);
|
|
}
|
|
},
|
|
methods: {
|
|
verifyProps: function verifyProps() {
|
|
var _this3 = this;
|
|
|
|
warning_warning(function () {
|
|
return _this3.async ? _this3.searchable : true;
|
|
}, function () {
|
|
return 'For async search mode, the value of "searchable" prop must be true.';
|
|
});
|
|
|
|
if (this.options == null && !this.loadOptions) {
|
|
warning_warning(function () {
|
|
return false;
|
|
}, function () {
|
|
return 'Are you meant to dynamically load options? You need to use "loadOptions" prop.';
|
|
});
|
|
}
|
|
|
|
if (this.flat) {
|
|
warning_warning(function () {
|
|
return _this3.multiple;
|
|
}, function () {
|
|
return 'You are using flat mode. But you forgot to add "multiple=true"?';
|
|
});
|
|
}
|
|
|
|
if (!this.flat) {
|
|
var propNames = ['autoSelectAncestors', 'autoSelectDescendants', 'autoDeselectAncestors', 'autoDeselectDescendants'];
|
|
propNames.forEach(function (propName) {
|
|
warning_warning(function () {
|
|
return !_this3[propName];
|
|
}, function () {
|
|
return "\"".concat(propName, "\" only applies to flat mode.");
|
|
});
|
|
});
|
|
}
|
|
},
|
|
resetFlags: function resetFlags() {
|
|
this._blurOnSelect = false;
|
|
},
|
|
initialize: function initialize() {
|
|
var options = this.async ? this.getRemoteSearchEntry().options : this.options;
|
|
|
|
if (Array.isArray(options)) {
|
|
var prevNodeMap = this.forest.nodeMap;
|
|
this.forest.nodeMap = createMap();
|
|
this.keepDataOfSelectedNodes(prevNodeMap);
|
|
this.forest.normalizedOptions = this.normalize(NO_PARENT_NODE, options, prevNodeMap);
|
|
this.fixSelectedNodeIds(this.internalValue);
|
|
} else {
|
|
this.forest.normalizedOptions = [];
|
|
}
|
|
},
|
|
getInstanceId: function getInstanceId() {
|
|
return this.instanceId == null ? this.id : this.instanceId;
|
|
},
|
|
getValue: function getValue() {
|
|
var _this4 = this;
|
|
|
|
if (this.valueFormat === 'id') {
|
|
return this.multiple ? this.internalValue.slice() : this.internalValue[0];
|
|
}
|
|
|
|
var rawNodes = this.internalValue.map(function (id) {
|
|
return _this4.getNode(id).raw;
|
|
});
|
|
return this.multiple ? rawNodes : rawNodes[0];
|
|
},
|
|
getNode: function getNode(nodeId) {
|
|
warning_warning(function () {
|
|
return nodeId != null;
|
|
}, function () {
|
|
return "Invalid node id: ".concat(nodeId);
|
|
});
|
|
if (nodeId == null) return null;
|
|
return nodeId in this.forest.nodeMap ? this.forest.nodeMap[nodeId] : this.createFallbackNode(nodeId);
|
|
},
|
|
createFallbackNode: function createFallbackNode(id) {
|
|
var raw = this.extractNodeFromValue(id);
|
|
var label = this.enhancedNormalizer(raw).label || "".concat(id, " (unknown)");
|
|
var fallbackNode = {
|
|
id: id,
|
|
label: label,
|
|
ancestors: [],
|
|
parentNode: NO_PARENT_NODE,
|
|
isFallbackNode: true,
|
|
isRootNode: true,
|
|
isLeaf: true,
|
|
isBranch: false,
|
|
isDisabled: false,
|
|
isNew: false,
|
|
index: [-1],
|
|
level: 0,
|
|
raw: raw
|
|
};
|
|
return this.$set(this.forest.nodeMap, id, fallbackNode);
|
|
},
|
|
extractCheckedNodeIdsFromValue: function extractCheckedNodeIdsFromValue() {
|
|
var _this5 = this;
|
|
|
|
if (this.value == null) return [];
|
|
|
|
if (this.valueFormat === 'id') {
|
|
return this.multiple ? this.value.slice() : [this.value];
|
|
}
|
|
|
|
return (this.multiple ? this.value : [this.value]).map(function (node) {
|
|
return _this5.enhancedNormalizer(node);
|
|
}).map(function (node) {
|
|
return node.id;
|
|
});
|
|
},
|
|
extractNodeFromValue: function extractNodeFromValue(id) {
|
|
var _this6 = this;
|
|
|
|
var defaultNode = {
|
|
id: id
|
|
};
|
|
|
|
if (this.valueFormat === 'id') {
|
|
return defaultNode;
|
|
}
|
|
|
|
var valueArray = this.multiple ? Array.isArray(this.value) ? this.value : [] : this.value ? [this.value] : [];
|
|
var matched = find(valueArray, function (node) {
|
|
return node && _this6.enhancedNormalizer(node).id === id;
|
|
});
|
|
return matched || defaultNode;
|
|
},
|
|
fixSelectedNodeIds: function fixSelectedNodeIds(nodeIdListOfPrevValue) {
|
|
var _this7 = this;
|
|
|
|
var nextSelectedNodeIds = [];
|
|
|
|
if (this.single || this.flat || this.disableBranchNodes || this.valueConsistsOf === ALL) {
|
|
nextSelectedNodeIds = nodeIdListOfPrevValue;
|
|
} else if (this.valueConsistsOf === BRANCH_PRIORITY) {
|
|
nodeIdListOfPrevValue.forEach(function (nodeId) {
|
|
nextSelectedNodeIds.push(nodeId);
|
|
|
|
var node = _this7.getNode(nodeId);
|
|
|
|
if (node.isBranch) _this7.traverseDescendantsBFS(node, function (descendant) {
|
|
nextSelectedNodeIds.push(descendant.id);
|
|
});
|
|
});
|
|
} else if (this.valueConsistsOf === LEAF_PRIORITY) {
|
|
var map = createMap();
|
|
var queue = nodeIdListOfPrevValue.slice();
|
|
|
|
while (queue.length) {
|
|
var nodeId = queue.shift();
|
|
var node = this.getNode(nodeId);
|
|
nextSelectedNodeIds.push(nodeId);
|
|
if (node.isRootNode) continue;
|
|
if (!(node.parentNode.id in map)) map[node.parentNode.id] = node.parentNode.children.length;
|
|
if (--map[node.parentNode.id] === 0) queue.push(node.parentNode.id);
|
|
}
|
|
} else if (this.valueConsistsOf === ALL_WITH_INDETERMINATE) {
|
|
var _map = createMap();
|
|
|
|
var _queue = nodeIdListOfPrevValue.filter(function (nodeId) {
|
|
var node = _this7.getNode(nodeId);
|
|
|
|
return node.isLeaf || node.children.length === 0;
|
|
});
|
|
|
|
while (_queue.length) {
|
|
var _nodeId = _queue.shift();
|
|
|
|
var _node = this.getNode(_nodeId);
|
|
|
|
nextSelectedNodeIds.push(_nodeId);
|
|
if (_node.isRootNode) continue;
|
|
if (!(_node.parentNode.id in _map)) _map[_node.parentNode.id] = _node.parentNode.children.length;
|
|
if (--_map[_node.parentNode.id] === 0) _queue.push(_node.parentNode.id);
|
|
}
|
|
}
|
|
|
|
var hasChanged = quickDiff(this.forest.selectedNodeIds, nextSelectedNodeIds);
|
|
if (hasChanged) this.forest.selectedNodeIds = nextSelectedNodeIds;
|
|
this.buildForestState();
|
|
},
|
|
keepDataOfSelectedNodes: function keepDataOfSelectedNodes(prevNodeMap) {
|
|
var _this8 = this;
|
|
|
|
this.forest.selectedNodeIds.forEach(function (id) {
|
|
if (!prevNodeMap[id]) return;
|
|
|
|
var node = _objectSpread({}, prevNodeMap[id], {
|
|
isFallbackNode: true
|
|
});
|
|
|
|
_this8.$set(_this8.forest.nodeMap, id, node);
|
|
});
|
|
},
|
|
isSelected: function isSelected(node) {
|
|
return this.forest.selectedNodeMap[node.id] === true;
|
|
},
|
|
traverseDescendantsBFS: function traverseDescendantsBFS(parentNode, callback) {
|
|
if (!parentNode.isBranch) return;
|
|
var queue = parentNode.children.slice();
|
|
|
|
while (queue.length) {
|
|
var currNode = queue[0];
|
|
if (currNode.isBranch) queue.push.apply(queue, toConsumableArray_default()(currNode.children));
|
|
callback(currNode);
|
|
queue.shift();
|
|
}
|
|
},
|
|
traverseDescendantsDFS: function traverseDescendantsDFS(parentNode, callback) {
|
|
var _this9 = this;
|
|
|
|
if (!parentNode.isBranch) return;
|
|
parentNode.children.forEach(function (child) {
|
|
_this9.traverseDescendantsDFS(child, callback);
|
|
|
|
callback(child);
|
|
});
|
|
},
|
|
traverseAllNodesDFS: function traverseAllNodesDFS(callback) {
|
|
var _this10 = this;
|
|
|
|
this.forest.normalizedOptions.forEach(function (rootNode) {
|
|
_this10.traverseDescendantsDFS(rootNode, callback);
|
|
|
|
callback(rootNode);
|
|
});
|
|
},
|
|
traverseAllNodesByIndex: function traverseAllNodesByIndex(callback) {
|
|
var walk = function walk(parentNode) {
|
|
parentNode.children.forEach(function (child) {
|
|
if (callback(child) !== false && child.isBranch) {
|
|
walk(child);
|
|
}
|
|
});
|
|
};
|
|
|
|
walk({
|
|
children: this.forest.normalizedOptions
|
|
});
|
|
},
|
|
toggleClickOutsideEvent: function toggleClickOutsideEvent(enabled) {
|
|
if (enabled) {
|
|
document.addEventListener('mousedown', this.handleClickOutside, false);
|
|
} else {
|
|
document.removeEventListener('mousedown', this.handleClickOutside, false);
|
|
}
|
|
},
|
|
getValueContainer: function getValueContainer() {
|
|
return this.$refs.control.$refs['value-container'];
|
|
},
|
|
getInput: function getInput() {
|
|
return this.getValueContainer().$refs.input;
|
|
},
|
|
focusInput: function focusInput() {
|
|
this.getInput().focus();
|
|
},
|
|
blurInput: function blurInput() {
|
|
this.getInput().blur();
|
|
},
|
|
handleMouseDown: onLeftClick(function handleMouseDown(evt) {
|
|
evt.preventDefault();
|
|
evt.stopPropagation();
|
|
if (this.disabled) return;
|
|
var isClickedOnValueContainer = this.getValueContainer().$el.contains(evt.target);
|
|
|
|
if (isClickedOnValueContainer && !this.menu.isOpen && (this.openOnClick || this.trigger.isFocused)) {
|
|
this.openMenu();
|
|
}
|
|
|
|
if (this._blurOnSelect) {
|
|
this.blurInput();
|
|
} else {
|
|
this.focusInput();
|
|
}
|
|
|
|
this.resetFlags();
|
|
}),
|
|
handleClickOutside: function handleClickOutside(evt) {
|
|
if (this.$refs.wrapper && !this.$refs.wrapper.contains(evt.target)) {
|
|
this.blurInput();
|
|
this.closeMenu();
|
|
}
|
|
},
|
|
handleLocalSearch: function handleLocalSearch() {
|
|
var _this11 = this;
|
|
|
|
var searchQuery = this.trigger.searchQuery;
|
|
|
|
var done = function done() {
|
|
return _this11.resetHighlightedOptionWhenNecessary(true);
|
|
};
|
|
|
|
if (!searchQuery) {
|
|
this.localSearch.active = false;
|
|
return done();
|
|
}
|
|
|
|
this.localSearch.active = true;
|
|
this.localSearch.noResults = true;
|
|
this.traverseAllNodesDFS(function (node) {
|
|
if (node.isBranch) {
|
|
var _this11$$set;
|
|
|
|
node.isExpandedOnSearch = false;
|
|
node.showAllChildrenOnSearch = false;
|
|
node.isMatched = false;
|
|
node.hasMatchedDescendants = false;
|
|
|
|
_this11.$set(_this11.localSearch.countMap, node.id, (_this11$$set = {}, defineProperty_default()(_this11$$set, ALL_CHILDREN, 0), defineProperty_default()(_this11$$set, ALL_DESCENDANTS, 0), defineProperty_default()(_this11$$set, LEAF_CHILDREN, 0), defineProperty_default()(_this11$$set, LEAF_DESCENDANTS, 0), _this11$$set));
|
|
}
|
|
});
|
|
var lowerCasedSearchQuery = searchQuery.trim().toLocaleLowerCase();
|
|
var splitSearchQuery = lowerCasedSearchQuery.replace(/\s+/g, ' ').split(' ');
|
|
this.traverseAllNodesDFS(function (node) {
|
|
if (_this11.searchNested && splitSearchQuery.length > 1) {
|
|
node.isMatched = splitSearchQuery.every(function (filterValue) {
|
|
return match(false, filterValue, node.nestedSearchLabel);
|
|
});
|
|
} else {
|
|
node.isMatched = _this11.matchKeys.some(function (matchKey) {
|
|
return match(!_this11.disableFuzzyMatching, lowerCasedSearchQuery, node.lowerCased[matchKey]);
|
|
});
|
|
}
|
|
|
|
if (node.isMatched) {
|
|
_this11.localSearch.noResults = false;
|
|
node.ancestors.forEach(function (ancestor) {
|
|
return _this11.localSearch.countMap[ancestor.id][ALL_DESCENDANTS]++;
|
|
});
|
|
if (node.isLeaf) node.ancestors.forEach(function (ancestor) {
|
|
return _this11.localSearch.countMap[ancestor.id][LEAF_DESCENDANTS]++;
|
|
});
|
|
|
|
if (node.parentNode !== NO_PARENT_NODE) {
|
|
_this11.localSearch.countMap[node.parentNode.id][ALL_CHILDREN] += 1;
|
|
if (node.isLeaf) _this11.localSearch.countMap[node.parentNode.id][LEAF_CHILDREN] += 1;
|
|
}
|
|
}
|
|
|
|
if ((node.isMatched || node.isBranch && node.isExpandedOnSearch) && node.parentNode !== NO_PARENT_NODE) {
|
|
node.parentNode.isExpandedOnSearch = true;
|
|
node.parentNode.hasMatchedDescendants = true;
|
|
}
|
|
});
|
|
done();
|
|
},
|
|
handleRemoteSearch: function handleRemoteSearch() {
|
|
var _this12 = this;
|
|
|
|
var searchQuery = this.trigger.searchQuery;
|
|
var entry = this.getRemoteSearchEntry();
|
|
|
|
var done = function done() {
|
|
_this12.initialize();
|
|
|
|
_this12.resetHighlightedOptionWhenNecessary(true);
|
|
};
|
|
|
|
if ((searchQuery === '' || this.cacheOptions) && entry.isLoaded) {
|
|
return done();
|
|
}
|
|
|
|
this.callLoadOptionsProp({
|
|
action: ASYNC_SEARCH,
|
|
args: {
|
|
searchQuery: searchQuery
|
|
},
|
|
isPending: function isPending() {
|
|
return entry.isLoading;
|
|
},
|
|
start: function start() {
|
|
entry.isLoading = true;
|
|
entry.isLoaded = false;
|
|
entry.loadingError = '';
|
|
},
|
|
succeed: function succeed(options) {
|
|
entry.isLoaded = true;
|
|
entry.options = options;
|
|
if (_this12.trigger.searchQuery === searchQuery) done();
|
|
},
|
|
fail: function fail(err) {
|
|
entry.loadingError = getErrorMessage(err);
|
|
},
|
|
end: function end() {
|
|
entry.isLoading = false;
|
|
}
|
|
});
|
|
},
|
|
getRemoteSearchEntry: function getRemoteSearchEntry() {
|
|
var _this13 = this;
|
|
|
|
var searchQuery = this.trigger.searchQuery;
|
|
|
|
var entry = this.remoteSearch[searchQuery] || _objectSpread({}, createAsyncOptionsStates(), {
|
|
options: []
|
|
});
|
|
|
|
this.$watch(function () {
|
|
return entry.options;
|
|
}, function () {
|
|
if (_this13.trigger.searchQuery === searchQuery) _this13.initialize();
|
|
}, {
|
|
deep: true
|
|
});
|
|
|
|
if (searchQuery === '') {
|
|
if (Array.isArray(this.defaultOptions)) {
|
|
entry.options = this.defaultOptions;
|
|
entry.isLoaded = true;
|
|
return entry;
|
|
} else if (this.defaultOptions !== true) {
|
|
entry.isLoaded = true;
|
|
return entry;
|
|
}
|
|
}
|
|
|
|
if (!this.remoteSearch[searchQuery]) {
|
|
this.$set(this.remoteSearch, searchQuery, entry);
|
|
}
|
|
|
|
return entry;
|
|
},
|
|
shouldExpand: function shouldExpand(node) {
|
|
return this.localSearch.active ? node.isExpandedOnSearch : node.isExpanded;
|
|
},
|
|
shouldOptionBeIncludedInSearchResult: function shouldOptionBeIncludedInSearchResult(node) {
|
|
if (node.isMatched) return true;
|
|
if (node.isBranch && node.hasMatchedDescendants && !this.flattenSearchResults) return true;
|
|
if (!node.isRootNode && node.parentNode.showAllChildrenOnSearch) return true;
|
|
return false;
|
|
},
|
|
shouldShowOptionInMenu: function shouldShowOptionInMenu(node) {
|
|
if (this.localSearch.active && !this.shouldOptionBeIncludedInSearchResult(node)) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
},
|
|
getControl: function getControl() {
|
|
return this.$refs.control.$el;
|
|
},
|
|
getMenu: function getMenu() {
|
|
var ref = this.appendToBody ? this.$refs.portal.portalTarget : this;
|
|
var $menu = ref.$refs.menu.$refs.menu;
|
|
return $menu && $menu.nodeName !== '#comment' ? $menu : null;
|
|
},
|
|
setCurrentHighlightedOption: function setCurrentHighlightedOption(node) {
|
|
var _this14 = this;
|
|
|
|
var scroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
var prev = this.menu.current;
|
|
|
|
if (prev != null && prev in this.forest.nodeMap) {
|
|
this.forest.nodeMap[prev].isHighlighted = false;
|
|
}
|
|
|
|
this.menu.current = node.id;
|
|
node.isHighlighted = true;
|
|
|
|
if (this.menu.isOpen && scroll) {
|
|
var scrollToOption = function scrollToOption() {
|
|
var $menu = _this14.getMenu();
|
|
|
|
var $option = $menu.querySelector(".vue-treeselect__option[data-id=\"".concat(node.id, "\"]"));
|
|
if ($option) scrollIntoView($menu, $option);
|
|
};
|
|
|
|
if (this.getMenu()) {
|
|
scrollToOption();
|
|
} else {
|
|
this.$nextTick(scrollToOption);
|
|
}
|
|
}
|
|
},
|
|
resetHighlightedOptionWhenNecessary: function resetHighlightedOptionWhenNecessary() {
|
|
var forceReset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
var current = this.menu.current;
|
|
|
|
if (forceReset || current == null || !(current in this.forest.nodeMap) || !this.shouldShowOptionInMenu(this.getNode(current))) {
|
|
this.highlightFirstOption();
|
|
}
|
|
},
|
|
highlightFirstOption: function highlightFirstOption() {
|
|
if (!this.hasVisibleOptions) return;
|
|
var first = this.visibleOptionIds[0];
|
|
this.setCurrentHighlightedOption(this.getNode(first));
|
|
},
|
|
highlightPrevOption: function highlightPrevOption() {
|
|
if (!this.hasVisibleOptions) return;
|
|
var prev = this.visibleOptionIds.indexOf(this.menu.current) - 1;
|
|
if (prev === -1) return this.highlightLastOption();
|
|
this.setCurrentHighlightedOption(this.getNode(this.visibleOptionIds[prev]));
|
|
},
|
|
highlightNextOption: function highlightNextOption() {
|
|
if (!this.hasVisibleOptions) return;
|
|
var next = this.visibleOptionIds.indexOf(this.menu.current) + 1;
|
|
if (next === this.visibleOptionIds.length) return this.highlightFirstOption();
|
|
this.setCurrentHighlightedOption(this.getNode(this.visibleOptionIds[next]));
|
|
},
|
|
highlightLastOption: function highlightLastOption() {
|
|
if (!this.hasVisibleOptions) return;
|
|
var last = last_default()(this.visibleOptionIds);
|
|
this.setCurrentHighlightedOption(this.getNode(last));
|
|
},
|
|
resetSearchQuery: function resetSearchQuery() {
|
|
this.trigger.searchQuery = '';
|
|
},
|
|
closeMenu: function closeMenu() {
|
|
if (!this.menu.isOpen || !this.disabled && this.alwaysOpen) return;
|
|
this.saveMenuScrollPosition();
|
|
this.menu.isOpen = false;
|
|
this.toggleClickOutsideEvent(false);
|
|
this.resetSearchQuery();
|
|
this.$emit('close', this.getValue(), this.getInstanceId());
|
|
},
|
|
openMenu: function openMenu() {
|
|
if (this.disabled || this.menu.isOpen) return;
|
|
this.menu.isOpen = true;
|
|
this.$nextTick(this.resetHighlightedOptionWhenNecessary);
|
|
this.$nextTick(this.restoreMenuScrollPosition);
|
|
if (!this.options && !this.async) this.loadRootOptions();
|
|
this.toggleClickOutsideEvent(true);
|
|
this.$emit('open', this.getInstanceId());
|
|
},
|
|
toggleMenu: function toggleMenu() {
|
|
if (this.menu.isOpen) {
|
|
this.closeMenu();
|
|
} else {
|
|
this.openMenu();
|
|
}
|
|
},
|
|
toggleExpanded: function toggleExpanded(node) {
|
|
var nextState;
|
|
|
|
if (this.localSearch.active) {
|
|
nextState = node.isExpandedOnSearch = !node.isExpandedOnSearch;
|
|
if (nextState) node.showAllChildrenOnSearch = true;
|
|
} else {
|
|
nextState = node.isExpanded = !node.isExpanded;
|
|
}
|
|
|
|
if (nextState && !node.childrenStates.isLoaded) {
|
|
this.loadChildrenOptions(node);
|
|
}
|
|
},
|
|
buildForestState: function buildForestState() {
|
|
var _this15 = this;
|
|
|
|
var selectedNodeMap = createMap();
|
|
this.forest.selectedNodeIds.forEach(function (selectedNodeId) {
|
|
selectedNodeMap[selectedNodeId] = true;
|
|
});
|
|
this.forest.selectedNodeMap = selectedNodeMap;
|
|
var checkedStateMap = createMap();
|
|
|
|
if (this.multiple) {
|
|
this.traverseAllNodesByIndex(function (node) {
|
|
checkedStateMap[node.id] = UNCHECKED;
|
|
});
|
|
this.selectedNodes.forEach(function (selectedNode) {
|
|
checkedStateMap[selectedNode.id] = CHECKED;
|
|
|
|
if (!_this15.flat && !_this15.disableBranchNodes) {
|
|
selectedNode.ancestors.forEach(function (ancestorNode) {
|
|
if (!_this15.isSelected(ancestorNode)) {
|
|
checkedStateMap[ancestorNode.id] = INDETERMINATE;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
this.forest.checkedStateMap = checkedStateMap;
|
|
},
|
|
enhancedNormalizer: function enhancedNormalizer(raw) {
|
|
return _objectSpread({}, raw, {}, this.normalizer(raw, this.getInstanceId()));
|
|
},
|
|
normalize: function normalize(parentNode, nodes, prevNodeMap) {
|
|
var _this16 = this;
|
|
|
|
var normalizedOptions = nodes.map(function (node) {
|
|
return [_this16.enhancedNormalizer(node), node];
|
|
}).map(function (_ref, index) {
|
|
var _ref2 = slicedToArray_default()(_ref, 2),
|
|
node = _ref2[0],
|
|
raw = _ref2[1];
|
|
|
|
_this16.checkDuplication(node);
|
|
|
|
_this16.verifyNodeShape(node);
|
|
|
|
var id = node.id,
|
|
label = node.label,
|
|
children = node.children,
|
|
isDefaultExpanded = node.isDefaultExpanded;
|
|
var isRootNode = parentNode === NO_PARENT_NODE;
|
|
var level = isRootNode ? 0 : parentNode.level + 1;
|
|
var isBranch = Array.isArray(children) || children === null;
|
|
var isLeaf = !isBranch;
|
|
var isDisabled = !!node.isDisabled || !_this16.flat && !isRootNode && parentNode.isDisabled;
|
|
var isNew = !!node.isNew;
|
|
|
|
var lowerCased = _this16.matchKeys.reduce(function (prev, key) {
|
|
return _objectSpread({}, prev, defineProperty_default()({}, key, stringifyOptionPropValue(node[key]).toLocaleLowerCase()));
|
|
}, {});
|
|
|
|
var nestedSearchLabel = isRootNode ? lowerCased.label : parentNode.nestedSearchLabel + ' ' + lowerCased.label;
|
|
|
|
var normalized = _this16.$set(_this16.forest.nodeMap, id, createMap());
|
|
|
|
_this16.$set(normalized, 'id', id);
|
|
|
|
_this16.$set(normalized, 'label', label);
|
|
|
|
_this16.$set(normalized, 'level', level);
|
|
|
|
_this16.$set(normalized, 'ancestors', isRootNode ? [] : [parentNode].concat(parentNode.ancestors));
|
|
|
|
_this16.$set(normalized, 'index', (isRootNode ? [] : parentNode.index).concat(index));
|
|
|
|
_this16.$set(normalized, 'parentNode', parentNode);
|
|
|
|
_this16.$set(normalized, 'lowerCased', lowerCased);
|
|
|
|
_this16.$set(normalized, 'nestedSearchLabel', nestedSearchLabel);
|
|
|
|
_this16.$set(normalized, 'isDisabled', isDisabled);
|
|
|
|
_this16.$set(normalized, 'isNew', isNew);
|
|
|
|
_this16.$set(normalized, 'isMatched', false);
|
|
|
|
_this16.$set(normalized, 'isHighlighted', false);
|
|
|
|
_this16.$set(normalized, 'isBranch', isBranch);
|
|
|
|
_this16.$set(normalized, 'isLeaf', isLeaf);
|
|
|
|
_this16.$set(normalized, 'isRootNode', isRootNode);
|
|
|
|
_this16.$set(normalized, 'raw', raw);
|
|
|
|
if (isBranch) {
|
|
var _this16$$set;
|
|
|
|
var isLoaded = Array.isArray(children);
|
|
|
|
_this16.$set(normalized, 'childrenStates', _objectSpread({}, createAsyncOptionsStates(), {
|
|
isLoaded: isLoaded
|
|
}));
|
|
|
|
_this16.$set(normalized, 'isExpanded', typeof isDefaultExpanded === 'boolean' ? isDefaultExpanded : level < _this16.defaultExpandLevel);
|
|
|
|
_this16.$set(normalized, 'hasMatchedDescendants', false);
|
|
|
|
_this16.$set(normalized, 'hasDisabledDescendants', false);
|
|
|
|
_this16.$set(normalized, 'isExpandedOnSearch', false);
|
|
|
|
_this16.$set(normalized, 'showAllChildrenOnSearch', false);
|
|
|
|
_this16.$set(normalized, 'count', (_this16$$set = {}, defineProperty_default()(_this16$$set, ALL_CHILDREN, 0), defineProperty_default()(_this16$$set, ALL_DESCENDANTS, 0), defineProperty_default()(_this16$$set, LEAF_CHILDREN, 0), defineProperty_default()(_this16$$set, LEAF_DESCENDANTS, 0), _this16$$set));
|
|
|
|
_this16.$set(normalized, 'children', isLoaded ? _this16.normalize(normalized, children, prevNodeMap) : []);
|
|
|
|
if (isDefaultExpanded === true) normalized.ancestors.forEach(function (ancestor) {
|
|
ancestor.isExpanded = true;
|
|
});
|
|
|
|
if (!isLoaded && typeof _this16.loadOptions !== 'function') {
|
|
warning_warning(function () {
|
|
return false;
|
|
}, function () {
|
|
return 'Unloaded branch node detected. "loadOptions" prop is required to load its children.';
|
|
});
|
|
} else if (!isLoaded && normalized.isExpanded) {
|
|
_this16.loadChildrenOptions(normalized);
|
|
}
|
|
}
|
|
|
|
normalized.ancestors.forEach(function (ancestor) {
|
|
return ancestor.count[ALL_DESCENDANTS]++;
|
|
});
|
|
if (isLeaf) normalized.ancestors.forEach(function (ancestor) {
|
|
return ancestor.count[LEAF_DESCENDANTS]++;
|
|
});
|
|
|
|
if (!isRootNode) {
|
|
parentNode.count[ALL_CHILDREN] += 1;
|
|
if (isLeaf) parentNode.count[LEAF_CHILDREN] += 1;
|
|
if (isDisabled) parentNode.hasDisabledDescendants = true;
|
|
}
|
|
|
|
if (prevNodeMap && prevNodeMap[id]) {
|
|
var prev = prevNodeMap[id];
|
|
normalized.isMatched = prev.isMatched;
|
|
normalized.showAllChildrenOnSearch = prev.showAllChildrenOnSearch;
|
|
normalized.isHighlighted = prev.isHighlighted;
|
|
|
|
if (prev.isBranch && normalized.isBranch) {
|
|
normalized.isExpanded = prev.isExpanded;
|
|
normalized.isExpandedOnSearch = prev.isExpandedOnSearch;
|
|
|
|
if (prev.childrenStates.isLoaded && !normalized.childrenStates.isLoaded) {
|
|
normalized.isExpanded = false;
|
|
} else {
|
|
normalized.childrenStates = _objectSpread({}, prev.childrenStates);
|
|
}
|
|
}
|
|
}
|
|
|
|
return normalized;
|
|
});
|
|
|
|
if (this.branchNodesFirst) {
|
|
var branchNodes = normalizedOptions.filter(function (option) {
|
|
return option.isBranch;
|
|
});
|
|
var leafNodes = normalizedOptions.filter(function (option) {
|
|
return option.isLeaf;
|
|
});
|
|
normalizedOptions = branchNodes.concat(leafNodes);
|
|
}
|
|
|
|
return normalizedOptions;
|
|
},
|
|
loadRootOptions: function loadRootOptions() {
|
|
var _this17 = this;
|
|
|
|
this.callLoadOptionsProp({
|
|
action: LOAD_ROOT_OPTIONS,
|
|
isPending: function isPending() {
|
|
return _this17.rootOptionsStates.isLoading;
|
|
},
|
|
start: function start() {
|
|
_this17.rootOptionsStates.isLoading = true;
|
|
_this17.rootOptionsStates.loadingError = '';
|
|
},
|
|
succeed: function succeed() {
|
|
_this17.rootOptionsStates.isLoaded = true;
|
|
|
|
_this17.$nextTick(function () {
|
|
_this17.resetHighlightedOptionWhenNecessary(true);
|
|
});
|
|
},
|
|
fail: function fail(err) {
|
|
_this17.rootOptionsStates.loadingError = getErrorMessage(err);
|
|
},
|
|
end: function end() {
|
|
_this17.rootOptionsStates.isLoading = false;
|
|
}
|
|
});
|
|
},
|
|
loadChildrenOptions: function loadChildrenOptions(parentNode) {
|
|
var _this18 = this;
|
|
|
|
var id = parentNode.id,
|
|
raw = parentNode.raw;
|
|
this.callLoadOptionsProp({
|
|
action: LOAD_CHILDREN_OPTIONS,
|
|
args: {
|
|
parentNode: raw
|
|
},
|
|
isPending: function isPending() {
|
|
return _this18.getNode(id).childrenStates.isLoading;
|
|
},
|
|
start: function start() {
|
|
_this18.getNode(id).childrenStates.isLoading = true;
|
|
_this18.getNode(id).childrenStates.loadingError = '';
|
|
},
|
|
succeed: function succeed() {
|
|
_this18.getNode(id).childrenStates.isLoaded = true;
|
|
},
|
|
fail: function fail(err) {
|
|
_this18.getNode(id).childrenStates.loadingError = getErrorMessage(err);
|
|
},
|
|
end: function end() {
|
|
_this18.getNode(id).childrenStates.isLoading = false;
|
|
}
|
|
});
|
|
},
|
|
callLoadOptionsProp: function callLoadOptionsProp(_ref3) {
|
|
var action = _ref3.action,
|
|
args = _ref3.args,
|
|
isPending = _ref3.isPending,
|
|
start = _ref3.start,
|
|
succeed = _ref3.succeed,
|
|
fail = _ref3.fail,
|
|
end = _ref3.end;
|
|
|
|
if (!this.loadOptions || isPending()) {
|
|
return;
|
|
}
|
|
|
|
start();
|
|
var callback = once_default()(function (err, result) {
|
|
if (err) {
|
|
fail(err);
|
|
} else {
|
|
succeed(result);
|
|
}
|
|
|
|
end();
|
|
});
|
|
var result = this.loadOptions(_objectSpread({
|
|
id: this.getInstanceId(),
|
|
instanceId: this.getInstanceId(),
|
|
action: action
|
|
}, args, {
|
|
callback: callback
|
|
}));
|
|
|
|
if (is_promise_default()(result)) {
|
|
result.then(function () {
|
|
callback();
|
|
}, function (err) {
|
|
callback(err);
|
|
}).catch(function (err) {
|
|
console.error(err);
|
|
});
|
|
}
|
|
},
|
|
checkDuplication: function checkDuplication(node) {
|
|
var _this19 = this;
|
|
|
|
warning_warning(function () {
|
|
return !(node.id in _this19.forest.nodeMap && !_this19.forest.nodeMap[node.id].isFallbackNode);
|
|
}, function () {
|
|
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.");
|
|
});
|
|
},
|
|
verifyNodeShape: function verifyNodeShape(node) {
|
|
warning_warning(function () {
|
|
return !(node.children === undefined && node.isBranch === true);
|
|
}, function () {
|
|
return 'Are you meant to declare an unloaded branch node? ' + '`isBranch: true` is no longer supported, please use `children: null` instead.';
|
|
});
|
|
},
|
|
select: function select(node) {
|
|
if (this.disabled || node.isDisabled) {
|
|
return;
|
|
}
|
|
|
|
if (this.single) {
|
|
this.clear();
|
|
}
|
|
|
|
var nextState = this.multiple && !this.flat ? this.forest.checkedStateMap[node.id] === UNCHECKED : !this.isSelected(node);
|
|
|
|
if (nextState) {
|
|
this._selectNode(node);
|
|
} else {
|
|
this._deselectNode(node);
|
|
}
|
|
|
|
this.buildForestState();
|
|
|
|
if (nextState) {
|
|
this.$emit('select', node.raw, this.getInstanceId());
|
|
} else {
|
|
this.$emit('deselect', node.raw, this.getInstanceId());
|
|
}
|
|
|
|
if (this.localSearch.active && nextState && (this.single || this.clearOnSelect)) {
|
|
this.resetSearchQuery();
|
|
}
|
|
|
|
if (this.single && this.closeOnSelect) {
|
|
this.closeMenu();
|
|
|
|
if (this.searchable) {
|
|
this._blurOnSelect = true;
|
|
}
|
|
}
|
|
},
|
|
clear: function clear() {
|
|
var _this20 = this;
|
|
|
|
if (this.hasValue) {
|
|
if (this.single || this.allowClearingDisabled) {
|
|
this.forest.selectedNodeIds = [];
|
|
} else {
|
|
this.forest.selectedNodeIds = this.forest.selectedNodeIds.filter(function (nodeId) {
|
|
return _this20.getNode(nodeId).isDisabled;
|
|
});
|
|
}
|
|
|
|
this.buildForestState();
|
|
}
|
|
},
|
|
_selectNode: function _selectNode(node) {
|
|
var _this21 = this;
|
|
|
|
if (this.single || this.disableBranchNodes) {
|
|
return this.addValue(node);
|
|
}
|
|
|
|
if (this.flat) {
|
|
this.addValue(node);
|
|
|
|
if (this.autoSelectAncestors) {
|
|
node.ancestors.forEach(function (ancestor) {
|
|
if (!_this21.isSelected(ancestor) && !ancestor.isDisabled) _this21.addValue(ancestor);
|
|
});
|
|
} else if (this.autoSelectDescendants) {
|
|
this.traverseDescendantsBFS(node, function (descendant) {
|
|
if (!_this21.isSelected(descendant) && !descendant.isDisabled) _this21.addValue(descendant);
|
|
});
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
var isFullyChecked = node.isLeaf || !node.hasDisabledDescendants || this.allowSelectingDisabledDescendants;
|
|
|
|
if (isFullyChecked) {
|
|
this.addValue(node);
|
|
}
|
|
|
|
if (node.isBranch) {
|
|
this.traverseDescendantsBFS(node, function (descendant) {
|
|
if (!descendant.isDisabled || _this21.allowSelectingDisabledDescendants) {
|
|
_this21.addValue(descendant);
|
|
}
|
|
});
|
|
}
|
|
|
|
if (isFullyChecked) {
|
|
var curr = node;
|
|
|
|
while ((curr = curr.parentNode) !== NO_PARENT_NODE) {
|
|
if (curr.children.every(this.isSelected)) this.addValue(curr);else break;
|
|
}
|
|
}
|
|
},
|
|
_deselectNode: function _deselectNode(node) {
|
|
var _this22 = this;
|
|
|
|
if (this.disableBranchNodes) {
|
|
return this.removeValue(node);
|
|
}
|
|
|
|
if (this.flat) {
|
|
this.removeValue(node);
|
|
|
|
if (this.autoDeselectAncestors) {
|
|
node.ancestors.forEach(function (ancestor) {
|
|
if (_this22.isSelected(ancestor) && !ancestor.isDisabled) _this22.removeValue(ancestor);
|
|
});
|
|
} else if (this.autoDeselectDescendants) {
|
|
this.traverseDescendantsBFS(node, function (descendant) {
|
|
if (_this22.isSelected(descendant) && !descendant.isDisabled) _this22.removeValue(descendant);
|
|
});
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
var hasUncheckedSomeDescendants = false;
|
|
|
|
if (node.isBranch) {
|
|
this.traverseDescendantsDFS(node, function (descendant) {
|
|
if (!descendant.isDisabled || _this22.allowSelectingDisabledDescendants) {
|
|
_this22.removeValue(descendant);
|
|
|
|
hasUncheckedSomeDescendants = true;
|
|
}
|
|
});
|
|
}
|
|
|
|
if (node.isLeaf || hasUncheckedSomeDescendants || node.children.length === 0) {
|
|
this.removeValue(node);
|
|
var curr = node;
|
|
|
|
while ((curr = curr.parentNode) !== NO_PARENT_NODE) {
|
|
if (this.isSelected(curr)) this.removeValue(curr);else break;
|
|
}
|
|
}
|
|
},
|
|
addValue: function addValue(node) {
|
|
this.forest.selectedNodeIds.push(node.id);
|
|
this.forest.selectedNodeMap[node.id] = true;
|
|
},
|
|
removeValue: function removeValue(node) {
|
|
removeFromArray(this.forest.selectedNodeIds, node.id);
|
|
delete this.forest.selectedNodeMap[node.id];
|
|
},
|
|
removeLastValue: function removeLastValue() {
|
|
if (!this.hasValue) return;
|
|
if (this.single) return this.clear();
|
|
var lastValue = last_default()(this.internalValue);
|
|
var lastSelectedNode = this.getNode(lastValue);
|
|
this.select(lastSelectedNode);
|
|
},
|
|
saveMenuScrollPosition: function saveMenuScrollPosition() {
|
|
var $menu = this.getMenu();
|
|
if ($menu) this.menu.lastScrollPosition = $menu.scrollTop;
|
|
},
|
|
restoreMenuScrollPosition: function restoreMenuScrollPosition() {
|
|
var $menu = this.getMenu();
|
|
if ($menu) $menu.scrollTop = this.menu.lastScrollPosition;
|
|
}
|
|
},
|
|
created: function created() {
|
|
this.verifyProps();
|
|
this.resetFlags();
|
|
},
|
|
mounted: function mounted() {
|
|
if (this.autoFocus) this.focusInput();
|
|
if (!this.options && !this.async && this.autoLoadRootOptions) this.loadRootOptions();
|
|
if (this.alwaysOpen) this.openMenu();
|
|
if (this.async && this.defaultOptions) this.handleRemoteSearch();
|
|
},
|
|
destroyed: function destroyed() {
|
|
this.toggleClickOutsideEvent(false);
|
|
}
|
|
});
|
|
// 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&
|
|
|
|
|
|
function stringifyValue(value) {
|
|
if (typeof value === 'string') return value;
|
|
if (value != null && !isNaN_isNaN(value)) return JSON.stringify(value);
|
|
return '';
|
|
}
|
|
|
|
/* harmony default export */ var HiddenFieldsvue_type_script_lang_js_ = ({
|
|
name: 'vue-treeselect--hidden-fields',
|
|
inject: ['instance'],
|
|
functional: true,
|
|
render: function render(_, context) {
|
|
var h = arguments[0];
|
|
var instance = context.injections.instance;
|
|
if (!instance.name || instance.disabled || !instance.hasValue) return null;
|
|
var stringifiedValues = instance.internalValue.map(stringifyValue);
|
|
if (instance.multiple && instance.joinValues) stringifiedValues = [stringifiedValues.join(instance.delimiter)];
|
|
return stringifiedValues.map(function (stringifiedValue, i) {
|
|
return h("input", {
|
|
attrs: {
|
|
type: "hidden",
|
|
name: instance.name
|
|
},
|
|
domProps: {
|
|
"value": stringifiedValue
|
|
},
|
|
key: 'hidden-field-' + i
|
|
});
|
|
});
|
|
}
|
|
});
|
|
// CONCATENATED MODULE: ./src/components/HiddenFields.vue?vue&type=script&lang=js&
|
|
/* harmony default export */ var components_HiddenFieldsvue_type_script_lang_js_ = (HiddenFieldsvue_type_script_lang_js_);
|
|
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
|
|
/* globals __VUE_SSR_CONTEXT__ */
|
|
|
|
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
|
|
// This module is a runtime utility for cleaner component module output and will
|
|
// be included in the final webpack user bundle.
|
|
|
|
function normalizeComponent (
|
|
scriptExports,
|
|
render,
|
|
staticRenderFns,
|
|
functionalTemplate,
|
|
injectStyles,
|
|
scopeId,
|
|
moduleIdentifier, /* server only */
|
|
shadowMode /* vue-cli only */
|
|
) {
|
|
// Vue.extend constructor export interop
|
|
var options = typeof scriptExports === 'function'
|
|
? scriptExports.options
|
|
: scriptExports
|
|
|
|
// render functions
|
|
if (render) {
|
|
options.render = render
|
|
options.staticRenderFns = staticRenderFns
|
|
options._compiled = true
|
|
}
|
|
|
|
// functional template
|
|
if (functionalTemplate) {
|
|
options.functional = true
|
|
}
|
|
|
|
// scopedId
|
|
if (scopeId) {
|
|
options._scopeId = 'data-v-' + scopeId
|
|
}
|
|
|
|
var hook
|
|
if (moduleIdentifier) { // server build
|
|
hook = function (context) {
|
|
// 2.3 injection
|
|
context =
|
|
context || // cached call
|
|
(this.$vnode && this.$vnode.ssrContext) || // stateful
|
|
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
|
|
// 2.2 with runInNewContext: true
|
|
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
|
context = __VUE_SSR_CONTEXT__
|
|
}
|
|
// inject component styles
|
|
if (injectStyles) {
|
|
injectStyles.call(this, context)
|
|
}
|
|
// register component module identifier for async chunk inferrence
|
|
if (context && context._registeredComponents) {
|
|
context._registeredComponents.add(moduleIdentifier)
|
|
}
|
|
}
|
|
// used by ssr in case component is cached and beforeCreate
|
|
// never gets called
|
|
options._ssrRegister = hook
|
|
} else if (injectStyles) {
|
|
hook = shadowMode
|
|
? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
|
|
: injectStyles
|
|
}
|
|
|
|
if (hook) {
|
|
if (options.functional) {
|
|
// for template-only hot-reload because in that case the render fn doesn't
|
|
// go through the normalizer
|
|
options._injectStyles = hook
|
|
// register for functioal component in vue file
|
|
var originalRender = options.render
|
|
options.render = function renderWithStyleInjection (h, context) {
|
|
hook.call(context)
|
|
return originalRender(h, context)
|
|
}
|
|
} else {
|
|
// inject component registration as beforeCreate hook
|
|
var existing = options.beforeCreate
|
|
options.beforeCreate = existing
|
|
? [].concat(existing, hook)
|
|
: [hook]
|
|
}
|
|
}
|
|
|
|
return {
|
|
exports: scriptExports,
|
|
options: options
|
|
}
|
|
}
|
|
|
|
// CONCATENATED MODULE: ./src/components/HiddenFields.vue
|
|
var HiddenFields_render, staticRenderFns
|
|
|
|
|
|
|
|
|
|
/* normalize component */
|
|
|
|
var component = normalizeComponent(
|
|
components_HiddenFieldsvue_type_script_lang_js_,
|
|
HiddenFields_render,
|
|
staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
|
|
)
|
|
|
|
/* hot reload */
|
|
if (false) { var api; }
|
|
component.options.__file = "src/components/HiddenFields.vue"
|
|
/* harmony default export */ var HiddenFields = (component.exports);
|
|
// EXTERNAL MODULE: ./node_modules/babel-helper-vue-jsx-merge-props/index.js
|
|
var babel_helper_vue_jsx_merge_props = __webpack_require__(33);
|
|
var babel_helper_vue_jsx_merge_props_default = /*#__PURE__*/__webpack_require__.n(babel_helper_vue_jsx_merge_props);
|
|
|
|
// 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&
|
|
|
|
|
|
|
|
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];
|
|
/* harmony default export */ var Inputvue_type_script_lang_js_ = ({
|
|
name: 'vue-treeselect--input',
|
|
inject: ['instance'],
|
|
data: function data() {
|
|
return {
|
|
inputWidth: MIN_INPUT_WIDTH,
|
|
value: ''
|
|
};
|
|
},
|
|
computed: {
|
|
needAutoSize: function needAutoSize() {
|
|
var instance = this.instance;
|
|
return instance.searchable && !instance.disabled && instance.multiple;
|
|
},
|
|
inputStyle: function inputStyle() {
|
|
return {
|
|
width: this.needAutoSize ? "".concat(this.inputWidth, "px") : null
|
|
};
|
|
}
|
|
},
|
|
watch: {
|
|
'instance.trigger.searchQuery': function instanceTriggerSearchQuery(newValue) {
|
|
this.value = newValue;
|
|
},
|
|
value: function value() {
|
|
if (this.needAutoSize) this.$nextTick(this.updateInputWidth);
|
|
}
|
|
},
|
|
created: function created() {
|
|
this.debouncedCallback = debounce_default()(this.updateSearchQuery, INPUT_DEBOUNCE_DELAY, {
|
|
leading: true,
|
|
trailing: true
|
|
});
|
|
},
|
|
methods: {
|
|
clear: function clear() {
|
|
this.onInput({
|
|
target: {
|
|
value: ''
|
|
}
|
|
});
|
|
},
|
|
focus: function focus() {
|
|
var instance = this.instance;
|
|
|
|
if (!instance.disabled) {
|
|
this.$refs.input && this.$refs.input.focus();
|
|
}
|
|
},
|
|
blur: function blur() {
|
|
this.$refs.input && this.$refs.input.blur();
|
|
},
|
|
onFocus: function onFocus() {
|
|
var instance = this.instance;
|
|
instance.trigger.isFocused = true;
|
|
if (instance.openOnFocus) instance.openMenu();
|
|
},
|
|
onBlur: function onBlur() {
|
|
var instance = this.instance;
|
|
var menu = instance.getMenu();
|
|
|
|
if (menu && document.activeElement === menu) {
|
|
return this.focus();
|
|
}
|
|
|
|
instance.trigger.isFocused = false;
|
|
instance.closeMenu();
|
|
},
|
|
onInput: function onInput(evt) {
|
|
var value = evt.target.value;
|
|
this.value = value;
|
|
|
|
if (value) {
|
|
this.debouncedCallback();
|
|
} else {
|
|
this.debouncedCallback.cancel();
|
|
this.updateSearchQuery();
|
|
}
|
|
},
|
|
onKeyDown: function onKeyDown(evt) {
|
|
var instance = this.instance;
|
|
var key = 'which' in evt ? evt.which : evt.keyCode;
|
|
if (evt.ctrlKey || evt.shiftKey || evt.altKey || evt.metaKey) return;
|
|
|
|
if (!instance.menu.isOpen && includes(keysThatRequireMenuBeingOpen, key)) {
|
|
evt.preventDefault();
|
|
return instance.openMenu();
|
|
}
|
|
|
|
switch (key) {
|
|
case KEY_CODES.BACKSPACE:
|
|
{
|
|
if (instance.backspaceRemoves && !this.value.length) {
|
|
instance.removeLastValue();
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case KEY_CODES.ENTER:
|
|
{
|
|
evt.preventDefault();
|
|
if (instance.menu.current === null) return;
|
|
var current = instance.getNode(instance.menu.current);
|
|
if (current.isBranch && instance.disableBranchNodes) return;
|
|
instance.select(current);
|
|
break;
|
|
}
|
|
|
|
case KEY_CODES.ESCAPE:
|
|
{
|
|
if (this.value.length) {
|
|
this.clear();
|
|
} else if (instance.menu.isOpen) {
|
|
instance.closeMenu();
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case KEY_CODES.END:
|
|
{
|
|
evt.preventDefault();
|
|
instance.highlightLastOption();
|
|
break;
|
|
}
|
|
|
|
case KEY_CODES.HOME:
|
|
{
|
|
evt.preventDefault();
|
|
instance.highlightFirstOption();
|
|
break;
|
|
}
|
|
|
|
case KEY_CODES.ARROW_LEFT:
|
|
{
|
|
var _current = instance.getNode(instance.menu.current);
|
|
|
|
if (_current.isBranch && instance.shouldExpand(_current)) {
|
|
evt.preventDefault();
|
|
instance.toggleExpanded(_current);
|
|
} else if (!_current.isRootNode && (_current.isLeaf || _current.isBranch && !instance.shouldExpand(_current))) {
|
|
evt.preventDefault();
|
|
instance.setCurrentHighlightedOption(_current.parentNode);
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case KEY_CODES.ARROW_UP:
|
|
{
|
|
evt.preventDefault();
|
|
instance.highlightPrevOption();
|
|
break;
|
|
}
|
|
|
|
case KEY_CODES.ARROW_RIGHT:
|
|
{
|
|
var _current2 = instance.getNode(instance.menu.current);
|
|
|
|
if (_current2.isBranch && !instance.shouldExpand(_current2)) {
|
|
evt.preventDefault();
|
|
instance.toggleExpanded(_current2);
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case KEY_CODES.ARROW_DOWN:
|
|
{
|
|
evt.preventDefault();
|
|
instance.highlightNextOption();
|
|
break;
|
|
}
|
|
|
|
case KEY_CODES.DELETE:
|
|
{
|
|
if (instance.deleteRemoves && !this.value.length) {
|
|
instance.removeLastValue();
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
default:
|
|
{
|
|
instance.openMenu();
|
|
}
|
|
}
|
|
},
|
|
onMouseDown: function onMouseDown(evt) {
|
|
if (this.value.length) {
|
|
evt.stopPropagation();
|
|
}
|
|
},
|
|
renderInputContainer: function renderInputContainer() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance;
|
|
var props = {};
|
|
var children = [];
|
|
|
|
if (instance.searchable && !instance.disabled) {
|
|
children.push(this.renderInput());
|
|
if (this.needAutoSize) children.push(this.renderSizer());
|
|
}
|
|
|
|
if (!instance.searchable) {
|
|
deepExtend(props, {
|
|
on: {
|
|
focus: this.onFocus,
|
|
blur: this.onBlur,
|
|
keydown: this.onKeyDown
|
|
},
|
|
ref: 'input'
|
|
});
|
|
}
|
|
|
|
if (!instance.searchable && !instance.disabled) {
|
|
deepExtend(props, {
|
|
attrs: {
|
|
tabIndex: instance.tabIndex
|
|
}
|
|
});
|
|
}
|
|
|
|
return h("div", babel_helper_vue_jsx_merge_props_default()([{
|
|
"class": "vue-treeselect__input-container"
|
|
}, props]), [children]);
|
|
},
|
|
renderInput: function renderInput() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance;
|
|
return h("input", {
|
|
ref: "input",
|
|
"class": "vue-treeselect__input",
|
|
attrs: {
|
|
type: "text",
|
|
autocomplete: "off",
|
|
tabIndex: instance.tabIndex,
|
|
required: instance.required && !instance.hasValue
|
|
},
|
|
domProps: {
|
|
"value": this.value
|
|
},
|
|
style: this.inputStyle,
|
|
on: {
|
|
"focus": this.onFocus,
|
|
"input": this.onInput,
|
|
"blur": this.onBlur,
|
|
"keydown": this.onKeyDown,
|
|
"mousedown": this.onMouseDown
|
|
}
|
|
});
|
|
},
|
|
renderSizer: function renderSizer() {
|
|
var h = this.$createElement;
|
|
return h("div", {
|
|
ref: "sizer",
|
|
"class": "vue-treeselect__sizer"
|
|
}, [this.value]);
|
|
},
|
|
updateInputWidth: function updateInputWidth() {
|
|
this.inputWidth = Math.max(MIN_INPUT_WIDTH, this.$refs.sizer.scrollWidth + 15);
|
|
},
|
|
updateSearchQuery: function updateSearchQuery() {
|
|
var instance = this.instance;
|
|
instance.trigger.searchQuery = this.value;
|
|
}
|
|
},
|
|
render: function render() {
|
|
return this.renderInputContainer();
|
|
}
|
|
});
|
|
// CONCATENATED MODULE: ./src/components/Input.vue?vue&type=script&lang=js&
|
|
/* harmony default export */ var components_Inputvue_type_script_lang_js_ = (Inputvue_type_script_lang_js_);
|
|
// CONCATENATED MODULE: ./src/components/Input.vue
|
|
var Input_render, Input_staticRenderFns
|
|
|
|
|
|
|
|
|
|
/* normalize component */
|
|
|
|
var Input_component = normalizeComponent(
|
|
components_Inputvue_type_script_lang_js_,
|
|
Input_render,
|
|
Input_staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
|
|
)
|
|
|
|
/* hot reload */
|
|
if (false) { var Input_api; }
|
|
Input_component.options.__file = "src/components/Input.vue"
|
|
/* harmony default export */ var Input = (Input_component.exports);
|
|
// 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&
|
|
/* harmony default export */ var Placeholdervue_type_script_lang_js_ = ({
|
|
name: 'vue-treeselect--placeholder',
|
|
inject: ['instance'],
|
|
render: function render() {
|
|
var h = arguments[0];
|
|
var instance = this.instance;
|
|
var placeholderClass = {
|
|
'vue-treeselect__placeholder': true,
|
|
'vue-treeselect-helper-zoom-effect-off': true,
|
|
'vue-treeselect-helper-hide': instance.hasValue || instance.trigger.searchQuery
|
|
};
|
|
return h("div", {
|
|
"class": placeholderClass
|
|
}, [instance.placeholder]);
|
|
}
|
|
});
|
|
// CONCATENATED MODULE: ./src/components/Placeholder.vue?vue&type=script&lang=js&
|
|
/* harmony default export */ var components_Placeholdervue_type_script_lang_js_ = (Placeholdervue_type_script_lang_js_);
|
|
// CONCATENATED MODULE: ./src/components/Placeholder.vue
|
|
var Placeholder_render, Placeholder_staticRenderFns
|
|
|
|
|
|
|
|
|
|
/* normalize component */
|
|
|
|
var Placeholder_component = normalizeComponent(
|
|
components_Placeholdervue_type_script_lang_js_,
|
|
Placeholder_render,
|
|
Placeholder_staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
|
|
)
|
|
|
|
/* hot reload */
|
|
if (false) { var Placeholder_api; }
|
|
Placeholder_component.options.__file = "src/components/Placeholder.vue"
|
|
/* harmony default export */ var Placeholder = (Placeholder_component.exports);
|
|
// 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&
|
|
|
|
|
|
/* harmony default export */ var SingleValuevue_type_script_lang_js_ = ({
|
|
name: 'vue-treeselect--single-value',
|
|
inject: ['instance'],
|
|
methods: {
|
|
renderSingleValueLabel: function renderSingleValueLabel() {
|
|
var instance = this.instance;
|
|
var node = instance.selectedNodes[0];
|
|
var customValueLabelRenderer = instance.$scopedSlots['value-label'];
|
|
return customValueLabelRenderer ? customValueLabelRenderer({
|
|
node: node
|
|
}) : node.label;
|
|
}
|
|
},
|
|
render: function render() {
|
|
var h = arguments[0];
|
|
var instance = this.instance,
|
|
renderValueContainer = this.$parent.renderValueContainer;
|
|
var shouldShowValue = instance.hasValue && !instance.trigger.searchQuery;
|
|
return renderValueContainer([shouldShowValue && h("div", {
|
|
"class": "vue-treeselect__single-value"
|
|
}, [this.renderSingleValueLabel()]), h(Placeholder), h(Input, {
|
|
ref: "input"
|
|
})]);
|
|
}
|
|
});
|
|
// CONCATENATED MODULE: ./src/components/SingleValue.vue?vue&type=script&lang=js&
|
|
/* harmony default export */ var components_SingleValuevue_type_script_lang_js_ = (SingleValuevue_type_script_lang_js_);
|
|
// CONCATENATED MODULE: ./src/components/SingleValue.vue
|
|
var SingleValue_render, SingleValue_staticRenderFns
|
|
|
|
|
|
|
|
|
|
/* normalize component */
|
|
|
|
var SingleValue_component = normalizeComponent(
|
|
components_SingleValuevue_type_script_lang_js_,
|
|
SingleValue_render,
|
|
SingleValue_staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
|
|
)
|
|
|
|
/* hot reload */
|
|
if (false) { var SingleValue_api; }
|
|
SingleValue_component.options.__file = "src/components/SingleValue.vue"
|
|
/* harmony default export */ var SingleValue = (SingleValue_component.exports);
|
|
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js!./node_modules/vue-loader/lib??vue-loader-options!./src/components/icons/Delete.vue?vue&type=template&id=364b6320&
|
|
var Deletevue_type_template_id_364b6320_render = function() {
|
|
var _vm = this
|
|
var _h = _vm.$createElement
|
|
var _c = _vm._self._c || _h
|
|
return _c(
|
|
"svg",
|
|
{
|
|
attrs: {
|
|
xmlns: "http://www.w3.org/2000/svg",
|
|
viewBox: "0 0 348.333 348.333"
|
|
}
|
|
},
|
|
[
|
|
_c("path", {
|
|
attrs: {
|
|
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"
|
|
}
|
|
})
|
|
]
|
|
)
|
|
}
|
|
var Deletevue_type_template_id_364b6320_staticRenderFns = []
|
|
Deletevue_type_template_id_364b6320_render._withStripped = true
|
|
|
|
|
|
// CONCATENATED MODULE: ./src/components/icons/Delete.vue?vue&type=template&id=364b6320&
|
|
|
|
// 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&
|
|
/* harmony default export */ var Deletevue_type_script_lang_js_ = ({
|
|
name: 'vue-treeselect--x'
|
|
});
|
|
// CONCATENATED MODULE: ./src/components/icons/Delete.vue?vue&type=script&lang=js&
|
|
/* harmony default export */ var icons_Deletevue_type_script_lang_js_ = (Deletevue_type_script_lang_js_);
|
|
// CONCATENATED MODULE: ./src/components/icons/Delete.vue
|
|
|
|
|
|
|
|
|
|
|
|
/* normalize component */
|
|
|
|
var Delete_component = normalizeComponent(
|
|
icons_Deletevue_type_script_lang_js_,
|
|
Deletevue_type_template_id_364b6320_render,
|
|
Deletevue_type_template_id_364b6320_staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
|
|
)
|
|
|
|
/* hot reload */
|
|
if (false) { var Delete_api; }
|
|
Delete_component.options.__file = "src/components/icons/Delete.vue"
|
|
/* harmony default export */ var Delete = (Delete_component.exports);
|
|
// 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&
|
|
|
|
|
|
/* harmony default export */ var MultiValueItemvue_type_script_lang_js_ = ({
|
|
name: 'vue-treeselect--multi-value-item',
|
|
inject: ['instance'],
|
|
props: {
|
|
node: {
|
|
type: Object,
|
|
required: true
|
|
}
|
|
},
|
|
methods: {
|
|
handleMouseDown: onLeftClick(function handleMouseDown() {
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
instance.select(node);
|
|
})
|
|
},
|
|
render: function render() {
|
|
var h = arguments[0];
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
var itemClass = {
|
|
'vue-treeselect__multi-value-item': true,
|
|
'vue-treeselect__multi-value-item-disabled': node.isDisabled,
|
|
'vue-treeselect__multi-value-item-new': node.isNew
|
|
};
|
|
var customValueLabelRenderer = instance.$scopedSlots['value-label'];
|
|
var labelRenderer = customValueLabelRenderer ? customValueLabelRenderer({
|
|
node: node
|
|
}) : node.label;
|
|
return h("div", {
|
|
"class": "vue-treeselect__multi-value-item-container"
|
|
}, [h("div", {
|
|
"class": itemClass,
|
|
on: {
|
|
"mousedown": this.handleMouseDown
|
|
}
|
|
}, [h("span", {
|
|
"class": "vue-treeselect__multi-value-label"
|
|
}, [labelRenderer]), h("span", {
|
|
"class": "vue-treeselect__icon vue-treeselect__value-remove"
|
|
}, [h(Delete)])])]);
|
|
}
|
|
});
|
|
// CONCATENATED MODULE: ./src/components/MultiValueItem.vue?vue&type=script&lang=js&
|
|
/* harmony default export */ var components_MultiValueItemvue_type_script_lang_js_ = (MultiValueItemvue_type_script_lang_js_);
|
|
// CONCATENATED MODULE: ./src/components/MultiValueItem.vue
|
|
var MultiValueItem_render, MultiValueItem_staticRenderFns
|
|
|
|
|
|
|
|
|
|
/* normalize component */
|
|
|
|
var MultiValueItem_component = normalizeComponent(
|
|
components_MultiValueItemvue_type_script_lang_js_,
|
|
MultiValueItem_render,
|
|
MultiValueItem_staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
|
|
)
|
|
|
|
/* hot reload */
|
|
if (false) { var MultiValueItem_api; }
|
|
MultiValueItem_component.options.__file = "src/components/MultiValueItem.vue"
|
|
/* harmony default export */ var MultiValueItem = (MultiValueItem_component.exports);
|
|
// 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&
|
|
|
|
|
|
|
|
|
|
/* harmony default export */ var MultiValuevue_type_script_lang_js_ = ({
|
|
name: 'vue-treeselect--multi-value',
|
|
inject: ['instance'],
|
|
methods: {
|
|
renderMultiValueItems: function renderMultiValueItems() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance;
|
|
return instance.internalValue.slice(0, instance.limit).map(instance.getNode).map(function (node) {
|
|
return h(MultiValueItem, {
|
|
key: "multi-value-item-".concat(node.id),
|
|
attrs: {
|
|
node: node
|
|
}
|
|
});
|
|
});
|
|
},
|
|
renderExceedLimitTip: function renderExceedLimitTip() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance;
|
|
var count = instance.internalValue.length - instance.limit;
|
|
if (count <= 0) return null;
|
|
return h("div", {
|
|
"class": "vue-treeselect__limit-tip vue-treeselect-helper-zoom-effect-off",
|
|
key: "exceed-limit-tip"
|
|
}, [h("span", {
|
|
"class": "vue-treeselect__limit-tip-text"
|
|
}, [instance.limitText(count)])]);
|
|
}
|
|
},
|
|
render: function render() {
|
|
var h = arguments[0];
|
|
var renderValueContainer = this.$parent.renderValueContainer;
|
|
var transitionGroupProps = {
|
|
props: {
|
|
tag: 'div',
|
|
name: 'vue-treeselect__multi-value-item--transition',
|
|
appear: true
|
|
}
|
|
};
|
|
return renderValueContainer(h("transition-group", babel_helper_vue_jsx_merge_props_default()([{
|
|
"class": "vue-treeselect__multi-value"
|
|
}, transitionGroupProps]), [this.renderMultiValueItems(), this.renderExceedLimitTip(), h(Placeholder, {
|
|
key: "placeholder"
|
|
}), h(Input, {
|
|
ref: "input",
|
|
key: "input"
|
|
})]));
|
|
}
|
|
});
|
|
// CONCATENATED MODULE: ./src/components/MultiValue.vue?vue&type=script&lang=js&
|
|
/* harmony default export */ var components_MultiValuevue_type_script_lang_js_ = (MultiValuevue_type_script_lang_js_);
|
|
// CONCATENATED MODULE: ./src/components/MultiValue.vue
|
|
var MultiValue_render, MultiValue_staticRenderFns
|
|
|
|
|
|
|
|
|
|
/* normalize component */
|
|
|
|
var MultiValue_component = normalizeComponent(
|
|
components_MultiValuevue_type_script_lang_js_,
|
|
MultiValue_render,
|
|
MultiValue_staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
|
|
)
|
|
|
|
/* hot reload */
|
|
if (false) { var MultiValue_api; }
|
|
MultiValue_component.options.__file = "src/components/MultiValue.vue"
|
|
/* harmony default export */ var MultiValue = (MultiValue_component.exports);
|
|
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js!./node_modules/vue-loader/lib??vue-loader-options!./src/components/icons/Arrow.vue?vue&type=template&id=11186cd4&
|
|
var Arrowvue_type_template_id_11186cd4_render = function() {
|
|
var _vm = this
|
|
var _h = _vm.$createElement
|
|
var _c = _vm._self._c || _h
|
|
return _c(
|
|
"svg",
|
|
{
|
|
attrs: {
|
|
xmlns: "http://www.w3.org/2000/svg",
|
|
viewBox: "0 0 292.362 292.362"
|
|
}
|
|
},
|
|
[
|
|
_c("path", {
|
|
attrs: {
|
|
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"
|
|
}
|
|
})
|
|
]
|
|
)
|
|
}
|
|
var Arrowvue_type_template_id_11186cd4_staticRenderFns = []
|
|
Arrowvue_type_template_id_11186cd4_render._withStripped = true
|
|
|
|
|
|
// CONCATENATED MODULE: ./src/components/icons/Arrow.vue?vue&type=template&id=11186cd4&
|
|
|
|
// 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&
|
|
/* harmony default export */ var Arrowvue_type_script_lang_js_ = ({
|
|
name: 'vue-treeselect--arrow'
|
|
});
|
|
// CONCATENATED MODULE: ./src/components/icons/Arrow.vue?vue&type=script&lang=js&
|
|
/* harmony default export */ var icons_Arrowvue_type_script_lang_js_ = (Arrowvue_type_script_lang_js_);
|
|
// CONCATENATED MODULE: ./src/components/icons/Arrow.vue
|
|
|
|
|
|
|
|
|
|
|
|
/* normalize component */
|
|
|
|
var Arrow_component = normalizeComponent(
|
|
icons_Arrowvue_type_script_lang_js_,
|
|
Arrowvue_type_template_id_11186cd4_render,
|
|
Arrowvue_type_template_id_11186cd4_staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
|
|
)
|
|
|
|
/* hot reload */
|
|
if (false) { var Arrow_api; }
|
|
Arrow_component.options.__file = "src/components/icons/Arrow.vue"
|
|
/* harmony default export */ var Arrow = (Arrow_component.exports);
|
|
// 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&
|
|
|
|
|
|
|
|
|
|
|
|
/* harmony default export */ var Controlvue_type_script_lang_js_ = ({
|
|
name: 'vue-treeselect--control',
|
|
inject: ['instance'],
|
|
computed: {
|
|
shouldShowX: function shouldShowX() {
|
|
var instance = this.instance;
|
|
return instance.clearable && !instance.disabled && instance.hasValue && (this.hasUndisabledValue || instance.allowClearingDisabled);
|
|
},
|
|
shouldShowArrow: function shouldShowArrow() {
|
|
var instance = this.instance;
|
|
if (!instance.alwaysOpen) return true;
|
|
return !instance.menu.isOpen;
|
|
},
|
|
hasUndisabledValue: function hasUndisabledValue() {
|
|
var instance = this.instance;
|
|
return instance.hasValue && instance.internalValue.some(function (id) {
|
|
return !instance.getNode(id).isDisabled;
|
|
});
|
|
}
|
|
},
|
|
methods: {
|
|
renderX: function renderX() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance;
|
|
var title = instance.multiple ? instance.clearAllText : instance.clearValueText;
|
|
if (!this.shouldShowX) return null;
|
|
return h("div", {
|
|
"class": "vue-treeselect__x-container",
|
|
attrs: {
|
|
title: title
|
|
},
|
|
on: {
|
|
"mousedown": this.handleMouseDownOnX
|
|
}
|
|
}, [h(Delete, {
|
|
"class": "vue-treeselect__x"
|
|
})]);
|
|
},
|
|
renderArrow: function renderArrow() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance;
|
|
var arrowClass = {
|
|
'vue-treeselect__control-arrow': true,
|
|
'vue-treeselect__control-arrow--rotated': instance.menu.isOpen
|
|
};
|
|
if (!this.shouldShowArrow) return null;
|
|
return h("div", {
|
|
"class": "vue-treeselect__control-arrow-container",
|
|
on: {
|
|
"mousedown": this.handleMouseDownOnArrow
|
|
}
|
|
}, [h(Arrow, {
|
|
"class": arrowClass
|
|
})]);
|
|
},
|
|
handleMouseDownOnX: onLeftClick(function handleMouseDownOnX(evt) {
|
|
evt.stopPropagation();
|
|
evt.preventDefault();
|
|
var instance = this.instance;
|
|
var result = instance.beforeClearAll();
|
|
|
|
var handler = function handler(shouldClear) {
|
|
if (shouldClear) instance.clear();
|
|
};
|
|
|
|
if (is_promise_default()(result)) {
|
|
result.then(handler);
|
|
} else {
|
|
setTimeout(function () {
|
|
return handler(result);
|
|
}, 0);
|
|
}
|
|
}),
|
|
handleMouseDownOnArrow: onLeftClick(function handleMouseDownOnArrow(evt) {
|
|
evt.preventDefault();
|
|
evt.stopPropagation();
|
|
var instance = this.instance;
|
|
instance.focusInput();
|
|
instance.toggleMenu();
|
|
}),
|
|
renderValueContainer: function renderValueContainer(children) {
|
|
var h = this.$createElement;
|
|
return h("div", {
|
|
"class": "vue-treeselect__value-container"
|
|
}, [children]);
|
|
}
|
|
},
|
|
render: function render() {
|
|
var h = arguments[0];
|
|
var instance = this.instance;
|
|
var ValueContainer = instance.single ? SingleValue : MultiValue;
|
|
return h("div", {
|
|
"class": "vue-treeselect__control",
|
|
on: {
|
|
"mousedown": instance.handleMouseDown
|
|
}
|
|
}, [h(ValueContainer, {
|
|
ref: "value-container"
|
|
}), this.renderX(), this.renderArrow()]);
|
|
}
|
|
});
|
|
// CONCATENATED MODULE: ./src/components/Control.vue?vue&type=script&lang=js&
|
|
/* harmony default export */ var components_Controlvue_type_script_lang_js_ = (Controlvue_type_script_lang_js_);
|
|
// CONCATENATED MODULE: ./src/components/Control.vue
|
|
var Control_render, Control_staticRenderFns
|
|
|
|
|
|
|
|
|
|
/* normalize component */
|
|
|
|
var Control_component = normalizeComponent(
|
|
components_Controlvue_type_script_lang_js_,
|
|
Control_render,
|
|
Control_staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
|
|
)
|
|
|
|
/* hot reload */
|
|
if (false) { var Control_api; }
|
|
Control_component.options.__file = "src/components/Control.vue"
|
|
/* harmony default export */ var Control = (Control_component.exports);
|
|
// 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&
|
|
/* harmony default export */ var Tipvue_type_script_lang_js_ = ({
|
|
name: 'vue-treeselect--tip',
|
|
functional: true,
|
|
props: {
|
|
type: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
icon: {
|
|
type: String,
|
|
required: true
|
|
}
|
|
},
|
|
render: function render(_, context) {
|
|
var h = arguments[0];
|
|
var props = context.props,
|
|
children = context.children;
|
|
return h("div", {
|
|
"class": "vue-treeselect__tip vue-treeselect__".concat(props.type, "-tip")
|
|
}, [h("div", {
|
|
"class": "vue-treeselect__icon-container"
|
|
}, [h("span", {
|
|
"class": "vue-treeselect__icon-".concat(props.icon)
|
|
})]), h("span", {
|
|
"class": "vue-treeselect__tip-text vue-treeselect__".concat(props.type, "-tip-text")
|
|
}, [children])]);
|
|
}
|
|
});
|
|
// CONCATENATED MODULE: ./src/components/Tip.vue?vue&type=script&lang=js&
|
|
/* harmony default export */ var components_Tipvue_type_script_lang_js_ = (Tipvue_type_script_lang_js_);
|
|
// CONCATENATED MODULE: ./src/components/Tip.vue
|
|
var Tip_render, Tip_staticRenderFns
|
|
|
|
|
|
|
|
|
|
/* normalize component */
|
|
|
|
var Tip_component = normalizeComponent(
|
|
components_Tipvue_type_script_lang_js_,
|
|
Tip_render,
|
|
Tip_staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
|
|
)
|
|
|
|
/* hot reload */
|
|
if (false) { var Tip_api; }
|
|
Tip_component.options.__file = "src/components/Tip.vue"
|
|
/* harmony default export */ var Tip = (Tip_component.exports);
|
|
// 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&
|
|
|
|
|
|
|
|
|
|
|
|
var arrowPlaceholder, checkMark, minusMark;
|
|
var Option = {
|
|
name: 'vue-treeselect--option',
|
|
inject: ['instance'],
|
|
props: {
|
|
node: {
|
|
type: Object,
|
|
required: true
|
|
}
|
|
},
|
|
computed: {
|
|
shouldExpand: function shouldExpand() {
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
return node.isBranch && instance.shouldExpand(node);
|
|
},
|
|
shouldShow: function shouldShow() {
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
return instance.shouldShowOptionInMenu(node);
|
|
}
|
|
},
|
|
methods: {
|
|
renderOption: function renderOption() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
var optionClass = {
|
|
'vue-treeselect__option': true,
|
|
'vue-treeselect__option--disabled': node.isDisabled,
|
|
'vue-treeselect__option--selected': instance.isSelected(node),
|
|
'vue-treeselect__option--highlight': node.isHighlighted,
|
|
'vue-treeselect__option--matched': instance.localSearch.active && node.isMatched,
|
|
'vue-treeselect__option--hide': !this.shouldShow
|
|
};
|
|
return h("div", {
|
|
"class": optionClass,
|
|
on: {
|
|
"mouseenter": this.handleMouseEnterOption
|
|
},
|
|
attrs: {
|
|
"data-id": node.id
|
|
}
|
|
}, [this.renderArrow(), this.renderLabelContainer([this.renderCheckboxContainer([this.renderCheckbox()]), this.renderLabel()])]);
|
|
},
|
|
renderSubOptionsList: function renderSubOptionsList() {
|
|
var h = this.$createElement;
|
|
if (!this.shouldExpand) return null;
|
|
return h("div", {
|
|
"class": "vue-treeselect__list"
|
|
}, [this.renderSubOptions(), this.renderNoChildrenTip(), this.renderLoadingChildrenTip(), this.renderLoadingChildrenErrorTip()]);
|
|
},
|
|
renderArrow: function renderArrow() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
if (instance.shouldFlattenOptions && this.shouldShow) return null;
|
|
|
|
if (node.isBranch) {
|
|
var transitionProps = {
|
|
props: {
|
|
name: 'vue-treeselect__option-arrow--prepare',
|
|
appear: true
|
|
}
|
|
};
|
|
var arrowClass = {
|
|
'vue-treeselect__option-arrow': true,
|
|
'vue-treeselect__option-arrow--rotated': this.shouldExpand
|
|
};
|
|
return h("div", {
|
|
"class": "vue-treeselect__option-arrow-container",
|
|
on: {
|
|
"mousedown": this.handleMouseDownOnArrow
|
|
}
|
|
}, [h("transition", transitionProps, [h(Arrow, {
|
|
"class": arrowClass
|
|
})])]);
|
|
}
|
|
|
|
if (instance.hasBranchNodes) {
|
|
if (!arrowPlaceholder) arrowPlaceholder = h("div", {
|
|
"class": "vue-treeselect__option-arrow-placeholder"
|
|
}, ["\xA0"]);
|
|
return arrowPlaceholder;
|
|
}
|
|
|
|
return null;
|
|
},
|
|
renderLabelContainer: function renderLabelContainer(children) {
|
|
var h = this.$createElement;
|
|
return h("div", {
|
|
"class": "vue-treeselect__label-container",
|
|
on: {
|
|
"mousedown": this.handleMouseDownOnLabelContainer
|
|
}
|
|
}, [children]);
|
|
},
|
|
renderCheckboxContainer: function renderCheckboxContainer(children) {
|
|
var h = this.$createElement;
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
if (instance.single) return null;
|
|
if (instance.disableBranchNodes && node.isBranch) return null;
|
|
return h("div", {
|
|
"class": "vue-treeselect__checkbox-container"
|
|
}, [children]);
|
|
},
|
|
renderCheckbox: function renderCheckbox() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
var checkedState = instance.forest.checkedStateMap[node.id];
|
|
var checkboxClass = {
|
|
'vue-treeselect__checkbox': true,
|
|
'vue-treeselect__checkbox--checked': checkedState === CHECKED,
|
|
'vue-treeselect__checkbox--indeterminate': checkedState === INDETERMINATE,
|
|
'vue-treeselect__checkbox--unchecked': checkedState === UNCHECKED,
|
|
'vue-treeselect__checkbox--disabled': node.isDisabled
|
|
};
|
|
if (!checkMark) checkMark = h("span", {
|
|
"class": "vue-treeselect__check-mark"
|
|
});
|
|
if (!minusMark) minusMark = h("span", {
|
|
"class": "vue-treeselect__minus-mark"
|
|
});
|
|
return h("span", {
|
|
"class": checkboxClass
|
|
}, [checkMark, minusMark]);
|
|
},
|
|
renderLabel: function renderLabel() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
var shouldShowCount = node.isBranch && (instance.localSearch.active ? instance.showCountOnSearchComputed : instance.showCount);
|
|
var count = shouldShowCount ? instance.localSearch.active ? instance.localSearch.countMap[node.id][instance.showCountOf] : node.count[instance.showCountOf] : NaN;
|
|
var labelClassName = 'vue-treeselect__label';
|
|
var countClassName = 'vue-treeselect__count';
|
|
var customLabelRenderer = instance.$scopedSlots['option-label'];
|
|
if (customLabelRenderer) return customLabelRenderer({
|
|
node: node,
|
|
shouldShowCount: shouldShowCount,
|
|
count: count,
|
|
labelClassName: labelClassName,
|
|
countClassName: countClassName
|
|
});
|
|
return h("label", {
|
|
"class": labelClassName
|
|
}, [node.label, shouldShowCount && h("span", {
|
|
"class": countClassName
|
|
}, ["(", count, ")"])]);
|
|
},
|
|
renderSubOptions: function renderSubOptions() {
|
|
var h = this.$createElement;
|
|
var node = this.node;
|
|
if (!node.childrenStates.isLoaded) return null;
|
|
return node.children.map(function (childNode) {
|
|
return h(Option, {
|
|
attrs: {
|
|
node: childNode
|
|
},
|
|
key: childNode.id
|
|
});
|
|
});
|
|
},
|
|
renderNoChildrenTip: function renderNoChildrenTip() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
if (!node.childrenStates.isLoaded || node.children.length) return null;
|
|
return h(Tip, {
|
|
attrs: {
|
|
type: "no-children",
|
|
icon: "warning"
|
|
}
|
|
}, [instance.noChildrenText]);
|
|
},
|
|
renderLoadingChildrenTip: function renderLoadingChildrenTip() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
if (!node.childrenStates.isLoading) return null;
|
|
return h(Tip, {
|
|
attrs: {
|
|
type: "loading",
|
|
icon: "loader"
|
|
}
|
|
}, [instance.loadingText]);
|
|
},
|
|
renderLoadingChildrenErrorTip: function renderLoadingChildrenErrorTip() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
if (!node.childrenStates.loadingError) return null;
|
|
return h(Tip, {
|
|
attrs: {
|
|
type: "error",
|
|
icon: "error"
|
|
}
|
|
}, [node.childrenStates.loadingError, h("a", {
|
|
"class": "vue-treeselect__retry",
|
|
attrs: {
|
|
title: instance.retryTitle
|
|
},
|
|
on: {
|
|
"mousedown": this.handleMouseDownOnRetry
|
|
}
|
|
}, [instance.retryText])]);
|
|
},
|
|
handleMouseEnterOption: function handleMouseEnterOption(evt) {
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
if (evt.target !== evt.currentTarget) return;
|
|
instance.setCurrentHighlightedOption(node, false);
|
|
},
|
|
handleMouseDownOnArrow: onLeftClick(function handleMouseDownOnOptionArrow() {
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
instance.toggleExpanded(node);
|
|
}),
|
|
handleMouseDownOnLabelContainer: onLeftClick(function handleMouseDownOnLabelContainer() {
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
|
|
if (node.isBranch && instance.disableBranchNodes) {
|
|
instance.toggleExpanded(node);
|
|
} else {
|
|
instance.select(node);
|
|
}
|
|
}),
|
|
handleMouseDownOnRetry: onLeftClick(function handleMouseDownOnRetry() {
|
|
var instance = this.instance,
|
|
node = this.node;
|
|
instance.loadChildrenOptions(node);
|
|
})
|
|
},
|
|
render: function render() {
|
|
var h = arguments[0];
|
|
var node = this.node;
|
|
var indentLevel = this.instance.shouldFlattenOptions ? 0 : node.level;
|
|
|
|
var listItemClass = defineProperty_default()({
|
|
'vue-treeselect__list-item': true
|
|
}, "vue-treeselect__indent-level-".concat(indentLevel), true);
|
|
|
|
var transitionProps = {
|
|
props: {
|
|
name: 'vue-treeselect__list--transition'
|
|
}
|
|
};
|
|
return h("div", {
|
|
"class": listItemClass
|
|
}, [this.renderOption(), node.isBranch && h("transition", transitionProps, [this.renderSubOptionsList()])]);
|
|
}
|
|
};
|
|
/* harmony default export */ var Optionvue_type_script_lang_js_ = (Option);
|
|
// CONCATENATED MODULE: ./src/components/Option.vue?vue&type=script&lang=js&
|
|
/* harmony default export */ var components_Optionvue_type_script_lang_js_ = (Optionvue_type_script_lang_js_);
|
|
// CONCATENATED MODULE: ./src/components/Option.vue
|
|
var Option_render, Option_staticRenderFns
|
|
|
|
|
|
|
|
|
|
/* normalize component */
|
|
|
|
var Option_component = normalizeComponent(
|
|
components_Optionvue_type_script_lang_js_,
|
|
Option_render,
|
|
Option_staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
|
|
)
|
|
|
|
/* hot reload */
|
|
if (false) { var Option_api; }
|
|
Option_component.options.__file = "src/components/Option.vue"
|
|
/* harmony default export */ var components_Option = (Option_component.exports);
|
|
// 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&
|
|
|
|
|
|
|
|
|
|
var directionMap = {
|
|
top: 'top',
|
|
bottom: 'bottom',
|
|
above: 'top',
|
|
below: 'bottom'
|
|
};
|
|
/* harmony default export */ var Menuvue_type_script_lang_js_ = ({
|
|
name: 'vue-treeselect--menu',
|
|
inject: ['instance'],
|
|
computed: {
|
|
menuStyle: function menuStyle() {
|
|
var instance = this.instance;
|
|
return {
|
|
maxHeight: instance.maxHeight + 'px'
|
|
};
|
|
},
|
|
menuContainerStyle: function menuContainerStyle() {
|
|
var instance = this.instance;
|
|
return {
|
|
zIndex: instance.appendToBody ? null : instance.zIndex
|
|
};
|
|
}
|
|
},
|
|
watch: {
|
|
'instance.menu.isOpen': function instanceMenuIsOpen(newValue) {
|
|
if (newValue) {
|
|
this.$nextTick(this.onMenuOpen);
|
|
} else {
|
|
this.onMenuClose();
|
|
}
|
|
}
|
|
},
|
|
created: function created() {
|
|
this.menuSizeWatcher = null;
|
|
this.menuResizeAndScrollEventListeners = null;
|
|
},
|
|
mounted: function mounted() {
|
|
var instance = this.instance;
|
|
if (instance.menu.isOpen) this.$nextTick(this.onMenuOpen);
|
|
},
|
|
destroyed: function destroyed() {
|
|
this.onMenuClose();
|
|
},
|
|
methods: {
|
|
renderMenu: function renderMenu() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance;
|
|
if (!instance.menu.isOpen) return null;
|
|
return h("div", {
|
|
ref: "menu",
|
|
"class": "vue-treeselect__menu",
|
|
on: {
|
|
"mousedown": instance.handleMouseDown
|
|
},
|
|
style: this.menuStyle
|
|
}, [this.renderBeforeList(), instance.async ? this.renderAsyncSearchMenuInner() : instance.localSearch.active ? this.renderLocalSearchMenuInner() : this.renderNormalMenuInner(), this.renderAfterList()]);
|
|
},
|
|
renderBeforeList: function renderBeforeList() {
|
|
var instance = this.instance;
|
|
var beforeListRenderer = instance.$scopedSlots['before-list'];
|
|
return beforeListRenderer ? beforeListRenderer() : null;
|
|
},
|
|
renderAfterList: function renderAfterList() {
|
|
var instance = this.instance;
|
|
var afterListRenderer = instance.$scopedSlots['after-list'];
|
|
return afterListRenderer ? afterListRenderer() : null;
|
|
},
|
|
renderNormalMenuInner: function renderNormalMenuInner() {
|
|
var instance = this.instance;
|
|
|
|
if (instance.rootOptionsStates.isLoading) {
|
|
return this.renderLoadingOptionsTip();
|
|
} else if (instance.rootOptionsStates.loadingError) {
|
|
return this.renderLoadingRootOptionsErrorTip();
|
|
} else if (instance.rootOptionsStates.isLoaded && instance.forest.normalizedOptions.length === 0) {
|
|
return this.renderNoAvailableOptionsTip();
|
|
} else {
|
|
return this.renderOptionList();
|
|
}
|
|
},
|
|
renderLocalSearchMenuInner: function renderLocalSearchMenuInner() {
|
|
var instance = this.instance;
|
|
|
|
if (instance.rootOptionsStates.isLoading) {
|
|
return this.renderLoadingOptionsTip();
|
|
} else if (instance.rootOptionsStates.loadingError) {
|
|
return this.renderLoadingRootOptionsErrorTip();
|
|
} else if (instance.rootOptionsStates.isLoaded && instance.forest.normalizedOptions.length === 0) {
|
|
return this.renderNoAvailableOptionsTip();
|
|
} else if (instance.localSearch.noResults) {
|
|
return this.renderNoResultsTip();
|
|
} else {
|
|
return this.renderOptionList();
|
|
}
|
|
},
|
|
renderAsyncSearchMenuInner: function renderAsyncSearchMenuInner() {
|
|
var instance = this.instance;
|
|
var entry = instance.getRemoteSearchEntry();
|
|
var shouldShowSearchPromptTip = instance.trigger.searchQuery === '' && !instance.defaultOptions;
|
|
var shouldShowNoResultsTip = shouldShowSearchPromptTip ? false : entry.isLoaded && entry.options.length === 0;
|
|
|
|
if (shouldShowSearchPromptTip) {
|
|
return this.renderSearchPromptTip();
|
|
} else if (entry.isLoading) {
|
|
return this.renderLoadingOptionsTip();
|
|
} else if (entry.loadingError) {
|
|
return this.renderAsyncSearchLoadingErrorTip();
|
|
} else if (shouldShowNoResultsTip) {
|
|
return this.renderNoResultsTip();
|
|
} else {
|
|
return this.renderOptionList();
|
|
}
|
|
},
|
|
renderOptionList: function renderOptionList() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance;
|
|
return h("div", {
|
|
"class": "vue-treeselect__list"
|
|
}, [instance.forest.normalizedOptions.map(function (rootNode) {
|
|
return h(components_Option, {
|
|
attrs: {
|
|
node: rootNode
|
|
},
|
|
key: rootNode.id
|
|
});
|
|
})]);
|
|
},
|
|
renderSearchPromptTip: function renderSearchPromptTip() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance;
|
|
return h(Tip, {
|
|
attrs: {
|
|
type: "search-prompt",
|
|
icon: "warning"
|
|
}
|
|
}, [instance.searchPromptText]);
|
|
},
|
|
renderLoadingOptionsTip: function renderLoadingOptionsTip() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance;
|
|
return h(Tip, {
|
|
attrs: {
|
|
type: "loading",
|
|
icon: "loader"
|
|
}
|
|
}, [instance.loadingText]);
|
|
},
|
|
renderLoadingRootOptionsErrorTip: function renderLoadingRootOptionsErrorTip() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance;
|
|
return h(Tip, {
|
|
attrs: {
|
|
type: "error",
|
|
icon: "error"
|
|
}
|
|
}, [instance.rootOptionsStates.loadingError, h("a", {
|
|
"class": "vue-treeselect__retry",
|
|
on: {
|
|
"click": instance.loadRootOptions
|
|
},
|
|
attrs: {
|
|
title: instance.retryTitle
|
|
}
|
|
}, [instance.retryText])]);
|
|
},
|
|
renderAsyncSearchLoadingErrorTip: function renderAsyncSearchLoadingErrorTip() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance;
|
|
var entry = instance.getRemoteSearchEntry();
|
|
return h(Tip, {
|
|
attrs: {
|
|
type: "error",
|
|
icon: "error"
|
|
}
|
|
}, [entry.loadingError, h("a", {
|
|
"class": "vue-treeselect__retry",
|
|
on: {
|
|
"click": instance.handleRemoteSearch
|
|
},
|
|
attrs: {
|
|
title: instance.retryTitle
|
|
}
|
|
}, [instance.retryText])]);
|
|
},
|
|
renderNoAvailableOptionsTip: function renderNoAvailableOptionsTip() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance;
|
|
return h(Tip, {
|
|
attrs: {
|
|
type: "no-options",
|
|
icon: "warning"
|
|
}
|
|
}, [instance.noOptionsText]);
|
|
},
|
|
renderNoResultsTip: function renderNoResultsTip() {
|
|
var h = this.$createElement;
|
|
var instance = this.instance;
|
|
return h(Tip, {
|
|
attrs: {
|
|
type: "no-results",
|
|
icon: "warning"
|
|
}
|
|
}, [instance.noResultsText]);
|
|
},
|
|
onMenuOpen: function onMenuOpen() {
|
|
this.adjustMenuOpenDirection();
|
|
this.setupMenuSizeWatcher();
|
|
this.setupMenuResizeAndScrollEventListeners();
|
|
},
|
|
onMenuClose: function onMenuClose() {
|
|
this.removeMenuSizeWatcher();
|
|
this.removeMenuResizeAndScrollEventListeners();
|
|
},
|
|
adjustMenuOpenDirection: function adjustMenuOpenDirection() {
|
|
var instance = this.instance;
|
|
if (!instance.menu.isOpen) return;
|
|
var $menu = instance.getMenu();
|
|
var $control = instance.getControl();
|
|
var menuRect = $menu.getBoundingClientRect();
|
|
var controlRect = $control.getBoundingClientRect();
|
|
var menuHeight = menuRect.height;
|
|
var viewportHeight = window.innerHeight;
|
|
var spaceAbove = controlRect.top;
|
|
var spaceBelow = window.innerHeight - controlRect.bottom;
|
|
var isControlInViewport = controlRect.top >= 0 && controlRect.top <= viewportHeight || controlRect.top < 0 && controlRect.bottom > 0;
|
|
var hasEnoughSpaceBelow = spaceBelow > menuHeight + MENU_BUFFER;
|
|
var hasEnoughSpaceAbove = spaceAbove > menuHeight + MENU_BUFFER;
|
|
|
|
if (!isControlInViewport) {
|
|
instance.closeMenu();
|
|
} else if (instance.openDirection !== 'auto') {
|
|
instance.menu.placement = directionMap[instance.openDirection];
|
|
} else if (hasEnoughSpaceBelow || !hasEnoughSpaceAbove) {
|
|
instance.menu.placement = 'bottom';
|
|
} else {
|
|
instance.menu.placement = 'top';
|
|
}
|
|
},
|
|
setupMenuSizeWatcher: function setupMenuSizeWatcher() {
|
|
var instance = this.instance;
|
|
var $menu = instance.getMenu();
|
|
if (this.menuSizeWatcher) return;
|
|
this.menuSizeWatcher = {
|
|
remove: watchSize($menu, this.adjustMenuOpenDirection)
|
|
};
|
|
},
|
|
setupMenuResizeAndScrollEventListeners: function setupMenuResizeAndScrollEventListeners() {
|
|
var instance = this.instance;
|
|
var $control = instance.getControl();
|
|
if (this.menuResizeAndScrollEventListeners) return;
|
|
this.menuResizeAndScrollEventListeners = {
|
|
remove: setupResizeAndScrollEventListeners($control, this.adjustMenuOpenDirection)
|
|
};
|
|
},
|
|
removeMenuSizeWatcher: function removeMenuSizeWatcher() {
|
|
if (!this.menuSizeWatcher) return;
|
|
this.menuSizeWatcher.remove();
|
|
this.menuSizeWatcher = null;
|
|
},
|
|
removeMenuResizeAndScrollEventListeners: function removeMenuResizeAndScrollEventListeners() {
|
|
if (!this.menuResizeAndScrollEventListeners) return;
|
|
this.menuResizeAndScrollEventListeners.remove();
|
|
this.menuResizeAndScrollEventListeners = null;
|
|
}
|
|
},
|
|
render: function render() {
|
|
var h = arguments[0];
|
|
return h("div", {
|
|
ref: "menu-container",
|
|
"class": "vue-treeselect__menu-container",
|
|
style: this.menuContainerStyle
|
|
}, [h("transition", {
|
|
attrs: {
|
|
name: "vue-treeselect__menu--transition"
|
|
}
|
|
}, [this.renderMenu()])]);
|
|
}
|
|
});
|
|
// CONCATENATED MODULE: ./src/components/Menu.vue?vue&type=script&lang=js&
|
|
/* harmony default export */ var components_Menuvue_type_script_lang_js_ = (Menuvue_type_script_lang_js_);
|
|
// CONCATENATED MODULE: ./src/components/Menu.vue
|
|
var Menu_render, Menu_staticRenderFns
|
|
|
|
|
|
|
|
|
|
/* normalize component */
|
|
|
|
var Menu_component = normalizeComponent(
|
|
components_Menuvue_type_script_lang_js_,
|
|
Menu_render,
|
|
Menu_staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
|
|
)
|
|
|
|
/* hot reload */
|
|
if (false) { var Menu_api; }
|
|
Menu_component.options.__file = "src/components/Menu.vue"
|
|
/* harmony default export */ var Menu = (Menu_component.exports);
|
|
// EXTERNAL MODULE: external "Vue"
|
|
var external_Vue_ = __webpack_require__(34);
|
|
var external_Vue_default = /*#__PURE__*/__webpack_require__.n(external_Vue_);
|
|
|
|
// 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&
|
|
|
|
|
|
function MenuPortalvue_type_script_lang_js_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
|
|
function MenuPortalvue_type_script_lang_js_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { MenuPortalvue_type_script_lang_js_ownKeys(source, true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { MenuPortalvue_type_script_lang_js_ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
|
|
|
|
|
|
|
|
var PortalTarget = {
|
|
name: 'vue-treeselect--portal-target',
|
|
inject: ['instance'],
|
|
watch: {
|
|
'instance.menu.isOpen': function instanceMenuIsOpen(newValue) {
|
|
if (newValue) {
|
|
this.setupHandlers();
|
|
} else {
|
|
this.removeHandlers();
|
|
}
|
|
},
|
|
'instance.menu.placement': function instanceMenuPlacement() {
|
|
this.updateMenuContainerOffset();
|
|
}
|
|
},
|
|
created: function created() {
|
|
this.controlResizeAndScrollEventListeners = null;
|
|
this.controlSizeWatcher = null;
|
|
},
|
|
mounted: function mounted() {
|
|
var instance = this.instance;
|
|
if (instance.menu.isOpen) this.setupHandlers();
|
|
},
|
|
methods: {
|
|
setupHandlers: function setupHandlers() {
|
|
this.updateWidth();
|
|
this.updateMenuContainerOffset();
|
|
this.setupControlResizeAndScrollEventListeners();
|
|
this.setupControlSizeWatcher();
|
|
},
|
|
removeHandlers: function removeHandlers() {
|
|
this.removeControlResizeAndScrollEventListeners();
|
|
this.removeControlSizeWatcher();
|
|
},
|
|
setupControlResizeAndScrollEventListeners: function setupControlResizeAndScrollEventListeners() {
|
|
var instance = this.instance;
|
|
var $control = instance.getControl();
|
|
if (this.controlResizeAndScrollEventListeners) return;
|
|
this.controlResizeAndScrollEventListeners = {
|
|
remove: setupResizeAndScrollEventListeners($control, this.updateMenuContainerOffset)
|
|
};
|
|
},
|
|
setupControlSizeWatcher: function setupControlSizeWatcher() {
|
|
var _this = this;
|
|
|
|
var instance = this.instance;
|
|
var $control = instance.getControl();
|
|
if (this.controlSizeWatcher) return;
|
|
this.controlSizeWatcher = {
|
|
remove: watchSize($control, function () {
|
|
_this.updateWidth();
|
|
|
|
_this.updateMenuContainerOffset();
|
|
})
|
|
};
|
|
},
|
|
removeControlResizeAndScrollEventListeners: function removeControlResizeAndScrollEventListeners() {
|
|
if (!this.controlResizeAndScrollEventListeners) return;
|
|
this.controlResizeAndScrollEventListeners.remove();
|
|
this.controlResizeAndScrollEventListeners = null;
|
|
},
|
|
removeControlSizeWatcher: function removeControlSizeWatcher() {
|
|
if (!this.controlSizeWatcher) return;
|
|
this.controlSizeWatcher.remove();
|
|
this.controlSizeWatcher = null;
|
|
},
|
|
updateWidth: function updateWidth() {
|
|
var instance = this.instance;
|
|
var $portalTarget = this.$el;
|
|
var $control = instance.getControl();
|
|
var controlRect = $control.getBoundingClientRect();
|
|
$portalTarget.style.width = controlRect.width + 'px';
|
|
},
|
|
updateMenuContainerOffset: function updateMenuContainerOffset() {
|
|
var instance = this.instance;
|
|
var $control = instance.getControl();
|
|
var $portalTarget = this.$el;
|
|
var controlRect = $control.getBoundingClientRect();
|
|
var portalTargetRect = $portalTarget.getBoundingClientRect();
|
|
var offsetY = instance.menu.placement === 'bottom' ? controlRect.height : 0;
|
|
var left = Math.round(controlRect.left - portalTargetRect.left) + 'px';
|
|
var top = Math.round(controlRect.top - portalTargetRect.top + offsetY) + 'px';
|
|
var menuContainerStyle = this.$refs.menu.$refs['menu-container'].style;
|
|
var transformVariations = ['transform', 'webkitTransform', 'MozTransform', 'msTransform'];
|
|
var transform = find(transformVariations, function (t) {
|
|
return t in document.body.style;
|
|
});
|
|
menuContainerStyle[transform] = "translate(".concat(left, ", ").concat(top, ")");
|
|
}
|
|
},
|
|
render: function render() {
|
|
var h = arguments[0];
|
|
var instance = this.instance;
|
|
var portalTargetClass = ['vue-treeselect__portal-target', instance.wrapperClass];
|
|
var portalTargetStyle = {
|
|
zIndex: instance.zIndex
|
|
};
|
|
return h("div", {
|
|
"class": portalTargetClass,
|
|
style: portalTargetStyle,
|
|
attrs: {
|
|
"data-instance-id": instance.getInstanceId()
|
|
}
|
|
}, [h(Menu, {
|
|
ref: "menu"
|
|
})]);
|
|
},
|
|
destroyed: function destroyed() {
|
|
this.removeHandlers();
|
|
}
|
|
};
|
|
var placeholder;
|
|
/* harmony default export */ var MenuPortalvue_type_script_lang_js_ = ({
|
|
name: 'vue-treeselect--menu-portal',
|
|
created: function created() {
|
|
this.portalTarget = null;
|
|
},
|
|
mounted: function mounted() {
|
|
this.setup();
|
|
},
|
|
destroyed: function destroyed() {
|
|
this.teardown();
|
|
},
|
|
methods: {
|
|
setup: function setup() {
|
|
var el = document.createElement('div');
|
|
document.body.appendChild(el);
|
|
this.portalTarget = new external_Vue_default.a(MenuPortalvue_type_script_lang_js_objectSpread({
|
|
el: el,
|
|
parent: this
|
|
}, PortalTarget));
|
|
},
|
|
teardown: function teardown() {
|
|
document.body.removeChild(this.portalTarget.$el);
|
|
this.portalTarget.$el.innerHTML = '';
|
|
this.portalTarget.$destroy();
|
|
this.portalTarget = null;
|
|
}
|
|
},
|
|
render: function render() {
|
|
var h = arguments[0];
|
|
if (!placeholder) placeholder = h("div", {
|
|
"class": "vue-treeselect__menu-placeholder"
|
|
});
|
|
return placeholder;
|
|
}
|
|
});
|
|
// CONCATENATED MODULE: ./src/components/MenuPortal.vue?vue&type=script&lang=js&
|
|
/* harmony default export */ var components_MenuPortalvue_type_script_lang_js_ = (MenuPortalvue_type_script_lang_js_);
|
|
// CONCATENATED MODULE: ./src/components/MenuPortal.vue
|
|
var MenuPortal_render, MenuPortal_staticRenderFns
|
|
|
|
|
|
|
|
|
|
/* normalize component */
|
|
|
|
var MenuPortal_component = normalizeComponent(
|
|
components_MenuPortalvue_type_script_lang_js_,
|
|
MenuPortal_render,
|
|
MenuPortal_staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
|
|
)
|
|
|
|
/* hot reload */
|
|
if (false) { var MenuPortal_api; }
|
|
MenuPortal_component.options.__file = "src/components/MenuPortal.vue"
|
|
/* harmony default export */ var MenuPortal = (MenuPortal_component.exports);
|
|
// 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&
|
|
|
|
|
|
|
|
|
|
|
|
/* harmony default export */ var Treeselectvue_type_script_lang_js_ = ({
|
|
name: 'vue-treeselect',
|
|
mixins: [treeselectMixin],
|
|
computed: {
|
|
wrapperClass: function wrapperClass() {
|
|
return {
|
|
'vue-treeselect': true,
|
|
'vue-treeselect--single': this.single,
|
|
'vue-treeselect--multi': this.multiple,
|
|
'vue-treeselect--searchable': this.searchable,
|
|
'vue-treeselect--disabled': this.disabled,
|
|
'vue-treeselect--focused': this.trigger.isFocused,
|
|
'vue-treeselect--has-value': this.hasValue,
|
|
'vue-treeselect--open': this.menu.isOpen,
|
|
'vue-treeselect--open-above': this.menu.placement === 'top',
|
|
'vue-treeselect--open-below': this.menu.placement === 'bottom',
|
|
'vue-treeselect--branch-nodes-disabled': this.disableBranchNodes,
|
|
'vue-treeselect--append-to-body': this.appendToBody
|
|
};
|
|
}
|
|
},
|
|
render: function render() {
|
|
var h = arguments[0];
|
|
return h("div", {
|
|
ref: "wrapper",
|
|
"class": this.wrapperClass
|
|
}, [h(HiddenFields), h(Control, {
|
|
ref: "control"
|
|
}), this.appendToBody ? h(MenuPortal, {
|
|
ref: "portal"
|
|
}) : h(Menu, {
|
|
ref: "menu"
|
|
})]);
|
|
}
|
|
});
|
|
// CONCATENATED MODULE: ./src/components/Treeselect.vue?vue&type=script&lang=js&
|
|
/* harmony default export */ var components_Treeselectvue_type_script_lang_js_ = (Treeselectvue_type_script_lang_js_);
|
|
// CONCATENATED MODULE: ./src/components/Treeselect.vue
|
|
var Treeselect_render, Treeselect_staticRenderFns
|
|
|
|
|
|
|
|
|
|
/* normalize component */
|
|
|
|
var Treeselect_component = normalizeComponent(
|
|
components_Treeselectvue_type_script_lang_js_,
|
|
Treeselect_render,
|
|
Treeselect_staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
|
|
)
|
|
|
|
/* hot reload */
|
|
if (false) { var Treeselect_api; }
|
|
Treeselect_component.options.__file = "src/components/Treeselect.vue"
|
|
/* harmony default export */ var Treeselect = (Treeselect_component.exports);
|
|
// EXTERNAL MODULE: ./src/style.less
|
|
var style = __webpack_require__(35);
|
|
|
|
// CONCATENATED MODULE: ./src/index.js
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VERSION", function() { return VERSION; });
|
|
/* concated harmony reexport Treeselect */__webpack_require__.d(__webpack_exports__, "Treeselect", function() { return Treeselect; });
|
|
/* concated harmony reexport treeselectMixin */__webpack_require__.d(__webpack_exports__, "treeselectMixin", function() { return treeselectMixin; });
|
|
/* concated harmony reexport LOAD_ROOT_OPTIONS */__webpack_require__.d(__webpack_exports__, "LOAD_ROOT_OPTIONS", function() { return LOAD_ROOT_OPTIONS; });
|
|
/* concated harmony reexport LOAD_CHILDREN_OPTIONS */__webpack_require__.d(__webpack_exports__, "LOAD_CHILDREN_OPTIONS", function() { return LOAD_CHILDREN_OPTIONS; });
|
|
/* concated harmony reexport ASYNC_SEARCH */__webpack_require__.d(__webpack_exports__, "ASYNC_SEARCH", function() { return ASYNC_SEARCH; });
|
|
|
|
|
|
|
|
/* harmony default export */ var src = __webpack_exports__["default"] = (Treeselect);
|
|
|
|
|
|
var VERSION = "0.4.0";
|
|
|
|
/***/ })
|
|
/******/ ]);
|
|
});
|
|
//# sourceMappingURL=vue-treeselect.umd.js.map
|