klsx 0.3.0 → 0.3.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/README.md +23 -21
- package/package.json +14 -16
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ import { klsx } from 'klsx'
|
|
|
37
37
|
klsx('foo', 'bar', 'baz')
|
|
38
38
|
// => "foo bar baz"
|
|
39
39
|
|
|
40
|
-
klsx({foo: 'string', bar: true, bux: null }, 'baz')
|
|
40
|
+
klsx({ foo: 'string', bar: true, bux: null }, 'baz')
|
|
41
41
|
// => "foo bar baz"
|
|
42
42
|
|
|
43
43
|
klsx(['foo', ['bar', true && 'baz']])
|
|
@@ -49,27 +49,29 @@ or importing the short alias `kx`:
|
|
|
49
49
|
### React
|
|
50
50
|
|
|
51
51
|
```jsx
|
|
52
|
-
import React, { useState } from 'react'
|
|
52
|
+
import React, { useState } from 'react'
|
|
53
53
|
import { kx } from 'klsx'
|
|
54
54
|
|
|
55
55
|
const MyComponent = () => {
|
|
56
|
-
const [isActive, setIsActive] = useState(false)
|
|
56
|
+
const [isActive, setIsActive] = useState(false)
|
|
57
57
|
return (
|
|
58
58
|
<div>
|
|
59
|
-
|
|
59
|
+
<div className={kx('base-class', isActive ? 'active' : 'inactive')}>
|
|
60
60
|
{/* ... */}
|
|
61
|
-
|
|
61
|
+
</div>
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
<div className={kx('base-class', { active: isActive, inactive: !isActive })}>
|
|
64
64
|
{/* ... */}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<div
|
|
68
|
+
className={kx('base-class', [isActive && 'active', !isActive && 'inactive'])}
|
|
69
|
+
>
|
|
68
70
|
{/* ... */}
|
|
69
|
-
|
|
71
|
+
</div>
|
|
70
72
|
</div>
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
+
)
|
|
74
|
+
}
|
|
73
75
|
```
|
|
74
76
|
|
|
75
77
|
### Migrate from `clsx`
|
|
@@ -81,9 +83,9 @@ From:
|
|
|
81
83
|
```typescript
|
|
82
84
|
// clsx
|
|
83
85
|
|
|
84
|
-
import { clsx, type ClassValue } from
|
|
85
|
-
import { twMerge } from
|
|
86
|
-
|
|
86
|
+
import { clsx, type ClassValue } from 'clsx'
|
|
87
|
+
import { twMerge } from 'tailwind-merge'
|
|
88
|
+
|
|
87
89
|
export function cn(...inputs: ClassValue[]) {
|
|
88
90
|
return twMerge(clsx(inputs))
|
|
89
91
|
}
|
|
@@ -94,10 +96,10 @@ To:
|
|
|
94
96
|
```typescript
|
|
95
97
|
// KLSX
|
|
96
98
|
|
|
97
|
-
import { klsx, type KlassValue } from
|
|
98
|
-
import { twMerge } from
|
|
99
|
-
|
|
100
|
-
export function cn(...inputs:
|
|
99
|
+
import { klsx, type KlassValue } from 'klsx'
|
|
100
|
+
import { twMerge } from 'tailwind-merge'
|
|
101
|
+
|
|
102
|
+
export function cn(...inputs: KlassValue[]) {
|
|
101
103
|
return twMerge(klsx(inputs))
|
|
102
104
|
}
|
|
103
105
|
```
|
|
@@ -135,8 +137,8 @@ bun add -D prettier prettier-plugin-tailwindcss
|
|
|
135
137
|
```javascript
|
|
136
138
|
/** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions} */
|
|
137
139
|
export default {
|
|
138
|
-
plugins: [
|
|
139
|
-
tailwindFunctions: ['klsx', 'kx']
|
|
140
|
+
plugins: ['prettier-plugin-tailwindcss'],
|
|
141
|
+
tailwindFunctions: ['klsx', 'kx'],
|
|
140
142
|
}
|
|
141
143
|
```
|
|
142
144
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "klsx",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Same as clsx but \"maybe\" better",
|
|
6
6
|
"author": {
|
|
@@ -28,8 +28,6 @@
|
|
|
28
28
|
"files": [
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
|
-
"main": "./dist/index.js",
|
|
32
|
-
"module": "./dist/index.js",
|
|
33
31
|
"types": "./dist/index.d.ts",
|
|
34
32
|
"exports": {
|
|
35
33
|
".": "./dist/index.js",
|
|
@@ -44,29 +42,29 @@
|
|
|
44
42
|
"postinstall": "npm install --force --ignore-scripts --package-lock-only --silent"
|
|
45
43
|
},
|
|
46
44
|
"devDependencies": {
|
|
47
|
-
"@eslint/js": "^
|
|
48
|
-
"@prettier/plugin-oxc": "^0.1.
|
|
49
|
-
"@socketsecurity/bun-security-scanner": "^1.1.
|
|
50
|
-
"@types/bun": "^1.3.
|
|
51
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
45
|
+
"@eslint/js": "^10.0.1",
|
|
46
|
+
"@prettier/plugin-oxc": "^0.1.3",
|
|
47
|
+
"@socketsecurity/bun-security-scanner": "^1.1.2",
|
|
48
|
+
"@types/bun": "^1.3.8",
|
|
49
|
+
"@typescript/native-preview": "^7.0.0-dev.20260207.1",
|
|
52
50
|
"classix": "^2.2.6",
|
|
53
51
|
"classnames": "^2.5.1",
|
|
54
52
|
"clsx": "^2.1.1",
|
|
55
|
-
"eslint": "^
|
|
53
|
+
"eslint": "^10.0.0",
|
|
56
54
|
"eslint-config-prettier": "^10.1.8",
|
|
57
55
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
58
56
|
"eslint-plugin-import-x": "^4.16.1",
|
|
59
|
-
"eslint-plugin-perfectionist": "^
|
|
60
|
-
"eslint-plugin-regexp": "^
|
|
57
|
+
"eslint-plugin-perfectionist": "^5.5.0",
|
|
58
|
+
"eslint-plugin-regexp": "^3.0.0",
|
|
61
59
|
"eslint-plugin-security": "^3.0.1",
|
|
62
|
-
"eslint-plugin-sonarjs": "^3.0.
|
|
60
|
+
"eslint-plugin-sonarjs": "^3.0.6",
|
|
63
61
|
"eslint-plugin-tsdoc": "^0.5.0",
|
|
64
62
|
"eslint-plugin-unicorn": "^62.0.0",
|
|
65
|
-
"globals": "^
|
|
66
|
-
"prettier": "^3.
|
|
63
|
+
"globals": "^17.3.0",
|
|
64
|
+
"prettier": "^3.8.1",
|
|
67
65
|
"tinybench": "^6.0.0",
|
|
68
|
-
"tsdown": "^0.
|
|
69
|
-
"typescript-eslint": "^8.
|
|
66
|
+
"tsdown": "^0.20.3",
|
|
67
|
+
"typescript-eslint": "^8.54.0"
|
|
70
68
|
},
|
|
71
69
|
"engines": {
|
|
72
70
|
"node": ">=18"
|