uiv
Version:
Bootstrap 3 components implemented by Vue 2.
1,755 lines (1,655 loc) • 235 kB
JavaScript
import Vue from 'vue';
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill
function assign (target, varArgs) {
var arguments$1 = arguments;
if (target === null || target === undefined) {
throw new TypeError('Cannot convert undefined or null to object')
}
var to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments$1[index];
if (nextSource !== null && nextSource !== undefined) {
for (var nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
/* istanbul ignore else */
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to
}
function isExist (obj) {
return typeof obj !== 'undefined' && obj !== null
}
function isFunction (obj) {
return typeof obj === 'function'
}
function isNumber (obj) {
return typeof obj === 'number'
}
function isString (obj) {
return typeof obj === 'string'
}
function isBoolean (obj) {
return typeof obj === 'boolean'
}
function isPromiseSupported () {
return typeof window !== 'undefined' && isExist(window.Promise)
}
function hasOwnProperty (o, k) {
return Object.prototype.hasOwnProperty.call(o, k)
}
var script$h = {
props: {
value: Number,
indicators: {
type: Boolean,
default: true
},
controls: {
type: Boolean,
default: true
},
interval: {
type: Number,
default: 5000
},
iconControlLeft: {
type: String,
default: 'glyphicon glyphicon-chevron-left'
},
iconControlRight: {
type: String,
default: 'glyphicon glyphicon-chevron-right'
}
},
data: function data () {
return {
slides: [],
activeIndex: 0, // Make v-model not required
timeoutId: 0,
intervalId: 0
}
},
watch: {
interval: function interval () {
this.startInterval();
},
value: function value (index, oldValue) {
this.run(index, oldValue);
this.activeIndex = index;
}
},
mounted: function mounted () {
if (isExist(this.value)) {
this.activeIndex = this.value;
}
if (this.slides.length > 0) {
this.$select(this.activeIndex);
}
this.startInterval();
},
beforeDestroy: function beforeDestroy () {
this.stopInterval();
},
methods: {
run: function run (newIndex, oldIndex) {
var this$1 = this;
var currentActiveIndex = oldIndex || 0;
var direction;
if (newIndex > currentActiveIndex) {
direction = ['next', 'left'];
} else {
direction = ['prev', 'right'];
}
this.slides[newIndex].slideClass[direction[0]] = true;
this.$nextTick(function () {
this$1.slides[newIndex].$el.offsetHeight;
this$1.slides.forEach(function (slide, i) {
if (i === currentActiveIndex) {
slide.slideClass.active = true;
slide.slideClass[direction[1]] = true;
} else if (i === newIndex) {
slide.slideClass[direction[1]] = true;
}
});
this$1.timeoutId = setTimeout(function () {
this$1.$select(newIndex);
this$1.$emit('change', newIndex);
this$1.timeoutId = 0;
}, 600);
});
},
startInterval: function startInterval () {
var this$1 = this;
this.stopInterval();
if (this.interval > 0) {
this.intervalId = setInterval(function () {
this$1.next();
}, this.interval);
}
},
stopInterval: function stopInterval () {
clearInterval(this.intervalId);
this.intervalId = 0;
},
resetAllSlideClass: function resetAllSlideClass () {
this.slides.forEach(function (slide) {
slide.slideClass.active = false;
slide.slideClass.left = false;
slide.slideClass.right = false;
slide.slideClass.next = false;
slide.slideClass.prev = false;
});
},
$select: function $select (index) {
this.resetAllSlideClass();
this.slides[index].slideClass.active = true;
},
select: function select (index) {
if (this.timeoutId !== 0 || index === this.activeIndex) {
return
}
if (isExist(this.value)) {
this.$emit('input', index);
} else {
this.run(index, this.activeIndex);
this.activeIndex = index;
}
},
prev: function prev () {
this.select(this.activeIndex === 0 ? this.slides.length - 1 : this.activeIndex - 1);
},
next: function next () {
this.select(this.activeIndex === this.slides.length - 1 ? 0 : this.activeIndex + 1);
}
}
};
function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
if (typeof shadowMode !== 'boolean') {
createInjectorSSR = createInjector;
createInjector = shadowMode;
shadowMode = false;
}
// Vue.extend constructor export interop.
var options = typeof script === 'function' ? script.options : script;
// render functions
if (template && template.render) {
options.render = template.render;
options.staticRenderFns = template.staticRenderFns;
options._compiled = true;
// functional template
if (isFunctionalTemplate) {
options.functional = true;
}
}
// scopedId
if (scopeId) {
options._scopeId = 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 (style) {
style.call(this, createInjectorSSR(context));
}
// register component module identifier for async chunk inference
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 (style) {
hook = shadowMode
? function (context) {
style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
}
: function (context) {
style.call(this, createInjector(context));
};
}
if (hook) {
if (options.functional) {
// 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 script;
}
/* script */
var __vue_script__$h = script$h;
/* template */
var __vue_render__$h = function() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c(
"div",
{
staticClass: "carousel slide",
attrs: { "data-ride": "carousel" },
on: { mouseenter: _vm.stopInterval, mouseleave: _vm.startInterval }
},
[
_vm.indicators
? _vm._t(
"indicators",
[
_c(
"ol",
{ staticClass: "carousel-indicators" },
_vm._l(_vm.slides, function(slide, index) {
return _c("li", {
class: { active: index === _vm.activeIndex },
on: {
click: function($event) {
return _vm.select(index)
}
}
})
}),
0
)
],
{ select: _vm.select, activeIndex: _vm.activeIndex }
)
: _vm._e(),
_vm._v(" "),
_c(
"div",
{ staticClass: "carousel-inner", attrs: { role: "listbox" } },
[_vm._t("default")],
2
),
_vm._v(" "),
_vm.controls
? _c(
"a",
{
staticClass: "left carousel-control",
attrs: { href: "#", role: "button" },
on: {
click: function($event) {
$event.preventDefault();
return _vm.prev()
}
}
},
[
_c("span", {
class: _vm.iconControlLeft,
attrs: { "aria-hidden": "true" }
}),
_vm._v(" "),
_c("span", { staticClass: "sr-only" }, [_vm._v("Previous")])
]
)
: _vm._e(),
_vm._v(" "),
_vm.controls
? _c(
"a",
{
staticClass: "right carousel-control",
attrs: { href: "#", role: "button" },
on: {
click: function($event) {
$event.preventDefault();
return _vm.next()
}
}
},
[
_c("span", {
class: _vm.iconControlRight,
attrs: { "aria-hidden": "true" }
}),
_vm._v(" "),
_c("span", { staticClass: "sr-only" }, [_vm._v("Next")])
]
)
: _vm._e()
],
2
)
};
var __vue_staticRenderFns__$h = [];
__vue_render__$h._withStripped = true;
/* style */
var __vue_inject_styles__$h = undefined;
/* scoped */
var __vue_scope_id__$h = undefined;
/* module identifier */
var __vue_module_identifier__$h = undefined;
/* functional template */
var __vue_is_functional_template__$h = false;
/* style inject */
/* style inject SSR */
/* style inject shadow dom */
var __vue_component__$h = /*#__PURE__*/normalizeComponent(
{ render: __vue_render__$h, staticRenderFns: __vue_staticRenderFns__$h },
__vue_inject_styles__$h,
__vue_script__$h,
__vue_scope_id__$h,
__vue_is_functional_template__$h,
__vue_module_identifier__$h,
false,
undefined,
undefined,
undefined
);
function spliceIfExist (arr, item) {
if (Array.isArray(arr)) {
var index = arr.indexOf(item);
if (index >= 0) {
arr.splice(index, 1);
}
}
}
function range (end, start, step) {
if ( start === void 0 ) start = 0;
if ( step === void 0 ) step = 1;
var arr = [];
for (var i = start; i < end; i += step) {
arr.push(i);
}
return arr
}
function nodeListToArray (nodeList) {
return Array.prototype.slice.call(nodeList || [])
}
function onlyUnique (value, index, self) {
return self.indexOf(value) === index
}
var script$g = {
data: function data () {
return {
slideClass: {
active: false,
prev: false,
next: false,
left: false,
right: false
}
}
},
created: function created () {
try {
this.$parent.slides.push(this);
} catch (e) {
throw new Error('Slide parent must be Carousel.')
}
},
beforeDestroy: function beforeDestroy () {
var slides = this.$parent && this.$parent.slides;
spliceIfExist(slides, this);
}
};
/* script */
var __vue_script__$g = script$g;
/* template */
var __vue_render__$g = function() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c(
"div",
{ staticClass: "item", class: _vm.slideClass },
[_vm._t("default")],
2
)
};
var __vue_staticRenderFns__$g = [];
__vue_render__$g._withStripped = true;
/* style */
var __vue_inject_styles__$g = undefined;
/* scoped */
var __vue_scope_id__$g = undefined;
/* module identifier */
var __vue_module_identifier__$g = undefined;
/* functional template */
var __vue_is_functional_template__$g = false;
/* style inject */
/* style inject SSR */
/* style inject shadow dom */
var __vue_component__$g = /*#__PURE__*/normalizeComponent(
{ render: __vue_render__$g, staticRenderFns: __vue_staticRenderFns__$g },
__vue_inject_styles__$g,
__vue_script__$g,
__vue_scope_id__$g,
__vue_is_functional_template__$g,
__vue_module_identifier__$g,
false,
undefined,
undefined,
undefined
);
var EVENTS = {
MOUSE_ENTER: 'mouseenter',
MOUSE_LEAVE: 'mouseleave',
MOUSE_DOWN: 'mousedown',
MOUSE_UP: 'mouseup',
FOCUS: 'focus',
BLUR: 'blur',
CLICK: 'click',
INPUT: 'input',
KEY_DOWN: 'keydown',
KEY_UP: 'keyup',
KEY_PRESS: 'keypress',
RESIZE: 'resize',
SCROLL: 'scroll',
TOUCH_START: 'touchstart',
TOUCH_END: 'touchend'
};
var TRIGGERS = {
CLICK: 'click',
HOVER: 'hover',
FOCUS: 'focus',
HOVER_FOCUS: 'hover-focus',
OUTSIDE_CLICK: 'outside-click',
MANUAL: 'manual'
};
var PLACEMENTS$1 = {
TOP: 'top',
RIGHT: 'right',
BOTTOM: 'bottom',
LEFT: 'left'
};
function isIE11 () {
/* istanbul ignore next */
return !!window.MSInputMethodContext && !!document.documentMode
}
function isIE10 () {
return window.navigator.appVersion.indexOf('MSIE 10') !== -1
}
function getComputedStyle (el) {
return window.getComputedStyle(el)
}
function getViewportSize () {
/* istanbul ignore next */
var width = Math.max(document.documentElement.clientWidth, window.innerWidth) || 0;
/* istanbul ignore next */
var height = Math.max(document.documentElement.clientHeight, window.innerHeight) || 0;
return { width: width, height: height }
}
var scrollbarWidth = null;
var savedScreenSize = null;
function getScrollbarWidth (recalculate) {
if ( recalculate === void 0 ) recalculate = false;
var screenSize = getViewportSize();
// return directly when already calculated & not force recalculate & screen size not changed
if (scrollbarWidth !== null && !recalculate &&
screenSize.height === savedScreenSize.height && screenSize.width === savedScreenSize.width) {
return scrollbarWidth
}
/* istanbul ignore next */
if (document.readyState === 'loading') {
return null
}
var div1 = document.createElement('div');
var div2 = document.createElement('div');
div1.style.width = div2.style.width = div1.style.height = div2.style.height = '100px';
div1.style.overflow = 'scroll';
div2.style.overflow = 'hidden';
document.body.appendChild(div1);
document.body.appendChild(div2);
scrollbarWidth = Math.abs(div1.scrollHeight - div2.scrollHeight);
document.body.removeChild(div1);
document.body.removeChild(div2);
// save new screen size
savedScreenSize = screenSize;
return scrollbarWidth
}
function on (element, event, handler) {
/* istanbul ignore next */
element.addEventListener(event, handler);
}
function off (element, event, handler) {
/* istanbul ignore next */
element.removeEventListener(event, handler);
}
function isElement (el) {
return el && el.nodeType === Node.ELEMENT_NODE
}
function removeFromDom (el) {
isElement(el) && isElement(el.parentNode) && el.parentNode.removeChild(el);
}
function ensureElementMatchesFunction () {
/* istanbul ignore next */
if (!Element.prototype.matches) {
Element.prototype.matches =
Element.prototype.matchesSelector ||
Element.prototype.mozMatchesSelector ||
Element.prototype.msMatchesSelector ||
Element.prototype.oMatchesSelector ||
Element.prototype.webkitMatchesSelector ||
function (s) {
var matches = (this.document || this.ownerDocument).querySelectorAll(s);
var i = matches.length;
// eslint-disable-next-line no-empty
while (--i >= 0 && matches.item(i) !== this) {}
return i > -1
};
}
}
function addClass (el, className) {
if (!isElement(el)) {
return
}
if (el.className) {
var classes = el.className.split(' ');
if (classes.indexOf(className) < 0) {
classes.push(className);
el.className = classes.join(' ');
}
} else {
el.className = className;
}
}
function removeClass (el, className) {
if (!isElement(el)) {
return
}
if (el.className) {
var classes = el.className.split(' ');
var newClasses = [];
for (var i = 0, l = classes.length; i < l; i++) {
if (classes[i] !== className) {
newClasses.push(classes[i]);
}
}
el.className = newClasses.join(' ');
}
}
function hasClass (el, className) {
if (!isElement(el)) {
return false
}
var classes = el.className.split(' ');
for (var i = 0, l = classes.length; i < l; i++) {
if (classes[i] === className) {
return true
}
}
return false
}
function setDropdownPosition (dropdown, trigger, options) {
if ( options === void 0 ) options = {};
var doc = document.documentElement;
var containerScrollLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
var containerScrollTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
var rect = trigger.getBoundingClientRect();
var dropdownRect = dropdown.getBoundingClientRect();
dropdown.style.right = 'auto';
dropdown.style.bottom = 'auto';
if (options.menuRight) {
dropdown.style.left = containerScrollLeft + rect.left + rect.width - dropdownRect.width + 'px';
} else {
dropdown.style.left = containerScrollLeft + rect.left + 'px';
}
if (options.dropup) {
dropdown.style.top = containerScrollTop + rect.top - dropdownRect.height - 4 + 'px';
} else {
dropdown.style.top = containerScrollTop + rect.top + rect.height + 'px';
}
}
function isAvailableAtPosition (trigger, popup, placement) {
var triggerRect = trigger.getBoundingClientRect();
var popupRect = popup.getBoundingClientRect();
var viewPortSize = getViewportSize();
var top = true;
var right = true;
var bottom = true;
var left = true;
switch (placement) {
case PLACEMENTS$1.TOP:
top = triggerRect.top >= popupRect.height;
left = triggerRect.left + triggerRect.width / 2 >= popupRect.width / 2;
right = triggerRect.right - triggerRect.width / 2 + popupRect.width / 2 <= viewPortSize.width;
break
case PLACEMENTS$1.BOTTOM:
bottom = triggerRect.bottom + popupRect.height <= viewPortSize.height;
left = triggerRect.left + triggerRect.width / 2 >= popupRect.width / 2;
right = triggerRect.right - triggerRect.width / 2 + popupRect.width / 2 <= viewPortSize.width;
break
case PLACEMENTS$1.RIGHT:
right = triggerRect.right + popupRect.width <= viewPortSize.width;
top = triggerRect.top + triggerRect.height / 2 >= popupRect.height / 2;
bottom = triggerRect.bottom - triggerRect.height / 2 + popupRect.height / 2 <= viewPortSize.height;
break
case PLACEMENTS$1.LEFT:
left = triggerRect.left >= popupRect.width;
top = triggerRect.top + triggerRect.height / 2 >= popupRect.height / 2;
bottom = triggerRect.bottom - triggerRect.height / 2 + popupRect.height / 2 <= viewPortSize.height;
break
}
return top && right && bottom && left
}
function setTooltipPosition (tooltip, trigger, placement, auto, appendTo, positionBy, viewport) {
if (!isElement(tooltip) || !isElement(trigger)) {
return
}
var isPopover = tooltip && tooltip.className && tooltip.className.indexOf('popover') >= 0;
var containerScrollTop;
var containerScrollLeft;
if (!isExist(appendTo) || appendTo === 'body' || positionBy === 'body') {
var doc = document.documentElement;
containerScrollLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
containerScrollTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
} else {
var container = getElementBySelectorOrRef(positionBy || appendTo);
containerScrollLeft = container.scrollLeft;
containerScrollTop = container.scrollTop;
}
// auto adjust placement
if (auto) {
// Try: right -> bottom -> left -> top
// Cause the default placement is top
var placements = [PLACEMENTS$1.RIGHT, PLACEMENTS$1.BOTTOM, PLACEMENTS$1.LEFT, PLACEMENTS$1.TOP];
// The class switch helper function
var changePlacementClass = function (placement) {
// console.log(placement)
placements.forEach(function (placement) {
removeClass(tooltip, placement);
});
addClass(tooltip, placement);
};
// No need to adjust if the default placement fits
if (!isAvailableAtPosition(trigger, tooltip, placement)) {
for (var i = 0, l = placements.length; i < l; i++) {
// Re-assign placement class
changePlacementClass(placements[i]);
// Break if new placement fits
if (isAvailableAtPosition(trigger, tooltip, placements[i])) {
placement = placements[i];
break
}
}
changePlacementClass(placement);
}
}
// fix left and top for tooltip
var rect = trigger.getBoundingClientRect();
var tooltipRect = tooltip.getBoundingClientRect();
var top;
var left;
if (placement === PLACEMENTS$1.BOTTOM) {
top = containerScrollTop + rect.top + rect.height;
left = containerScrollLeft + rect.left + rect.width / 2 - tooltipRect.width / 2;
} else if (placement === PLACEMENTS$1.LEFT) {
top = containerScrollTop + rect.top + rect.height / 2 - tooltipRect.height / 2;
left = containerScrollLeft + rect.left - tooltipRect.width;
} else if (placement === PLACEMENTS$1.RIGHT) {
top = containerScrollTop + rect.top + rect.height / 2 - tooltipRect.height / 2;
// https://github.com/uiv-lib/uiv/issues/272
// add 1px to fix above issue
left = containerScrollLeft + rect.left + rect.width + 1;
} else {
top = containerScrollTop + rect.top - tooltipRect.height;
left = containerScrollLeft + rect.left + rect.width / 2 - tooltipRect.width / 2;
}
var viewportEl;
// viewport option
if (isString(viewport)) {
viewportEl = document.querySelector(viewport);
} else if (isFunction(viewport)) {
viewportEl = viewport(trigger);
}
if (isElement(viewportEl)) {
var popoverFix = isPopover ? 11 : 0;
var viewportReact = viewportEl.getBoundingClientRect();
var viewportTop = containerScrollTop + viewportReact.top;
var viewportLeft = containerScrollLeft + viewportReact.left;
var viewportBottom = viewportTop + viewportReact.height;
var viewportRight = viewportLeft + viewportReact.width;
// fix top
if (top < viewportTop) {
top = viewportTop;
} else if (top + tooltipRect.height > viewportBottom) {
top = viewportBottom - tooltipRect.height;
}
// fix left
if (left < viewportLeft) {
left = viewportLeft;
} else if (left + tooltipRect.width > viewportRight) {
left = viewportRight - tooltipRect.width;
}
// fix for popover pointer
if (placement === PLACEMENTS$1.BOTTOM) {
top -= popoverFix;
} else if (placement === PLACEMENTS$1.LEFT) {
left += popoverFix;
} else if (placement === PLACEMENTS$1.RIGHT) {
left -= popoverFix;
} else {
top += popoverFix;
}
}
// set position finally
tooltip.style.top = top + "px";
tooltip.style.left = left + "px";
}
function hasScrollbar (el) {
var SCROLL = 'scroll';
var hasVScroll = el.scrollHeight > el.clientHeight;
var style = getComputedStyle(el);
return hasVScroll || style.overflow === SCROLL || style.overflowY === SCROLL
}
function toggleBodyOverflow (enable) {
var MODAL_OPEN = 'modal-open';
var FIXED_CONTENT = '.navbar-fixed-top, .navbar-fixed-bottom';
var body = document.body;
if (enable) {
removeClass(body, MODAL_OPEN);
body.style.paddingRight = null;
nodeListToArray(document.querySelectorAll(FIXED_CONTENT)).forEach(function (node) {
node.style.paddingRight = null;
});
} else {
var browsersWithFloatingScrollbar = isIE10() || isIE11();
var documentHasScrollbar = hasScrollbar(document.documentElement) || hasScrollbar(document.body);
if (documentHasScrollbar && !browsersWithFloatingScrollbar) {
var scrollbarWidth = getScrollbarWidth();
body.style.paddingRight = scrollbarWidth + "px";
nodeListToArray(document.querySelectorAll(FIXED_CONTENT)).forEach(function (node) {
node.style.paddingRight = scrollbarWidth + "px";
});
}
addClass(body, MODAL_OPEN);
}
}
function getClosest (el, selector) {
ensureElementMatchesFunction();
var parent;
var _el = el;
while (_el) {
parent = _el.parentElement;
if (parent && parent.matches(selector)) {
return parent
}
_el = parent;
}
return null
}
function getParents (el, selector, until) {
if ( until === void 0 ) until = null;
ensureElementMatchesFunction();
var parents = [];
var parent = el.parentElement;
while (parent) {
if (parent.matches(selector)) {
parents.push(parent);
} else if (until && (until === parent || parent.matches(until))) {
break
}
parent = parent.parentElement;
}
return parents
}
function focus (el) {
if (!isElement(el)) {
return
}
el.getAttribute('tabindex') ? null : el.setAttribute('tabindex', '-1');
el.focus();
}
var MODAL_BACKDROP = 'modal-backdrop';
function getOpenModals () {
return document.querySelectorAll(("." + MODAL_BACKDROP))
}
function getOpenModalNum () {
return getOpenModals().length
}
function getElementBySelectorOrRef (q) {
if (isString(q)) { // is selector
return document.querySelector(q)
} else if (isElement(q)) { // is element
return q
} else if (isElement(q.$el)) { // is component
return q.$el
} else {
return null
}
}
var COLLAPSE = 'collapse';
var IN$1 = 'in';
var COLLAPSING = 'collapsing';
var Collapse = {
render: function render (h) {
return h(this.tag, {}, this.$slots.default)
},
props: {
tag: {
type: String,
default: 'div'
},
value: {
type: Boolean,
default: false
},
transition: {
type: Number,
default: 350
}
},
data: function data () {
return {
timeoutId: 0
}
},
watch: {
value: function value (show) {
this.toggle(show);
}
},
mounted: function mounted () {
var el = this.$el;
addClass(el, COLLAPSE);
if (this.value) {
addClass(el, IN$1);
}
},
methods: {
toggle: function toggle (show) {
var this$1 = this;
clearTimeout(this.timeoutId);
var el = this.$el;
if (show) {
this.$emit('show');
removeClass(el, COLLAPSE);
el.style.height = 'auto';
var height = window.getComputedStyle(el).height;
el.style.height = null;
addClass(el, COLLAPSING);
el.offsetHeight; // force repaint
el.style.height = height;
this.timeoutId = setTimeout(function () {
removeClass(el, COLLAPSING);
addClass(el, COLLAPSE);
addClass(el, IN$1);
el.style.height = null;
this$1.timeoutId = 0;
this$1.$emit('shown');
}, this.transition);
} else {
this.$emit('hide');
el.style.height = window.getComputedStyle(el).height;
removeClass(el, IN$1);
removeClass(el, COLLAPSE);
el.offsetHeight;
el.style.height = null;
addClass(el, COLLAPSING);
this.timeoutId = setTimeout(function () {
addClass(el, COLLAPSE);
removeClass(el, COLLAPSING);
el.style.height = null;
this$1.timeoutId = 0;
this$1.$emit('hidden');
}, this.transition);
}
}
}
};
var DEFAULT_TAG = 'div';
var Dropdown = {
render: function render (h) {
return h(
this.tag,
{
class: {
'btn-group': this.tag === DEFAULT_TAG,
dropdown: !this.dropup,
dropup: this.dropup,
open: this.show
}
},
[
this.$slots.default,
h(
'ul',
{
class: {
'dropdown-menu': true,
'dropdown-menu-right': this.menuRight
},
ref: 'dropdown'
},
[this.$slots.dropdown]
)
]
)
},
props: {
tag: {
type: String,
default: DEFAULT_TAG
},
appendToBody: {
type: Boolean,
default: false
},
value: Boolean,
dropup: {
type: Boolean,
default: false
},
menuRight: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
notCloseElements: Array,
positionElement: null
},
data: function data () {
return {
show: false,
triggerEl: undefined
}
},
watch: {
value: function value (v) {
this.toggle(v);
}
},
mounted: function mounted () {
this.initTrigger();
if (this.triggerEl) {
on(this.triggerEl, EVENTS.CLICK, this.toggle);
on(this.triggerEl, EVENTS.KEY_DOWN, this.onKeyPress);
}
on(this.$refs.dropdown, EVENTS.KEY_DOWN, this.onKeyPress);
on(window, EVENTS.CLICK, this.windowClicked);
on(window, EVENTS.TOUCH_END, this.windowClicked);
if (this.value) {
this.toggle(true);
}
},
beforeDestroy: function beforeDestroy () {
this.removeDropdownFromBody();
if (this.triggerEl) {
off(this.triggerEl, EVENTS.CLICK, this.toggle);
off(this.triggerEl, EVENTS.KEY_DOWN, this.onKeyPress);
}
off(this.$refs.dropdown, EVENTS.KEY_DOWN, this.onKeyPress);
off(window, EVENTS.CLICK, this.windowClicked);
off(window, EVENTS.TOUCH_END, this.windowClicked);
},
methods: {
getFocusItem: function getFocusItem () {
var dropdownEl = this.$refs.dropdown;
/* istanbul ignore next */
return dropdownEl.querySelector('li > a:focus')
},
onKeyPress: function onKeyPress (event) {
if (this.show) {
var dropdownEl = this.$refs.dropdown;
var keyCode = event.keyCode;
if (keyCode === 27) {
// esc
this.toggle(false);
this.triggerEl && this.triggerEl.focus();
} else if (keyCode === 13) {
// enter
var currentFocus = this.getFocusItem();
currentFocus && currentFocus.click();
} else if (keyCode === 38 || keyCode === 40) {
// up || down
event.preventDefault();
event.stopPropagation();
var currentFocus$1 = this.getFocusItem();
var items = dropdownEl.querySelectorAll('li:not(.disabled) > a');
if (!currentFocus$1) {
focus(items[0]);
} else {
for (var i = 0; i < items.length; i++) {
if (currentFocus$1 === items[i]) {
if (keyCode === 38 && i < items.length > 0) {
focus(items[i - 1]);
} else if (keyCode === 40 && i < items.length - 1) {
focus(items[i + 1]);
}
break
}
}
}
}
}
},
initTrigger: function initTrigger () {
var trigger = this.$el.querySelector('[data-role="trigger"]') || this.$el.querySelector('.dropdown-toggle') || this.$el.firstChild;
this.triggerEl = trigger && trigger !== this.$refs.dropdown ? trigger : null;
},
toggle: function toggle (show) {
if (this.disabled) {
return
}
if (isBoolean(show)) {
this.show = show;
} else {
this.show = !this.show;
}
if (this.appendToBody) {
this.show ? this.appendDropdownToBody() : this.removeDropdownFromBody();
}
this.$emit('input', this.show);
},
windowClicked: function windowClicked (event) {
var target = event.target;
if (this.show && target) {
var targetInNotCloseElements = false;
if (this.notCloseElements) {
for (var i = 0, l = this.notCloseElements.length; i < l; i++) {
var isTargetInElement = this.notCloseElements[i].contains(target);
var shouldBreak = isTargetInElement;
/* istanbul ignore else */
if (this.appendToBody) {
var isTargetInDropdown = this.$refs.dropdown.contains(target);
var isElInElements = this.notCloseElements.indexOf(this.$el) >= 0;
shouldBreak = isTargetInElement || (isTargetInDropdown && isElInElements);
}
if (shouldBreak) {
targetInNotCloseElements = true;
break
}
}
}
var targetInDropdownBody = this.$refs.dropdown.contains(target);
var targetInTrigger = this.$el.contains(target) && !targetInDropdownBody;
// normally, a dropdown select event is handled by @click that trigger after @touchend
// then @touchend event have to be ignore in this case
var targetInDropdownAndIsTouchEvent = targetInDropdownBody && event.type === 'touchend';
if (!targetInTrigger && !targetInNotCloseElements && !targetInDropdownAndIsTouchEvent) {
this.toggle(false);
}
}
},
appendDropdownToBody: function appendDropdownToBody () {
try {
var el = this.$refs.dropdown;
el.style.display = 'block';
document.body.appendChild(el);
var positionElement = this.positionElement || this.$el;
setDropdownPosition(el, positionElement, this);
} catch (e) {
// Silent
}
},
removeDropdownFromBody: function removeDropdownFromBody () {
try {
var el = this.$refs.dropdown;
el.removeAttribute('style');
this.$el.appendChild(el);
} catch (e) {
// Silent
}
}
}
};
var defaultLang = {
uiv: {
datePicker: {
clear: 'Clear',
today: 'Today',
month: 'Month',
month1: 'January',
month2: 'February',
month3: 'March',
month4: 'April',
month5: 'May',
month6: 'June',
month7: 'July',
month8: 'August',
month9: 'September',
month10: 'October',
month11: 'November',
month12: 'December',
year: 'Year',
week1: 'Mon',
week2: 'Tue',
week3: 'Wed',
week4: 'Thu',
week5: 'Fri',
week6: 'Sat',
week7: 'Sun'
},
timePicker: {
am: 'AM',
pm: 'PM'
},
modal: {
cancel: 'Cancel',
ok: 'OK'
},
multiSelect: {
placeholder: 'Select...',
filterPlaceholder: 'Search...'
}
}
};
// https://github.com/ElemeFE/element/blob/dev/src/locale/index.js
var lang = defaultLang;
var i18nHandler = function () {
var vuei18n = Object.getPrototypeOf(this).$t;
/* istanbul ignore else */
/* istanbul ignore next */
if (isFunction(vuei18n)) {
/* istanbul ignore next */
try {
return vuei18n.apply(this, arguments)
} catch (err) {
return this.$t.apply(this, arguments)
}
}
};
var t$1 = function (path, options) {
options = options || {};
var value;
try {
value = i18nHandler.apply(this, arguments);
/* istanbul ignore next */
if (isExist(value) && !options.$$locale) {
return value
}
} catch (e) {
// ignore
}
var array = path.split('.');
var current = options.$$locale || lang;
for (var i = 0, j = array.length; i < j; i++) {
var property = array[i];
value = current[property];
if (i === j - 1) { return value }
if (!value) { return '' }
current = value;
}
/* istanbul ignore next */
return ''
};
var use = function (l) {
lang = l || lang;
};
var i18n = function (fn) {
i18nHandler = fn || i18nHandler;
};
var locale = { use: use, t: t$1, i18n: i18n };
var Local = {
methods: {
t: function t$1$1 () {
var arguments$1 = arguments;
var args = [];
for (var i = 0; i < arguments.length; ++i) {
args.push(arguments$1[i]);
}
args[1] = assign({}, { $$locale: this.locale }, args[1]);
return t$1.apply(this, args)
}
},
props: {
locale: Object
}
};
var e=function(){return (e=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){ for(var a in t=arguments[r]){ Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]); } }return e}).apply(this,arguments)},t={kebab:/-(\w)/g,styleProp:/:(.*)/,styleList:/;(?![^(]*\))/g};function r(e,t){return t?t.toUpperCase():""}function s(e){for(var s,a={},c=0,o=e.split(t.styleList);c<o.length;c++){var n=o[c].split(t.styleProp),i=n[0],l=n[1];(i=i.trim())&&("string"==typeof l&&(l=l.trim()),a[(s=i,s.replace(t.kebab,r))]=l);}return a}function a(){
var arguments$1 = arguments;
for(var t,r,a={},c=arguments.length;c--;){ for(var o=0,n=Object.keys(arguments[c]);o<n.length;o++){ switch(t=n[o]){case"class":case"style":case"directives":if(Array.isArray(a[t])||(a[t]=[]),"style"===t){var i=void 0;i=Array.isArray(arguments$1[c].style)?arguments$1[c].style:[arguments$1[c].style];for(var l=0;l<i.length;l++){var y=i[l];"string"==typeof y&&(i[l]=s(y));}arguments$1[c].style=i;}a[t]=a[t].concat(arguments$1[c][t]);break;case"staticClass":if(!arguments$1[c][t]){ break; }void 0===a[t]&&(a[t]=""),a[t]&&(a[t]+=" "),a[t]+=arguments$1[c][t].trim();break;case"on":case"nativeOn":a[t]||(a[t]={});for(var p=0,f=Object.keys(arguments[c][t]||{});p<f.length;p++){ r=f[p],a[t][r]?a[t][r]=[].concat(a[t][r],arguments$1[c][t][r]):a[t][r]=arguments$1[c][t][r]; }break;case"attrs":case"props":case"domProps":case"scopedSlots":case"staticStyle":case"hook":case"transition":a[t]||(a[t]={}),a[t]=e({},arguments$1[c][t],a[t]);break;case"slot":case"key":case"ref":case"tag":case"show":case"keepAlive":default:a[t]||(a[t]=arguments$1[c][t]);} } }return a}
var linkMixin = {
props: {
// <a> props
href: String,
target: String,
// <router-link> props
to: null,
replace: {
type: Boolean,
default: false
},
append: {
type: Boolean,
default: false
},
exact: {
type: Boolean,
default: false
}
}
};
var BtnGroup = {
functional: true,
render: function render (h, ref) {
var obj;
var props = ref.props;
var children = ref.children;
var data = ref.data;
return h(
'div',
a(data, {
class: ( obj = {
'btn-group': !props.vertical,
'btn-group-vertical': props.vertical,
'btn-group-justified': props.justified
}, obj[("btn-group-" + (props.size))] = props.size, obj ),
attrs: {
role: 'group',
'data-toggle': 'buttons'
}
}),
children
)
},
props: {
size: String,
vertical: {
type: Boolean,
default: false
},
justified: {
type: Boolean,
default: false
}
}
};
var INPUT_TYPE_CHECKBOX = 'checkbox';
var INPUT_TYPE_RADIO = 'radio';
var Btn = {
functional: true,
mixins: [linkMixin],
render: function render (h, ref) {
var children = ref.children;
var props = ref.props;
var data = ref.data;
// event listeners
var listeners = data.on || {};
// checkbox: model contain inputValue
// radio: model === inputValue
var isInputActive = props.inputType === INPUT_TYPE_CHECKBOX ? props.value.indexOf(props.inputValue) >= 0 : props.value === props.inputValue;
// button class
var classes = {
btn: true,
active: props.inputType ? isInputActive : props.active,
disabled: props.disabled,
'btn-block': props.block
};
classes[("btn-" + (props.type))] = Boolean(props.type);
classes[("btn-" + (props.size))] = Boolean(props.size);
// prevent event for disabled links
var on = {
click: function click (e) {
if (props.disabled && e instanceof Event) {
e.preventDefault();
e.stopPropagation();
}
}
};
// render params
var tag, options, slot;
if (props.href) {
// is native link
tag = 'a';
slot = children;
options = a(data, {
on: on,
class: classes,
attrs: {
role: 'button',
href: props.href,
target: props.target
}
});
} else if (props.to) {
// is vue router link
tag = 'router-link';
slot = children;
options = a(data, {
nativeOn: on,
class: classes,
props: {
event: props.disabled ? '' : 'click', // prevent nav while disabled
to: props.to,
replace: props.replace,
append: props.append,
exact: props.exact
},
attrs: {
role: 'button'
}
});
} else if (props.inputType) {
// is input checkbox or radio
tag = 'label';
options = a(data, {
on: on,
class: classes
});
slot = [
h('input', {
attrs: {
autocomplete: 'off',
type: props.inputType,
checked: isInputActive ? 'checked' : null,
disabled: props.disabled
},
domProps: {
checked: isInputActive // required
},
on: {
input: function input (evt) {
evt.stopPropagation();
},
change: function change () {
if (props.inputType === INPUT_TYPE_CHECKBOX) {
var valueCopied = props.value.slice();
if (isInputActive) {
valueCopied.splice(valueCopied.indexOf(props.inputValue), 1);
} else {
valueCopied.push(props.inputValue);
}
listeners.input(valueCopied);
} else {
listeners.input(props.inputValue);
}
}
}
}),
children
];
} else if (props.justified) {
// is in justified btn-group
tag = BtnGroup;
options = {};
slot = [
h('button', a(data, {
on: on,
class: classes,
attrs: {
type: props.nativeType,
disabled: props.disabled
}
}), children)
];
} else {
// is button
tag = 'button';
slot = children;
options = a(data, {
on: on,
class: classes,
attrs: {
type: props.nativeType,
disabled: props.disabled
}
});
}
return h(tag, options, slot)
},
props: {
justified: {
type: Boolean,
default: false
},
type: {
type: String,
default: 'default'
},
nativeType: {
type: String,
default: 'button'
},
size: String,
block: {
type: Boolean,
default: false
},
active: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
// <input> props
value: null,
inputValue: null,
inputType: {
type: String,
validator: function validator (value) {
return value === INPUT_TYPE_CHECKBOX || value === INPUT_TYPE_RADIO
}
}
}
};
var IN = 'in';
var script$f = {
mixins: [Local],
components: { Btn: Btn },
props: {
value: {
type: Boolean,
default: false
},
title: String,
size: String,
backdrop: {
type: Boolean,
default: true
},
footer: {
type: Boolean,
default: true
},
header: {
type: Boolean,
default: true
},
cancelText: String,
cancelType: {
type: String,
default: 'default'
},
okText: String,
okType: {
type: String,
default: 'primary'
},
dismissBtn: {
type: Boolean,
default: true
},
transition: {
type: Number,
default: 150
},
autoFocus: {
type: Boolean,
default: false
},
keyboard: {
type: Boolean,
default: true
},
beforeClose: Function,
zOffset: {
type: Number,
default: 20
},
appendToBody: {
type: Boolean,
default: false
},
displayStyle: {
type: String,
default: 'block'
}
},
data: function data () {
return {
msg: ''
}
},
computed: {
modalSizeClass: function modalSizeClass () {
var obj;
return ( obj = {}, obj[("modal-" + (this.size))] = Boolean(this.size), obj )
}
},
watch: {
value: function value (v) {
this.$toggle(v);
}
},
mounted: function mounted () {
removeFromDom(this.$refs.backdrop);
on(window, EVENTS.MOUSE_DOWN, this.suppressBackgroundClose);
on(window, EVENTS.KEY_UP, this.onKeyPress);
if (this.value) {
this.$toggle(true);
}
},
beforeDestroy: function beforeDestroy () {
clearTimeout(this.timeoutId);
removeFromDom(this.$refs.backdrop);
removeFromDom(this.$el);
if (getOpenModalNum() === 0) {
toggleBodyOverflow(true);
}
off(window, EVENTS.MOUSE_DOWN, this.suppressBackgroundClose);
off(window, EVENTS.MOUSE_UP, this.unsuppressBackgroundClose);
off(window, EVENTS.KEY_UP, this.onKeyPress);
},
methods: {
onKeyPress: function onKeyPress (event) {
if (this.keyboard && this.value && event.keyCode === 27) {
var thisModal = this.$refs.backdrop;
var thisZIndex = thisModal.style.zIndex;
thisZIndex = thisZIndex && thisZIndex !== 'auto' ? parseInt(thisZIndex) : 0;
// Find out if this modal is the top most one.
var modals = getOpenModals();
var modalsLength = modals.length;
for (var i = 0; i < modalsLength; i++) {
if (modals[i] !== thisModal) {
var zIndex = modals[i].style.zIndex;
zIndex = zIndex && zIndex !== 'auto' ? parseInt(zIndex) : 0;
// if any existing modal has higher zIndex, ignore
if (zIndex > thisZIndex) {
return
}
}
}
this.toggle(false);
}
},
toggle: function toggle (show, msg) {
var this$1 = this;
var shouldClose = true;
if (isFunction(this.beforeClose)) {
shouldClose = this.beforeClose(msg);
}
if (isPromiseSupported()) {
// Skip the hiding when beforeClose returning falsely value or returned Promise resolves to falsely value
// Use Promise.resolve to accept both Boolean values and Promises
Promise.resolve(shouldClose).then(function (shouldClose) {
// Skip the hiding while show===false
if (!show && shouldClose) {
this$1.msg = msg;
this$1.$emit('input', show);
}
});
} else {
// Fallback to old version if promise is not supported
// skip the hiding while show===false & beforeClose returning falsely value
if (!show && !shouldClose) {
return
}
this.msg = msg;
this.$emit('input', show);
}
},
$toggle: function $toggle (show) {
var this$1 = this;
var modal = this.$el;
var backdrop = this.$refs.backdrop;
clearTimeout(this.timeoutId);
if (show) {
// If two modals share the same v-if condition the calculated z-index is incorrect,
// resulting in popover misbehaviour.
// solved by adding a nextTick.
// https://github.com/uiv-lib/uiv/issues/342
this.$nextTick(function () {
var alreadyOpenModalNum = getOpenModalNum();
document.body.appendChild(backdrop);
if (this$1.appendToBody) {
document.body.appendChild(modal);
}
modal.style.display = this$1.displayStyle;
modal.scrollTop = 0;
backdrop.offsetHeight; // force repaint
toggleBodyOverflow(false);
addClass(backdrop, IN);
addClass(modal, IN);
// fix z-index for nested modals
// no need to calculate if no modal is already open
if (alreadyOpenModalNum > 0) {
var modalBaseZ = parseInt(getComputedStyle(modal).zIndex) || 1050; // 1050 is default modal z-Index
var backdropBaseZ = parseInt(getComputedStyle(backdrop).zIndex) || 1040; // 1040 is default backdrop z-Index
var offset = alreadyOpenModalNum * this$1.zOffset;
modal.style.zIndex = "" + (modalBaseZ + offset);
backdrop.style.zIndex = "" + (backdropBaseZ + offset);
}
// z-index fix end
this$1.timeoutId = setTimeout(function () {
if (this$1.autoFocus) {
var btn = this$1.$el.querySelector('[data-action="auto-focus"]');
if (btn) {
btn.focus();
}
}
this$1.$emit('show');
this$1.timeoutId = 0;
}, this$1.transition);
});
} else {
removeClass(backdrop, IN);
removeClass(modal, IN);
this.timeoutId = setTimeout(function () {
modal.style.display = 'none';
removeFromDom(backdrop);
if (this$1.appendToBody) {
removeFromDom(modal);
}
if (getOpenModalNum() === 0) {
toggleBodyOverflow(true);
}
this$1.$emit('hide', this$1.msg || 'dismiss');
this$1.msg = '';
this$1.timeoutId = 0;
// restore z-index for nested modals
modal.style.zIndex = '';
backdrop.style.zIndex = '';