bootstrap-vue
Version:
With more than 85 components, over 45 available plugins, several directives, and 1000+ icons, BootstrapVue provides one of the most comprehensive implementations of the Bootstrap v4 component and grid system available for Vue.js v2.6, complete with extens
78 lines (65 loc) • 3.24 kB
JavaScript
import Vue from '../vue';
import cloneDeep from './clone-deep';
import { getRaw } from './get';
import memoize from './memoize';
import DEFAULTS from './config-defaults'; // --- Constants ---
var PROP_NAME = '$bvConfig';
var VueProto = Vue.prototype; // --- Getter methods ---
// All methods return a deep clone (immutable) copy of the config
// value, to prevent mutation of the user config object.
// Get the current user config. For testing purposes only
export var getConfig = function getConfig() {
return VueProto[PROP_NAME] ? VueProto[PROP_NAME].getConfig() : {};
}; // Method to grab a config value based on a dotted/array notation key
export var getConfigValue = function getConfigValue(key) {
return VueProto[PROP_NAME] ? VueProto[PROP_NAME].getConfigValue(key) : cloneDeep(getRaw(DEFAULTS, key));
}; // Method to grab a config value for a particular component
export var getComponentConfig = function getComponentConfig(cmpName) {
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
// Return the particular config value for key for if specified,
// otherwise we return the full config (or an empty object if not found)
return key ? getConfigValue("".concat(cmpName, ".").concat(key)) : getConfigValue(cmpName) || {};
}; // Convenience method for getting all breakpoint names
export var getBreakpoints = function getBreakpoints() {
return getConfigValue('breakpoints');
}; // Private function for caching / locking-in breakpoint names
var _getBreakpointsCached = memoize(function () {
return getBreakpoints();
}); // Convenience method for getting all breakpoint names.
// Caches the results after first access.
export var getBreakpointsCached = function getBreakpointsCached() {
return cloneDeep(_getBreakpointsCached());
}; // Convenience method for getting breakpoints with
// the smallest breakpoint set as ''.
// Useful for components that create breakpoint specific props.
export var getBreakpointsUp = function getBreakpointsUp() {
var breakpoints = getBreakpoints();
breakpoints[0] = '';
return breakpoints;
}; // Convenience method for getting breakpoints with
// the smallest breakpoint set as ''.
// Useful for components that create breakpoint specific props.
// Caches the results after first access.
export var getBreakpointsUpCached = memoize(function () {
var breakpoints = getBreakpointsCached();
breakpoints[0] = '';
return breakpoints;
}); // Convenience method for getting breakpoints with
// the largest breakpoint set as ''.
// Useful for components that create breakpoint specific props.
export var getBreakpointsDown = function getBreakpointsDown() {
var breakpoints = getBreakpoints();
breakpoints[breakpoints.length - 1] = '';
return breakpoints;
}; // Convenience method for getting breakpoints with
// the largest breakpoint set as ''.
// Useful for components that create breakpoint specific props.
// Caches the results after first access.
/* istanbul ignore next: we don't use this method anywhere, yet */
export var getBreakpointsDownCached = function getBreakpointsDownCached()
/* istanbul ignore next */
{
var breakpoints = getBreakpointsCached();
breakpoints[breakpoints.length - 1] = '';
return breakpoints;
};