@unocss/transformer-attributify-jsx 0.50.3 → 0.50.5
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 +5 -9
- package/dist/index.mjs +5 -9
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -11,10 +11,9 @@ function createFilter(include, exclude) {
|
|
|
11
11
|
return includePattern.some((p) => id.match(p));
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
const elementRE =
|
|
14
|
+
const elementRE = /(<\w[\w:\.$-]*\s)((?:'[^>]*?'|"[^>]*?"|`(?:[^>]|[\S])*?`|\{(?:[^>]|[\S])*?\}|[^>]*?)*)/g;
|
|
15
15
|
const attributeRE = /([a-zA-Z()#][\[?a-zA-Z0-9-_:()#%\]?]*)(?:\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+))?/g;
|
|
16
|
-
const
|
|
17
|
-
const curlybraceRE = /\w+\s?=\s?\{.+?\}/g;
|
|
16
|
+
const valuedAttributeRE = /((?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:!%-.~<]+)=(?:["]([^"]*)["]|[']([^']*)[']|[{]((?:[`(](?:[^`)]*)[`)]|[^}])+)[}])/gms;
|
|
18
17
|
function transformerAttributifyJsx(options = {}) {
|
|
19
18
|
const {
|
|
20
19
|
blocklist = []
|
|
@@ -41,12 +40,9 @@ function transformerAttributifyJsx(options = {}) {
|
|
|
41
40
|
async transform(code, _, { uno }) {
|
|
42
41
|
const tasks = [];
|
|
43
42
|
for (const item of Array.from(code.original.matchAll(elementRE))) {
|
|
44
|
-
const classNamePart = item[2].match(classFilterRE);
|
|
45
43
|
let attributifyPart = item[2];
|
|
46
|
-
if (
|
|
47
|
-
attributifyPart =
|
|
48
|
-
if (curlybraceRE.test(attributifyPart))
|
|
49
|
-
attributifyPart = attributifyPart.replace(curlybraceRE, (match) => " ".repeat(match.length));
|
|
44
|
+
if (valuedAttributeRE.test(attributifyPart))
|
|
45
|
+
attributifyPart = attributifyPart.replace(valuedAttributeRE, (match) => " ".repeat(match.length));
|
|
50
46
|
for (const attr of attributifyPart.matchAll(attributeRE)) {
|
|
51
47
|
const matchedRule = attr[0].replace(/\:/i, "-");
|
|
52
48
|
if (matchedRule.includes("=") || isBlocked(matchedRule))
|
|
@@ -54,7 +50,7 @@ function transformerAttributifyJsx(options = {}) {
|
|
|
54
50
|
tasks.push(uno.parseToken(matchedRule).then((matched) => {
|
|
55
51
|
if (matched) {
|
|
56
52
|
const tag = item[1];
|
|
57
|
-
const startIdx = (item.index || 0) + (attr.index || 0) + tag.length
|
|
53
|
+
const startIdx = (item.index || 0) + (attr.index || 0) + tag.length;
|
|
58
54
|
const endIdx = startIdx + matchedRule.length;
|
|
59
55
|
code.overwrite(startIdx, endIdx, `${matchedRule}=""`);
|
|
60
56
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -9,10 +9,9 @@ function createFilter(include, exclude) {
|
|
|
9
9
|
return includePattern.some((p) => id.match(p));
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
const elementRE =
|
|
12
|
+
const elementRE = /(<\w[\w:\.$-]*\s)((?:'[^>]*?'|"[^>]*?"|`(?:[^>]|[\S])*?`|\{(?:[^>]|[\S])*?\}|[^>]*?)*)/g;
|
|
13
13
|
const attributeRE = /([a-zA-Z()#][\[?a-zA-Z0-9-_:()#%\]?]*)(?:\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+))?/g;
|
|
14
|
-
const
|
|
15
|
-
const curlybraceRE = /\w+\s?=\s?\{.+?\}/g;
|
|
14
|
+
const valuedAttributeRE = /((?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:!%-.~<]+)=(?:["]([^"]*)["]|[']([^']*)[']|[{]((?:[`(](?:[^`)]*)[`)]|[^}])+)[}])/gms;
|
|
16
15
|
function transformerAttributifyJsx(options = {}) {
|
|
17
16
|
const {
|
|
18
17
|
blocklist = []
|
|
@@ -39,12 +38,9 @@ function transformerAttributifyJsx(options = {}) {
|
|
|
39
38
|
async transform(code, _, { uno }) {
|
|
40
39
|
const tasks = [];
|
|
41
40
|
for (const item of Array.from(code.original.matchAll(elementRE))) {
|
|
42
|
-
const classNamePart = item[2].match(classFilterRE);
|
|
43
41
|
let attributifyPart = item[2];
|
|
44
|
-
if (
|
|
45
|
-
attributifyPart =
|
|
46
|
-
if (curlybraceRE.test(attributifyPart))
|
|
47
|
-
attributifyPart = attributifyPart.replace(curlybraceRE, (match) => " ".repeat(match.length));
|
|
42
|
+
if (valuedAttributeRE.test(attributifyPart))
|
|
43
|
+
attributifyPart = attributifyPart.replace(valuedAttributeRE, (match) => " ".repeat(match.length));
|
|
48
44
|
for (const attr of attributifyPart.matchAll(attributeRE)) {
|
|
49
45
|
const matchedRule = attr[0].replace(/\:/i, "-");
|
|
50
46
|
if (matchedRule.includes("=") || isBlocked(matchedRule))
|
|
@@ -52,7 +48,7 @@ function transformerAttributifyJsx(options = {}) {
|
|
|
52
48
|
tasks.push(uno.parseToken(matchedRule).then((matched) => {
|
|
53
49
|
if (matched) {
|
|
54
50
|
const tag = item[1];
|
|
55
|
-
const startIdx = (item.index || 0) + (attr.index || 0) + tag.length
|
|
51
|
+
const startIdx = (item.index || 0) + (attr.index || 0) + tag.length;
|
|
56
52
|
const endIdx = startIdx + matchedRule.length;
|
|
57
53
|
code.overwrite(startIdx, endIdx, `${matchedRule}=""`);
|
|
58
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/transformer-attributify-jsx",
|
|
3
|
-
"version": "0.50.
|
|
3
|
+
"version": "0.50.5",
|
|
4
4
|
"description": "Support valueless attributify in JSX/TSX.",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@unocss/core": "0.50.
|
|
36
|
+
"@unocss/core": "0.50.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"magic-string": "^0.30.0"
|