@flupkejs/clsx 1.0.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/package.json +12 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +21 -0
package/package.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flupkejs/clsx",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Drop-in replacement for clsx — conditional class strings",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"types": "src/index.d.ts",
|
|
7
|
+
"files": ["src"],
|
|
8
|
+
"exports": { ".": { "types": "./src/index.d.ts", "default": "./src/index.js" }, "./package.json": "./package.json" },
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": { "type": "git", "url": "https://github.com/rkristelijn/flupke" },
|
|
11
|
+
"keywords": ["clsx", "classnames", "css", "flupke", "hardened"]
|
|
12
|
+
}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
module.exports = function classnames(...args) {
|
|
3
|
+
var result = '';
|
|
4
|
+
for (var i = 0; i < args.length; i++) {
|
|
5
|
+
var arg = args[i];
|
|
6
|
+
if (!arg) continue;
|
|
7
|
+
if (typeof arg === 'string') {
|
|
8
|
+
result = result ? result + ' ' + arg : arg;
|
|
9
|
+
} else if (Array.isArray(arg)) {
|
|
10
|
+
var inner = classnames.apply(null, arg);
|
|
11
|
+
if (inner) result = result ? result + ' ' + inner : inner;
|
|
12
|
+
} else if (typeof arg === 'object') {
|
|
13
|
+
for (var key in arg) {
|
|
14
|
+
if (Object.prototype.hasOwnProperty.call(arg, key) && arg[key]) {
|
|
15
|
+
result = result ? result + ' ' + key : key;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
};
|