Release 5.0.0-beta5
This commit is contained in:
@@ -25,7 +25,13 @@ var UNITS_IN_GRID = 16;
|
||||
var DEFAULT_FAMILY_PREFIX = 'fa';
|
||||
var DEFAULT_REPLACEMENT_CLASS = 'svg-inline--fa';
|
||||
|
||||
var PRODUCTION = typeof process !== 'undefined' && process.env && undefined === 'production';
|
||||
var PRODUCTION = function () {
|
||||
try {
|
||||
return "development" === 'production';
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}();
|
||||
|
||||
var oneToTen = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
var oneToTwenty = oneToTen.concat([11, 12, 13, 14, 15, 16, 17, 18, 19, 20]);
|
||||
@@ -38,6 +44,36 @@ var RESERVED_CLASSES = ['xs', 'sm', 'lg', 'fw', 'ul', 'li', 'border', 'pull-left
|
||||
return 'w-' + n;
|
||||
}));
|
||||
|
||||
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 _extends = Object.assign || function (target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
@@ -151,7 +187,7 @@ function bunker(fn) {
|
||||
try {
|
||||
fn();
|
||||
} catch (e) {
|
||||
if (undefined !== 'production') {
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -554,7 +590,7 @@ function makeLayersTextHtml(params) {
|
||||
|
||||
var noop$1 = function noop() {};
|
||||
var p = config.measurePerformance && PERFORMANCE ? PERFORMANCE : { mark: noop$1, measure: noop$1 };
|
||||
var preamble = 'FA "5.0.0-beta4"';
|
||||
var preamble = 'FA "5.0.0-beta5"';
|
||||
|
||||
var begin = function begin(name) {
|
||||
p.mark(preamble + ' ' + name + ' begins');
|
||||
@@ -794,6 +830,16 @@ function getCanonicalIcon(values) {
|
||||
}, emptyCanonicalIcon());
|
||||
}
|
||||
|
||||
function iconFromMapping(mapping, prefix, iconName) {
|
||||
if (mapping && mapping[prefix] && mapping[prefix][iconName]) {
|
||||
return {
|
||||
prefix: prefix,
|
||||
iconName: iconName,
|
||||
icon: mapping[prefix][iconName]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var classParser = function (node) {
|
||||
var existingPrefix = node.getAttribute('data-prefix');
|
||||
var existingIconName = node.getAttribute('data-icon');
|
||||
@@ -1089,6 +1135,56 @@ var styles = function () {
|
||||
return s;
|
||||
};
|
||||
|
||||
var Library = function () {
|
||||
function Library() {
|
||||
classCallCheck(this, Library);
|
||||
|
||||
this.definitions = {};
|
||||
}
|
||||
|
||||
createClass(Library, [{
|
||||
key: "add",
|
||||
value: function add() {
|
||||
var _this = this;
|
||||
|
||||
for (var _len = arguments.length, definitions = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
definitions[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var additions = definitions.reduce(this._pullDefinitions, {});
|
||||
|
||||
Object.keys(additions).forEach(function (key) {
|
||||
_this.definitions[key] = _extends({}, _this.definitions[key] || {}, additions[key]);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "reset",
|
||||
value: function reset() {
|
||||
this.definitions = {};
|
||||
}
|
||||
}, {
|
||||
key: "_pullDefinitions",
|
||||
value: function _pullDefinitions(additions, definition) {
|
||||
var normalized = definition.prefix && definition.iconName && definition.icon ? { 0: definition } : definition;
|
||||
|
||||
Object.keys(normalized).map(function (key) {
|
||||
var _normalized$key = normalized[key],
|
||||
prefix = _normalized$key.prefix,
|
||||
iconName = _normalized$key.iconName,
|
||||
icon = _normalized$key.icon;
|
||||
|
||||
|
||||
if (!additions[prefix]) additions[prefix] = {};
|
||||
|
||||
additions[prefix][iconName] = icon;
|
||||
});
|
||||
|
||||
return additions;
|
||||
}
|
||||
}]);
|
||||
return Library;
|
||||
}();
|
||||
|
||||
function prepIcon(icon) {
|
||||
var width = icon[0];
|
||||
var height = icon[1];
|
||||
@@ -1142,6 +1238,19 @@ function apiObject(val, abstractCreator) {
|
||||
return val;
|
||||
}
|
||||
|
||||
function findIconDefinition(params) {
|
||||
var _params$prefix = params.prefix,
|
||||
prefix = _params$prefix === undefined ? 'fa' : _params$prefix,
|
||||
iconName = params.iconName;
|
||||
|
||||
|
||||
if (!iconName) return;
|
||||
|
||||
return iconFromMapping(library.definitions, prefix, iconName) || iconFromMapping(namespace.packs, prefix, iconName);
|
||||
}
|
||||
|
||||
var library = new Library();
|
||||
|
||||
var api = {
|
||||
dom: {
|
||||
i2svg: function i2svg() {
|
||||
@@ -1165,26 +1274,16 @@ var api = {
|
||||
}
|
||||
},
|
||||
|
||||
library: library,
|
||||
|
||||
parse: {
|
||||
transform: function transform(transformString) {
|
||||
return parseTransformString(transformString);
|
||||
},
|
||||
|
||||
iconFromPack: function iconFromPack(iconString) {
|
||||
var _getCanonicalIcon = getCanonicalIcon(iconString.split(' ')),
|
||||
prefix = _getCanonicalIcon.prefix,
|
||||
iconName = _getCanonicalIcon.iconName;
|
||||
|
||||
if (namespace.packs && namespace.packs[prefix] && namespace.packs[prefix][iconName]) {
|
||||
return {
|
||||
prefix: prefix,
|
||||
iconName: iconName,
|
||||
icon: namespace.packs[prefix][iconName]
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
findIconDefinition: findIconDefinition,
|
||||
|
||||
icon: function icon(iconDefinition) {
|
||||
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var _params$transform = params.transform,
|
||||
@@ -1199,10 +1298,11 @@ var api = {
|
||||
attributes = _params$attributes === undefined ? {} : _params$attributes,
|
||||
_params$style = params.style,
|
||||
style = _params$style === undefined ? {} : _params$style;
|
||||
var prefix = iconDefinition.prefix,
|
||||
iconName = iconDefinition.iconName,
|
||||
icon = iconDefinition.icon;
|
||||
|
||||
var _ref = iconDefinition.icon ? iconDefinition : findIconDefinition(iconDefinition),
|
||||
prefix = _ref.prefix,
|
||||
iconName = _ref.iconName,
|
||||
icon = _ref.icon;
|
||||
|
||||
return apiObject(_extends({ type: 'icon' }, iconDefinition), function () {
|
||||
ensureStyles();
|
||||
|
||||
Reference in New Issue
Block a user