tailwind-to-style 2.9.1 → 2.9.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 +932 -882
- package/dist/index.browser.js +75 -41
- package/dist/index.cjs +75 -41
- package/dist/index.esm.js +75 -41
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tailwind-to-style v2.9.
|
|
2
|
+
* tailwind-to-style v2.9.2
|
|
3
3
|
* Convert tailwind classes to inline style
|
|
4
4
|
*
|
|
5
5
|
* @author Bigetion
|
|
@@ -3247,6 +3247,7 @@ var tailwindToStyle = (function (exports) {
|
|
|
3247
3247
|
theme = {}
|
|
3248
3248
|
} = configOptions;
|
|
3249
3249
|
const prefix = `${globalPrefix}font`;
|
|
3250
|
+
const customPrefix = `${globalPrefix}font-weight`;
|
|
3250
3251
|
const {
|
|
3251
3252
|
fontWeight = {}
|
|
3252
3253
|
} = theme;
|
|
@@ -3254,11 +3255,20 @@ var tailwindToStyle = (function (exports) {
|
|
|
3254
3255
|
let {
|
|
3255
3256
|
getCssByOptions
|
|
3256
3257
|
} = _ref;
|
|
3257
|
-
const cssString = getCssByOptions(fontWeight, (key, value) =>
|
|
3258
|
+
const cssString = getCssByOptions(fontWeight, (key, value) => {
|
|
3259
|
+
if (value === "custom_value") {
|
|
3260
|
+
return `
|
|
3261
|
+
${customPrefix}${key} {
|
|
3262
|
+
font-weight: ${value};
|
|
3263
|
+
}
|
|
3264
|
+
`;
|
|
3265
|
+
}
|
|
3266
|
+
return `
|
|
3258
3267
|
${prefix}-${key} {
|
|
3259
3268
|
font-weight: ${value};
|
|
3260
3269
|
}
|
|
3261
|
-
|
|
3270
|
+
`;
|
|
3271
|
+
});
|
|
3262
3272
|
return cssString;
|
|
3263
3273
|
}, configOptions);
|
|
3264
3274
|
return responsiveCssString;
|
|
@@ -6222,8 +6232,32 @@ var tailwindToStyle = (function (exports) {
|
|
|
6222
6232
|
}
|
|
6223
6233
|
};
|
|
6224
6234
|
|
|
6235
|
+
const fontFamily = {
|
|
6236
|
+
fontCustom: {
|
|
6237
|
+
regex: /^font-\[([^\]]+)\]$/,
|
|
6238
|
+
cssProp: "font-family",
|
|
6239
|
+
formatter: value => {
|
|
6240
|
+
// Decode URL-encoded value first (in case it comes from bracket encoding)
|
|
6241
|
+
const decodedValue = decodeURIComponent(value.replace(/__P__/g, "(").replace(/__C__/g, ")"));
|
|
6242
|
+
|
|
6243
|
+
// Split by comma and process each font
|
|
6244
|
+
const fonts = decodedValue.split(",").map(font => {
|
|
6245
|
+
const trimmedFont = font.trim();
|
|
6246
|
+
|
|
6247
|
+
// If font contains spaces and is not already quoted, add quotes
|
|
6248
|
+
if (trimmedFont.includes(" ") && !trimmedFont.startsWith('"') && !trimmedFont.startsWith("'")) {
|
|
6249
|
+
return `"${trimmedFont}"`;
|
|
6250
|
+
}
|
|
6251
|
+
return trimmedFont;
|
|
6252
|
+
});
|
|
6253
|
+
return fonts.join(", ");
|
|
6254
|
+
}
|
|
6255
|
+
}
|
|
6256
|
+
};
|
|
6257
|
+
|
|
6225
6258
|
const patterns = {
|
|
6226
|
-
...transition
|
|
6259
|
+
...transition,
|
|
6260
|
+
...fontFamily
|
|
6227
6261
|
};
|
|
6228
6262
|
|
|
6229
6263
|
const plugins = {
|
|
@@ -6400,10 +6434,10 @@ var tailwindToStyle = (function (exports) {
|
|
|
6400
6434
|
return null;
|
|
6401
6435
|
}
|
|
6402
6436
|
|
|
6403
|
-
/**
|
|
6404
|
-
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
6405
|
-
* @param {string} cssString
|
|
6406
|
-
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
6437
|
+
/**
|
|
6438
|
+
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
6439
|
+
* @param {string} cssString
|
|
6440
|
+
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
6407
6441
|
*/
|
|
6408
6442
|
function resolveCssToClearCss(cssString) {
|
|
6409
6443
|
const customVars = {};
|
|
@@ -6539,7 +6573,7 @@ var tailwindToStyle = (function (exports) {
|
|
|
6539
6573
|
media = breakpoints[v];
|
|
6540
6574
|
} else if (pseudoVariants.has(v)) {
|
|
6541
6575
|
finalSelector += `:${v}`;
|
|
6542
|
-
} else if (v ===
|
|
6576
|
+
} else if (v === "dark") {
|
|
6543
6577
|
// Special handling for dark variant
|
|
6544
6578
|
finalSelector = `.dark ${finalSelector}`;
|
|
6545
6579
|
} else {
|
|
@@ -6687,11 +6721,11 @@ var tailwindToStyle = (function (exports) {
|
|
|
6687
6721
|
}
|
|
6688
6722
|
}
|
|
6689
6723
|
|
|
6690
|
-
/**
|
|
6691
|
-
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
6692
|
-
* @param {string} className - Class name with potential opacity modifier
|
|
6693
|
-
* @param {string} cssDeclaration - CSS declaration to modify
|
|
6694
|
-
* @returns {string} Modified CSS declaration with opacity applied
|
|
6724
|
+
/**
|
|
6725
|
+
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
6726
|
+
* @param {string} className - Class name with potential opacity modifier
|
|
6727
|
+
* @param {string} cssDeclaration - CSS declaration to modify
|
|
6728
|
+
* @returns {string} Modified CSS declaration with opacity applied
|
|
6695
6729
|
*/
|
|
6696
6730
|
function processOpacityModifier(className, cssDeclaration) {
|
|
6697
6731
|
const opacityMatch = className.match(/\/(\d+)$/);
|
|
@@ -6752,11 +6786,11 @@ var tailwindToStyle = (function (exports) {
|
|
|
6752
6786
|
return modifiedDeclaration;
|
|
6753
6787
|
}
|
|
6754
6788
|
|
|
6755
|
-
/**
|
|
6756
|
-
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
6757
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
6758
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
6759
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
6789
|
+
/**
|
|
6790
|
+
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
6791
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
6792
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
6793
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
6760
6794
|
*/
|
|
6761
6795
|
function tws(classNames, convertToJson) {
|
|
6762
6796
|
const totalMarker = performanceMonitor.start("tws:total");
|
|
@@ -6882,7 +6916,7 @@ var tailwindToStyle = (function (exports) {
|
|
|
6882
6916
|
function expandDirectiveGroups(str) {
|
|
6883
6917
|
return str.replace(/(\w+)\(([^()]+)\)/g, (_, directive, content) => {
|
|
6884
6918
|
// Special handling for dark mode syntax: dark:(classes)
|
|
6885
|
-
if (directive ===
|
|
6919
|
+
if (directive === "dark") {
|
|
6886
6920
|
return content.trim().split(/\s+/).map(cls => `dark:${cls}`).join(" ");
|
|
6887
6921
|
}
|
|
6888
6922
|
return content.trim().split(/\s+/).map(val => {
|
|
@@ -7024,7 +7058,7 @@ var tailwindToStyle = (function (exports) {
|
|
|
7024
7058
|
const cssDeclarations = Object.entries(nestedVal).map(_ref3 => {
|
|
7025
7059
|
let [key, value] = _ref3;
|
|
7026
7060
|
// Ensure CSS values are properly formatted and not processed through Tailwind conversion
|
|
7027
|
-
const cleanValue = typeof value ===
|
|
7061
|
+
const cleanValue = typeof value === "string" ? value.trim() : String(value);
|
|
7028
7062
|
return `${key}: ${cleanValue};`;
|
|
7029
7063
|
}).join(" ");
|
|
7030
7064
|
if (selector in styles) {
|
|
@@ -7084,12 +7118,12 @@ var tailwindToStyle = (function (exports) {
|
|
|
7084
7118
|
}
|
|
7085
7119
|
|
|
7086
7120
|
// Check if this is a @css object within the current object
|
|
7087
|
-
if (val[
|
|
7121
|
+
if (val["@css"] && typeof val["@css"] === "object") {
|
|
7088
7122
|
// Handle object with @css directive - process the @css part specially
|
|
7089
|
-
const cssDeclarations = Object.entries(val[
|
|
7123
|
+
const cssDeclarations = Object.entries(val["@css"]).map(_ref4 => {
|
|
7090
7124
|
let [key, value] = _ref4;
|
|
7091
7125
|
// Keep CSS values intact without any processing
|
|
7092
|
-
const cleanValue = typeof value ===
|
|
7126
|
+
const cleanValue = typeof value === "string" ? value.trim() : String(value);
|
|
7093
7127
|
return `${key}: ${cleanValue};`;
|
|
7094
7128
|
}).join(" ");
|
|
7095
7129
|
if (selector in styles) {
|
|
@@ -7102,7 +7136,7 @@ var tailwindToStyle = (function (exports) {
|
|
|
7102
7136
|
const otherProps = {
|
|
7103
7137
|
...val
|
|
7104
7138
|
};
|
|
7105
|
-
delete otherProps[
|
|
7139
|
+
delete otherProps["@css"];
|
|
7106
7140
|
if (Object.keys(otherProps).length > 0) {
|
|
7107
7141
|
processNestedSelectors(otherProps, selector, styles, walk);
|
|
7108
7142
|
}
|
|
@@ -7193,12 +7227,12 @@ var tailwindToStyle = (function (exports) {
|
|
|
7193
7227
|
return cssString.trim();
|
|
7194
7228
|
}
|
|
7195
7229
|
|
|
7196
|
-
/**
|
|
7197
|
-
* Generate CSS string from style object with SCSS-like syntax
|
|
7198
|
-
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
7199
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
7200
|
-
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
7201
|
-
* @returns {string} Generated CSS string
|
|
7230
|
+
/**
|
|
7231
|
+
* Generate CSS string from style object with SCSS-like syntax
|
|
7232
|
+
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
7233
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
7234
|
+
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
7235
|
+
* @returns {string} Generated CSS string
|
|
7202
7236
|
*/
|
|
7203
7237
|
function twsx(obj) {
|
|
7204
7238
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -7340,19 +7374,19 @@ var tailwindToStyle = (function (exports) {
|
|
|
7340
7374
|
}
|
|
7341
7375
|
|
|
7342
7376
|
// Enhanced debounced functions with performance monitoring configuration
|
|
7343
|
-
/**
|
|
7344
|
-
* Debounced version of tws function with performance monitoring
|
|
7345
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
7346
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
7347
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
7377
|
+
/**
|
|
7378
|
+
* Debounced version of tws function with performance monitoring
|
|
7379
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
7380
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
7381
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
7348
7382
|
*/
|
|
7349
7383
|
const debouncedTws = debounce(tws, 50); // Faster debounce for tws
|
|
7350
7384
|
|
|
7351
|
-
/**
|
|
7352
|
-
* Debounced version of twsx function with performance monitoring
|
|
7353
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
7354
|
-
* @param {Object} [options] - Additional options
|
|
7355
|
-
* @returns {string} Generated CSS string
|
|
7385
|
+
/**
|
|
7386
|
+
* Debounced version of twsx function with performance monitoring
|
|
7387
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
7388
|
+
* @param {Object} [options] - Additional options
|
|
7389
|
+
* @returns {string} Generated CSS string
|
|
7356
7390
|
*/
|
|
7357
7391
|
const debouncedTwsx = debounce(twsx, 100); // Standard debounce for twsx
|
|
7358
7392
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tailwind-to-style v2.9.
|
|
2
|
+
* tailwind-to-style v2.9.2
|
|
3
3
|
* Convert tailwind classes to inline style
|
|
4
4
|
*
|
|
5
5
|
* @author Bigetion
|
|
@@ -3248,6 +3248,7 @@ function generator$1C() {
|
|
|
3248
3248
|
theme = {}
|
|
3249
3249
|
} = configOptions;
|
|
3250
3250
|
const prefix = `${globalPrefix}font`;
|
|
3251
|
+
const customPrefix = `${globalPrefix}font-weight`;
|
|
3251
3252
|
const {
|
|
3252
3253
|
fontWeight = {}
|
|
3253
3254
|
} = theme;
|
|
@@ -3255,11 +3256,20 @@ function generator$1C() {
|
|
|
3255
3256
|
let {
|
|
3256
3257
|
getCssByOptions
|
|
3257
3258
|
} = _ref;
|
|
3258
|
-
const cssString = getCssByOptions(fontWeight, (key, value) =>
|
|
3259
|
+
const cssString = getCssByOptions(fontWeight, (key, value) => {
|
|
3260
|
+
if (value === "custom_value") {
|
|
3261
|
+
return `
|
|
3262
|
+
${customPrefix}${key} {
|
|
3263
|
+
font-weight: ${value};
|
|
3264
|
+
}
|
|
3265
|
+
`;
|
|
3266
|
+
}
|
|
3267
|
+
return `
|
|
3259
3268
|
${prefix}-${key} {
|
|
3260
3269
|
font-weight: ${value};
|
|
3261
3270
|
}
|
|
3262
|
-
|
|
3271
|
+
`;
|
|
3272
|
+
});
|
|
3263
3273
|
return cssString;
|
|
3264
3274
|
}, configOptions);
|
|
3265
3275
|
return responsiveCssString;
|
|
@@ -6223,8 +6233,32 @@ const transition = {
|
|
|
6223
6233
|
}
|
|
6224
6234
|
};
|
|
6225
6235
|
|
|
6236
|
+
const fontFamily = {
|
|
6237
|
+
fontCustom: {
|
|
6238
|
+
regex: /^font-\[([^\]]+)\]$/,
|
|
6239
|
+
cssProp: "font-family",
|
|
6240
|
+
formatter: value => {
|
|
6241
|
+
// Decode URL-encoded value first (in case it comes from bracket encoding)
|
|
6242
|
+
const decodedValue = decodeURIComponent(value.replace(/__P__/g, "(").replace(/__C__/g, ")"));
|
|
6243
|
+
|
|
6244
|
+
// Split by comma and process each font
|
|
6245
|
+
const fonts = decodedValue.split(",").map(font => {
|
|
6246
|
+
const trimmedFont = font.trim();
|
|
6247
|
+
|
|
6248
|
+
// If font contains spaces and is not already quoted, add quotes
|
|
6249
|
+
if (trimmedFont.includes(" ") && !trimmedFont.startsWith('"') && !trimmedFont.startsWith("'")) {
|
|
6250
|
+
return `"${trimmedFont}"`;
|
|
6251
|
+
}
|
|
6252
|
+
return trimmedFont;
|
|
6253
|
+
});
|
|
6254
|
+
return fonts.join(", ");
|
|
6255
|
+
}
|
|
6256
|
+
}
|
|
6257
|
+
};
|
|
6258
|
+
|
|
6226
6259
|
const patterns = {
|
|
6227
|
-
...transition
|
|
6260
|
+
...transition,
|
|
6261
|
+
...fontFamily
|
|
6228
6262
|
};
|
|
6229
6263
|
|
|
6230
6264
|
const plugins = {
|
|
@@ -6401,10 +6435,10 @@ function parseCustomClassWithPatterns(className) {
|
|
|
6401
6435
|
return null;
|
|
6402
6436
|
}
|
|
6403
6437
|
|
|
6404
|
-
/**
|
|
6405
|
-
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
6406
|
-
* @param {string} cssString
|
|
6407
|
-
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
6438
|
+
/**
|
|
6439
|
+
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
6440
|
+
* @param {string} cssString
|
|
6441
|
+
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
6408
6442
|
*/
|
|
6409
6443
|
function resolveCssToClearCss(cssString) {
|
|
6410
6444
|
const customVars = {};
|
|
@@ -6540,7 +6574,7 @@ function resolveVariants(selector, variants) {
|
|
|
6540
6574
|
media = breakpoints[v];
|
|
6541
6575
|
} else if (pseudoVariants.has(v)) {
|
|
6542
6576
|
finalSelector += `:${v}`;
|
|
6543
|
-
} else if (v ===
|
|
6577
|
+
} else if (v === "dark") {
|
|
6544
6578
|
// Special handling for dark variant
|
|
6545
6579
|
finalSelector = `.dark ${finalSelector}`;
|
|
6546
6580
|
} else {
|
|
@@ -6688,11 +6722,11 @@ function separateAndResolveCSS(arr) {
|
|
|
6688
6722
|
}
|
|
6689
6723
|
}
|
|
6690
6724
|
|
|
6691
|
-
/**
|
|
6692
|
-
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
6693
|
-
* @param {string} className - Class name with potential opacity modifier
|
|
6694
|
-
* @param {string} cssDeclaration - CSS declaration to modify
|
|
6695
|
-
* @returns {string} Modified CSS declaration with opacity applied
|
|
6725
|
+
/**
|
|
6726
|
+
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
6727
|
+
* @param {string} className - Class name with potential opacity modifier
|
|
6728
|
+
* @param {string} cssDeclaration - CSS declaration to modify
|
|
6729
|
+
* @returns {string} Modified CSS declaration with opacity applied
|
|
6696
6730
|
*/
|
|
6697
6731
|
function processOpacityModifier(className, cssDeclaration) {
|
|
6698
6732
|
const opacityMatch = className.match(/\/(\d+)$/);
|
|
@@ -6753,11 +6787,11 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
6753
6787
|
return modifiedDeclaration;
|
|
6754
6788
|
}
|
|
6755
6789
|
|
|
6756
|
-
/**
|
|
6757
|
-
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
6758
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
6759
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
6760
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
6790
|
+
/**
|
|
6791
|
+
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
6792
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
6793
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
6794
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
6761
6795
|
*/
|
|
6762
6796
|
function tws(classNames, convertToJson) {
|
|
6763
6797
|
const totalMarker = performanceMonitor.start("tws:total");
|
|
@@ -6883,7 +6917,7 @@ const performanceMonitor = {
|
|
|
6883
6917
|
function expandDirectiveGroups(str) {
|
|
6884
6918
|
return str.replace(/(\w+)\(([^()]+)\)/g, (_, directive, content) => {
|
|
6885
6919
|
// Special handling for dark mode syntax: dark:(classes)
|
|
6886
|
-
if (directive ===
|
|
6920
|
+
if (directive === "dark") {
|
|
6887
6921
|
return content.trim().split(/\s+/).map(cls => `dark:${cls}`).join(" ");
|
|
6888
6922
|
}
|
|
6889
6923
|
return content.trim().split(/\s+/).map(val => {
|
|
@@ -7025,7 +7059,7 @@ function processNestedSelectors(nested, selector, styles, walk) {
|
|
|
7025
7059
|
const cssDeclarations = Object.entries(nestedVal).map(_ref3 => {
|
|
7026
7060
|
let [key, value] = _ref3;
|
|
7027
7061
|
// Ensure CSS values are properly formatted and not processed through Tailwind conversion
|
|
7028
|
-
const cleanValue = typeof value ===
|
|
7062
|
+
const cleanValue = typeof value === "string" ? value.trim() : String(value);
|
|
7029
7063
|
return `${key}: ${cleanValue};`;
|
|
7030
7064
|
}).join(" ");
|
|
7031
7065
|
if (selector in styles) {
|
|
@@ -7085,12 +7119,12 @@ function walkStyleTree(selector, val, styles, walk) {
|
|
|
7085
7119
|
}
|
|
7086
7120
|
|
|
7087
7121
|
// Check if this is a @css object within the current object
|
|
7088
|
-
if (val[
|
|
7122
|
+
if (val["@css"] && typeof val["@css"] === "object") {
|
|
7089
7123
|
// Handle object with @css directive - process the @css part specially
|
|
7090
|
-
const cssDeclarations = Object.entries(val[
|
|
7124
|
+
const cssDeclarations = Object.entries(val["@css"]).map(_ref4 => {
|
|
7091
7125
|
let [key, value] = _ref4;
|
|
7092
7126
|
// Keep CSS values intact without any processing
|
|
7093
|
-
const cleanValue = typeof value ===
|
|
7127
|
+
const cleanValue = typeof value === "string" ? value.trim() : String(value);
|
|
7094
7128
|
return `${key}: ${cleanValue};`;
|
|
7095
7129
|
}).join(" ");
|
|
7096
7130
|
if (selector in styles) {
|
|
@@ -7103,7 +7137,7 @@ function walkStyleTree(selector, val, styles, walk) {
|
|
|
7103
7137
|
const otherProps = {
|
|
7104
7138
|
...val
|
|
7105
7139
|
};
|
|
7106
|
-
delete otherProps[
|
|
7140
|
+
delete otherProps["@css"];
|
|
7107
7141
|
if (Object.keys(otherProps).length > 0) {
|
|
7108
7142
|
processNestedSelectors(otherProps, selector, styles, walk);
|
|
7109
7143
|
}
|
|
@@ -7194,12 +7228,12 @@ function generateCssString(styles) {
|
|
|
7194
7228
|
return cssString.trim();
|
|
7195
7229
|
}
|
|
7196
7230
|
|
|
7197
|
-
/**
|
|
7198
|
-
* Generate CSS string from style object with SCSS-like syntax
|
|
7199
|
-
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
7200
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
7201
|
-
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
7202
|
-
* @returns {string} Generated CSS string
|
|
7231
|
+
/**
|
|
7232
|
+
* Generate CSS string from style object with SCSS-like syntax
|
|
7233
|
+
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
7234
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
7235
|
+
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
7236
|
+
* @returns {string} Generated CSS string
|
|
7203
7237
|
*/
|
|
7204
7238
|
function twsx(obj) {
|
|
7205
7239
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -7341,19 +7375,19 @@ function autoInjectCss(cssString) {
|
|
|
7341
7375
|
}
|
|
7342
7376
|
|
|
7343
7377
|
// Enhanced debounced functions with performance monitoring configuration
|
|
7344
|
-
/**
|
|
7345
|
-
* Debounced version of tws function with performance monitoring
|
|
7346
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
7347
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
7348
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
7378
|
+
/**
|
|
7379
|
+
* Debounced version of tws function with performance monitoring
|
|
7380
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
7381
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
7382
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
7349
7383
|
*/
|
|
7350
7384
|
const debouncedTws = debounce(tws, 50); // Faster debounce for tws
|
|
7351
7385
|
|
|
7352
|
-
/**
|
|
7353
|
-
* Debounced version of twsx function with performance monitoring
|
|
7354
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
7355
|
-
* @param {Object} [options] - Additional options
|
|
7356
|
-
* @returns {string} Generated CSS string
|
|
7386
|
+
/**
|
|
7387
|
+
* Debounced version of twsx function with performance monitoring
|
|
7388
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
7389
|
+
* @param {Object} [options] - Additional options
|
|
7390
|
+
* @returns {string} Generated CSS string
|
|
7357
7391
|
*/
|
|
7358
7392
|
const debouncedTwsx = debounce(twsx, 100); // Standard debounce for twsx
|
|
7359
7393
|
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tailwind-to-style v2.9.
|
|
2
|
+
* tailwind-to-style v2.9.2
|
|
3
3
|
* Convert tailwind classes to inline style
|
|
4
4
|
*
|
|
5
5
|
* @author Bigetion
|
|
@@ -3244,6 +3244,7 @@ function generator$1C() {
|
|
|
3244
3244
|
theme = {}
|
|
3245
3245
|
} = configOptions;
|
|
3246
3246
|
const prefix = `${globalPrefix}font`;
|
|
3247
|
+
const customPrefix = `${globalPrefix}font-weight`;
|
|
3247
3248
|
const {
|
|
3248
3249
|
fontWeight = {}
|
|
3249
3250
|
} = theme;
|
|
@@ -3251,11 +3252,20 @@ function generator$1C() {
|
|
|
3251
3252
|
let {
|
|
3252
3253
|
getCssByOptions
|
|
3253
3254
|
} = _ref;
|
|
3254
|
-
const cssString = getCssByOptions(fontWeight, (key, value) =>
|
|
3255
|
+
const cssString = getCssByOptions(fontWeight, (key, value) => {
|
|
3256
|
+
if (value === "custom_value") {
|
|
3257
|
+
return `
|
|
3258
|
+
${customPrefix}${key} {
|
|
3259
|
+
font-weight: ${value};
|
|
3260
|
+
}
|
|
3261
|
+
`;
|
|
3262
|
+
}
|
|
3263
|
+
return `
|
|
3255
3264
|
${prefix}-${key} {
|
|
3256
3265
|
font-weight: ${value};
|
|
3257
3266
|
}
|
|
3258
|
-
|
|
3267
|
+
`;
|
|
3268
|
+
});
|
|
3259
3269
|
return cssString;
|
|
3260
3270
|
}, configOptions);
|
|
3261
3271
|
return responsiveCssString;
|
|
@@ -6219,8 +6229,32 @@ const transition = {
|
|
|
6219
6229
|
}
|
|
6220
6230
|
};
|
|
6221
6231
|
|
|
6232
|
+
const fontFamily = {
|
|
6233
|
+
fontCustom: {
|
|
6234
|
+
regex: /^font-\[([^\]]+)\]$/,
|
|
6235
|
+
cssProp: "font-family",
|
|
6236
|
+
formatter: value => {
|
|
6237
|
+
// Decode URL-encoded value first (in case it comes from bracket encoding)
|
|
6238
|
+
const decodedValue = decodeURIComponent(value.replace(/__P__/g, "(").replace(/__C__/g, ")"));
|
|
6239
|
+
|
|
6240
|
+
// Split by comma and process each font
|
|
6241
|
+
const fonts = decodedValue.split(",").map(font => {
|
|
6242
|
+
const trimmedFont = font.trim();
|
|
6243
|
+
|
|
6244
|
+
// If font contains spaces and is not already quoted, add quotes
|
|
6245
|
+
if (trimmedFont.includes(" ") && !trimmedFont.startsWith('"') && !trimmedFont.startsWith("'")) {
|
|
6246
|
+
return `"${trimmedFont}"`;
|
|
6247
|
+
}
|
|
6248
|
+
return trimmedFont;
|
|
6249
|
+
});
|
|
6250
|
+
return fonts.join(", ");
|
|
6251
|
+
}
|
|
6252
|
+
}
|
|
6253
|
+
};
|
|
6254
|
+
|
|
6222
6255
|
const patterns = {
|
|
6223
|
-
...transition
|
|
6256
|
+
...transition,
|
|
6257
|
+
...fontFamily
|
|
6224
6258
|
};
|
|
6225
6259
|
|
|
6226
6260
|
const plugins = {
|
|
@@ -6397,10 +6431,10 @@ function parseCustomClassWithPatterns(className) {
|
|
|
6397
6431
|
return null;
|
|
6398
6432
|
}
|
|
6399
6433
|
|
|
6400
|
-
/**
|
|
6401
|
-
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
6402
|
-
* @param {string} cssString
|
|
6403
|
-
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
6434
|
+
/**
|
|
6435
|
+
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
6436
|
+
* @param {string} cssString
|
|
6437
|
+
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
6404
6438
|
*/
|
|
6405
6439
|
function resolveCssToClearCss(cssString) {
|
|
6406
6440
|
const customVars = {};
|
|
@@ -6536,7 +6570,7 @@ function resolveVariants(selector, variants) {
|
|
|
6536
6570
|
media = breakpoints[v];
|
|
6537
6571
|
} else if (pseudoVariants.has(v)) {
|
|
6538
6572
|
finalSelector += `:${v}`;
|
|
6539
|
-
} else if (v ===
|
|
6573
|
+
} else if (v === "dark") {
|
|
6540
6574
|
// Special handling for dark variant
|
|
6541
6575
|
finalSelector = `.dark ${finalSelector}`;
|
|
6542
6576
|
} else {
|
|
@@ -6684,11 +6718,11 @@ function separateAndResolveCSS(arr) {
|
|
|
6684
6718
|
}
|
|
6685
6719
|
}
|
|
6686
6720
|
|
|
6687
|
-
/**
|
|
6688
|
-
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
6689
|
-
* @param {string} className - Class name with potential opacity modifier
|
|
6690
|
-
* @param {string} cssDeclaration - CSS declaration to modify
|
|
6691
|
-
* @returns {string} Modified CSS declaration with opacity applied
|
|
6721
|
+
/**
|
|
6722
|
+
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
6723
|
+
* @param {string} className - Class name with potential opacity modifier
|
|
6724
|
+
* @param {string} cssDeclaration - CSS declaration to modify
|
|
6725
|
+
* @returns {string} Modified CSS declaration with opacity applied
|
|
6692
6726
|
*/
|
|
6693
6727
|
function processOpacityModifier(className, cssDeclaration) {
|
|
6694
6728
|
const opacityMatch = className.match(/\/(\d+)$/);
|
|
@@ -6749,11 +6783,11 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
6749
6783
|
return modifiedDeclaration;
|
|
6750
6784
|
}
|
|
6751
6785
|
|
|
6752
|
-
/**
|
|
6753
|
-
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
6754
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
6755
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
6756
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
6786
|
+
/**
|
|
6787
|
+
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
6788
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
6789
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
6790
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
6757
6791
|
*/
|
|
6758
6792
|
function tws(classNames, convertToJson) {
|
|
6759
6793
|
const totalMarker = performanceMonitor.start("tws:total");
|
|
@@ -6879,7 +6913,7 @@ const performanceMonitor = {
|
|
|
6879
6913
|
function expandDirectiveGroups(str) {
|
|
6880
6914
|
return str.replace(/(\w+)\(([^()]+)\)/g, (_, directive, content) => {
|
|
6881
6915
|
// Special handling for dark mode syntax: dark:(classes)
|
|
6882
|
-
if (directive ===
|
|
6916
|
+
if (directive === "dark") {
|
|
6883
6917
|
return content.trim().split(/\s+/).map(cls => `dark:${cls}`).join(" ");
|
|
6884
6918
|
}
|
|
6885
6919
|
return content.trim().split(/\s+/).map(val => {
|
|
@@ -7021,7 +7055,7 @@ function processNestedSelectors(nested, selector, styles, walk) {
|
|
|
7021
7055
|
const cssDeclarations = Object.entries(nestedVal).map(_ref3 => {
|
|
7022
7056
|
let [key, value] = _ref3;
|
|
7023
7057
|
// Ensure CSS values are properly formatted and not processed through Tailwind conversion
|
|
7024
|
-
const cleanValue = typeof value ===
|
|
7058
|
+
const cleanValue = typeof value === "string" ? value.trim() : String(value);
|
|
7025
7059
|
return `${key}: ${cleanValue};`;
|
|
7026
7060
|
}).join(" ");
|
|
7027
7061
|
if (selector in styles) {
|
|
@@ -7081,12 +7115,12 @@ function walkStyleTree(selector, val, styles, walk) {
|
|
|
7081
7115
|
}
|
|
7082
7116
|
|
|
7083
7117
|
// Check if this is a @css object within the current object
|
|
7084
|
-
if (val[
|
|
7118
|
+
if (val["@css"] && typeof val["@css"] === "object") {
|
|
7085
7119
|
// Handle object with @css directive - process the @css part specially
|
|
7086
|
-
const cssDeclarations = Object.entries(val[
|
|
7120
|
+
const cssDeclarations = Object.entries(val["@css"]).map(_ref4 => {
|
|
7087
7121
|
let [key, value] = _ref4;
|
|
7088
7122
|
// Keep CSS values intact without any processing
|
|
7089
|
-
const cleanValue = typeof value ===
|
|
7123
|
+
const cleanValue = typeof value === "string" ? value.trim() : String(value);
|
|
7090
7124
|
return `${key}: ${cleanValue};`;
|
|
7091
7125
|
}).join(" ");
|
|
7092
7126
|
if (selector in styles) {
|
|
@@ -7099,7 +7133,7 @@ function walkStyleTree(selector, val, styles, walk) {
|
|
|
7099
7133
|
const otherProps = {
|
|
7100
7134
|
...val
|
|
7101
7135
|
};
|
|
7102
|
-
delete otherProps[
|
|
7136
|
+
delete otherProps["@css"];
|
|
7103
7137
|
if (Object.keys(otherProps).length > 0) {
|
|
7104
7138
|
processNestedSelectors(otherProps, selector, styles, walk);
|
|
7105
7139
|
}
|
|
@@ -7190,12 +7224,12 @@ function generateCssString(styles) {
|
|
|
7190
7224
|
return cssString.trim();
|
|
7191
7225
|
}
|
|
7192
7226
|
|
|
7193
|
-
/**
|
|
7194
|
-
* Generate CSS string from style object with SCSS-like syntax
|
|
7195
|
-
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
7196
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
7197
|
-
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
7198
|
-
* @returns {string} Generated CSS string
|
|
7227
|
+
/**
|
|
7228
|
+
* Generate CSS string from style object with SCSS-like syntax
|
|
7229
|
+
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
7230
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
7231
|
+
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
7232
|
+
* @returns {string} Generated CSS string
|
|
7199
7233
|
*/
|
|
7200
7234
|
function twsx(obj) {
|
|
7201
7235
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -7337,19 +7371,19 @@ function autoInjectCss(cssString) {
|
|
|
7337
7371
|
}
|
|
7338
7372
|
|
|
7339
7373
|
// Enhanced debounced functions with performance monitoring configuration
|
|
7340
|
-
/**
|
|
7341
|
-
* Debounced version of tws function with performance monitoring
|
|
7342
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
7343
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
7344
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
7374
|
+
/**
|
|
7375
|
+
* Debounced version of tws function with performance monitoring
|
|
7376
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
7377
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
7378
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
7345
7379
|
*/
|
|
7346
7380
|
const debouncedTws = debounce(tws, 50); // Faster debounce for tws
|
|
7347
7381
|
|
|
7348
|
-
/**
|
|
7349
|
-
* Debounced version of twsx function with performance monitoring
|
|
7350
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
7351
|
-
* @param {Object} [options] - Additional options
|
|
7352
|
-
* @returns {string} Generated CSS string
|
|
7382
|
+
/**
|
|
7383
|
+
* Debounced version of twsx function with performance monitoring
|
|
7384
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
7385
|
+
* @param {Object} [options] - Additional options
|
|
7386
|
+
* @returns {string} Generated CSS string
|
|
7353
7387
|
*/
|
|
7354
7388
|
const debouncedTwsx = debounce(twsx, 100); // Standard debounce for twsx
|
|
7355
7389
|
|