@fortawesome/vue-fontawesome
Advanced tools
Comparing version 0.1.0-3 to 0.1.0-4
999
index.js
@@ -7,681 +7,506 @@ (function (global, factory) { | ||
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
function createCommonjsModule(fn, module) { | ||
return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
} | ||
var humps = createCommonjsModule(function (module) { | ||
(function(global) { | ||
var _processKeys = function(convert, obj, options) { | ||
if(!_isObject(obj) || _isDate(obj) || _isRegExp(obj) || _isBoolean(obj) || _isFunction(obj)) { | ||
return obj; | ||
} | ||
var output, | ||
i = 0, | ||
l = 0; | ||
function createCommonjsModule(fn, module) { | ||
return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
} | ||
if(_isArray(obj)) { | ||
output = []; | ||
for(l=obj.length; i<l; i++) { | ||
output.push(_processKeys(convert, obj[i], options)); | ||
} | ||
} | ||
else { | ||
output = {}; | ||
for(var key in obj) { | ||
if(Object.prototype.hasOwnProperty.call(obj, key)) { | ||
output[convert(key, options)] = _processKeys(convert, obj[key], options); | ||
} | ||
} | ||
} | ||
return output; | ||
}; | ||
var humps = createCommonjsModule(function (module) { | ||
// ========= | ||
// = humps = | ||
// ========= | ||
// Underscore-to-camelCase converter (and vice versa) | ||
// for strings and object keys | ||
// String conversion methods | ||
// humps is copyright © 2012+ Dom Christie | ||
// Released under the MIT license. | ||
var separateWords = function(string, options) { | ||
options = options || {}; | ||
var separator = options.separator || '_'; | ||
var split = options.split || /(?=[A-Z])/; | ||
return string.split(split).join(separator); | ||
}; | ||
(function(global) { | ||
var camelize = function(string) { | ||
if (_isNumerical(string)) { | ||
return string; | ||
} | ||
string = string.replace(/[\-_\s]+(.)?/g, function(match, chr) { | ||
return chr ? chr.toUpperCase() : ''; | ||
}); | ||
// Ensure 1st char is always lowercase | ||
return string.substr(0, 1).toLowerCase() + string.substr(1); | ||
}; | ||
var _processKeys = function(convert, obj, options) { | ||
if(!_isObject(obj) || _isDate(obj) || _isRegExp(obj) || _isBoolean(obj) || _isFunction(obj)) { | ||
return obj; | ||
} | ||
var pascalize = function(string) { | ||
var camelized = camelize(string); | ||
// Ensure 1st char is always uppercase | ||
return camelized.substr(0, 1).toUpperCase() + camelized.substr(1); | ||
}; | ||
var output, | ||
i = 0, | ||
l = 0; | ||
var decamelize = function(string, options) { | ||
return separateWords(string, options).toLowerCase(); | ||
}; | ||
if(_isArray(obj)) { | ||
output = []; | ||
for(l=obj.length; i<l; i++) { | ||
output.push(_processKeys(convert, obj[i], options)); | ||
} | ||
} | ||
else { | ||
output = {}; | ||
for(var key in obj) { | ||
if(Object.prototype.hasOwnProperty.call(obj, key)) { | ||
output[convert(key, options)] = _processKeys(convert, obj[key], options); | ||
} | ||
} | ||
} | ||
return output; | ||
}; | ||
// Utilities | ||
// Taken from Underscore.js | ||
// String conversion methods | ||
var toString = Object.prototype.toString; | ||
var separateWords = function(string, options) { | ||
options = options || {}; | ||
var separator = options.separator || '_'; | ||
var split = options.split || /(?=[A-Z])/; | ||
var _isFunction = function(obj) { | ||
return typeof(obj) === 'function'; | ||
}; | ||
var _isObject = function(obj) { | ||
return obj === Object(obj); | ||
}; | ||
var _isArray = function(obj) { | ||
return toString.call(obj) == '[object Array]'; | ||
}; | ||
var _isDate = function(obj) { | ||
return toString.call(obj) == '[object Date]'; | ||
}; | ||
var _isRegExp = function(obj) { | ||
return toString.call(obj) == '[object RegExp]'; | ||
}; | ||
var _isBoolean = function(obj) { | ||
return toString.call(obj) == '[object Boolean]'; | ||
}; | ||
return string.split(split).join(separator); | ||
}; | ||
// Performant way to determine if obj coerces to a number | ||
var _isNumerical = function(obj) { | ||
obj = obj - 0; | ||
return obj === obj; | ||
}; | ||
var camelize = function(string) { | ||
if (_isNumerical(string)) { | ||
return string; | ||
} | ||
string = string.replace(/[\-_\s]+(.)?/g, function(match, chr) { | ||
return chr ? chr.toUpperCase() : ''; | ||
}); | ||
// Ensure 1st char is always lowercase | ||
return string.substr(0, 1).toLowerCase() + string.substr(1); | ||
}; | ||
// Sets up function which handles processing keys | ||
// allowing the convert function to be modified by a callback | ||
var _processor = function(convert, options) { | ||
var callback = options && 'process' in options ? options.process : options; | ||
var pascalize = function(string) { | ||
var camelized = camelize(string); | ||
// Ensure 1st char is always uppercase | ||
return camelized.substr(0, 1).toUpperCase() + camelized.substr(1); | ||
}; | ||
if(typeof(callback) !== 'function') { | ||
return convert; | ||
} | ||
var decamelize = function(string, options) { | ||
return separateWords(string, options).toLowerCase(); | ||
}; | ||
return function(string, options) { | ||
return callback(string, convert, options); | ||
} | ||
}; | ||
// Utilities | ||
// Taken from Underscore.js | ||
var humps = { | ||
camelize: camelize, | ||
decamelize: decamelize, | ||
pascalize: pascalize, | ||
depascalize: decamelize, | ||
camelizeKeys: function(object, options) { | ||
return _processKeys(_processor(camelize, options), object); | ||
}, | ||
decamelizeKeys: function(object, options) { | ||
return _processKeys(_processor(decamelize, options), object, options); | ||
}, | ||
pascalizeKeys: function(object, options) { | ||
return _processKeys(_processor(pascalize, options), object); | ||
}, | ||
depascalizeKeys: function () { | ||
return this.decamelizeKeys.apply(this, arguments); | ||
} | ||
}; | ||
var toString = Object.prototype.toString; | ||
if (typeof undefined === 'function' && undefined.amd) { | ||
undefined(humps); | ||
} else if ('object' !== 'undefined' && module.exports) { | ||
module.exports = humps; | ||
} else { | ||
global.humps = humps; | ||
} | ||
var _isFunction = function(obj) { | ||
return typeof(obj) === 'function'; | ||
}; | ||
var _isObject = function(obj) { | ||
return obj === Object(obj); | ||
}; | ||
var _isArray = function(obj) { | ||
return toString.call(obj) == '[object Array]'; | ||
}; | ||
var _isDate = function(obj) { | ||
return toString.call(obj) == '[object Date]'; | ||
}; | ||
var _isRegExp = function(obj) { | ||
return toString.call(obj) == '[object RegExp]'; | ||
}; | ||
var _isBoolean = function(obj) { | ||
return toString.call(obj) == '[object Boolean]'; | ||
}; | ||
})(commonjsGlobal); | ||
}); | ||
// Performant way to determine if obj coerces to a number | ||
var _isNumerical = function(obj) { | ||
obj = obj - 0; | ||
return obj === obj; | ||
}; | ||
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; | ||
}; | ||
// Sets up function which handles processing keys | ||
// allowing the convert function to be modified by a callback | ||
var _processor = function(convert, options) { | ||
var callback = options && 'process' in options ? options.process : options; | ||
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; | ||
} | ||
if(typeof(callback) !== 'function') { | ||
return convert; | ||
} | ||
return obj; | ||
}; | ||
return function(string, options) { | ||
return callback(string, convert, options); | ||
} | ||
}; | ||
var _extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
var humps = { | ||
camelize: camelize, | ||
decamelize: decamelize, | ||
pascalize: pascalize, | ||
depascalize: decamelize, | ||
camelizeKeys: function(object, options) { | ||
return _processKeys(_processor(camelize, options), object); | ||
}, | ||
decamelizeKeys: function(object, options) { | ||
return _processKeys(_processor(decamelize, options), object, options); | ||
}, | ||
pascalizeKeys: function(object, options) { | ||
return _processKeys(_processor(pascalize, options), object); | ||
}, | ||
depascalizeKeys: function () { | ||
return this.decamelizeKeys.apply(this, arguments); | ||
} | ||
}; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
if (typeof undefined === 'function' && undefined.amd) { | ||
undefined(humps); | ||
} else if ('object' !== 'undefined' && module.exports) { | ||
module.exports = humps; | ||
} else { | ||
global.humps = humps; | ||
} | ||
return target; | ||
}; | ||
})(commonjsGlobal); | ||
}); | ||
var objectWithoutProperties = function (obj, keys) { | ||
var target = {}; | ||
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; | ||
}; | ||
for (var i in obj) { | ||
if (keys.indexOf(i) >= 0) continue; | ||
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; | ||
target[i] = obj[i]; | ||
} | ||
return target; | ||
}; | ||
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); | ||
} | ||
}; | ||
function styleToObject(style) { | ||
return style.split(';').map(function (s) { | ||
return s.trim(); | ||
}).filter(function (s) { | ||
return s; | ||
}).reduce(function (acc, pair) { | ||
var i = pair.indexOf(':'); | ||
var prop = humps.camelize(pair.slice(0, i)); | ||
var value = pair.slice(i + 1).trim(); | ||
var asyncGenerator = function () { | ||
function AwaitValue(value) { | ||
this.value = value; | ||
} | ||
acc[prop] = value; | ||
function AsyncGenerator(gen) { | ||
var front, back; | ||
return acc; | ||
}, {}); | ||
} | ||
function send(key, arg) { | ||
return new Promise(function (resolve, reject) { | ||
var request = { | ||
key: key, | ||
arg: arg, | ||
resolve: resolve, | ||
reject: reject, | ||
next: null | ||
}; | ||
function classToObject(cls) { | ||
return cls.split(/\s+/).reduce(function (acc, c) { | ||
acc[c] = true; | ||
if (back) { | ||
back = back.next = request; | ||
} else { | ||
front = back = request; | ||
resume(key, arg); | ||
} | ||
}); | ||
} | ||
return acc; | ||
}, {}); | ||
} | ||
function resume(key, arg) { | ||
try { | ||
var result = gen[key](arg); | ||
var value = result.value; | ||
function combineClassObjects() { | ||
for (var _len = arguments.length, objs = Array(_len), _key = 0; _key < _len; _key++) { | ||
objs[_key] = arguments[_key]; | ||
} | ||
if (value instanceof AwaitValue) { | ||
Promise.resolve(value.value).then(function (arg) { | ||
resume("next", arg); | ||
}, function (arg) { | ||
resume("throw", arg); | ||
}); | ||
} else { | ||
settle(result.done ? "return" : "normal", result.value); | ||
} | ||
} catch (err) { | ||
settle("throw", err); | ||
} | ||
} | ||
return objs.reduce(function (acc, obj) { | ||
if (Array.isArray(obj)) { | ||
acc = acc.concat(obj); | ||
} else { | ||
acc.push(obj); | ||
} | ||
function settle(type, value) { | ||
switch (type) { | ||
case "return": | ||
front.resolve({ | ||
value: value, | ||
done: true | ||
}); | ||
break; | ||
return acc; | ||
}, []); | ||
} | ||
case "throw": | ||
front.reject(value); | ||
break; | ||
function convert(h, element) { | ||
var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
default: | ||
front.resolve({ | ||
value: value, | ||
done: false | ||
}); | ||
break; | ||
} | ||
var children = (element.children || []).map(convert.bind(null, h)); | ||
front = front.next; | ||
var mixins = Object.keys(element.attributes || {}).reduce(function (acc, key) { | ||
var val = element.attributes[key]; | ||
if (front) { | ||
resume(front.key, front.arg); | ||
} else { | ||
back = null; | ||
} | ||
} | ||
switch (key) { | ||
case 'class': | ||
acc['class'] = classToObject(val); | ||
break; | ||
case 'style': | ||
acc['style'] = styleToObject(val); | ||
break; | ||
default: | ||
acc.attrs[key] = val; | ||
} | ||
this._invoke = send; | ||
return acc; | ||
}, { 'class': {}, style: {}, attrs: {} }); | ||
if (typeof gen.return !== "function") { | ||
this.return = undefined; | ||
} | ||
} | ||
var _data$class = data.class, | ||
dClass = _data$class === undefined ? {} : _data$class, | ||
_data$style = data.style, | ||
dStyle = _data$style === undefined ? {} : _data$style, | ||
_data$attrs = data.attrs, | ||
dAttrs = _data$attrs === undefined ? {} : _data$attrs, | ||
remainingData = objectWithoutProperties(data, ['class', 'style', 'attrs']); | ||
if (typeof Symbol === "function" && Symbol.asyncIterator) { | ||
AsyncGenerator.prototype[Symbol.asyncIterator] = function () { | ||
return this; | ||
}; | ||
} | ||
AsyncGenerator.prototype.next = function (arg) { | ||
return this._invoke("next", arg); | ||
}; | ||
if (typeof element === 'string') { | ||
return element; | ||
} else { | ||
return h(element.tag, _extends({ | ||
class: combineClassObjects(mixins.class, dClass), | ||
style: _extends({}, mixins.style, dStyle), | ||
attrs: _extends({}, mixins.attrs, dAttrs) | ||
}, remainingData, { | ||
props: props | ||
}), children); | ||
} | ||
} | ||
AsyncGenerator.prototype.throw = function (arg) { | ||
return this._invoke("throw", arg); | ||
}; | ||
var PRODUCTION = false; | ||
AsyncGenerator.prototype.return = function (arg) { | ||
return this._invoke("return", arg); | ||
}; | ||
try { | ||
PRODUCTION = process.env.NODE_ENV === 'production'; | ||
} catch (e) {} | ||
return { | ||
wrap: function (fn) { | ||
return function () { | ||
return new AsyncGenerator(fn.apply(this, arguments)); | ||
}; | ||
}, | ||
await: function (value) { | ||
return new AwaitValue(value); | ||
} | ||
}; | ||
}(); | ||
function log () { | ||
if (!PRODUCTION && console && typeof console.error === 'function') { | ||
var _console; | ||
(_console = console).error.apply(_console, arguments); | ||
} | ||
} | ||
function objectWithKey(key, value) { | ||
return Array.isArray(value) && value.length > 0 || !Array.isArray(value) && value ? defineProperty({}, key, value) : {}; | ||
} | ||
function classList(props) { | ||
var _classes; | ||
var classes = (_classes = { | ||
'fa-spin': props.spin, | ||
'fa-pulse': props.pulse, | ||
'fa-fw': props.fixedWidth, | ||
'fa-border': props.border, | ||
'fa-li': props.listItem, | ||
'fa-flip-horizontal': props.flip === 'horizontal' || props.flip === 'both', | ||
'fa-flip-vertical': props.flip === 'vertical' || props.flip === 'both' | ||
}, defineProperty(_classes, 'fa-' + props.size, props.size !== null), defineProperty(_classes, 'fa-rotate-' + props.rotation, props.rotation !== null), defineProperty(_classes, 'fa-pull-' + props.pull, props.pull !== null), _classes); | ||
return Object.keys(classes).map(function (key) { | ||
return classes[key] ? key : null; | ||
}).filter(function (key) { | ||
return key; | ||
}); | ||
} | ||
function addStaticClass(to, what) { | ||
var val = (to || '').length === 0 ? [] : [to]; | ||
return val.concat(what).join(' '); | ||
} | ||
function normalizeIconArgs(icon) { | ||
if (icon === null) { | ||
return null; | ||
} | ||
if ((typeof icon === 'undefined' ? 'undefined' : _typeof(icon)) === 'object' && icon.prefix && icon.iconName) { | ||
return icon; | ||
} | ||
if (Array.isArray(icon) && icon.length === 2) { | ||
return { prefix: icon[0], iconName: icon[1] }; | ||
} | ||
if (typeof icon === 'string') { | ||
return { prefix: 'fas', iconName: icon }; | ||
} | ||
} | ||
var FontAwesomeIcon = { | ||
name: 'FontAwesomeIcon', | ||
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; | ||
} | ||
functional: true, | ||
return obj; | ||
}; | ||
props: { | ||
border: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
fixedWidth: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
flip: { | ||
type: String, | ||
default: null, | ||
validator: function validator(value) { | ||
return ['horizontal', 'vertical', 'both'].indexOf(value) > -1; | ||
} | ||
}, | ||
icon: { | ||
type: [Object, Array, String], | ||
required: true | ||
}, | ||
mask: { | ||
type: [Object, Array, String], | ||
default: null | ||
}, | ||
listItem: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
pull: { | ||
type: String, | ||
default: null, | ||
validator: function validator(value) { | ||
return ['right', 'left'].indexOf(value) > -1; | ||
} | ||
}, | ||
pulse: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
rotation: { | ||
type: Number, | ||
default: null, | ||
validator: function validator(value) { | ||
return [90, 180, 270].indexOf(value) > -1; | ||
} | ||
}, | ||
size: { | ||
type: String, | ||
default: null, | ||
validator: function validator(value) { | ||
return ['lg', 'xs', 'sm', '1x', '2x', '3x', '4x', '5x', '6x', '7x', '8x', '9x', '10x'].indexOf(value) > -1; | ||
} | ||
}, | ||
spin: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
transform: { | ||
type: [String, Object], | ||
default: null | ||
}, | ||
symbol: { | ||
type: [Boolean, String], | ||
default: false | ||
} | ||
}, | ||
var _extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
render: function render(createElement, context) { | ||
var props = context.props; | ||
var iconArgs = props.icon, | ||
maskArgs = props.mask, | ||
symbol = props.symbol; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
var icon = normalizeIconArgs(iconArgs); | ||
var classes = objectWithKey('classes', classList(props)); | ||
var transform = objectWithKey('transform', typeof props.transform === 'string' ? fontawesomeSvgCore.parse.transform(props.transform) : props.transform); | ||
var mask = objectWithKey('mask', normalizeIconArgs(maskArgs)); | ||
return target; | ||
}; | ||
var renderedIcon = fontawesomeSvgCore.icon(icon, _extends({}, classes, transform, mask, { symbol: symbol })); | ||
if (!renderedIcon) { | ||
return log('Could not find one or more icon(s)', icon, mask); | ||
} | ||
var abstract = renderedIcon.abstract; | ||
var convertCurry = convert.bind(null, createElement); | ||
return convertCurry(abstract[0], {}, context.data); | ||
} | ||
}; | ||
var FontAwesomeLayers = { | ||
name: 'FontAwesomeLayers', | ||
functional: true, | ||
props: { | ||
fixedWidth: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}, | ||
render: function render(createElement, context) { | ||
var familyPrefix = fontawesomeSvgCore.config.familyPrefix; | ||
var staticClass = context.data.staticClass; | ||
var classes = [familyPrefix + '-layers'].concat(toConsumableArray(context.props.fixedWidth ? [familyPrefix + '-fw'] : [])); | ||
return createElement('div', _extends({}, context.data, { | ||
staticClass: addStaticClass(staticClass, classes) | ||
}), context.children); | ||
} | ||
}; | ||
var FontAwesomeLayersText = { | ||
name: 'FontAwesomeLayersText', | ||
var objectWithoutProperties = function (obj, keys) { | ||
var target = {}; | ||
functional: true, | ||
for (var i in obj) { | ||
if (keys.indexOf(i) >= 0) continue; | ||
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; | ||
target[i] = obj[i]; | ||
} | ||
props: { | ||
value: { | ||
type: String, | ||
default: '' | ||
}, | ||
transform: { | ||
type: [String, Object], | ||
default: null | ||
} | ||
}, | ||
return target; | ||
}; | ||
render: function render(createElement, context) { | ||
var props = context.props; | ||
var transform = objectWithKey('transform', typeof props.transform === 'string' ? fontawesomeSvgCore.parse.transform(props.transform) : props.transform); | ||
var renderedText = fontawesomeSvgCore.text(props.value, _extends({}, transform)); | ||
var abstract = renderedText.abstract; | ||
var convertCurry = convert.bind(null, createElement); | ||
return convertCurry(abstract[0], {}, context.data); | ||
} | ||
}; | ||
exports.FontAwesomeIcon = FontAwesomeIcon; | ||
exports.FontAwesomeLayers = FontAwesomeLayers; | ||
exports.FontAwesomeLayersText = FontAwesomeLayersText; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
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); | ||
} | ||
}; | ||
function styleToObject(style) { | ||
return style.split(';').map(function (s) { | ||
return s.trim(); | ||
}).filter(function (s) { | ||
return s; | ||
}).reduce(function (acc, pair) { | ||
var i = pair.indexOf(':'); | ||
var prop = humps.camelize(pair.slice(0, i)); | ||
var value = pair.slice(i + 1).trim(); | ||
acc[prop] = value; | ||
return acc; | ||
}, {}); | ||
} | ||
function classToObject(cls) { | ||
return cls.split(/\s+/).reduce(function (acc, c) { | ||
acc[c] = true; | ||
return acc; | ||
}, {}); | ||
} | ||
function combineClassObjects() { | ||
for (var _len = arguments.length, objs = Array(_len), _key = 0; _key < _len; _key++) { | ||
objs[_key] = arguments[_key]; | ||
} | ||
return objs.reduce(function (acc, obj) { | ||
if (Array.isArray(obj)) { | ||
acc = acc.concat(obj); | ||
} else { | ||
acc.push(obj); | ||
} | ||
return acc; | ||
}, []); | ||
} | ||
function convert(h, element) { | ||
var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
var children = (element.children || []).map(convert.bind(null, h)); | ||
var mixins = Object.keys(element.attributes || {}).reduce(function (acc, key) { | ||
var val = element.attributes[key]; | ||
switch (key) { | ||
case 'class': | ||
acc['class'] = classToObject(val); | ||
break; | ||
case 'style': | ||
acc['style'] = styleToObject(val); | ||
break; | ||
default: | ||
acc.attrs[key] = val; | ||
} | ||
return acc; | ||
}, { 'class': {}, style: {}, attrs: {} }); | ||
var _data$class = data.class, | ||
dClass = _data$class === undefined ? {} : _data$class, | ||
_data$style = data.style, | ||
dStyle = _data$style === undefined ? {} : _data$style, | ||
_data$attrs = data.attrs, | ||
dAttrs = _data$attrs === undefined ? {} : _data$attrs, | ||
remainingData = objectWithoutProperties(data, ['class', 'style', 'attrs']); | ||
if (typeof element === 'string') { | ||
return element; | ||
} else { | ||
return h(element.tag, _extends({ | ||
class: combineClassObjects(mixins.class, dClass), | ||
style: _extends({}, mixins.style, dStyle), | ||
attrs: _extends({}, mixins.attrs, dAttrs) | ||
}, remainingData, { | ||
props: props | ||
}), children); | ||
} | ||
} | ||
var PRODUCTION = false; | ||
try { | ||
PRODUCTION = process.env.NODE_ENV === 'production'; | ||
} catch (e) {} | ||
var log = function () { | ||
if (!PRODUCTION && console && typeof console.error === 'function') { | ||
var _console; | ||
(_console = console).error.apply(_console, arguments); | ||
} | ||
}; | ||
function objectWithKey(key, value) { | ||
return Array.isArray(value) && value.length > 0 || !Array.isArray(value) && value ? defineProperty({}, key, value) : {}; | ||
} | ||
function classList(props) { | ||
var _classes; | ||
var classes = (_classes = { | ||
'fa-spin': props.spin, | ||
'fa-pulse': props.pulse, | ||
'fa-fw': props.fixedWidth, | ||
'fa-border': props.border, | ||
'fa-li': props.listItem, | ||
'fa-flip-horizontal': props.flip === 'horizontal' || props.flip === 'both', | ||
'fa-flip-vertical': props.flip === 'vertical' || props.flip === 'both' | ||
}, babelHelpers.defineProperty(_classes, 'fa-' + props.size, props.size !== null), babelHelpers.defineProperty(_classes, 'fa-rotate-' + props.rotation, props.rotation !== null), babelHelpers.defineProperty(_classes, 'fa-pull-' + props.pull, props.pull !== null), _classes); | ||
return Object.keys(classes).map(function (key) { | ||
return classes[key] ? key : null; | ||
}).filter(function (key) { | ||
return key; | ||
}); | ||
} | ||
function addStaticClass(to, what) { | ||
var val = (to || '').length === 0 ? [] : [to]; | ||
return val.concat(what).join(' '); | ||
} | ||
function normalizeIconArgs(icon$$1) { | ||
if (icon$$1 === null) { | ||
return null; | ||
} | ||
if ((typeof icon$$1 === 'undefined' ? 'undefined' : _typeof(icon$$1)) === 'object' && icon$$1.prefix && icon$$1.iconName) { | ||
return icon$$1; | ||
} | ||
if (Array.isArray(icon$$1) && icon$$1.length === 2) { | ||
return { prefix: icon$$1[0], iconName: icon$$1[1] }; | ||
} | ||
if (typeof icon$$1 === 'string') { | ||
return { prefix: 'fas', iconName: icon$$1 }; | ||
} | ||
} | ||
var FontAwesomeIcon = { | ||
name: 'FontAwesomeIcon', | ||
functional: true, | ||
props: { | ||
border: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
fixedWidth: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
flip: { | ||
type: String, | ||
default: null, | ||
validator: function validator(value) { | ||
return ['horizontal', 'vertical', 'both'].indexOf(value) > -1; | ||
} | ||
}, | ||
icon: { | ||
type: [Object, Array, String], | ||
required: true | ||
}, | ||
mask: { | ||
type: [Object, Array, String], | ||
default: null | ||
}, | ||
listItem: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
pull: { | ||
type: String, | ||
default: null, | ||
validator: function validator(value) { | ||
return ['right', 'left'].indexOf(value) > -1; | ||
} | ||
}, | ||
pulse: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
rotation: { | ||
type: Number, | ||
default: null, | ||
validator: function validator(value) { | ||
return [90, 180, 270].indexOf(value) > -1; | ||
} | ||
}, | ||
size: { | ||
type: String, | ||
default: null, | ||
validator: function validator(value) { | ||
return ['lg', 'xs', 'sm', '1x', '2x', '3x', '4x', '5x', '6x', '7x', '8x', '9x', '10x'].indexOf(value) > -1; | ||
} | ||
}, | ||
spin: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
transform: { | ||
type: [String, Object], | ||
default: null | ||
}, | ||
symbol: { | ||
type: [Boolean, String], | ||
default: false | ||
} | ||
}, | ||
render: function render(createElement, context) { | ||
var props = context.props; | ||
var iconArgs = props.icon, | ||
maskArgs = props.mask, | ||
symbol = props.symbol; | ||
var icon$$1 = normalizeIconArgs(iconArgs); | ||
var classes = objectWithKey('classes', classList(props)); | ||
var transform = objectWithKey('transform', typeof props.transform === 'string' ? fontawesomeSvgCore.parse.transform(props.transform) : props.transform); | ||
var mask = objectWithKey('mask', normalizeIconArgs(maskArgs)); | ||
var renderedIcon = fontawesomeSvgCore.icon(icon$$1, _extends({}, classes, transform, mask, { symbol: symbol })); | ||
if (!renderedIcon) { | ||
return log('Could not find one or more icon(s)', icon$$1, mask); | ||
} | ||
var abstract = renderedIcon.abstract; | ||
var convertCurry = convert.bind(null, createElement); | ||
return convertCurry(abstract[0], {}, context.data); | ||
} | ||
}; | ||
var FontAwesomeLayers = { | ||
name: 'FontAwesomeLayers', | ||
functional: true, | ||
props: { | ||
fixedWidth: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}, | ||
render: function render(createElement, context) { | ||
var familyPrefix = fontawesomeSvgCore.config.familyPrefix; | ||
var staticClass = context.data.staticClass; | ||
var classes = [familyPrefix + '-layers'].concat(toConsumableArray(context.props.fixedWidth ? [familyPrefix + '-fw'] : [])); | ||
return createElement('div', _extends({}, context.data, { | ||
staticClass: addStaticClass(staticClass, classes) | ||
}), context.children); | ||
} | ||
}; | ||
var FontAwesomeLayersText = { | ||
name: 'FontAwesomeLayersText', | ||
functional: true, | ||
props: { | ||
value: { | ||
type: String, | ||
default: '' | ||
}, | ||
transform: { | ||
type: [String, Object], | ||
default: null | ||
} | ||
}, | ||
render: function render(createElement, context) { | ||
var props = context.props; | ||
var transform = objectWithKey('transform', typeof props.transform === 'string' ? fontawesomeSvgCore.parse.transform(props.transform) : props.transform); | ||
var renderedText = fontawesomeSvgCore.text(props.value, _extends({}, transform)); | ||
var abstract = renderedText.abstract; | ||
var convertCurry = convert.bind(null, createElement); | ||
return convertCurry(abstract[0], {}, context.data); | ||
} | ||
}; | ||
exports.FontAwesomeIcon = FontAwesomeIcon; | ||
exports.FontAwesomeLayers = FontAwesomeLayers; | ||
exports.FontAwesomeLayersText = FontAwesomeLayersText; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); |
{ | ||
"name": "@fortawesome/vue-fontawesome", | ||
"description": "Official Vue component for Font Awesome 5", | ||
"version": "0.1.0-3", | ||
"version": "0.1.0-4", | ||
"main": "index.js", | ||
@@ -31,5 +31,5 @@ "module": "index.es.js", | ||
"babel-core": "^6.26.0", | ||
"babel-jest": "^21.2.0", | ||
"babel-jest": "^22.4.3", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-preset-stage-3": "^6.24.1", | ||
@@ -39,6 +39,6 @@ "concurrently": "^3.5.0", | ||
"humps": "^2.0.1", | ||
"jest": "^21.0.1", | ||
"rollup": "^0.50.0", | ||
"jest": "^22.4.3", | ||
"rollup": "^0.57.1", | ||
"rollup-plugin-babel": "^3.0.2", | ||
"rollup-plugin-commonjs": "^8.1.0", | ||
"rollup-plugin-commonjs": "^9.1.0", | ||
"rollup-plugin-node-resolve": "^3.0.0", | ||
@@ -45,0 +45,0 @@ "vue": "^2.4.4" |
# vue-fontawesome | ||
[![npm](https://img.shields.io/npm/v/@fortawesome/vue-fontawesome.svg?style=flat-square)](https://www.npmjs.com/package/@fortawesome/vue-fontawesome) | ||
[![Travis-CI](https://img.shields.io/travis/FortAwesome/vue-fontawesome/master.svg)](https://travis-ci.org/FortAwesome/vue-fontawesome) | ||
@@ -5,0 +6,0 @@ > Font Awesome 5 Vue component using SVG with JS |
@@ -5,2 +5,7 @@ import resolve from 'rollup-plugin-node-resolve' | ||
const name = 'vue-fontawesome' | ||
const globals = { | ||
'@fortawesome/fontawesome-svg-core': 'FontAwesome' | ||
} | ||
export default { | ||
@@ -10,14 +15,14 @@ external: [ | ||
], | ||
globals: { | ||
'@fortawesome/fontawesome-svg-core': 'FontAwesome' | ||
}, | ||
input: 'src/index.js', | ||
name: 'vue-fontawesome', | ||
output: [ | ||
{ | ||
name, | ||
globals, | ||
format: 'umd', | ||
exports: 'named', | ||
file: 'index.js' | ||
file: 'index.js', | ||
}, | ||
{ | ||
name, | ||
globals, | ||
format: 'es', | ||
@@ -38,3 +43,7 @@ file: 'index.es.js' | ||
presets: [ | ||
['es2015', { modules: false }], | ||
['env', { | ||
debug: true, | ||
targets: {"browsers": ["> 1%", "last 2 versions", "ie > 9"]}, | ||
modules: false | ||
}], | ||
'stage-3' | ||
@@ -41,0 +50,0 @@ ], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
376101
47
401
1588