83 lines
2.5 KiB
JavaScript
83 lines
2.5 KiB
JavaScript
|
"use strict";
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.default = void 0;
|
||
|
|
||
|
var _mixins = _interopRequireDefault(require("../../util/mixins"));
|
||
|
|
||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
|
||
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
||
|
|
||
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
||
|
|
||
|
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
|
||
|
|
||
|
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; } }
|
||
|
|
||
|
function searchChildren(children) {
|
||
|
var results = [];
|
||
|
|
||
|
for (var index = 0; index < children.length; index++) {
|
||
|
var child = children[index];
|
||
|
|
||
|
if (child.isActive && child.isDependent) {
|
||
|
results.push(child);
|
||
|
} else {
|
||
|
results.push.apply(results, _toConsumableArray(searchChildren(child.$children)));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return results;
|
||
|
}
|
||
|
/* @vue/component */
|
||
|
|
||
|
|
||
|
var _default = (0, _mixins.default)().extend({
|
||
|
name: 'dependent',
|
||
|
data: function data() {
|
||
|
return {
|
||
|
closeDependents: true,
|
||
|
isActive: false,
|
||
|
isDependent: true
|
||
|
};
|
||
|
},
|
||
|
watch: {
|
||
|
isActive: function isActive(val) {
|
||
|
if (val) return;
|
||
|
var openDependents = this.getOpenDependents();
|
||
|
|
||
|
for (var index = 0; index < openDependents.length; index++) {
|
||
|
openDependents[index].isActive = false;
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
getOpenDependents: function getOpenDependents() {
|
||
|
if (this.closeDependents) return searchChildren(this.$children);
|
||
|
return [];
|
||
|
},
|
||
|
getOpenDependentElements: function getOpenDependentElements() {
|
||
|
var result = [];
|
||
|
var openDependents = this.getOpenDependents();
|
||
|
|
||
|
for (var index = 0; index < openDependents.length; index++) {
|
||
|
result.push.apply(result, _toConsumableArray(openDependents[index].getClickableDependentElements()));
|
||
|
}
|
||
|
|
||
|
return result;
|
||
|
},
|
||
|
getClickableDependentElements: function getClickableDependentElements() {
|
||
|
var result = [this.$el];
|
||
|
if (this.$refs.content) result.push(this.$refs.content);
|
||
|
if (this.overlay) result.push(this.overlay);
|
||
|
result.push.apply(result, _toConsumableArray(this.getOpenDependentElements()));
|
||
|
return result;
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
exports.default = _default;
|
||
|
//# sourceMappingURL=index.js.map
|