1234567891011121314151617181920212223242526272829303132333435363738394041 |
- "use strict";
- exports.__esModule = true;
- exports.ClickOutsideMixin = void 0;
- var _event = require("../utils/dom/event");
- /**
- * Listen to click outside event
- */
- var ClickOutsideMixin = function ClickOutsideMixin(config) {
- return {
- props: {
- closeOnClickOutside: {
- type: Boolean,
- default: true
- }
- },
- data: function data() {
- var _this = this;
- var clickOutsideHandler = function clickOutsideHandler(event) {
- if (_this.closeOnClickOutside && !_this.$el.contains(event.target)) {
- _this[config.method]();
- }
- };
- return {
- clickOutsideHandler: clickOutsideHandler
- };
- },
- mounted: function mounted() {
- (0, _event.on)(document, config.event, this.clickOutsideHandler);
- },
- beforeDestroy: function beforeDestroy() {
- (0, _event.off)(document, config.event, this.clickOutsideHandler);
- }
- };
- };
- exports.ClickOutsideMixin = ClickOutsideMixin;
|