transform-to-unocss-core 0.0.50 → 0.0.52
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 +28 -4
- package/dist/index.d.cts +11 -7
- package/dist/index.d.ts +11 -7
- package/dist/index.iife.js +28 -4
- package/dist/index.js +24 -5
- package/dist/index.umd.js +28 -4
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -35,8 +35,23 @@ function isHsl(s) {
|
|
|
35
35
|
function isCubicBezier(s) {
|
|
36
36
|
return s.startsWith("cubic-bezier");
|
|
37
37
|
}
|
|
38
|
+
function isAttr(s) {
|
|
39
|
+
return /^attr\(/i.test(s);
|
|
40
|
+
}
|
|
41
|
+
function isRepeatingLinearGradient(s) {
|
|
42
|
+
return /^repeating-linear-gradient\(/i.test(s);
|
|
43
|
+
}
|
|
44
|
+
function isRepeatingRadialGradient(s) {
|
|
45
|
+
return /^repeating-radial-gradient\(/i.test(s);
|
|
46
|
+
}
|
|
47
|
+
function isConstant(s) {
|
|
48
|
+
return /^constant\(/.test(s);
|
|
49
|
+
}
|
|
50
|
+
function isEnv(s) {
|
|
51
|
+
return /^env\(/.test(s);
|
|
52
|
+
}
|
|
38
53
|
function getVal(val, transform$1, inClass, prefix = "") {
|
|
39
|
-
if (isCalc(val) || isUrl(val) || isHex(val) || isRgb(val) || isHsl(val) || isPercent(val) || isVar(val) || isCubicBezier(val)) return inClass ? `-[${prefix}${trim(val, "all").replace(/['"]/g, "")}]` : `="[${prefix}${trim(val, "all").replace(/['"]/g, "")}]"`;
|
|
54
|
+
if (isCalc(val) || isUrl(val) || isHex(val) || isRgb(val) || isHsl(val) || isPercent(val) || isVar(val) || isCubicBezier(val) || isConstant(val) || isAttr(val) || isEnv(val) || isRepeatingLinearGradient(val) || isRepeatingRadialGradient(val)) return inClass ? `-[${prefix}${trim(val, "all").replace(/['"]/g, "")}]` : `="[${prefix}${trim(val, "all").replace(/['"]/g, "")}]"`;
|
|
40
55
|
return prefix ? `-[${prefix}${transform$1 ? transform$1(val) : val}]` : `-${transform$1 ? transform$1(val) : val}`;
|
|
41
56
|
}
|
|
42
57
|
function getHundred(n) {
|
|
@@ -253,7 +268,7 @@ function background(key, val) {
|
|
|
253
268
|
}
|
|
254
269
|
const matcher1 = newValue.match(linearGradientReg1);
|
|
255
270
|
if (!matcher1) return;
|
|
256
|
-
return `bg-gradient-linear bg-gradient-[${matcher1[1]}
|
|
271
|
+
return `bg-gradient-linear bg-gradient-[${matcher1[1]}${matcher1[2] ? `,${matcher1[2].replace(/\s+/, "_").replaceAll(commaReplacer, ",")}` : ""},${matcher1[3].replace(/\s+/, "_").replaceAll(commaReplacer, ",")}]`;
|
|
257
272
|
} else if (/^(?:radial|conic)-gradient/.test(value)) {
|
|
258
273
|
const newValue = value.replace(/rgba?\(([^)]+)\)/g, (all, v) => all.replace(v, v.replace(/\s*,\s*/g, commaReplacer)));
|
|
259
274
|
const matcher = newValue.match(otherGradientReg);
|
|
@@ -366,7 +381,11 @@ function border(key, val) {
|
|
|
366
381
|
return `border${getVal(value)}${important}`;
|
|
367
382
|
}
|
|
368
383
|
if (key === "border-radius") return isCalc(value) || !value.includes(" ") ? `border-rd${getVal(value)}${important}` : `border-rd="[${joinWithUnderLine(value)}]${important}"`;
|
|
369
|
-
if (borderSize.some((b) => key.startsWith(b)))
|
|
384
|
+
if (borderSize.some((b) => key.startsWith(b))) {
|
|
385
|
+
const keys = key.split("-");
|
|
386
|
+
if (keys.slice(-1)[0] === "radius") return value.split(" ").map((v) => `border-rd-${keys.slice(1, -1).map((s) => s[0]).join("")}${getVal(v)}${important}`).join(" ");
|
|
387
|
+
return value.split(" ").map((v) => `border-${key.split("-")[1][0]}${getVal(v)}${important}`).join(" ");
|
|
388
|
+
}
|
|
370
389
|
if (key === "border-inline-end-width") return `border-e${getVal(value)}${important}`;
|
|
371
390
|
if (key === "border-inline-start-width") return `border-s${getVal(value)}${important}`;
|
|
372
391
|
if (key.startsWith("border-image")) return "";
|
|
@@ -840,7 +859,7 @@ function transformTransition(v, important) {
|
|
|
840
859
|
hasDuration = true;
|
|
841
860
|
return `duration${getVal(item, void 0, true)}${important}`;
|
|
842
861
|
}
|
|
843
|
-
if (item === "background-color") return
|
|
862
|
+
if (item === "background-color") return `colors${important}`;
|
|
844
863
|
if (/^(?:linear|ease|ease-in|ease-out|ease-in-out|step-start|step-end)$/.test(item)) return `ease-[${item}]${important}`;
|
|
845
864
|
else if (item.startsWith("cubic-bezier") || item.startsWith("steps")) return `ease-[${item}]${important}`;
|
|
846
865
|
return `${item}${important}`;
|
|
@@ -1121,14 +1140,19 @@ exports.getHundred = getHundred
|
|
|
1121
1140
|
exports.getLastName = getLastName
|
|
1122
1141
|
exports.getStyleScoped = getStyleScoped
|
|
1123
1142
|
exports.getVal = getVal
|
|
1143
|
+
exports.isAttr = isAttr
|
|
1124
1144
|
exports.isCalc = isCalc
|
|
1125
1145
|
exports.isColor = isColor
|
|
1146
|
+
exports.isConstant = isConstant
|
|
1126
1147
|
exports.isCubicBezier = isCubicBezier
|
|
1127
1148
|
exports.isEmptyStyle = isEmptyStyle
|
|
1149
|
+
exports.isEnv = isEnv
|
|
1128
1150
|
exports.isHex = isHex
|
|
1129
1151
|
exports.isHsl = isHsl
|
|
1130
1152
|
exports.isNot = isNot
|
|
1131
1153
|
exports.isPercent = isPercent
|
|
1154
|
+
exports.isRepeatingLinearGradient = isRepeatingLinearGradient
|
|
1155
|
+
exports.isRepeatingRadialGradient = isRepeatingRadialGradient
|
|
1132
1156
|
exports.isRgb = isRgb
|
|
1133
1157
|
exports.isSize = isSize
|
|
1134
1158
|
exports.isUrl = isUrl
|
package/dist/index.d.cts
CHANGED
|
@@ -31,19 +31,23 @@ declare function isHex(hex: string): boolean;
|
|
|
31
31
|
declare function isRgb(s: string): boolean;
|
|
32
32
|
declare function isHsl(s: string): boolean;
|
|
33
33
|
declare function isCubicBezier(s: string): boolean;
|
|
34
|
+
declare function isAttr(s: string): boolean;
|
|
35
|
+
declare function isRepeatingLinearGradient(s: string): boolean;
|
|
36
|
+
declare function isRepeatingRadialGradient(s: string): boolean;
|
|
37
|
+
declare function isConstant(s: string): boolean;
|
|
38
|
+
declare function isEnv(s: string): boolean;
|
|
34
39
|
declare function getVal(val: string, transform?: (v: string) => string, inClass?: boolean, prefix?: string): string;
|
|
35
40
|
declare function getHundred(n: string | number): string | number;
|
|
36
41
|
declare function joinWithLine(s: string): string;
|
|
37
42
|
declare function joinWithUnderLine(s: string): string;
|
|
38
43
|
declare const positionMap: string[];
|
|
39
44
|
type TrimType = 'all' | 'pre' | 'around' | 'post';
|
|
40
|
-
|
|
41
45
|
/**
|
|
42
|
-
* 删除空格
|
|
43
|
-
* @param { string } s 字符串
|
|
44
|
-
* @param { TrimType } type 所有 | 前置 | 前后 | 后置 'all' | 'pre' | 'around' | 'post'
|
|
45
|
-
* @returns string
|
|
46
|
-
*/
|
|
46
|
+
* 删除空格
|
|
47
|
+
* @param { string } s 字符串
|
|
48
|
+
* @param { TrimType } type 所有 | 前置 | 前后 | 后置 'all' | 'pre' | 'around' | 'post'
|
|
49
|
+
* @returns string
|
|
50
|
+
*/
|
|
47
51
|
declare function trim(s: string, type?: TrimType): string;
|
|
48
52
|
declare function transformImportant(v: string): string[];
|
|
49
53
|
declare function diffTemplateStyle(before: string, after: string): boolean;
|
|
@@ -61,4 +65,4 @@ declare const commaReplacer = "__comma__";
|
|
|
61
65
|
declare function getGradient(s: string): "" | "linear" | "radial" | "conic";
|
|
62
66
|
|
|
63
67
|
//#endregion
|
|
64
|
-
export { TrimType, browserReg, commaReplacer, cssMathFnRE, diffTemplateStyle, flag, getFirstName, getGradient, getHundred, getLastName, getStyleScoped, getVal, isCalc, isColor, isCubicBezier, isEmptyStyle, isHex, isHsl, isNot, isPercent, isRgb, isSize, isUrl, isVar, joinEmpty, joinWithLine, joinWithUnderLine, linearGradientReg, linearGradientReg1, numberWithUnitRE, otherGradientReg, positionMap, toUnocss, toUnocssClass, transformImportant, transformStyleToUnocss, transformStyleToUnocssPre, trim };
|
|
68
|
+
export { TrimType, browserReg, commaReplacer, cssMathFnRE, diffTemplateStyle, flag, getFirstName, getGradient, getHundred, getLastName, getStyleScoped, getVal, isAttr, isCalc, isColor, isConstant, isCubicBezier, isEmptyStyle, isEnv, isHex, isHsl, isNot, isPercent, isRepeatingLinearGradient, isRepeatingRadialGradient, isRgb, isSize, isUrl, isVar, joinEmpty, joinWithLine, joinWithUnderLine, linearGradientReg, linearGradientReg1, numberWithUnitRE, otherGradientReg, positionMap, toUnocss, toUnocssClass, transformImportant, transformStyleToUnocss, transformStyleToUnocssPre, trim };
|
package/dist/index.d.ts
CHANGED
|
@@ -31,19 +31,23 @@ declare function isHex(hex: string): boolean;
|
|
|
31
31
|
declare function isRgb(s: string): boolean;
|
|
32
32
|
declare function isHsl(s: string): boolean;
|
|
33
33
|
declare function isCubicBezier(s: string): boolean;
|
|
34
|
+
declare function isAttr(s: string): boolean;
|
|
35
|
+
declare function isRepeatingLinearGradient(s: string): boolean;
|
|
36
|
+
declare function isRepeatingRadialGradient(s: string): boolean;
|
|
37
|
+
declare function isConstant(s: string): boolean;
|
|
38
|
+
declare function isEnv(s: string): boolean;
|
|
34
39
|
declare function getVal(val: string, transform?: (v: string) => string, inClass?: boolean, prefix?: string): string;
|
|
35
40
|
declare function getHundred(n: string | number): string | number;
|
|
36
41
|
declare function joinWithLine(s: string): string;
|
|
37
42
|
declare function joinWithUnderLine(s: string): string;
|
|
38
43
|
declare const positionMap: string[];
|
|
39
44
|
type TrimType = 'all' | 'pre' | 'around' | 'post';
|
|
40
|
-
|
|
41
45
|
/**
|
|
42
|
-
* 删除空格
|
|
43
|
-
* @param { string } s 字符串
|
|
44
|
-
* @param { TrimType } type 所有 | 前置 | 前后 | 后置 'all' | 'pre' | 'around' | 'post'
|
|
45
|
-
* @returns string
|
|
46
|
-
*/
|
|
46
|
+
* 删除空格
|
|
47
|
+
* @param { string } s 字符串
|
|
48
|
+
* @param { TrimType } type 所有 | 前置 | 前后 | 后置 'all' | 'pre' | 'around' | 'post'
|
|
49
|
+
* @returns string
|
|
50
|
+
*/
|
|
47
51
|
declare function trim(s: string, type?: TrimType): string;
|
|
48
52
|
declare function transformImportant(v: string): string[];
|
|
49
53
|
declare function diffTemplateStyle(before: string, after: string): boolean;
|
|
@@ -61,4 +65,4 @@ declare const commaReplacer = "__comma__";
|
|
|
61
65
|
declare function getGradient(s: string): "" | "linear" | "radial" | "conic";
|
|
62
66
|
|
|
63
67
|
//#endregion
|
|
64
|
-
export { TrimType, browserReg, commaReplacer, cssMathFnRE, diffTemplateStyle, flag, getFirstName, getGradient, getHundred, getLastName, getStyleScoped, getVal, isCalc, isColor, isCubicBezier, isEmptyStyle, isHex, isHsl, isNot, isPercent, isRgb, isSize, isUrl, isVar, joinEmpty, joinWithLine, joinWithUnderLine, linearGradientReg, linearGradientReg1, numberWithUnitRE, otherGradientReg, positionMap, toUnocss, toUnocssClass, transformImportant, transformStyleToUnocss, transformStyleToUnocssPre, trim };
|
|
68
|
+
export { TrimType, browserReg, commaReplacer, cssMathFnRE, diffTemplateStyle, flag, getFirstName, getGradient, getHundred, getLastName, getStyleScoped, getVal, isAttr, isCalc, isColor, isConstant, isCubicBezier, isEmptyStyle, isEnv, isHex, isHsl, isNot, isPercent, isRepeatingLinearGradient, isRepeatingRadialGradient, isRgb, isSize, isUrl, isVar, joinEmpty, joinWithLine, joinWithUnderLine, linearGradientReg, linearGradientReg1, numberWithUnitRE, otherGradientReg, positionMap, toUnocss, toUnocssClass, transformImportant, transformStyleToUnocss, transformStyleToUnocssPre, trim };
|
package/dist/index.iife.js
CHANGED
|
@@ -37,8 +37,23 @@ function isHsl(s) {
|
|
|
37
37
|
function isCubicBezier(s) {
|
|
38
38
|
return s.startsWith("cubic-bezier");
|
|
39
39
|
}
|
|
40
|
+
function isAttr(s) {
|
|
41
|
+
return /^attr\(/i.test(s);
|
|
42
|
+
}
|
|
43
|
+
function isRepeatingLinearGradient(s) {
|
|
44
|
+
return /^repeating-linear-gradient\(/i.test(s);
|
|
45
|
+
}
|
|
46
|
+
function isRepeatingRadialGradient(s) {
|
|
47
|
+
return /^repeating-radial-gradient\(/i.test(s);
|
|
48
|
+
}
|
|
49
|
+
function isConstant(s) {
|
|
50
|
+
return /^constant\(/.test(s);
|
|
51
|
+
}
|
|
52
|
+
function isEnv(s) {
|
|
53
|
+
return /^env\(/.test(s);
|
|
54
|
+
}
|
|
40
55
|
function getVal(val, transform$1, inClass, prefix = "") {
|
|
41
|
-
if (isCalc(val) || isUrl(val) || isHex(val) || isRgb(val) || isHsl(val) || isPercent(val) || isVar(val) || isCubicBezier(val)) return inClass ? `-[${prefix}${trim(val, "all").replace(/['"]/g, "")}]` : `="[${prefix}${trim(val, "all").replace(/['"]/g, "")}]"`;
|
|
56
|
+
if (isCalc(val) || isUrl(val) || isHex(val) || isRgb(val) || isHsl(val) || isPercent(val) || isVar(val) || isCubicBezier(val) || isConstant(val) || isAttr(val) || isEnv(val) || isRepeatingLinearGradient(val) || isRepeatingRadialGradient(val)) return inClass ? `-[${prefix}${trim(val, "all").replace(/['"]/g, "")}]` : `="[${prefix}${trim(val, "all").replace(/['"]/g, "")}]"`;
|
|
42
57
|
return prefix ? `-[${prefix}${transform$1 ? transform$1(val) : val}]` : `-${transform$1 ? transform$1(val) : val}`;
|
|
43
58
|
}
|
|
44
59
|
function getHundred(n) {
|
|
@@ -255,7 +270,7 @@ function background(key, val) {
|
|
|
255
270
|
}
|
|
256
271
|
const matcher1 = newValue.match(linearGradientReg1);
|
|
257
272
|
if (!matcher1) return;
|
|
258
|
-
return `bg-gradient-linear bg-gradient-[${matcher1[1]}
|
|
273
|
+
return `bg-gradient-linear bg-gradient-[${matcher1[1]}${matcher1[2] ? `,${matcher1[2].replace(/\s+/, "_").replaceAll(commaReplacer, ",")}` : ""},${matcher1[3].replace(/\s+/, "_").replaceAll(commaReplacer, ",")}]`;
|
|
259
274
|
} else if (/^(?:radial|conic)-gradient/.test(value)) {
|
|
260
275
|
const newValue = value.replace(/rgba?\(([^)]+)\)/g, (all, v) => all.replace(v, v.replace(/\s*,\s*/g, commaReplacer)));
|
|
261
276
|
const matcher = newValue.match(otherGradientReg);
|
|
@@ -368,7 +383,11 @@ function border(key, val) {
|
|
|
368
383
|
return `border${getVal(value)}${important}`;
|
|
369
384
|
}
|
|
370
385
|
if (key === "border-radius") return isCalc(value) || !value.includes(" ") ? `border-rd${getVal(value)}${important}` : `border-rd="[${joinWithUnderLine(value)}]${important}"`;
|
|
371
|
-
if (borderSize.some((b) => key.startsWith(b)))
|
|
386
|
+
if (borderSize.some((b) => key.startsWith(b))) {
|
|
387
|
+
const keys = key.split("-");
|
|
388
|
+
if (keys.slice(-1)[0] === "radius") return value.split(" ").map((v) => `border-rd-${keys.slice(1, -1).map((s) => s[0]).join("")}${getVal(v)}${important}`).join(" ");
|
|
389
|
+
return value.split(" ").map((v) => `border-${key.split("-")[1][0]}${getVal(v)}${important}`).join(" ");
|
|
390
|
+
}
|
|
372
391
|
if (key === "border-inline-end-width") return `border-e${getVal(value)}${important}`;
|
|
373
392
|
if (key === "border-inline-start-width") return `border-s${getVal(value)}${important}`;
|
|
374
393
|
if (key.startsWith("border-image")) return "";
|
|
@@ -842,7 +861,7 @@ function transformTransition(v, important) {
|
|
|
842
861
|
hasDuration = true;
|
|
843
862
|
return `duration${getVal(item, void 0, true)}${important}`;
|
|
844
863
|
}
|
|
845
|
-
if (item === "background-color") return
|
|
864
|
+
if (item === "background-color") return `colors${important}`;
|
|
846
865
|
if (/^(?:linear|ease|ease-in|ease-out|ease-in-out|step-start|step-end)$/.test(item)) return `ease-[${item}]${important}`;
|
|
847
866
|
else if (item.startsWith("cubic-bezier") || item.startsWith("steps")) return `ease-[${item}]${important}`;
|
|
848
867
|
return `${item}${important}`;
|
|
@@ -1123,14 +1142,19 @@ exports.getHundred = getHundred
|
|
|
1123
1142
|
exports.getLastName = getLastName
|
|
1124
1143
|
exports.getStyleScoped = getStyleScoped
|
|
1125
1144
|
exports.getVal = getVal
|
|
1145
|
+
exports.isAttr = isAttr
|
|
1126
1146
|
exports.isCalc = isCalc
|
|
1127
1147
|
exports.isColor = isColor
|
|
1148
|
+
exports.isConstant = isConstant
|
|
1128
1149
|
exports.isCubicBezier = isCubicBezier
|
|
1129
1150
|
exports.isEmptyStyle = isEmptyStyle
|
|
1151
|
+
exports.isEnv = isEnv
|
|
1130
1152
|
exports.isHex = isHex
|
|
1131
1153
|
exports.isHsl = isHsl
|
|
1132
1154
|
exports.isNot = isNot
|
|
1133
1155
|
exports.isPercent = isPercent
|
|
1156
|
+
exports.isRepeatingLinearGradient = isRepeatingLinearGradient
|
|
1157
|
+
exports.isRepeatingRadialGradient = isRepeatingRadialGradient
|
|
1134
1158
|
exports.isRgb = isRgb
|
|
1135
1159
|
exports.isSize = isSize
|
|
1136
1160
|
exports.isUrl = isUrl
|
package/dist/index.js
CHANGED
|
@@ -33,8 +33,23 @@ function isHsl(s) {
|
|
|
33
33
|
function isCubicBezier(s) {
|
|
34
34
|
return s.startsWith("cubic-bezier");
|
|
35
35
|
}
|
|
36
|
+
function isAttr(s) {
|
|
37
|
+
return /^attr\(/i.test(s);
|
|
38
|
+
}
|
|
39
|
+
function isRepeatingLinearGradient(s) {
|
|
40
|
+
return /^repeating-linear-gradient\(/i.test(s);
|
|
41
|
+
}
|
|
42
|
+
function isRepeatingRadialGradient(s) {
|
|
43
|
+
return /^repeating-radial-gradient\(/i.test(s);
|
|
44
|
+
}
|
|
45
|
+
function isConstant(s) {
|
|
46
|
+
return /^constant\(/.test(s);
|
|
47
|
+
}
|
|
48
|
+
function isEnv(s) {
|
|
49
|
+
return /^env\(/.test(s);
|
|
50
|
+
}
|
|
36
51
|
function getVal(val, transform$1, inClass, prefix = "") {
|
|
37
|
-
if (isCalc(val) || isUrl(val) || isHex(val) || isRgb(val) || isHsl(val) || isPercent(val) || isVar(val) || isCubicBezier(val)) return inClass ? `-[${prefix}${trim(val, "all").replace(/['"]/g, "")}]` : `="[${prefix}${trim(val, "all").replace(/['"]/g, "")}]"`;
|
|
52
|
+
if (isCalc(val) || isUrl(val) || isHex(val) || isRgb(val) || isHsl(val) || isPercent(val) || isVar(val) || isCubicBezier(val) || isConstant(val) || isAttr(val) || isEnv(val) || isRepeatingLinearGradient(val) || isRepeatingRadialGradient(val)) return inClass ? `-[${prefix}${trim(val, "all").replace(/['"]/g, "")}]` : `="[${prefix}${trim(val, "all").replace(/['"]/g, "")}]"`;
|
|
38
53
|
return prefix ? `-[${prefix}${transform$1 ? transform$1(val) : val}]` : `-${transform$1 ? transform$1(val) : val}`;
|
|
39
54
|
}
|
|
40
55
|
function getHundred(n) {
|
|
@@ -251,7 +266,7 @@ function background(key, val) {
|
|
|
251
266
|
}
|
|
252
267
|
const matcher1 = newValue.match(linearGradientReg1);
|
|
253
268
|
if (!matcher1) return;
|
|
254
|
-
return `bg-gradient-linear bg-gradient-[${matcher1[1]}
|
|
269
|
+
return `bg-gradient-linear bg-gradient-[${matcher1[1]}${matcher1[2] ? `,${matcher1[2].replace(/\s+/, "_").replaceAll(commaReplacer, ",")}` : ""},${matcher1[3].replace(/\s+/, "_").replaceAll(commaReplacer, ",")}]`;
|
|
255
270
|
} else if (/^(?:radial|conic)-gradient/.test(value)) {
|
|
256
271
|
const newValue = value.replace(/rgba?\(([^)]+)\)/g, (all, v) => all.replace(v, v.replace(/\s*,\s*/g, commaReplacer)));
|
|
257
272
|
const matcher = newValue.match(otherGradientReg);
|
|
@@ -364,7 +379,11 @@ function border(key, val) {
|
|
|
364
379
|
return `border${getVal(value)}${important}`;
|
|
365
380
|
}
|
|
366
381
|
if (key === "border-radius") return isCalc(value) || !value.includes(" ") ? `border-rd${getVal(value)}${important}` : `border-rd="[${joinWithUnderLine(value)}]${important}"`;
|
|
367
|
-
if (borderSize.some((b) => key.startsWith(b)))
|
|
382
|
+
if (borderSize.some((b) => key.startsWith(b))) {
|
|
383
|
+
const keys = key.split("-");
|
|
384
|
+
if (keys.slice(-1)[0] === "radius") return value.split(" ").map((v) => `border-rd-${keys.slice(1, -1).map((s) => s[0]).join("")}${getVal(v)}${important}`).join(" ");
|
|
385
|
+
return value.split(" ").map((v) => `border-${key.split("-")[1][0]}${getVal(v)}${important}`).join(" ");
|
|
386
|
+
}
|
|
368
387
|
if (key === "border-inline-end-width") return `border-e${getVal(value)}${important}`;
|
|
369
388
|
if (key === "border-inline-start-width") return `border-s${getVal(value)}${important}`;
|
|
370
389
|
if (key.startsWith("border-image")) return "";
|
|
@@ -838,7 +857,7 @@ function transformTransition(v, important) {
|
|
|
838
857
|
hasDuration = true;
|
|
839
858
|
return `duration${getVal(item, void 0, true)}${important}`;
|
|
840
859
|
}
|
|
841
|
-
if (item === "background-color") return
|
|
860
|
+
if (item === "background-color") return `colors${important}`;
|
|
842
861
|
if (/^(?:linear|ease|ease-in|ease-out|ease-in-out|step-start|step-end)$/.test(item)) return `ease-[${item}]${important}`;
|
|
843
862
|
else if (item.startsWith("cubic-bezier") || item.startsWith("steps")) return `ease-[${item}]${important}`;
|
|
844
863
|
return `${item}${important}`;
|
|
@@ -1108,4 +1127,4 @@ function toUnocssClass(css, isRem = false) {
|
|
|
1108
1127
|
}
|
|
1109
1128
|
|
|
1110
1129
|
//#endregion
|
|
1111
|
-
export { browserReg, commaReplacer, cssMathFnRE, diffTemplateStyle, flag, getFirstName, getGradient, getHundred, getLastName, getStyleScoped, getVal, isCalc, isColor, isCubicBezier, isEmptyStyle, isHex, isHsl, isNot, isPercent, isRgb, isSize, isUrl, isVar, joinEmpty, joinWithLine, joinWithUnderLine, linearGradientReg, linearGradientReg1, numberWithUnitRE, otherGradientReg, positionMap, toUnocss, toUnocssClass, transformImportant, transformStyleToUnocss, transformStyleToUnocssPre, trim };
|
|
1130
|
+
export { browserReg, commaReplacer, cssMathFnRE, diffTemplateStyle, flag, getFirstName, getGradient, getHundred, getLastName, getStyleScoped, getVal, isAttr, isCalc, isColor, isConstant, isCubicBezier, isEmptyStyle, isEnv, isHex, isHsl, isNot, isPercent, isRepeatingLinearGradient, isRepeatingRadialGradient, isRgb, isSize, isUrl, isVar, joinEmpty, joinWithLine, joinWithUnderLine, linearGradientReg, linearGradientReg1, numberWithUnitRE, otherGradientReg, positionMap, toUnocss, toUnocssClass, transformImportant, transformStyleToUnocss, transformStyleToUnocssPre, trim };
|
package/dist/index.umd.js
CHANGED
|
@@ -40,8 +40,23 @@ function isHsl(s) {
|
|
|
40
40
|
function isCubicBezier(s) {
|
|
41
41
|
return s.startsWith("cubic-bezier");
|
|
42
42
|
}
|
|
43
|
+
function isAttr(s) {
|
|
44
|
+
return /^attr\(/i.test(s);
|
|
45
|
+
}
|
|
46
|
+
function isRepeatingLinearGradient(s) {
|
|
47
|
+
return /^repeating-linear-gradient\(/i.test(s);
|
|
48
|
+
}
|
|
49
|
+
function isRepeatingRadialGradient(s) {
|
|
50
|
+
return /^repeating-radial-gradient\(/i.test(s);
|
|
51
|
+
}
|
|
52
|
+
function isConstant(s) {
|
|
53
|
+
return /^constant\(/.test(s);
|
|
54
|
+
}
|
|
55
|
+
function isEnv(s) {
|
|
56
|
+
return /^env\(/.test(s);
|
|
57
|
+
}
|
|
43
58
|
function getVal(val, transform$1, inClass, prefix = "") {
|
|
44
|
-
if (isCalc(val) || isUrl(val) || isHex(val) || isRgb(val) || isHsl(val) || isPercent(val) || isVar(val) || isCubicBezier(val)) return inClass ? `-[${prefix}${trim(val, "all").replace(/['"]/g, "")}]` : `="[${prefix}${trim(val, "all").replace(/['"]/g, "")}]"`;
|
|
59
|
+
if (isCalc(val) || isUrl(val) || isHex(val) || isRgb(val) || isHsl(val) || isPercent(val) || isVar(val) || isCubicBezier(val) || isConstant(val) || isAttr(val) || isEnv(val) || isRepeatingLinearGradient(val) || isRepeatingRadialGradient(val)) return inClass ? `-[${prefix}${trim(val, "all").replace(/['"]/g, "")}]` : `="[${prefix}${trim(val, "all").replace(/['"]/g, "")}]"`;
|
|
45
60
|
return prefix ? `-[${prefix}${transform$1 ? transform$1(val) : val}]` : `-${transform$1 ? transform$1(val) : val}`;
|
|
46
61
|
}
|
|
47
62
|
function getHundred(n) {
|
|
@@ -258,7 +273,7 @@ function background(key, val) {
|
|
|
258
273
|
}
|
|
259
274
|
const matcher1 = newValue.match(linearGradientReg1);
|
|
260
275
|
if (!matcher1) return;
|
|
261
|
-
return `bg-gradient-linear bg-gradient-[${matcher1[1]}
|
|
276
|
+
return `bg-gradient-linear bg-gradient-[${matcher1[1]}${matcher1[2] ? `,${matcher1[2].replace(/\s+/, "_").replaceAll(commaReplacer, ",")}` : ""},${matcher1[3].replace(/\s+/, "_").replaceAll(commaReplacer, ",")}]`;
|
|
262
277
|
} else if (/^(?:radial|conic)-gradient/.test(value)) {
|
|
263
278
|
const newValue = value.replace(/rgba?\(([^)]+)\)/g, (all, v) => all.replace(v, v.replace(/\s*,\s*/g, commaReplacer)));
|
|
264
279
|
const matcher = newValue.match(otherGradientReg);
|
|
@@ -371,7 +386,11 @@ function border(key, val) {
|
|
|
371
386
|
return `border${getVal(value)}${important}`;
|
|
372
387
|
}
|
|
373
388
|
if (key === "border-radius") return isCalc(value) || !value.includes(" ") ? `border-rd${getVal(value)}${important}` : `border-rd="[${joinWithUnderLine(value)}]${important}"`;
|
|
374
|
-
if (borderSize.some((b) => key.startsWith(b)))
|
|
389
|
+
if (borderSize.some((b) => key.startsWith(b))) {
|
|
390
|
+
const keys = key.split("-");
|
|
391
|
+
if (keys.slice(-1)[0] === "radius") return value.split(" ").map((v) => `border-rd-${keys.slice(1, -1).map((s) => s[0]).join("")}${getVal(v)}${important}`).join(" ");
|
|
392
|
+
return value.split(" ").map((v) => `border-${key.split("-")[1][0]}${getVal(v)}${important}`).join(" ");
|
|
393
|
+
}
|
|
375
394
|
if (key === "border-inline-end-width") return `border-e${getVal(value)}${important}`;
|
|
376
395
|
if (key === "border-inline-start-width") return `border-s${getVal(value)}${important}`;
|
|
377
396
|
if (key.startsWith("border-image")) return "";
|
|
@@ -845,7 +864,7 @@ function transformTransition(v, important) {
|
|
|
845
864
|
hasDuration = true;
|
|
846
865
|
return `duration${getVal(item, void 0, true)}${important}`;
|
|
847
866
|
}
|
|
848
|
-
if (item === "background-color") return
|
|
867
|
+
if (item === "background-color") return `colors${important}`;
|
|
849
868
|
if (/^(?:linear|ease|ease-in|ease-out|ease-in-out|step-start|step-end)$/.test(item)) return `ease-[${item}]${important}`;
|
|
850
869
|
else if (item.startsWith("cubic-bezier") || item.startsWith("steps")) return `ease-[${item}]${important}`;
|
|
851
870
|
return `${item}${important}`;
|
|
@@ -1126,14 +1145,19 @@ exports.getHundred = getHundred
|
|
|
1126
1145
|
exports.getLastName = getLastName
|
|
1127
1146
|
exports.getStyleScoped = getStyleScoped
|
|
1128
1147
|
exports.getVal = getVal
|
|
1148
|
+
exports.isAttr = isAttr
|
|
1129
1149
|
exports.isCalc = isCalc
|
|
1130
1150
|
exports.isColor = isColor
|
|
1151
|
+
exports.isConstant = isConstant
|
|
1131
1152
|
exports.isCubicBezier = isCubicBezier
|
|
1132
1153
|
exports.isEmptyStyle = isEmptyStyle
|
|
1154
|
+
exports.isEnv = isEnv
|
|
1133
1155
|
exports.isHex = isHex
|
|
1134
1156
|
exports.isHsl = isHsl
|
|
1135
1157
|
exports.isNot = isNot
|
|
1136
1158
|
exports.isPercent = isPercent
|
|
1159
|
+
exports.isRepeatingLinearGradient = isRepeatingLinearGradient
|
|
1160
|
+
exports.isRepeatingRadialGradient = isRepeatingRadialGradient
|
|
1137
1161
|
exports.isRgb = isRgb
|
|
1138
1162
|
exports.isSize = isSize
|
|
1139
1163
|
exports.isUrl = isUrl
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "transform-to-unocss-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.52",
|
|
5
5
|
"description": "A utility to transform CSS to UnoCSS syntax. Supports various CSS properties and custom parsing.",
|
|
6
6
|
"author": "Simon He",
|
|
7
7
|
"license": "MIT",
|
|
@@ -61,15 +61,15 @@
|
|
|
61
61
|
"typecheck": "tsc --noEmit"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@antfu/eslint-config": "^4.
|
|
65
|
-
"@types/node": "^18.19.
|
|
64
|
+
"@antfu/eslint-config": "^4.13.0",
|
|
65
|
+
"@types/node": "^18.19.98",
|
|
66
66
|
"bumpp": "^8.2.1",
|
|
67
|
-
"eslint": "^9.
|
|
67
|
+
"eslint": "^9.26.0",
|
|
68
68
|
"esno": "^0.16.3",
|
|
69
69
|
"picocolors": "^1.1.1",
|
|
70
70
|
"prettier": "^2.8.8",
|
|
71
71
|
"rimraf": "^3.0.2",
|
|
72
|
-
"tsdown": "^0.10.
|
|
72
|
+
"tsdown": "^0.10.2",
|
|
73
73
|
"tsx": "^3.14.0",
|
|
74
74
|
"typescript": "^4.9.5",
|
|
75
75
|
"vitest": "^0.15.2"
|