clases 1.1.7 → 1.1.10
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/index.cjs +20 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +37 -40
package/dist/index.cjs
CHANGED
|
@@ -1,42 +1,37 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var tailwindMerge = require('tailwind-merge');
|
|
4
|
-
var clsx = require('clsx');
|
|
5
|
-
|
|
6
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
-
|
|
8
|
-
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
9
4
|
|
|
10
5
|
// src/index.ts
|
|
11
6
|
function createCl(...plugins) {
|
|
12
7
|
const registry = Object.assign({}, ...plugins);
|
|
13
|
-
const process = (
|
|
14
|
-
if (!
|
|
15
|
-
if (
|
|
16
|
-
return
|
|
8
|
+
const process = (accumulatedPrefix, input) => {
|
|
9
|
+
if (!input) return "";
|
|
10
|
+
if (typeof input === "string") {
|
|
11
|
+
return input.split(/[,\s\n]+/).filter(Boolean).map((cls) => accumulatedPrefix ? `${accumulatedPrefix}:${cls}` : cls).join(" ");
|
|
17
12
|
}
|
|
18
|
-
if (
|
|
19
|
-
return
|
|
20
|
-
const isPrefix = registry[nestedKey] !== void 0;
|
|
21
|
-
if (isPrefix) {
|
|
22
|
-
const nextKey = key ? `${key}:${nestedKey}` : nestedKey;
|
|
23
|
-
return process(nextKey, nestedValue);
|
|
24
|
-
}
|
|
25
|
-
if (nestedValue) {
|
|
26
|
-
return process(key, nestedKey);
|
|
27
|
-
}
|
|
28
|
-
return "";
|
|
29
|
-
}).join(" ");
|
|
13
|
+
if (Array.isArray(input)) {
|
|
14
|
+
return input.map((i) => process(accumulatedPrefix, i)).filter(Boolean).join(" ");
|
|
30
15
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
if (typeof input === "object") {
|
|
17
|
+
let results = [];
|
|
18
|
+
for (const [key, value] of Object.entries(input)) {
|
|
19
|
+
if (!value) continue;
|
|
20
|
+
const registeredPrefix = registry[key];
|
|
21
|
+
if (registeredPrefix) {
|
|
22
|
+
const nextPrefix = accumulatedPrefix ? `${accumulatedPrefix}:${registeredPrefix}` : registeredPrefix;
|
|
23
|
+
results.push(process(nextPrefix, value));
|
|
24
|
+
} else {
|
|
25
|
+
results.push(process(accumulatedPrefix, key));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return results.join(" ");
|
|
34
29
|
}
|
|
35
30
|
return "";
|
|
36
31
|
};
|
|
37
32
|
return (...inputs) => {
|
|
38
33
|
const processed = inputs.map((input) => process("", input));
|
|
39
|
-
return tailwindMerge.twMerge(
|
|
34
|
+
return tailwindMerge.twMerge(processed.filter(Boolean).join(" "));
|
|
40
35
|
};
|
|
41
36
|
}
|
|
42
37
|
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["twMerge"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["twMerge"],"mappings":";;;;;AAGO,SAAS,YAAuD,OAAA,EAAmB;AACtF,EAAA,MAAM,WAAmC,MAAA,CAAO,MAAA,CAAO,EAAC,EAAG,GAAG,OAAO,CAAA;AAErE,EAAA,MAAM,OAAA,GAAU,CAAC,iBAAA,EAA2B,KAAA,KAAuB;AAC/D,IAAA,IAAI,CAAC,OAAO,OAAO,EAAA;AAGnB,IAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC3B,MAAA,OAAO,MACF,KAAA,CAAM,UAAU,EAChB,MAAA,CAAO,OAAO,EACd,GAAA,CAAI,CAAC,QAAS,iBAAA,GAAoB,CAAA,EAAG,iBAAiB,CAAA,CAAA,EAAI,GAAG,KAAK,GAAI,CAAA,CACtE,KAAK,GAAG,CAAA;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.cjs","sourcesContent":["import { twMerge } from 'tailwind-merge';\r\nimport clsx, { type ClassValue } from 'clsx';\r\n\r\nexport function createCl<TPlugins extends Record<string, string>[]>(...plugins: TPlugins) {\r\n const registry: Record<string, string> = Object.assign({}, ...plugins);\r\n\r\n const process = (accumulatedPrefix: string, input: any): string => {\r\n if (!input) return '';\r\n\r\n // 1. Strings: Aplicar prefijo acumulado\r\n if (typeof input === 'string') {\r\n return input\r\n .split(/[,\\s\\n]+/)\r\n .filter(Boolean)\r\n .map((cls) => (accumulatedPrefix ? `${accumulatedPrefix}:${cls}` : cls))\r\n .join(' ');\r\n }\r\n\r\n // 2. Arrays: Procesar cada elemento\r\n if (Array.isArray(input)) {\r\n return input\r\n .map((i) => process(accumulatedPrefix, i))\r\n .filter(Boolean)\r\n .join(' ');\r\n }\r\n\r\n // 3. Objetos: El corazón del problema\r\n if (typeof input === 'object') {\r\n let results: string[] = [];\r\n\r\n for (const [key, value] of Object.entries(input)) {\r\n if (!value) continue;\r\n\r\n const registeredPrefix = registry[key];\r\n\r\n if (registeredPrefix) {\r\n // Es un prefijo: acumulamos y bajamos un nivel\r\n const nextPrefix = accumulatedPrefix\r\n ? `${accumulatedPrefix}:${registeredPrefix}`\r\n : registeredPrefix;\r\n results.push(process(nextPrefix, value));\r\n } else {\r\n // NO es prefijo: es lógica { 'clase': true }\r\n // Procesamos la llave 'key' como el contenido, bajo el prefijo actual\r\n results.push(process(accumulatedPrefix, key));\r\n }\r\n }\r\n return results.join(' ');\r\n }\r\n\r\n return '';\r\n };\r\n\r\n return (...inputs: ClassValue[]) => {\r\n // Ejecutamos nuestro motor en cada input\r\n const processed = inputs.map((input) => process('', input));\r\n // twMerge se encarga de limpiar el string final\r\n return twMerge(processed.filter(Boolean).join(' '));\r\n };\r\n}\r\n"]}
|
package/dist/index.js
CHANGED
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
import { twMerge } from 'tailwind-merge';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
2
|
|
|
4
3
|
// src/index.ts
|
|
5
4
|
function createCl(...plugins) {
|
|
6
5
|
const registry = Object.assign({}, ...plugins);
|
|
7
|
-
const process = (
|
|
8
|
-
if (!
|
|
9
|
-
if (
|
|
10
|
-
return
|
|
6
|
+
const process = (accumulatedPrefix, input) => {
|
|
7
|
+
if (!input) return "";
|
|
8
|
+
if (typeof input === "string") {
|
|
9
|
+
return input.split(/[,\s\n]+/).filter(Boolean).map((cls) => accumulatedPrefix ? `${accumulatedPrefix}:${cls}` : cls).join(" ");
|
|
11
10
|
}
|
|
12
|
-
if (
|
|
13
|
-
return
|
|
14
|
-
const isPrefix = registry[nestedKey] !== void 0;
|
|
15
|
-
if (isPrefix) {
|
|
16
|
-
const nextKey = key ? `${key}:${nestedKey}` : nestedKey;
|
|
17
|
-
return process(nextKey, nestedValue);
|
|
18
|
-
}
|
|
19
|
-
if (nestedValue) {
|
|
20
|
-
return process(key, nestedKey);
|
|
21
|
-
}
|
|
22
|
-
return "";
|
|
23
|
-
}).join(" ");
|
|
11
|
+
if (Array.isArray(input)) {
|
|
12
|
+
return input.map((i) => process(accumulatedPrefix, i)).filter(Boolean).join(" ");
|
|
24
13
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
if (typeof input === "object") {
|
|
15
|
+
let results = [];
|
|
16
|
+
for (const [key, value] of Object.entries(input)) {
|
|
17
|
+
if (!value) continue;
|
|
18
|
+
const registeredPrefix = registry[key];
|
|
19
|
+
if (registeredPrefix) {
|
|
20
|
+
const nextPrefix = accumulatedPrefix ? `${accumulatedPrefix}:${registeredPrefix}` : registeredPrefix;
|
|
21
|
+
results.push(process(nextPrefix, value));
|
|
22
|
+
} else {
|
|
23
|
+
results.push(process(accumulatedPrefix, key));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return results.join(" ");
|
|
28
27
|
}
|
|
29
28
|
return "";
|
|
30
29
|
};
|
|
31
30
|
return (...inputs) => {
|
|
32
31
|
const processed = inputs.map((input) => process("", input));
|
|
33
|
-
return twMerge(
|
|
32
|
+
return twMerge(processed.filter(Boolean).join(" "));
|
|
34
33
|
};
|
|
35
34
|
}
|
|
36
35
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAGO,SAAS,YAAuD,OAAA,EAAmB;AACtF,EAAA,MAAM,WAAmC,MAAA,CAAO,MAAA,CAAO,EAAC,EAAG,GAAG,OAAO,CAAA;AAErE,EAAA,MAAM,OAAA,GAAU,CAAC,iBAAA,EAA2B,KAAA,KAAuB;AAC/D,IAAA,IAAI,CAAC,OAAO,OAAO,EAAA;AAGnB,IAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC3B,MAAA,OAAO,MACF,KAAA,CAAM,UAAU,EAChB,MAAA,CAAO,OAAO,EACd,GAAA,CAAI,CAAC,QAAS,iBAAA,GAAoB,CAAA,EAAG,iBAAiB,CAAA,CAAA,EAAI,GAAG,KAAK,GAAI,CAAA,CACtE,KAAK,GAAG,CAAA;AAAA,IACjB;AAGA,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACtB,MAAA,OAAO,KAAA,CACF,GAAA,CAAI,CAAC,CAAA,KAAM,OAAA,CAAQ,iBAAA,EAAmB,CAAC,CAAC,CAAA,CACxC,MAAA,CAAO,OAAO,CAAA,CACd,KAAK,GAAG,CAAA;AAAA,IACjB;AAGA,IAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC3B,MAAA,IAAI,UAAoB,EAAC;AAEzB,MAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AAC9C,QAAA,IAAI,CAAC,KAAA,EAAO;AAEZ,QAAA,MAAM,gBAAA,GAAmB,SAAS,GAAG,CAAA;AAErC,QAAA,IAAI,gBAAA,EAAkB;AAElB,UAAA,MAAM,aAAa,iBAAA,GACb,CAAA,EAAG,iBAAiB,CAAA,CAAA,EAAI,gBAAgB,CAAA,CAAA,GACxC,gBAAA;AACN,UAAA,OAAA,CAAQ,IAAA,CAAK,OAAA,CAAQ,UAAA,EAAY,KAAK,CAAC,CAAA;AAAA,QAC3C,CAAA,MAAO;AAGH,UAAA,OAAA,CAAQ,IAAA,CAAK,OAAA,CAAQ,iBAAA,EAAmB,GAAG,CAAC,CAAA;AAAA,QAChD;AAAA,MACJ;AACA,MAAA,OAAO,OAAA,CAAQ,KAAK,GAAG,CAAA;AAAA,IAC3B;AAEA,IAAA,OAAO,EAAA;AAAA,EACX,CAAA;AAEA,EAAA,OAAO,IAAI,MAAA,KAAyB;AAEhC,IAAA,MAAM,SAAA,GAAY,OAAO,GAAA,CAAI,CAAC,UAAU,OAAA,CAAQ,EAAA,EAAI,KAAK,CAAC,CAAA;AAE1D,IAAA,OAAO,QAAQ,SAAA,CAAU,MAAA,CAAO,OAAO,CAAA,CAAE,IAAA,CAAK,GAAG,CAAC,CAAA;AAAA,EACtD,CAAA;AACJ","file":"index.js","sourcesContent":["import { twMerge } from 'tailwind-merge';\r\nimport clsx, { type ClassValue } from 'clsx';\r\n\r\nexport function createCl<TPlugins extends Record<string, string>[]>(...plugins: TPlugins) {\r\n const registry: Record<string, string> = Object.assign({}, ...plugins);\r\n\r\n const process = (accumulatedPrefix: string, input: any): string => {\r\n if (!input) return '';\r\n\r\n // 1. Strings: Aplicar prefijo acumulado\r\n if (typeof input === 'string') {\r\n return input\r\n .split(/[,\\s\\n]+/)\r\n .filter(Boolean)\r\n .map((cls) => (accumulatedPrefix ? `${accumulatedPrefix}:${cls}` : cls))\r\n .join(' ');\r\n }\r\n\r\n // 2. Arrays: Procesar cada elemento\r\n if (Array.isArray(input)) {\r\n return input\r\n .map((i) => process(accumulatedPrefix, i))\r\n .filter(Boolean)\r\n .join(' ');\r\n }\r\n\r\n // 3. Objetos: El corazón del problema\r\n if (typeof input === 'object') {\r\n let results: string[] = [];\r\n\r\n for (const [key, value] of Object.entries(input)) {\r\n if (!value) continue;\r\n\r\n const registeredPrefix = registry[key];\r\n\r\n if (registeredPrefix) {\r\n // Es un prefijo: acumulamos y bajamos un nivel\r\n const nextPrefix = accumulatedPrefix\r\n ? `${accumulatedPrefix}:${registeredPrefix}`\r\n : registeredPrefix;\r\n results.push(process(nextPrefix, value));\r\n } else {\r\n // NO es prefijo: es lógica { 'clase': true }\r\n // Procesamos la llave 'key' como el contenido, bajo el prefijo actual\r\n results.push(process(accumulatedPrefix, key));\r\n }\r\n }\r\n return results.join(' ');\r\n }\r\n\r\n return '';\r\n };\r\n\r\n return (...inputs: ClassValue[]) => {\r\n // Ejecutamos nuestro motor en cada input\r\n const processed = inputs.map((input) => process('', input));\r\n // twMerge se encarga de limpiar el string final\r\n return twMerge(processed.filter(Boolean).join(' '));\r\n };\r\n}\r\n"]}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -4,60 +4,57 @@ import clsx, { type ClassValue } from 'clsx';
|
|
|
4
4
|
export function createCl<TPlugins extends Record<string, string>[]>(...plugins: TPlugins) {
|
|
5
5
|
const registry: Record<string, string> = Object.assign({}, ...plugins);
|
|
6
6
|
|
|
7
|
-
const process = (
|
|
8
|
-
if (!
|
|
7
|
+
const process = (accumulatedPrefix: string, input: any): string => {
|
|
8
|
+
if (!input) return '';
|
|
9
9
|
|
|
10
|
-
// 1.
|
|
11
|
-
if (
|
|
12
|
-
return
|
|
13
|
-
.
|
|
10
|
+
// 1. Strings: Aplicar prefijo acumulado
|
|
11
|
+
if (typeof input === 'string') {
|
|
12
|
+
return input
|
|
13
|
+
.split(/[,\s\n]+/)
|
|
14
14
|
.filter(Boolean)
|
|
15
|
+
.map((cls) => (accumulatedPrefix ? `${accumulatedPrefix}:${cls}` : cls))
|
|
15
16
|
.join(' ');
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
// 2.
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
21
|
-
.map((
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (isPrefix) {
|
|
25
|
-
const nextKey = key ? `${key}:${nestedKey}` : nestedKey;
|
|
26
|
-
return process(nextKey, nestedValue);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// CORRECCIÓN: Si es lógica { 'clase': true },
|
|
30
|
-
// procesamos la LLAVE como el valor para que reciba el prefijo
|
|
31
|
-
if (nestedValue) {
|
|
32
|
-
return process(key, nestedKey);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return '';
|
|
36
|
-
})
|
|
19
|
+
// 2. Arrays: Procesar cada elemento
|
|
20
|
+
if (Array.isArray(input)) {
|
|
21
|
+
return input
|
|
22
|
+
.map((i) => process(accumulatedPrefix, i))
|
|
23
|
+
.filter(Boolean)
|
|
37
24
|
.join(' ');
|
|
38
25
|
}
|
|
39
26
|
|
|
40
|
-
// 3.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
27
|
+
// 3. Objetos: El corazón del problema
|
|
28
|
+
if (typeof input === 'object') {
|
|
29
|
+
let results: string[] = [];
|
|
30
|
+
|
|
31
|
+
for (const [key, value] of Object.entries(input)) {
|
|
32
|
+
if (!value) continue;
|
|
33
|
+
|
|
34
|
+
const registeredPrefix = registry[key];
|
|
35
|
+
|
|
36
|
+
if (registeredPrefix) {
|
|
37
|
+
// Es un prefijo: acumulamos y bajamos un nivel
|
|
38
|
+
const nextPrefix = accumulatedPrefix
|
|
39
|
+
? `${accumulatedPrefix}:${registeredPrefix}`
|
|
40
|
+
: registeredPrefix;
|
|
41
|
+
results.push(process(nextPrefix, value));
|
|
42
|
+
} else {
|
|
43
|
+
// NO es prefijo: es lógica { 'clase': true }
|
|
44
|
+
// Procesamos la llave 'key' como el contenido, bajo el prefijo actual
|
|
45
|
+
results.push(process(accumulatedPrefix, key));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return results.join(' ');
|
|
54
49
|
}
|
|
55
50
|
|
|
56
51
|
return '';
|
|
57
52
|
};
|
|
58
53
|
|
|
59
54
|
return (...inputs: ClassValue[]) => {
|
|
55
|
+
// Ejecutamos nuestro motor en cada input
|
|
60
56
|
const processed = inputs.map((input) => process('', input));
|
|
61
|
-
|
|
57
|
+
// twMerge se encarga de limpiar el string final
|
|
58
|
+
return twMerge(processed.filter(Boolean).join(' '));
|
|
62
59
|
};
|
|
63
60
|
}
|