@odyzeo/popup
Version:
Odyzeo popup component with Vue
771 lines (668 loc) • 28.1 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("vue"));
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["popup"] = factory(require("vue"));
else
root["popup"] = factory(root["Vue"]);
})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__8bbf__) {
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 = "fb15");
/******/ })
/************************************************************************/
/******/ ({
/***/ "3865":
/***/ (function(module, exports, __webpack_require__) {
// extracted by mini-css-extract-plugin
/***/ }),
/***/ "622c":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_10_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_10_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_10_oneOf_1_2_node_modules_less_loader_dist_cjs_js_ref_10_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_Popup_vue_vue_type_style_index_0_lang_less___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("3865");
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_10_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_10_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_10_oneOf_1_2_node_modules_less_loader_dist_cjs_js_ref_10_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_Popup_vue_vue_type_style_index_0_lang_less___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_mini_css_extract_plugin_dist_loader_js_ref_10_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_10_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_10_oneOf_1_2_node_modules_less_loader_dist_cjs_js_ref_10_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_Popup_vue_vue_type_style_index_0_lang_less___WEBPACK_IMPORTED_MODULE_0__);
/* unused harmony reexport * */
/***/ }),
/***/ "8875":
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// addapted from the document.currentScript polyfill by Adam Miller
// MIT license
// source: https://github.com/amiller-gh/currentScript-polyfill
// added support for Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1620505
(function (root, factory) {
if (true) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}(typeof self !== 'undefined' ? self : this, function () {
function getCurrentScript () {
var descriptor = Object.getOwnPropertyDescriptor(document, 'currentScript')
// for chrome
if (!descriptor && 'currentScript' in document && document.currentScript) {
return document.currentScript
}
// for other browsers with native support for currentScript
if (descriptor && descriptor.get !== getCurrentScript && document.currentScript) {
return document.currentScript
}
// IE 8-10 support script readyState
// IE 11+ & Firefox support stack trace
try {
throw new Error();
}
catch (err) {
// Find the second match for the "at" string to get file src url from stack.
var ieStackRegExp = /.*at [^(]*\((.*):(.+):(.+)\)$/ig,
ffStackRegExp = /@([^@]*):(\d+):(\d+)\s*$/ig,
stackDetails = ieStackRegExp.exec(err.stack) || ffStackRegExp.exec(err.stack),
scriptLocation = (stackDetails && stackDetails[1]) || false,
line = (stackDetails && stackDetails[2]) || false,
currentLocation = document.location.href.replace(document.location.hash, ''),
pageSource,
inlineScriptSourceRegExp,
inlineScriptSource,
scripts = document.getElementsByTagName('script'); // Live NodeList collection
if (scriptLocation === currentLocation) {
pageSource = document.documentElement.outerHTML;
inlineScriptSourceRegExp = new RegExp('(?:[^\\n]+?\\n){0,' + (line - 2) + '}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*', 'i');
inlineScriptSource = pageSource.replace(inlineScriptSourceRegExp, '$1').trim();
}
for (var i = 0; i < scripts.length; i++) {
// If ready state is interactive, return the script tag
if (scripts[i].readyState === 'interactive') {
return scripts[i];
}
// If src matches, return the script tag
if (scripts[i].src === scriptLocation) {
return scripts[i];
}
// If inline source matches, return the script tag
if (
scriptLocation === currentLocation &&
scripts[i].innerHTML &&
scripts[i].innerHTML.trim() === inlineScriptSource
) {
return scripts[i];
}
}
// If no match, return null
return null;
}
};
return getCurrentScript
}));
/***/ }),
/***/ "8bbf":
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__8bbf__;
/***/ }),
/***/ "fb15":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js
// This file is imported into lib/wc client bundles.
if (typeof window !== 'undefined') {
var currentScript = window.document.currentScript
if (true) {
var getCurrentScript = __webpack_require__("8875")
currentScript = getCurrentScript()
// for backward compatibility, because previously we directly included the polyfill
if (!('currentScript' in document)) {
Object.defineProperty(document, 'currentScript', { get: getCurrentScript })
}
}
var src = currentScript && currentScript.src.match(/(.+\/)[^/]+\.js(\?.*)?$/)
if (src) {
__webpack_require__.p = src[1] // eslint-disable-line
}
}
// Indicate to webpack that this file can be concatenated
/* harmony default export */ var setPublicPath = (null);
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"190e0d10-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Popup.vue?vue&type=template&id=20125ffa&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"popup",class:[
_vm.classType,
("popup--" + _vm.type),
_vm.transition && ("popup-transition-" + _vm.transition),
_vm.menu && ("popup-menu popup-menu--" + _vm.menu) ]},[_c('div',{ref:"inner",staticClass:"popup__inner"},[(_vm.showCloseButton)?_c('div',{staticClass:"popup__close",on:{"click":function($event){$event.preventDefault();return _vm.close($event)}}},[_vm._t("close",[_vm._m(0)])],2):_vm._e(),_vm._t("default",null,{"close":_vm.close,"ok":_vm.ok})],2)])}
var staticRenderFns = [function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"popup__close-default"},[_c('img',{staticClass:"popup__icon-close",attrs:{"src":"data:image/svg+xml;base64,PCEtLSBHZW5lcmF0ZWQgYnkgSWNvTW9vbi5pbyAtLT4KPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjUxMiIgaGVpZ2h0PSI1MTIiIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj4KPHRpdGxlPjwvdGl0bGU+CjxnIGlkPSJpY29tb29uLWlnbm9yZSI+CjwvZz4KPHBhdGggZmlsbD0iIzAwMCIgZD0iTTUwNy4zMzEgNDExLjMzYy0wLjAwMi0wLjAwMi0wLjAwNC0wLjAwNC0wLjAwNi0wLjAwNWwtMTU1LjMyMi0xNTUuMzI1IDE1NS4zMjItMTU1LjMyNWMwLjAwMi0wLjAwMiAwLjAwNC0wLjAwMyAwLjAwNi0wLjAwNSAxLjY3Mi0xLjY3MyAyLjg4MS0zLjYyNyAzLjY1Ni01LjcwOCAyLjEyMy01LjY4OCAwLjkxMi0xMi4zNDEtMy42NjItMTYuOTE1bC03My4zNzMtNzMuMzczYy00LjU3NC00LjU3My0xMS4yMjUtNS43ODMtMTYuOTE0LTMuNjYtMi4wODAgMC43NzUtNC4wMzUgMS45ODQtNS43MDkgMy42NTUgMCAwLjAwMi0wLjAwMiAwLjAwMy0wLjAwNCAwLjAwNWwtMTU1LjMyNCAxNTUuMzI2LTE1NS4zMjQtMTU1LjMyNWMtMC4wMDItMC4wMDItMC4wMDMtMC4wMDMtMC4wMDUtMC4wMDUtMS42NzMtMS42NzEtMy42MjctMi44OC01LjcwNy0zLjY1NS01LjY5LTIuMTI0LTEyLjM0MS0wLjkxMy0xNi45MTUgMy42NmwtNzMuMzc0IDczLjM3NGMtNC41NzQgNC41NzQtNS43ODQgMTEuMjI2LTMuNjYxIDE2LjkxNCAwLjc3NiAyLjA4MCAxLjk4NSA0LjAzNiAzLjY1NiA1LjcwOCAwLjAwMiAwLjAwMSAwLjAwMyAwLjAwMyAwLjAwNSAwLjAwNWwxNTUuMzI1IDE1NS4zMjQtMTU1LjMyNSAxNTUuMzI2Yy0wLjAwMSAwLjAwMi0wLjAwMyAwLjAwMy0wLjAwNCAwLjAwNS0xLjY3MSAxLjY3My0yLjg4IDMuNjI3LTMuNjU3IDUuNzA3LTIuMTI0IDUuNjg4LTAuOTEzIDEyLjM0MSAzLjY2MSAxNi45MTVsNzMuMzc0IDczLjM3M2M0LjU3NSA0LjU3NCAxMS4yMjYgNS43ODQgMTYuOTE1IDMuNjYxIDIuMDgwLTAuNzc2IDQuMDM1LTEuOTg1IDUuNzA4LTMuNjU2IDAuMDAxLTAuMDAyIDAuMDAzLTAuMDAzIDAuMDA1LTAuMDA1bDE1NS4zMjQtMTU1LjMyNSAxNTUuMzI0IDE1NS4zMjVjMC4wMDIgMC4wMDEgMC4wMDQgMC4wMDMgMC4wMDYgMC4wMDQgMS42NzQgMS42NzIgMy42MjcgMi44ODEgNS43MDcgMy42NTcgNS42ODkgMi4xMjMgMTIuMzQyIDAuOTEzIDE2LjkxNC0zLjY2MWw3My4zNzMtNzMuMzc0YzQuNTc0LTQuNTc0IDUuNzg1LTExLjIyNyAzLjY2Mi0xNi45MTUtMC43NzYtMi4wODAtMS45ODUtNC4wMzQtMy42NTctNS43MDd6Ij48L3BhdGg+Cjwvc3ZnPgo="}})])}]
// CONCATENATED MODULE: ./src/components/Popup.vue?vue&type=template&id=20125ffa&
// EXTERNAL MODULE: external {"commonjs":"vue","commonjs2":"vue","root":"Vue"}
var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__("8bbf");
var external_commonjs_vue_commonjs2_vue_root_Vue_default = /*#__PURE__*/__webpack_require__.n(external_commonjs_vue_commonjs2_vue_root_Vue_);
// CONCATENATED MODULE: ./src/plugin/event.js
/* harmony default export */ var plugin_event = (new external_commonjs_vue_commonjs2_vue_root_Vue_default.a());
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Popup.vue?vue&type=script&lang=js&
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var Popupvue_type_script_lang_js_ = ({
name: 'Popup',
props: {
value: {
type: Boolean,
default: false
},
name: {
required: true,
type: String
},
type: {
type: String,
default: 'fixed'
},
disableClose: {
type: Boolean,
default: false
},
disableOffClick: {
type: Boolean,
default: false
},
disableEsc: {
type: Boolean,
default: false
},
menu: {
type: String,
default: null
},
transition: {
type: String,
default: 'fade'
},
permanent: {
type: Boolean,
default: false
},
inline: {
type: Boolean,
default: false
},
parentSelector: {
type: String,
default: null
}
},
data: function data() {
return {
isOpen: false,
scrollTop: null,
originalParent: null
};
},
computed: {
parent: function parent() {
var _document$querySelect;
var selector = this.parentSelector || this.$popup.parentSelector;
return (_document$querySelect = document.querySelector(selector)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.body;
},
classType: function classType() {
return this.isOpen ? 'popup--open' : '';
},
enableEsc: function enableEsc() {
return this.permanent ? false : !this.disableEsc;
},
enableOffClick: function enableOffClick() {
return this.permanent ? false : !this.disableOffClick;
},
showCloseButton: function showCloseButton() {
return this.permanent ? false : !this.disableClose;
}
},
watch: {
value: function value(n) {
this.toggle(n);
},
inline: function inline(n) {
if (n) {
this.appendToParent();
} else {
this.appendToBody();
}
}
},
/**
* Sets global listeners
*/
beforeMount: function beforeMount() {
plugin_event.$on('toggle', this.handleToggleEvent);
},
mounted: function mounted() {
this.originalParent = this.$el.parentNode;
if (!this.inline) {
this.appendToBody();
}
if (this.value) {
this.toggle(true);
}
},
beforeDestroy: function beforeDestroy() {
plugin_event.$off('toggle', this.handleToggleEvent);
if (this.isOpen) {
this.close();
}
this.removePopupFromDOM();
},
methods: {
appendToParent: function appendToParent() {
this.originalParent.appendChild(this.$el);
},
appendToBody: function appendToBody() {
this.parent.appendChild(this.$el);
},
handleToggleEvent: function handleToggleEvent(name, state) {
if (this.name === name) {
var nextState = typeof state === 'undefined' ? !this.isOpen : state;
this.toggle(nextState);
}
},
toggle: function toggle(state) {
if (state) {
this.show();
return;
}
this.close();
},
escClose: function escClose(ev) {
if (ev.keyCode === 27) {
ev.preventDefault();
this.close();
}
},
show: function show() {
var _this = this;
this.isOpen = true;
this.scrollTop = window.pageYOffset || this.parent.scrollTop;
if (this.type === 'fixed') {
this.addBodyStyles();
}
if (this.enableOffClick) {
/**
* Need to add listener to end of Call Stack.
* this.$nextTick can't be used because it's still in component.
*/
setTimeout(function () {
document.addEventListener('click', _this.offClick);
});
}
if (this.enableEsc) {
window.addEventListener('keydown', this.escClose);
}
this.$popup.currentPopups = new Set([].concat(_toConsumableArray(this.$popup.currentPopups), [this.name]));
this.$emit('show', this.name);
this.$emit('input', true);
},
ok: function ok() {
this.closePopup();
},
close: function close() {
this.closePopup();
this.$emit('close', this.name);
},
closePopup: function closePopup() {
var _this2 = this;
this.isOpen = false;
this.$popup.currentPopups = new Set(_toConsumableArray(this.$popup.currentPopups).filter(function (name) {
return name !== _this2.name;
}));
if (this.type === 'fixed') {
this.removeBodyStyles();
}
if (this.enableOffClick) {
document.removeEventListener('click', this.offClick);
}
if (this.enableEsc) {
window.removeEventListener('keydown', this.escClose);
}
this.$emit('input', false);
},
removePopupFromDOM: function removePopupFromDOM() {
if (this.parent.contains(this.$el)) {
if (this.inline) {
this.originalParent.removeChild(this.$el);
} else {
this.parent.removeChild(this.$el);
}
}
},
addBodyStyles: function addBodyStyles() {
this.parent.style.width = "".concat(this.parent.clientWidth, "px");
this.parent.classList.add('open-popup');
this.parent.style.top = "-".concat(this.scrollTop, "px");
},
removeBodyStyles: function removeBodyStyles() {
this.parent.style.top = null;
this.parent.style.width = null;
this.parent.classList.remove('open-popup');
window.scrollTo(0, this.scrollTop);
},
offClick: function offClick(ev) {
if (!this.$refs.inner.contains(ev.target)) {
this.close();
}
}
}
});
// CONCATENATED MODULE: ./src/components/Popup.vue?vue&type=script&lang=js&
/* harmony default export */ var components_Popupvue_type_script_lang_js_ = (Popupvue_type_script_lang_js_);
// EXTERNAL MODULE: ./src/components/Popup.vue?vue&type=style&index=0&lang=less&
var Popupvue_type_style_index_0_lang_less_ = __webpack_require__("622c");
// 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,
(options.functional ? this.parent : 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 functional 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/Popup.vue
/* normalize component */
var component = normalizeComponent(
components_Popupvue_type_script_lang_js_,
render,
staticRenderFns,
false,
null,
null,
null
)
/* harmony default export */ var Popup = (component.exports);
// CONCATENATED MODULE: ./src/plugin/popup.js
function popup_toConsumableArray(arr) { return popup_arrayWithoutHoles(arr) || popup_iterableToArray(arr) || popup_unsupportedIterableToArray(arr) || popup_nonIterableSpread(); }
function popup_nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function popup_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return popup_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return popup_arrayLikeToArray(o, minLen); }
function popup_iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function popup_arrayWithoutHoles(arr) { if (Array.isArray(arr)) return popup_arrayLikeToArray(arr); }
function popup_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
var Plugin = {
install: function install(Vue) {
var _this = this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
/**
* Makes sure that plugin can be installed only once
*/
if (this.installed) {
return;
}
var defaultComponentName = 'Popup';
this.installed = true;
this.componentName = options.componentName || defaultComponentName;
this.parentSelector = options.parentSelector;
/**
* Set global reactive property
*/
this.currentPopups = new Vue({
data: {
getCurrentPopups: new Set()
}
});
/**
* Plugin API
*/
// eslint-disable-next-line
Vue.prototype.$popup = {
show: function show(name) {
if (typeof name === 'string') {
this.currentPopups.add(name);
plugin_event.$emit('toggle', name, true);
}
},
/**
* Close all popups when no params
* else just requested.
*/
hide: function hide() {
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
if (name == null) {
this.currentPopups.forEach(function (current) {
plugin_event.$emit('toggle', current, false);
});
this.currentPopups = new Set();
} else {
plugin_event.$emit('toggle', name, false);
this.currentPopups = new Set(popup_toConsumableArray(this.currentPopups).filter(function (current) {
return current !== name;
}));
}
},
parentSelector: this.parentSelector
};
/**
* Create getters/setters for reactive properties
*/
Object.defineProperties(Vue.prototype.$popup, {
currentPopups: {
get: function get() {
return _this.currentPopups.getCurrentPopups;
},
set: function set(popups) {
_this.currentPopups.getCurrentPopups = popups;
return _this.currentPopups.getCurrentPopups;
}
}
});
/**
* Sets custom component name (if provided)
*/
Vue.component(this.componentName, Popup);
}
};
/* harmony default export */ var popup = (Plugin);
// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js
/* harmony default export */ var entry_lib = __webpack_exports__["default"] = (popup);
/***/ })
/******/ });
});
//# sourceMappingURL=popup.umd.js.map