@folklore/utils 0.1.1
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/dist/cjs.js +31 -0
- package/dist/es.js +22 -0
- package/package.json +47 -0
package/dist/cjs.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var isString = require('lodash/isString');
|
|
6
|
+
var pascalCase = require('pascal-case');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
|
|
11
|
+
|
|
12
|
+
function getComponentFromName(components, name) {
|
|
13
|
+
let defaultComponentName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
14
|
+
const defaultComponent = (isString__default["default"](defaultComponentName) ? components[pascalCase.pascalCase(defaultComponentName)] : defaultComponentName) || null;
|
|
15
|
+
if (name === null) {
|
|
16
|
+
return defaultComponent;
|
|
17
|
+
}
|
|
18
|
+
const componentName = pascalCase.pascalCase(name);
|
|
19
|
+
return components[componentName] || defaultComponent;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getDisplayName(_ref) {
|
|
23
|
+
let {
|
|
24
|
+
displayName = null,
|
|
25
|
+
name = null
|
|
26
|
+
} = _ref;
|
|
27
|
+
return displayName || name || 'Component';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
exports.getComponentFromName = getComponentFromName;
|
|
31
|
+
exports.getDisplayName = getDisplayName;
|
package/dist/es.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import isString from 'lodash/isString';
|
|
2
|
+
import { pascalCase } from 'pascal-case';
|
|
3
|
+
|
|
4
|
+
function getComponentFromName(components, name) {
|
|
5
|
+
let defaultComponentName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
6
|
+
const defaultComponent = (isString(defaultComponentName) ? components[pascalCase(defaultComponentName)] : defaultComponentName) || null;
|
|
7
|
+
if (name === null) {
|
|
8
|
+
return defaultComponent;
|
|
9
|
+
}
|
|
10
|
+
const componentName = pascalCase(name);
|
|
11
|
+
return components[componentName] || defaultComponent;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getDisplayName(_ref) {
|
|
15
|
+
let {
|
|
16
|
+
displayName = null,
|
|
17
|
+
name = null
|
|
18
|
+
} = _ref;
|
|
19
|
+
return displayName || name || 'Component';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { getComponentFromName, getDisplayName };
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@folklore/utils",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Utilities",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"javascript",
|
|
7
|
+
"size",
|
|
8
|
+
"ui",
|
|
9
|
+
"utils",
|
|
10
|
+
"gesture"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/folkloreinc/folklore-js",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/folkloreinc/folklore-js.git"
|
|
16
|
+
},
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "Folklore",
|
|
19
|
+
"email": "info@folklore.email"
|
|
20
|
+
},
|
|
21
|
+
"contributors": [
|
|
22
|
+
{
|
|
23
|
+
"name": "David Mongeau-Petitpas",
|
|
24
|
+
"email": "dmp@folklore.email"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "Nicolas Roy-Bourdages",
|
|
28
|
+
"email": "nrb@folklore.email"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"main": "dist/cjs.js",
|
|
32
|
+
"module": "dist/es.js",
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"clean": "rm -rf dist",
|
|
38
|
+
"build": "rollup --config ../../rollup.config.js",
|
|
39
|
+
"prepare": "npm run clean && npm run build"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@babel/runtime": "^7.4.3",
|
|
43
|
+
"lodash": "^4.17.4",
|
|
44
|
+
"pascal-case": "^3.1.2"
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "c054f8aebebb312df15dbd87158516bbc750855f"
|
|
47
|
+
}
|