UNPKG

bootstrap-vue

Version:

BootstrapVue provides one of the most comprehensive implementations of Bootstrap 4 components and grid system for Vue.js and with extensive and automated WAI-ARIA accessibility markup.

1,983 lines (1,711 loc) 474 kB
'use strict'; var __assign = Object.assign || function (e) { for (var a, s = 1, t = arguments.length; s < t; s++) { for (var r in a = arguments[s]) { Object.prototype.hasOwnProperty.call(a, r) && (e[r] = a[r]); } }return e; };function mergeData() { for (var e, a, s = {}, t = arguments.length; t--;) { for (var r = 0, c = Object.keys(arguments[t]); r < c.length; r++) { switch (e = c[r]) {case "class":case "style":case "directives": Array.isArray(s[e]) || (s[e] = []), s[e] = s[e].concat(arguments[t][e]);break;case "staticClass": if (!arguments[t][e]) break;void 0 === s[e] && (s[e] = ""), s[e] && (s[e] += " "), s[e] += arguments[t][e].trim();break;case "on":case "nativeOn": s[e] || (s[e] = {});for (var o = 0, n = Object.keys(arguments[t][e] || {}); o < n.length; o++) { a = n[o], s[e][a] ? s[e][a] = [].concat(s[e][a], arguments[t][e][a]) : s[e][a] = arguments[t][e][a]; }break;case "attrs":case "props":case "domProps":case "scopedSlots":case "staticStyle":case "hook":case "transition": s[e] || (s[e] = {}), s[e] = __assign({}, arguments[t][e], s[e]);break;case "slot":case "key":case "ref":case "tag":case "show":case "keepAlive":default: s[e] || (s[e] = arguments[t][e]);} } }return s; } var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; var createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var defineProperty = function (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; }; var inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }; var possibleConstructorReturn = function (self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }; var toConsumableArray = function (arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }; var props = { disabled: { type: Boolean, default: false }, ariaLabel: { type: String, default: 'Close' }, textVariant: { type: String, default: null } }; var bBtnClose = { functional: true, props: props, render: function render(h, _ref) { var props = _ref.props, data = _ref.data, listeners = _ref.listeners, slots = _ref.slots; var componentData = { staticClass: 'close', class: defineProperty({}, 'text-' + props.textVariant, props.textVariant), attrs: { type: 'button', disabled: props.disabled, 'aria-label': props.ariaLabel ? String(props.ariaLabel) : null }, on: { click: function click(e) { // Ensure click on button HTML content is also disabled if (props.disabled && e instanceof Event) { e.stopPropagation(); e.preventDefault(); } } } // Careful not to override the slot with innerHTML };if (!slots().default) { componentData.domProps = { innerHTML: '&times;' }; } return h('button', mergeData(data, componentData), slots().default); } }; var bAlert = { components: { bButtonClose: bBtnClose }, render: function render(h) { if (!this.localShow) { // If not showing, render placeholder return h(false); } var dismissBtn = h(false); if (this.dismissible) { // Add dismiss button dismissBtn = h('b-button-close', { attrs: { 'aria-label': this.dismissLabel }, on: { click: this.dismiss } }, [this.$slots.dismiss]); } return h('div', { class: this.classObject, attrs: { role: 'alert', 'aria-live': 'polite', 'aria-atomic': true } }, [dismissBtn, this.$slots.default]); }, model: { prop: 'show', event: 'input' }, data: function data() { return { countDownTimerId: null, dismissed: false }; }, computed: { classObject: function classObject() { return ['alert', this.alertVariant, this.dismissible ? 'alert-dismissible' : '']; }, alertVariant: function alertVariant() { var variant = this.variant; return 'alert-' + variant; }, localShow: function localShow() { return !this.dismissed && (this.countDownTimerId || this.show); } }, props: { variant: { type: String, default: 'info' }, dismissible: { type: Boolean, default: false }, dismissLabel: { type: String, default: 'Close' }, show: { type: [Boolean, Number], default: false } }, watch: { show: function show() { this.showChanged(); } }, mounted: function mounted() { this.showChanged(); }, destroyed /* istanbul ignore next */: function destroyed() { this.clearCounter(); }, methods: { dismiss: function dismiss() { this.clearCounter(); this.dismissed = true; this.$emit('dismissed'); this.$emit('input', false); if (typeof this.show === 'number') { this.$emit('dismiss-count-down', 0); this.$emit('input', 0); } else { this.$emit('input', false); } }, clearCounter: function clearCounter() { if (this.countDownTimerId) { clearInterval(this.countDownTimerId); this.countDownTimerId = null; } }, showChanged: function showChanged() { var _this = this; // Reset counter status this.clearCounter(); // Reset dismiss status this.dismissed = false; // No timer for boolean values if (this.show === true || this.show === false || this.show === null || this.show === 0) { return; } // Start counter var dismissCountDown = this.show; this.countDownTimerId = setInterval(function () { if (dismissCountDown < 1) { _this.dismiss(); return; } dismissCountDown--; _this.$emit('dismiss-count-down', dismissCountDown); _this.$emit('input', dismissCountDown); }, 1000); } } }; /** * Register a component plugin as being loaded. returns true if compoent plugin already registered * @param {object} Vue * @param {string} Component name * @param {object} Component definition */ function registerComponent(Vue, name, def) { Vue._bootstrap_vue_components_ = Vue._bootstrap_vue_components_ || {}; var loaded = Vue._bootstrap_vue_components_[name]; if (!loaded && def && name) { Vue._bootstrap_vue_components_[name] = true; Vue.component(name, def); } return loaded; } /** * Register a group of components as being loaded. * @param {object} Vue * @param {object} Object of component definitions */ function registerComponents(Vue, components) { for (var component in components) { registerComponent(Vue, component, components[component]); } } /** * Register a directive as being loaded. returns true if directive plugin already registered * @param {object} Vue * @param {string} Directive name * @param {object} Directive definition */ function registerDirective(Vue, name, def) { Vue._bootstrap_vue_directives_ = Vue._bootstrap_vue_directives_ || {}; var loaded = Vue._bootstrap_vue_directives_[name]; if (!loaded && def && name) { Vue._bootstrap_vue_directives_[name] = true; Vue.directive(name, def); } return loaded; } /** * Register a group of directives as being loaded. * @param {object} Vue * @param {object} Object of directive definitions */ function registerDirectives(Vue, directives) { for (var directive in directives) { registerDirective(Vue, directive, directives[directive]); } } /** * Install plugin if window.Vue available * @param {object} Plugin definition */ function vueUse(VuePlugin) { if (typeof window !== 'undefined' && window.Vue) { window.Vue.use(VuePlugin); } } var components = { bAlert: bAlert }; var VuePlugin = { install: function install(Vue) { registerComponents(Vue, components); } }; vueUse(VuePlugin); /** * Aliasing Object[method] allows the minifier to shorten methods to a single character variable, * as well as giving BV a chance to inject polyfills. * As long as we avoid * - import * as Object from "utils/object" * all unused exports should be removed by tree-shaking. */ // @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign if (typeof Object.assign !== 'function') { Object.assign = function (target, varArgs) { // .length of function is 2 if (target == null) { // TypeError if undefined or null 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[index]; if (nextSource != null) { // Skip over if undefined or null for (var nextKey in nextSource) { // Avoid bugs when hasOwnProperty is shadowed if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { to[nextKey] = nextSource[nextKey]; } } } } return to; }; } // @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#Polyfill if (!Object.is) { Object.is = function (x, y) { // SameValue algorithm if (x === y) { // Steps 1-5, 7-10 // Steps 6.b-6.e: +0 != -0 return x !== 0 || 1 / x === 1 / y; } else { // Step 6.a: NaN == NaN // eslint-disable-next-line no-self-compare return x !== x && y !== y; } }; } var assign = Object.assign; var keys = Object.keys; var defineProperties = Object.defineProperties; var defineProperty$1 = Object.defineProperty; var create = Object.create; function readonlyDescriptor() { return { enumerable: true, configurable: false, writable: false }; } // Production steps of ECMA-262, Edition 6, 22.1.2.1 // es6-ified by @alexsasharegan if (!Array.from) { Array.from = function () { var toStr = Object.prototype.toString; var isCallable = function isCallable(fn) { return typeof fn === 'function' || toStr.call(fn) === '[object Function]'; }; var toInteger = function toInteger(value) { var number = Number(value); if (isNaN(number)) { return 0; } if (number === 0 || !isFinite(number)) { return number; } return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number)); }; var maxSafeInteger = Math.pow(2, 53) - 1; var toLength = function toLength(value) { return Math.min(Math.max(toInteger(value), 0), maxSafeInteger); }; // The length property of the from method is 1. return function from(arrayLike /*, mapFn, thisArg */) { // 1. Let C be the this value. var C = this; // 2. Let items be ToObject(arrayLike). var items = Object(arrayLike); // 3. ReturnIfAbrupt(items). if (arrayLike == null) { throw new TypeError('Array.from requires an array-like object - not null or undefined'); } // 4. If mapfn is undefined, then let mapping be false. var mapFn = arguments.length > 1 ? arguments[1] : void undefined; var T = void 0; if (typeof mapFn !== 'undefined') { // 5. else // 5. a If IsCallable(mapfn) is false, throw a TypeError exception. if (!isCallable(mapFn)) { throw new TypeError('Array.from: when provided, the second argument must be a function'); } // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined. if (arguments.length > 2) { T = arguments[2]; } } // 10. Let lenValue be Get(items, "length"). // 11. Let len be ToLength(lenValue). var len = toLength(items.length); // 13. If IsConstructor(C) is true, then // 13. a. Let A be the result of calling the [[Construct]] internal method // of C with an argument list containing the single item len. // 14. a. Else, Let A be ArrayCreate(len). var A = isCallable(C) ? Object(new C(len)) : new Array(len); // 16. Let k be 0. var k = 0; // 17. Repeat, while k < len… (also steps a - h) var kValue = void 0; while (k < len) { kValue = items[k]; if (mapFn) { A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k); } else { A[k] = kValue; } k += 1; } // 18. Let putStatus be Put(A, "length", len, true). A.length = len; // 20. Return A. return A; }; }(); } // https://tc39.github.io/ecma262/#sec-array.prototype.find // Needed for IE support if (!Array.prototype.find) { // eslint-disable-next-line no-extend-native Object.defineProperty(Array.prototype, 'find', { value: function value(predicate) { // 1. Let O be ? ToObject(this value). if (this == null) { throw new TypeError('"this" is null or not defined'); } var o = Object(this); // 2. Let len be ? ToLength(? Get(O, "length")). var len = o.length >>> 0; // 3. If IsCallable(predicate) is false, throw a TypeError exception. if (typeof predicate !== 'function') { throw new TypeError('predicate must be a function'); } // 4. If thisArg was supplied, let T be thisArg; else let T be undefined. var thisArg = arguments[1]; // 5. Let k be 0. var k = 0; // 6. Repeat, while k < len while (k < len) { // a. Let Pk be ! ToString(k). // b. Let kValue be ? Get(O, Pk). // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). // d. If testResult is true, return kValue. var kValue = o[k]; if (predicate.call(thisArg, kValue, k, o)) { return kValue; } // e. Increase k by 1. k++; } // 7. Return undefined. return undefined; } }); } if (!Array.isArray) { Array.isArray = function (arg) { return Object.prototype.toString.call(arg) === '[object Array]'; }; } // Static var from = Array.from; var isArray = Array.isArray; // Instance var arrayIncludes = function arrayIncludes(array, value) { return array.indexOf(value) !== -1; }; function concat() { return Array.prototype.concat.apply([], arguments); } function identity(x) { return x; } /** * Given an array of properties or an object of property keys, * plucks all the values off the target object. * @param {{}|string[]} keysToPluck * @param {{}} objToPluck * @param {Function} transformFn * @return {{}} */ function pluckProps(keysToPluck, objToPluck) { var transformFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : identity; return (isArray(keysToPluck) ? keysToPluck.slice() : keys(keysToPluck)).reduce(function (memo, prop) { // eslint-disable-next-line no-sequences return memo[transformFn(prop)] = objToPluck[prop], memo; }, {}); } /** * The Link component is used in many other BV components. * As such, sharing its props makes supporting all its features easier. * However, some components need to modify the defaults for their own purpose. * Prefer sharing a fresh copy of the props to ensure mutations * do not affect other component references to the props. * * https://github.com/vuejs/vue-router/blob/dev/src/components/link.js * @return {{}} */ function propsFactory() { return { href: { type: String, default: null }, rel: { type: String, default: null }, target: { type: String, default: '_self' }, active: { type: Boolean, default: false }, activeClass: { type: String, default: 'active' }, append: { type: Boolean, default: false }, disabled: { type: Boolean, default: false }, event: { type: [String, Array], default: 'click' }, exact: { type: Boolean, default: false }, exactActiveClass: { type: String, default: 'active' }, replace: { type: Boolean, default: false }, routerTag: { type: String, default: 'a' }, to: { type: [String, Object], default: null } }; } function pickLinkProps(propsToPick) { var freshLinkProps = propsFactory(); // Normalize everything to array. propsToPick = concat(propsToPick); return keys(freshLinkProps).reduce(function (memo, prop) { if (arrayIncludes(propsToPick, prop)) { memo[prop] = freshLinkProps[prop]; } return memo; }, {}); } function computeTag(props, parent) { return Boolean(parent.$router) && props.to && !props.disabled ? 'router-link' : 'a'; } function computeHref(_ref, tag) { var disabled = _ref.disabled, href = _ref.href, to = _ref.to; // We've already checked the parent.$router in computeTag, // so router-link means live router. // When deferring to Vue Router's router-link, // don't use the href attr at all. // Must return undefined for router-link to populate href. if (tag === 'router-link') return void 0; // If href explicitly provided if (href) return href; // Reconstruct href when `to` used, but no router if (to) { // Fallback to `to` prop (if `to` is a string) if (typeof to === 'string') return to; // Fallback to `to.path` prop (if `to` is an object) if ((typeof to === 'undefined' ? 'undefined' : _typeof(to)) === 'object' && typeof to.path === 'string') return to.path; } // If nothing is provided use '#' return '#'; } function computeRel(_ref2) { var target = _ref2.target, rel = _ref2.rel; if (target === '_blank' && rel === null) { return 'noopener'; } return rel || null; } function clickHandlerFactory(_ref3) { var disabled = _ref3.disabled, tag = _ref3.tag, href = _ref3.href, suppliedHandler = _ref3.suppliedHandler, parent = _ref3.parent; var isRouterLink = tag === 'router-link'; return function onClick(e) { if (disabled && e instanceof Event) { // Stop event from bubbling up. e.stopPropagation(); // Kill the event loop attached to this specific EventTarget. e.stopImmediatePropagation(); } else { parent.$root.$emit('clicked::link', e); if (isRouterLink && e.target.__vue__) { e.target.__vue__.$emit('click', e); } if (typeof suppliedHandler === 'function') { suppliedHandler.apply(undefined, arguments); } } if (!isRouterLink && href === '#' || disabled) { // Stop scroll-to-top behavior or navigation. e.preventDefault(); } }; } var bLink = { functional: true, props: propsFactory(), render: function render(h, _ref4) { var props = _ref4.props, data = _ref4.data, parent = _ref4.parent, children = _ref4.children; var tag = computeTag(props, parent); var rel = computeRel(props); var href = computeHref(props, tag); var eventType = tag === 'router-link' ? 'nativeOn' : 'on'; var suppliedHandler = (data[eventType] || {}).click; var handlers = { click: clickHandlerFactory({ tag: tag, href: href, disabled: props.disabled, suppliedHandler: suppliedHandler, parent: parent }) }; var componentData = mergeData(data, { class: [props.active ? props.exact ? props.exactActiveClass : props.activeClass : null, { disabled: props.disabled }], attrs: { rel: rel, href: href, target: props.target, tabindex: props.disabled ? '-1' : data.attrs ? data.attrs.tabindex : null, 'aria-disabled': tag === 'a' && props.disabled ? 'true' : null }, props: assign(props, { tag: props.routerTag }) }); // If href prop exists on router-link (even undefined or null) it fails working on SSR if (!componentData.attrs.href) { delete componentData.attrs.href; } // We want to overwrite any click handler since our callback // will invoke the supplied handler if !props.disabled componentData[eventType] = assign(componentData[eventType] || {}, handlers); return h(tag, componentData, children); } }; var linkProps = propsFactory(); delete linkProps.href.default; delete linkProps.to.default; var props$2 = assign(linkProps, { tag: { type: String, default: 'span' }, variant: { type: String, default: 'secondary' }, pill: { type: Boolean, default: false } }); var bBadge = { functional: true, props: props$2, render: function render(h, _ref) { var props = _ref.props, data = _ref.data, children = _ref.children; var tag = !props.href && !props.to ? props.tag : bLink; var componentData = { staticClass: 'badge', class: [!props.variant ? 'badge-secondary' : 'badge-' + props.variant, { 'badge-pill': Boolean(props.pill), active: props.active, disabled: props.disabled }], props: pluckProps(linkProps, props) }; return h(tag, mergeData(data, componentData), children); } }; var components$1 = { bBadge: bBadge }; var VuePlugin$2 = { install: function install(Vue) { registerComponents(Vue, components$1); } }; vueUse(VuePlugin$2); var props$3 = assign(propsFactory(), { text: { type: String, default: null }, active: { type: Boolean, default: false }, href: { type: String, default: '#' }, ariaCurrent: { type: String, default: 'location' } }); var bBreadcrumbLink = { functional: true, props: props$3, render: function render(h, _ref) { var suppliedProps = _ref.props, data = _ref.data, children = _ref.children; var tag = suppliedProps.active ? 'span' : bLink; var componentData = { props: pluckProps(props$3, suppliedProps), domProps: { innerHTML: suppliedProps.text } }; if (suppliedProps.active) { componentData.attrs = { 'aria-current': suppliedProps.ariaCurrent }; } else { componentData.attrs = { href: suppliedProps.href }; } return h(tag, mergeData(data, componentData), children); } }; var props$4 = assign({}, props$3, { text: { type: String, default: null }, href: { type: String, default: null } }); var bBreadcrumbItem = { functional: true, props: props$4, render: function render(h, _ref) { var props$$1 = _ref.props, data = _ref.data, children = _ref.children; return h('li', mergeData(data, { staticClass: 'breadcrumb-item', class: { active: props$$1.active }, attrs: { role: 'presentation' } }), [h(bBreadcrumbLink, { props: props$$1 }, children)]); } }; var props$5 = { items: { type: Array, default: null } }; var bBreadcrumb = { functional: true, props: props$5, render: function render(h, _ref) { var props = _ref.props, data = _ref.data, children = _ref.children; var childNodes = children; // Build child nodes from items if given. if (isArray(props.items)) { var activeDefined = false; childNodes = props.items.map(function (item, idx) { if ((typeof item === 'undefined' ? 'undefined' : _typeof(item)) !== 'object') { item = { text: item }; } // Copy the value here so we can normalize it. var active = item.active; if (active) { activeDefined = true; } if (!active && !activeDefined) { // Auto-detect active by position in list. active = idx + 1 === props.items.length; } return h(bBreadcrumbItem, { props: assign({}, item, { active: active }) }); }); } return h('ol', mergeData(data, { staticClass: 'breadcrumb' }), childNodes); } }; var components$2 = { bBreadcrumb: bBreadcrumb, bBreadcrumbItem: bBreadcrumbItem, bBreadcrumbLink: bBreadcrumbLink }; var VuePlugin$4 = { install: function install(Vue) { registerComponents(Vue, components$2); } }; vueUse(VuePlugin$4); // Determine if an element is an HTML Element var isElement = function isElement(el) { return el && el.nodeType === Node.ELEMENT_NODE; }; // Determine if an HTML element is visible - Faster than CSS check var isVisible = function isVisible(el) { return isElement(el) && document.body.contains(el) && el.getBoundingClientRect().height > 0 && el.getBoundingClientRect().width > 0; }; // Determine if an element is disabled var isDisabled = function isDisabled(el) { return !isElement(el) || el.disabled || el.classList.contains('disabled') || Boolean(el.getAttribute('disabled')); }; // Cause/wait-for an element to reflow it's content (adjusting it's height/width) var reflow = function reflow(el) { // requsting an elements offsetHight will trigger a reflow of the element content return isElement(el) && el.offsetHeight; }; // Select all elements matching selector. Returns [] if none found var selectAll = function selectAll(selector, root) { if (!isElement(root)) { root = document; } return from(root.querySelectorAll(selector)); }; // Select a single element, returns null if not found var select = function select(selector, root) { if (!isElement(root)) { root = document; } return root.querySelector(selector) || null; }; // Determine if an element matches a selector var matches = function matches(el, selector) { if (!isElement(el)) { return false; } // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill // Prefer native implementations over polyfill function var proto = Element.prototype; var Matches = proto.matches || proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector || proto.webkitMatchesSelector || /* istanbul ignore next */ function (sel) { var element = this; var m = selectAll(sel, element.document || element.ownerDocument); var i = m.length; // eslint-disable-next-line no-empty while (--i >= 0 && m.item(i) !== element) {} return i > -1; }; return Matches.call(el, selector); }; // Finds closest element matching selector. Returns null if not found var closest = function closest(selector, root) { if (!isElement(root)) { return null; } // https://developer.mozilla.org/en-US/docs/Web/API/Element/closest // Since we dont support IE < 10, we can use the "Matches" version of the polyfill for speed // Prefer native implementation over polyfill function var Closest = Element.prototype.closest || /* istanbul ignore next */ function (sel) { var element = this; if (!document.documentElement.contains(element)) { return null; } do { // Use our "patched" matches function if (matches(element, sel)) { return element; } element = element.parentElement; } while (element !== null); return null; }; var el = Closest.call(root, selector); // Emulate jQuery closest and return null if match is the passed in element (root) return el === root ? null : el; }; // Get an element given an ID var getById = function getById(id) { return document.getElementById(/^#/.test(id) ? id.slice(1) : id) || null; }; // Add a class to an element var addClass = function addClass(el, className) { if (className && isElement(el)) { el.classList.add(className); } }; // Remove a class from an element var removeClass = function removeClass(el, className) { if (className && isElement(el)) { el.classList.remove(className); } }; // Test if an element has a class var hasClass = function hasClass(el, className) { if (className && isElement(el)) { return el.classList.contains(className); } return false; }; // Set an attribute on an element var setAttr = function setAttr(el, attr, value) { if (attr && isElement(el)) { el.setAttribute(attr, value); } }; // Remove an attribute from an element var removeAttr = function removeAttr(el, attr) { if (attr && isElement(el)) { el.removeAttribute(attr); } }; // Get an attribute value from an element (returns null if not found) var getAttr = function getAttr(el, attr) { if (attr && isElement(el)) { return el.getAttribute(attr); } return null; }; // Determine if an attribute exists on an element (returns true or false, or null if element not found) var hasAttr = function hasAttr(el, attr) { if (attr && isElement(el)) { return el.hasAttribute(attr); } return null; }; // Return the Bounding Client Rec of an element. Retruns null if not an element var getBCR = function getBCR(el) { return isElement(el) ? el.getBoundingClientRect() : null; }; // Get computed style object for an element var getCS = function getCS(el) { return isElement(el) ? window.getComputedStyle(el) : {}; }; // Return an element's offset wrt document element // https://j11y.io/jquery/#v=git&fn=jQuery.fn.offset var offset = function offset(el) { if (isElement(el)) { if (!el.getClientRects().length) { return { top: 0, left: 0 }; } var bcr = getBCR(el); var win = el.ownerDocument.defaultView; return { top: bcr.top + win.pageYOffset, left: bcr.left + win.pageXOffset }; } }; // Return an element's offset wrt to it's offsetParent // https://j11y.io/jquery/#v=git&fn=jQuery.fn.position var position = function position(el) { if (!isElement(el)) { return; } var parentOffset = { top: 0, left: 0 }; var offsetSelf = void 0; var offsetParent = void 0; if (getCS(el).position === 'fixed') { offsetSelf = getBCR(el); } else { offsetSelf = offset(el); var doc = el.ownerDocument; offsetParent = el.offsetParent || doc.documentElement; while (offsetParent && (offsetParent === doc.body || offsetParent === doc.documentElement) && getCS(offsetParent).position === 'static') { offsetParent = offsetParent.parentNode; } if (offsetParent && offsetParent !== el && offsetParent.nodeType === Node.ELEMENT_NODE) { parentOffset = offset(offsetParent); parentOffset.top += parseFloat(getCS(offsetParent).borderTopWidth); parentOffset.left += parseFloat(getCS(offsetParent).borderLeftWidth); } } return { top: offsetSelf.top - parentOffset.top - parseFloat(getCS(el).marginTop), left: offsetSelf.left - parentOffset.left - parseFloat(getCS(el).marginLeft) }; }; // Attach an event listener to an element var eventOn = function eventOn(el, evtName, handler) { if (el && el.addEventListener) { el.addEventListener(evtName, handler); } }; // Remove an event listener from an element var eventOff = function eventOff(el, evtName, handler) { if (el && el.removeEventListener) { el.removeEventListener(evtName, handler); } }; var btnProps = { block: { type: Boolean, default: false }, disabled: { type: Boolean, default: false }, size: { type: String, default: null }, variant: { type: String, default: null }, type: { type: String, default: 'button' }, pressed: { // tri-state prop: true, false or null // => on, off, not a toggle type: Boolean, default: null } }; var linkProps$1 = propsFactory(); delete linkProps$1.href.default; delete linkProps$1.to.default; var linkPropKeys = keys(linkProps$1); var props$6 = assign(linkProps$1, btnProps); function handleFocus(evt) { if (evt.type === 'focusin') { addClass(evt.target, 'focus'); } else if (evt.type === 'focusout') { removeClass(evt.target, 'focus'); } } var bBtn = { functional: true, props: props$6, render: function render(h, _ref) { var _ref2; var props = _ref.props, data = _ref.data, listeners = _ref.listeners, children = _ref.children; var isLink = Boolean(props.href || props.to); var isToggle = typeof props.pressed === 'boolean'; var on = { click: function click(e) { if (props.disabled && e instanceof Event) { e.stopPropagation(); e.preventDefault(); } else if (isToggle) { // Concat will normalize the value to an array // without double wrapping an array value in an array. concat(listeners['update:pressed']).forEach(function (fn) { if (typeof fn === 'function') { fn(!props.pressed); } }); } } }; if (isToggle) { on.focusin = handleFocus; on.focusout = handleFocus; } var componentData = { staticClass: 'btn', class: [props.variant ? 'btn-' + props.variant : 'btn-secondary', (_ref2 = {}, defineProperty(_ref2, 'btn-' + props.size, Boolean(props.size)), defineProperty(_ref2, 'btn-block', props.block), defineProperty(_ref2, 'disabled', props.disabled), defineProperty(_ref2, 'active', props.pressed), _ref2)], props: isLink ? pluckProps(linkPropKeys, props) : null, attrs: { type: isLink ? null : props.type, disabled: isLink ? null : props.disabled, // Data attribute not used for js logic, // but only for BS4 style selectors. 'data-toggle': isToggle ? 'button' : null, 'aria-pressed': isToggle ? String(props.pressed) : null, // Tab index is used when the component becomes a link. // Links are tabable, but don't allow disabled, // so we mimic that functionality by disabling tabbing. tabindex: props.disabled && isLink ? '-1' : data.attrs ? data.attrs['tabindex'] : null }, on: on }; return h(isLink ? bLink : 'button', mergeData(data, componentData), children); } }; var components$3 = { bButton: bBtn, bBtn: bBtn, bButtonClose: bBtnClose, bBtnClose: bBtnClose }; var VuePlugin$6 = { install: function install(Vue) { registerComponents(Vue, components$3); } }; vueUse(VuePlugin$6); var props$7 = { vertical: { type: Boolean, default: false }, size: { type: String, default: null, validator: function validator(size) { return arrayIncludes(['sm', '', 'lg'], size); } }, tag: { type: String, default: 'div' }, ariaRole: { type: String, default: 'group' } }; var bButtonGroup = { functional: true, props: props$7, render: function render(h, _ref) { var props = _ref.props, data = _ref.data, children = _ref.children; return h(props.tag, mergeData(data, { class: defineProperty({ 'btn-group': !props.vertical, 'btn-group-vertical': props.vertical }, 'btn-group-' + props.size, Boolean(props.size)), attrs: { 'role': props.ariaRole } }), children); } }; var components$4 = { bButtonGroup: bButtonGroup, bBtnGroup: bButtonGroup }; var VuePlugin$8 = { install: function install(Vue) { registerComponents(Vue, components$4); } }; vueUse(VuePlugin$8); /* * Key Codes (events) */ var KeyCodes = { SPACE: 32, ENTER: 13, ESC: 27, LEFT: 37, UP: 38, RIGHT: 39, DOWN: 40, PAGEUP: 33, PAGEDOWN: 34, HOME: 36, END: 35 }; var ITEM_SELECTOR = ['.btn:not(.disabled):not([disabled]):not(.dropdown-item)', '.form-control:not(.disabled):not([disabled])', 'select:not(.disabled):not([disabled])', 'input[type="checkbox"]:not(.disabled)', 'input[type="radio"]:not(.disabled)'].join(','); var bButtonToolbar = { render: function render(h) { var t = this; return h('div', { class: t.classObject, attrs: { role: 'toolbar', tabindex: t.keyNav ? '0' : null }, on: { focusin: t.onFocusin, keydown: t.onKeydown } }, [t.$slots.default]); }, computed: { classObject: function classObject() { return ['btn-toolbar', this.justify && !this.vertical ? 'justify-content-between' : '']; } }, props: { justify: { type: Boolean, default: false }, keyNav: { type: Boolean, default: false } }, methods: { onFocusin: function onFocusin(evt) { if (evt.target === this.$el) { evt.preventDefault(); evt.stopPropagation(); this.focusFirst(evt); } }, onKeydown: function onKeydown(evt) { if (!this.keyNav) { return; } var key = evt.keyCode; var shift = evt.shiftKey; if (key === KeyCodes.UP || key === KeyCodes.LEFT) { evt.preventDefault(); evt.stopPropagation(); if (shift) { this.focusFirst(evt); } else { this.focusNext(evt, true); } } else if (key === KeyCodes.DOWN || key === KeyCodes.RIGHT) { evt.preventDefault(); evt.stopPropagation(); if (shift) { this.focusLast(evt); } else { this.focusNext(evt, false); } } }, setItemFocus: function setItemFocus(item) { this.$nextTick(function () { item.focus(); }); }, focusNext: function focusNext(evt, prev) { var items = this.getItems(); if (items.length < 1) { return; } var index = items.indexOf(evt.target); if (prev && index > 0) { index--; } else if (!prev && index < items.length - 1) { index++; } if (index < 0) { index = 0; } this.setItemFocus(items[index]); }, focusFirst: function focusFirst(evt) { var items = this.getItems(); if (items.length > 0) { this.setItemFocus(items[0]); } }, focusLast: function focusLast(evt) { var items = this.getItems(); if (items.length > 0) { this.setItemFocus([items.length - 1]); } }, getItems: function getItems() { var items = selectAll(ITEM_SELECTOR, this.$el); items.forEach(function (item) { // Ensure tabfocus is -1 on any new elements item.tabIndex = -1; }); return items.filter(function (el) { return isVisible(el); }); } }, mounted: function mounted() { if (this.keyNav) { // Pre-set the tabindexes if the markup does not include tabindex="-1" on the toolbar items this.getItems(); } } }; var components$5 = { bButtonToolbar: bButtonToolbar, bBtnToolbar: bButtonToolbar }; var VuePlugin$10 = { install: function install(Vue) { registerComponents(Vue, components$5); } }; vueUse(VuePlugin$10); var props$8 = { tag: { type: String, default: 'div' } }; var bInputGroupText = { props: props$8, functional: true, render: function render(h, _ref) { var props = _ref.props, data = _ref.data, children = _ref.children; return h(props.tag, mergeData(data, { staticClass: 'input-group-text' }), children); } }; var propsFactory$1 = function propsFactory(append) { return { id: { type: String, default: null }, tag: { type: String, default: 'div' }, append: { type: Boolean, default: append }, isText: { type: Boolean, default: false } }; }; var bInputGroupAddon = { functional: true, props: propsFactory$1(false), render: function render(h, _ref) { var props = _ref.props, data = _ref.data, children = _ref.children; return h(props.tag, mergeData(data, { staticClass: 'input-group-' + (props.append ? 'append' : 'prepend'), attrs: { id: props.id } }), props.isText ? [h(bInputGroupText, children)] : children); } }; var bInputGroupPrepend = { functional: true, props: propsFactory$1(false), render: bInputGroupAddon.render }; var bInputGroupAppend = { functional: true, props: propsFactory$1(true), render: bInputGroupAddon.render }; var props$9 = { id: { type: String, default: null }, size: { type: String, default: null }, prepend: { type: String, default: null }, append: { type: String, default: null }, tag: { type: String, default: 'div' } }; var bInputGroup = { functional: true, props: props$9, render: function render(h, _ref) { var props = _ref.props, data = _ref.data, slots = _ref.slots; var $slots = slots(); var childNodes = []; // Prepend prop if (props.prepend) { childNodes.push(h(bInputGroupPrepend, [h(bInputGroupText, { domProps: { innerHTML: props.prepend } })])); } // Prepend slot if ($slots.prepend) { childNodes.push(h(bInputGroupPrepend, $slots.prepend)); } // Default slot childNodes.push($slots.default); // Append prop if (props.append) { childNodes.push(h(bInputGroupAppend, [h(bInputGroupText, { domProps: { innerHTML: props.append } })])); } // Append slot if ($slots.append) { childNodes.push(h(bInputGroupAppend, $slots.append)); } return h(props.tag, mergeData(data, { staticClass: 'input-group', class: defineProperty({}, 'input-group-' + props.size, Boolean(props.size)), attrs: { id: props.id || null, role: 'group' } }), childNodes); } }; var components$6 = { bInputGroup: bInputGroup, bInputGroupAddon: bInputGroupAddon, bInputGroupPrepend: bInputGroupPrepend, bInputGroupAppend: bInputGroupAppend, bInputGroupText: bInputGroupText }; var VuePlugin$12 = { install: function install(Vue) { registerComponents(Vue, components$6); } }; vueUse(VuePlugin$12); /** * @param {string} str */ function upperFirst(str) { if (typeof str !== 'string') { str = String(str); } return str.charAt(0).toUpperCase() + str.slice(1); } /** * @param {string} prefix * @param {string} value */ function prefixPropName(prefix, value) { return prefix + upperFirst(value); } /** * @param {string} str */ function lowerFirst(str) { if (typeof str !== 'string') { str = String(str); } return str.charAt(0).toLowerCase() + str.slice(1); } /** * @param {string} prefix * @param {string} value */ function unPrefixPropName(prefix, value) { return lowerFirst(value.replace(prefix, '')); } /** * @param {[]|{}} props * @param {Function} transformFn */ function copyProps(props) { var transformFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity; if (isArray(props)) { return props.map(transformFn); } // Props as an object. var copied = {}; for (var prop in props) { if (props.hasOwnProperty(prop)) { if ((typeof prop === 'undefined' ? 'undefined' : _typeof(prop)) === 'object') { copied[transformFn(prop)] = assign({}, props[prop]); } else { copied[transformFn(prop)] = props[prop]; } } } return copied; } var cardMixin = { props: { tag: { type: String, default: 'div' }, bgVariant: { type: String, default: null }, borderVariant: { type: String, default: null }, textVariant: { type: String, default: null } } }; var props$10 = assign({}, copyProps(cardMixin.props, prefixPropName.bind(null, 'body')), { bodyClass: { type: [String, Object, Array], default: null }, title: { type: String, default: null }, titleTag: { type: String, default: 'h4' }, subTitle: { type: String, default: null }, subTitleTag: { type: String, default: 'h6' }, overlay: { type: Boolean, default: false } }); var bCardBody = { functional: true, props: props$10, render: function render(h, _ref) { var _ref2; var props = _ref.props, data = _ref.data, slots = _ref.slots; var cardBodyChildren = []; if (props.title) { cardBodyChildren.push(h(props.titleTag, { staticClass: 'card-title', domProps: { innerHTML: props.title } })); } if (props.subTitle) { cardBodyChildren.push(h(props.subTitleTag, { staticClass: 'card-subtitle mb-2 text-muted', domProps: { innerHTML: props.subTitle } })); } cardBodyChildren.push(slots().default); return h(props.bodyTag, mergeData(data, { staticClass: 'card-body', class: [(_ref2 = { 'card-img-overlay': props.overlay }, defineProperty(_ref2, 'bg-' + props.bodyBgVariant, Boolean(props.bodyBgVariant)), defineProperty(_ref2, 'border-' + props.bodyBorderVariant, Boolean(props.bodyBorderVariant)), defineProperty(_ref2, 'text-' + props.bodyTextVariant, Boolean(props.bodyTextVariant)), _ref2), props.bodyClass || {}] }), cardBodyChildren); } }; var props$11 = assign({}, copyProps(cardMixin.props, prefixPropName.bind(null, 'header')), { header: { type: String, default: null }, headerClass: { type: [String, Object, Array], default: null } }); var bCardHeader = { functional: true, props: props$11, render: function render(h, _ref) { var _ref2; var props = _ref.props, data = _ref.data, slots = _ref.slots; return h(props.headerTag, mergeData(data, { staticClass: 'card-header', class: [props.headerClass, (_ref2 = {}, defineProperty(_ref2, 'bg-' + props.headerBgVariant, Boolean(props.headerBgVariant)), defineProperty(_ref2, 'border-' + props.headerBorderVariant, Boolean(props.headerBorderVariant)), defineProperty(_ref2, 'text-' + props.headerTextVariant, Boolean(props.headerTextVariant)), _ref2)] }), slots().default || [h('div', { domProps: { innerHTML: props.header } })]); } }; var props$12 = assign({}, copyProps(cardMixin.props, prefixPropName.bind(null, 'footer')), { footer: { type: String, default: null }, footerClass: { type: [String, Object, Array], default: null } }); var bCardFooter = { functional: true, props: props$12, render: function render(h, _ref) { var _ref2; var props = _ref.props, data = _ref.data, slots = _ref.slots; return h(props.footerTag, mergeData(data, { staticClass: 'card-footer', class: [props.footerClass, (_ref2 = {}, defineProperty(_ref2, 'bg-' + props.footerBgVariant, Boolean(props.footerBgVariant)), defineProperty(_ref2, 'border-' + props.footerBorderVariant, Boolean(props.footerBorderVariant)), defineProperty(_ref2, 'text-' + props.footerTextVariant, Boolean(props.footerTextVariant)), _ref2)] }), slots().default || [h('div', { domProps: { innerHTML: props.footer } })]); } }; var props$13 = { src: { type: String, default: null, required: true }, alt: { type: String, default: null }, top: { type: Boolean, default: false }, bottom: { type: Boolean, default: false }, fluid: { type: Boolean, default: false } }; var bCardImg = { functional: true, props: props$13, render: function render(h, _ref) { var props = _ref.props, data = _ref.data, slots = _ref.slots; var staticClass = 'card-img'; if (props.top) { staticClass += '-top'; } else if (props.bottom) { staticClass += '-bottom'; } return h('img', mergeData(data, { staticClass: staticClass, class: { 'img-fluid': props.fluid }, attrs: { src: props.src, alt: props.alt } })); } }; var cardImgProps = copyProps(props$13, prefixPropName.bind(null, 'img')); cardImgProps.imgSrc.required = false; var props$14 = assign({}, props$10, props$11, props$12, cardImgProps, copyProps(cardMixin.props), { align: { type: String, default: null }, noBody: { type: Boolean, default: false } }); var bCard = { functional: true, props: props$14, render: function render(h, _ref) { var _class; var props$$1 = _ref.props, data = _ref.data, slots = _ref.slots; // The order of the conditionals matter. // We are building the component markup in order. var childNodes = []; var $slots = slots(); var img = props$$1.imgSrc ? h(bCardImg, { props: pluckProps(cardImgProps, props$$1, unPrefixPropName.bind(null, 'img')) }) : null; if (img) { // Above the header placement. if (props$$1.imgTop || !props$$1.imgBottom) { childNodes.push(img); } } if (props