@fortawesome/vue-fontawesome 0.1.0-4 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.es.js ADDED
@@ -0,0 +1,501 @@
1
+ import { parse, icon, config, text } from '@fortawesome/fontawesome-svg-core';
2
+
3
+ var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
+
5
+ function createCommonjsModule(fn, module) {
6
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
7
+ }
8
+
9
+ var humps = createCommonjsModule(function (module) {
10
+ (function(global) {
11
+
12
+ var _processKeys = function(convert, obj, options) {
13
+ if(!_isObject(obj) || _isDate(obj) || _isRegExp(obj) || _isBoolean(obj) || _isFunction(obj)) {
14
+ return obj;
15
+ }
16
+
17
+ var output,
18
+ i = 0,
19
+ l = 0;
20
+
21
+ if(_isArray(obj)) {
22
+ output = [];
23
+ for(l=obj.length; i<l; i++) {
24
+ output.push(_processKeys(convert, obj[i], options));
25
+ }
26
+ }
27
+ else {
28
+ output = {};
29
+ for(var key in obj) {
30
+ if(Object.prototype.hasOwnProperty.call(obj, key)) {
31
+ output[convert(key, options)] = _processKeys(convert, obj[key], options);
32
+ }
33
+ }
34
+ }
35
+ return output;
36
+ };
37
+
38
+ // String conversion methods
39
+
40
+ var separateWords = function(string, options) {
41
+ options = options || {};
42
+ var separator = options.separator || '_';
43
+ var split = options.split || /(?=[A-Z])/;
44
+
45
+ return string.split(split).join(separator);
46
+ };
47
+
48
+ var camelize = function(string) {
49
+ if (_isNumerical(string)) {
50
+ return string;
51
+ }
52
+ string = string.replace(/[\-_\s]+(.)?/g, function(match, chr) {
53
+ return chr ? chr.toUpperCase() : '';
54
+ });
55
+ // Ensure 1st char is always lowercase
56
+ return string.substr(0, 1).toLowerCase() + string.substr(1);
57
+ };
58
+
59
+ var pascalize = function(string) {
60
+ var camelized = camelize(string);
61
+ // Ensure 1st char is always uppercase
62
+ return camelized.substr(0, 1).toUpperCase() + camelized.substr(1);
63
+ };
64
+
65
+ var decamelize = function(string, options) {
66
+ return separateWords(string, options).toLowerCase();
67
+ };
68
+
69
+ // Utilities
70
+ // Taken from Underscore.js
71
+
72
+ var toString = Object.prototype.toString;
73
+
74
+ var _isFunction = function(obj) {
75
+ return typeof(obj) === 'function';
76
+ };
77
+ var _isObject = function(obj) {
78
+ return obj === Object(obj);
79
+ };
80
+ var _isArray = function(obj) {
81
+ return toString.call(obj) == '[object Array]';
82
+ };
83
+ var _isDate = function(obj) {
84
+ return toString.call(obj) == '[object Date]';
85
+ };
86
+ var _isRegExp = function(obj) {
87
+ return toString.call(obj) == '[object RegExp]';
88
+ };
89
+ var _isBoolean = function(obj) {
90
+ return toString.call(obj) == '[object Boolean]';
91
+ };
92
+
93
+ // Performant way to determine if obj coerces to a number
94
+ var _isNumerical = function(obj) {
95
+ obj = obj - 0;
96
+ return obj === obj;
97
+ };
98
+
99
+ // Sets up function which handles processing keys
100
+ // allowing the convert function to be modified by a callback
101
+ var _processor = function(convert, options) {
102
+ var callback = options && 'process' in options ? options.process : options;
103
+
104
+ if(typeof(callback) !== 'function') {
105
+ return convert;
106
+ }
107
+
108
+ return function(string, options) {
109
+ return callback(string, convert, options);
110
+ }
111
+ };
112
+
113
+ var humps = {
114
+ camelize: camelize,
115
+ decamelize: decamelize,
116
+ pascalize: pascalize,
117
+ depascalize: decamelize,
118
+ camelizeKeys: function(object, options) {
119
+ return _processKeys(_processor(camelize, options), object);
120
+ },
121
+ decamelizeKeys: function(object, options) {
122
+ return _processKeys(_processor(decamelize, options), object, options);
123
+ },
124
+ pascalizeKeys: function(object, options) {
125
+ return _processKeys(_processor(pascalize, options), object);
126
+ },
127
+ depascalizeKeys: function () {
128
+ return this.decamelizeKeys.apply(this, arguments);
129
+ }
130
+ };
131
+
132
+ if (typeof undefined === 'function' && undefined.amd) {
133
+ undefined(humps);
134
+ } else if ('object' !== 'undefined' && module.exports) {
135
+ module.exports = humps;
136
+ } else {
137
+ global.humps = humps;
138
+ }
139
+
140
+ })(commonjsGlobal);
141
+ });
142
+
143
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
144
+ return typeof obj;
145
+ } : function (obj) {
146
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
147
+ };
148
+
149
+ var defineProperty = function (obj, key, value) {
150
+ if (key in obj) {
151
+ Object.defineProperty(obj, key, {
152
+ value: value,
153
+ enumerable: true,
154
+ configurable: true,
155
+ writable: true
156
+ });
157
+ } else {
158
+ obj[key] = value;
159
+ }
160
+
161
+ return obj;
162
+ };
163
+
164
+ var _extends = Object.assign || function (target) {
165
+ for (var i = 1; i < arguments.length; i++) {
166
+ var source = arguments[i];
167
+
168
+ for (var key in source) {
169
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
170
+ target[key] = source[key];
171
+ }
172
+ }
173
+ }
174
+
175
+ return target;
176
+ };
177
+
178
+ var objectWithoutProperties = function (obj, keys) {
179
+ var target = {};
180
+
181
+ for (var i in obj) {
182
+ if (keys.indexOf(i) >= 0) continue;
183
+ if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
184
+ target[i] = obj[i];
185
+ }
186
+
187
+ return target;
188
+ };
189
+
190
+ var toConsumableArray = function (arr) {
191
+ if (Array.isArray(arr)) {
192
+ for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
193
+
194
+ return arr2;
195
+ } else {
196
+ return Array.from(arr);
197
+ }
198
+ };
199
+
200
+ function styleToObject(style) {
201
+ return style.split(';').map(function (s) {
202
+ return s.trim();
203
+ }).filter(function (s) {
204
+ return s;
205
+ }).reduce(function (acc, pair) {
206
+ var i = pair.indexOf(':');
207
+ var prop = humps.camelize(pair.slice(0, i));
208
+ var value = pair.slice(i + 1).trim();
209
+
210
+ acc[prop] = value;
211
+
212
+ return acc;
213
+ }, {});
214
+ }
215
+
216
+ function classToObject(cls) {
217
+ return cls.split(/\s+/).reduce(function (acc, c) {
218
+ acc[c] = true;
219
+
220
+ return acc;
221
+ }, {});
222
+ }
223
+
224
+ function combineClassObjects() {
225
+ for (var _len = arguments.length, objs = Array(_len), _key = 0; _key < _len; _key++) {
226
+ objs[_key] = arguments[_key];
227
+ }
228
+
229
+ return objs.reduce(function (acc, obj) {
230
+ if (Array.isArray(obj)) {
231
+ acc = acc.concat(obj);
232
+ } else {
233
+ acc.push(obj);
234
+ }
235
+
236
+ return acc;
237
+ }, []);
238
+ }
239
+
240
+ function convert(h, element) {
241
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
242
+ var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
243
+
244
+ var children = (element.children || []).map(convert.bind(null, h));
245
+
246
+ var mixins = Object.keys(element.attributes || {}).reduce(function (acc, key) {
247
+ var val = element.attributes[key];
248
+
249
+ switch (key) {
250
+ case 'class':
251
+ acc['class'] = classToObject(val);
252
+ break;
253
+ case 'style':
254
+ acc['style'] = styleToObject(val);
255
+ break;
256
+ default:
257
+ acc.attrs[key] = val;
258
+ }
259
+
260
+ return acc;
261
+ }, { 'class': {}, style: {}, attrs: {} });
262
+
263
+ var _data$class = data.class,
264
+ dClass = _data$class === undefined ? {} : _data$class,
265
+ _data$style = data.style,
266
+ dStyle = _data$style === undefined ? {} : _data$style,
267
+ _data$attrs = data.attrs,
268
+ dAttrs = _data$attrs === undefined ? {} : _data$attrs,
269
+ remainingData = objectWithoutProperties(data, ['class', 'style', 'attrs']);
270
+
271
+
272
+ if (typeof element === 'string') {
273
+ return element;
274
+ } else {
275
+ return h(element.tag, _extends({
276
+ class: combineClassObjects(mixins.class, dClass),
277
+ style: _extends({}, mixins.style, dStyle),
278
+ attrs: _extends({}, mixins.attrs, dAttrs)
279
+ }, remainingData, {
280
+ props: props
281
+ }), children);
282
+ }
283
+ }
284
+
285
+ var PRODUCTION = false;
286
+
287
+ try {
288
+ PRODUCTION = process.env.NODE_ENV === 'production';
289
+ } catch (e) {}
290
+
291
+ function log () {
292
+ if (!PRODUCTION && console && typeof console.error === 'function') {
293
+ var _console;
294
+
295
+ (_console = console).error.apply(_console, arguments);
296
+ }
297
+ }
298
+
299
+ function objectWithKey(key, value) {
300
+ return Array.isArray(value) && value.length > 0 || !Array.isArray(value) && value ? defineProperty({}, key, value) : {};
301
+ }
302
+
303
+ function classList(props) {
304
+ var _classes;
305
+
306
+ var classes = (_classes = {
307
+ 'fa-spin': props.spin,
308
+ 'fa-pulse': props.pulse,
309
+ 'fa-fw': props.fixedWidth,
310
+ 'fa-border': props.border,
311
+ 'fa-li': props.listItem,
312
+ 'fa-flip-horizontal': props.flip === 'horizontal' || props.flip === 'both',
313
+ 'fa-flip-vertical': props.flip === 'vertical' || props.flip === 'both'
314
+ }, 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);
315
+
316
+ return Object.keys(classes).map(function (key) {
317
+ return classes[key] ? key : null;
318
+ }).filter(function (key) {
319
+ return key;
320
+ });
321
+ }
322
+
323
+ function addStaticClass(to, what) {
324
+ var val = (to || '').length === 0 ? [] : [to];
325
+
326
+ return val.concat(what).join(' ');
327
+ }
328
+
329
+ function normalizeIconArgs(icon$$1) {
330
+ if (icon$$1 === null) {
331
+ return null;
332
+ }
333
+
334
+ if ((typeof icon$$1 === 'undefined' ? 'undefined' : _typeof(icon$$1)) === 'object' && icon$$1.prefix && icon$$1.iconName) {
335
+ return icon$$1;
336
+ }
337
+
338
+ if (Array.isArray(icon$$1) && icon$$1.length === 2) {
339
+ return { prefix: icon$$1[0], iconName: icon$$1[1] };
340
+ }
341
+
342
+ if (typeof icon$$1 === 'string') {
343
+ return { prefix: 'fas', iconName: icon$$1 };
344
+ }
345
+ }
346
+
347
+ var FontAwesomeIcon = {
348
+ name: 'FontAwesomeIcon',
349
+
350
+ functional: true,
351
+
352
+ props: {
353
+ border: {
354
+ type: Boolean,
355
+ default: false
356
+ },
357
+ fixedWidth: {
358
+ type: Boolean,
359
+ default: false
360
+ },
361
+ flip: {
362
+ type: String,
363
+ default: null,
364
+ validator: function validator(value) {
365
+ return ['horizontal', 'vertical', 'both'].indexOf(value) > -1;
366
+ }
367
+ },
368
+ icon: {
369
+ type: [Object, Array, String],
370
+ required: true
371
+ },
372
+ mask: {
373
+ type: [Object, Array, String],
374
+ default: null
375
+ },
376
+ listItem: {
377
+ type: Boolean,
378
+ default: false
379
+ },
380
+ pull: {
381
+ type: String,
382
+ default: null,
383
+ validator: function validator(value) {
384
+ return ['right', 'left'].indexOf(value) > -1;
385
+ }
386
+ },
387
+ pulse: {
388
+ type: Boolean,
389
+ default: false
390
+ },
391
+ rotation: {
392
+ type: Number,
393
+ default: null,
394
+ validator: function validator(value) {
395
+ return [90, 180, 270].indexOf(value) > -1;
396
+ }
397
+ },
398
+ size: {
399
+ type: String,
400
+ default: null,
401
+ validator: function validator(value) {
402
+ return ['lg', 'xs', 'sm', '1x', '2x', '3x', '4x', '5x', '6x', '7x', '8x', '9x', '10x'].indexOf(value) > -1;
403
+ }
404
+ },
405
+ spin: {
406
+ type: Boolean,
407
+ default: false
408
+ },
409
+ transform: {
410
+ type: [String, Object],
411
+ default: null
412
+ },
413
+ symbol: {
414
+ type: [Boolean, String],
415
+ default: false
416
+ }
417
+ },
418
+
419
+ render: function render(createElement, context) {
420
+ var props = context.props;
421
+ var iconArgs = props.icon,
422
+ maskArgs = props.mask,
423
+ symbol = props.symbol;
424
+
425
+ var icon$$1 = normalizeIconArgs(iconArgs);
426
+ var classes = objectWithKey('classes', classList(props));
427
+ var transform = objectWithKey('transform', typeof props.transform === 'string' ? parse.transform(props.transform) : props.transform);
428
+ var mask = objectWithKey('mask', normalizeIconArgs(maskArgs));
429
+
430
+ var renderedIcon = icon(icon$$1, _extends({}, classes, transform, mask, { symbol: symbol }));
431
+
432
+ if (!renderedIcon) {
433
+ return log('Could not find one or more icon(s)', icon$$1, mask);
434
+ }
435
+
436
+ var abstract = renderedIcon.abstract;
437
+
438
+ var convertCurry = convert.bind(null, createElement);
439
+
440
+ return convertCurry(abstract[0], {}, context.data);
441
+ }
442
+ };
443
+
444
+ var FontAwesomeLayers = {
445
+ name: 'FontAwesomeLayers',
446
+
447
+ functional: true,
448
+
449
+ props: {
450
+ fixedWidth: {
451
+ type: Boolean,
452
+ default: false
453
+ }
454
+ },
455
+
456
+ render: function render(createElement, context) {
457
+ var familyPrefix = config.familyPrefix;
458
+ var staticClass = context.data.staticClass;
459
+
460
+
461
+ var classes = [familyPrefix + '-layers'].concat(toConsumableArray(context.props.fixedWidth ? [familyPrefix + '-fw'] : []));
462
+
463
+ return createElement('div', _extends({}, context.data, {
464
+ staticClass: addStaticClass(staticClass, classes)
465
+ }), context.children);
466
+ }
467
+ };
468
+
469
+ var FontAwesomeLayersText = {
470
+ name: 'FontAwesomeLayersText',
471
+
472
+ functional: true,
473
+
474
+ props: {
475
+ value: {
476
+ type: [String, Number],
477
+ default: ''
478
+ },
479
+ transform: {
480
+ type: [String, Object],
481
+ default: null
482
+ }
483
+ },
484
+
485
+ render: function render(createElement, context) {
486
+ var props = context.props;
487
+
488
+ var transform = objectWithKey('transform', typeof props.transform === 'string' ? parse.transform(props.transform) : props.transform);
489
+
490
+ var renderedText = text(props.value.toString(), _extends({}, transform));
491
+
492
+ var abstract = renderedText.abstract;
493
+
494
+
495
+ var convertCurry = convert.bind(null, createElement);
496
+
497
+ return convertCurry(abstract[0], {}, context.data);
498
+ }
499
+ };
500
+
501
+ export { FontAwesomeIcon, FontAwesomeLayers, FontAwesomeLayersText };
package/index.js CHANGED
@@ -477,7 +477,7 @@
477
477
 
478
478
  props: {
479
479
  value: {
480
- type: String,
480
+ type: [String, Number],
481
481
  default: ''
482
482
  },
483
483
  transform: {
@@ -491,7 +491,7 @@
491
491
 
492
492
  var transform = objectWithKey('transform', typeof props.transform === 'string' ? fontawesomeSvgCore.parse.transform(props.transform) : props.transform);
493
493
 
494
- var renderedText = fontawesomeSvgCore.text(props.value, _extends({}, transform));
494
+ var renderedText = fontawesomeSvgCore.text(props.value.toString(), _extends({}, transform));
495
495
 
496
496
  var abstract = renderedText.abstract;
497
497
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fortawesome/vue-fontawesome",
3
3
  "description": "Official Vue component for Font Awesome 5",
4
- "version": "0.1.0-4",
4
+ "version": "0.1.2",
5
5
  "main": "index.js",
6
6
  "module": "index.es.js",
7
7
  "jsnext:main": "index.es.js",
@@ -19,14 +19,21 @@
19
19
  "build": "rollup -c rollup.config.js",
20
20
  "dist": "cross-env NODE_ENV=production npm run build",
21
21
  "test": "jest",
22
- "prepack": "npm run dist"
22
+ "prepack": "npm run dist",
23
+ "precommit": "lint-staged"
24
+ },
25
+ "lint-staged": {
26
+ "README.md": [
27
+ "markdown-toc -i",
28
+ "git add"
29
+ ]
23
30
  },
24
31
  "peerDependencies": {
25
32
  "@fortawesome/fontawesome-svg-core": ">= 1.2.0 < 1.3",
26
33
  "vue": "~2"
27
34
  },
28
35
  "devDependencies": {
29
- "@fortawesome/fontawesome-svg-core": "^1.2.0-7",
36
+ "@fortawesome/fontawesome-svg-core": "^1.2.0",
30
37
  "babel-core": "^6.26.0",
31
38
  "babel-jest": "^22.4.3",
32
39
  "babel-plugin-external-helpers": "^6.22.0",
@@ -35,7 +42,10 @@
35
42
  "concurrently": "^3.5.0",
36
43
  "cross-env": "^5.1.1",
37
44
  "humps": "^2.0.1",
38
- "jest": "^22.4.3",
45
+ "husky": "^1.1.2",
46
+ "jest": "^23.6.0",
47
+ "lint-staged": "^7.0.1",
48
+ "markdown-toc": "^1.2.0",
39
49
  "rollup": "^0.57.1",
40
50
  "rollup-plugin-babel": "^3.0.2",
41
51
  "rollup-plugin-commonjs": "^9.1.0",
@@ -9,7 +9,7 @@ export default {
9
9
 
10
10
  props: {
11
11
  value: {
12
- type: String,
12
+ type: [String, Number],
13
13
  default: ''
14
14
  },
15
15
  transform: {
@@ -22,7 +22,7 @@ export default {
22
22
  const { props } = context
23
23
  const transform = objectWithKey('transform', (typeof props.transform === 'string') ? parse.transform(props.transform) : props.transform)
24
24
 
25
- const renderedText = text(props.value, { ...transform })
25
+ const renderedText = text(props.value.toString(), { ...transform })
26
26
 
27
27
  const { abstract } = renderedText
28
28
 
@@ -83,7 +83,7 @@ describe('unrelated Vue data options', () => {
83
83
  )
84
84
 
85
85
  expect(hasBeenClicked).toBeFalsy()
86
- vm.$el.click()
86
+ vm.$el.dispatchEvent(new Event('click'))
87
87
  expect(hasBeenClicked).toBeTruthy()
88
88
  })
89
89
  })
@@ -199,7 +199,7 @@ describe('mask', () => {
199
199
  test('will add icon', () => {
200
200
  const vm = mountFromProps({ icon: faCoffee, mask: faCircle })
201
201
 
202
- expect(vm.$el.innerHTML).toMatch(/clippath/)
202
+ expect(vm.$el.innerHTML).toMatch(/clipPath/)
203
203
  })
204
204
 
205
205
  test('will add icon referencing librbary', () => {
@@ -19,6 +19,13 @@ test('simple text', () => {
19
19
  expect(vm.$el.innerHTML).toBe('Test')
20
20
  })
21
21
 
22
+ test('accept number for value', () => {
23
+ const vm = compileAndMount('<font-awesome-layers-text :value="42" />')
24
+
25
+ expect(vm.$el.getAttribute('class')).toBe('fa-layers-text')
26
+ expect(vm.$el.innerHTML).toBe('42')
27
+ })
28
+
22
29
  describe('transform', () => {
23
30
  test('string', () => {
24
31
  const vm = compileAndMount('<font-awesome-layers-text value="1" transform="shrink-6" />')