tailwind-to-style 2.9.0 → 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 -864
- package/dist/index.browser.js +82 -40
- package/dist/index.cjs +82 -40
- package/dist/index.esm.js +82 -40
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +5 -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 = {};
|
|
@@ -6488,7 +6522,8 @@ var tailwindToStyle = (function (exports) {
|
|
|
6488
6522
|
const pseudoVariants = new Set(["hover", "focus", "focus-within", "active", "visited", "disabled", "first", "last", "checked", "invalid", "required"]);
|
|
6489
6523
|
const specialVariants = {
|
|
6490
6524
|
group: (state, sel) => `.group:${state} ${sel}`,
|
|
6491
|
-
peer: (state, sel) => `.peer:${state} ~ ${sel}
|
|
6525
|
+
peer: (state, sel) => `.peer:${state} ~ ${sel}`,
|
|
6526
|
+
dark: (state, sel) => `.dark ${sel}`
|
|
6492
6527
|
};
|
|
6493
6528
|
const selectorVariants = {
|
|
6494
6529
|
first: () => `> :first-child`,
|
|
@@ -6538,6 +6573,9 @@ var tailwindToStyle = (function (exports) {
|
|
|
6538
6573
|
media = breakpoints[v];
|
|
6539
6574
|
} else if (pseudoVariants.has(v)) {
|
|
6540
6575
|
finalSelector += `:${v}`;
|
|
6576
|
+
} else if (v === "dark") {
|
|
6577
|
+
// Special handling for dark variant
|
|
6578
|
+
finalSelector = `.dark ${finalSelector}`;
|
|
6541
6579
|
} else {
|
|
6542
6580
|
for (const key in specialVariants) {
|
|
6543
6581
|
if (v.startsWith(`${key}-`)) {
|
|
@@ -6683,11 +6721,11 @@ var tailwindToStyle = (function (exports) {
|
|
|
6683
6721
|
}
|
|
6684
6722
|
}
|
|
6685
6723
|
|
|
6686
|
-
/**
|
|
6687
|
-
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
6688
|
-
* @param {string} className - Class name with potential opacity modifier
|
|
6689
|
-
* @param {string} cssDeclaration - CSS declaration to modify
|
|
6690
|
-
* @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
|
|
6691
6729
|
*/
|
|
6692
6730
|
function processOpacityModifier(className, cssDeclaration) {
|
|
6693
6731
|
const opacityMatch = className.match(/\/(\d+)$/);
|
|
@@ -6748,11 +6786,11 @@ var tailwindToStyle = (function (exports) {
|
|
|
6748
6786
|
return modifiedDeclaration;
|
|
6749
6787
|
}
|
|
6750
6788
|
|
|
6751
|
-
/**
|
|
6752
|
-
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
6753
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
6754
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
6755
|
-
* @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
|
|
6756
6794
|
*/
|
|
6757
6795
|
function tws(classNames, convertToJson) {
|
|
6758
6796
|
const totalMarker = performanceMonitor.start("tws:total");
|
|
@@ -6877,6 +6915,10 @@ var tailwindToStyle = (function (exports) {
|
|
|
6877
6915
|
// Utility functions for class expansion
|
|
6878
6916
|
function expandDirectiveGroups(str) {
|
|
6879
6917
|
return str.replace(/(\w+)\(([^()]+)\)/g, (_, directive, content) => {
|
|
6918
|
+
// Special handling for dark mode syntax: dark:(classes)
|
|
6919
|
+
if (directive === "dark") {
|
|
6920
|
+
return content.trim().split(/\s+/).map(cls => `dark:${cls}`).join(" ");
|
|
6921
|
+
}
|
|
6880
6922
|
return content.trim().split(/\s+/).map(val => {
|
|
6881
6923
|
if (val.includes(":")) {
|
|
6882
6924
|
const [variant, v] = val.split(":");
|
|
@@ -7016,7 +7058,7 @@ var tailwindToStyle = (function (exports) {
|
|
|
7016
7058
|
const cssDeclarations = Object.entries(nestedVal).map(_ref3 => {
|
|
7017
7059
|
let [key, value] = _ref3;
|
|
7018
7060
|
// Ensure CSS values are properly formatted and not processed through Tailwind conversion
|
|
7019
|
-
const cleanValue = typeof value ===
|
|
7061
|
+
const cleanValue = typeof value === "string" ? value.trim() : String(value);
|
|
7020
7062
|
return `${key}: ${cleanValue};`;
|
|
7021
7063
|
}).join(" ");
|
|
7022
7064
|
if (selector in styles) {
|
|
@@ -7076,12 +7118,12 @@ var tailwindToStyle = (function (exports) {
|
|
|
7076
7118
|
}
|
|
7077
7119
|
|
|
7078
7120
|
// Check if this is a @css object within the current object
|
|
7079
|
-
if (val[
|
|
7121
|
+
if (val["@css"] && typeof val["@css"] === "object") {
|
|
7080
7122
|
// Handle object with @css directive - process the @css part specially
|
|
7081
|
-
const cssDeclarations = Object.entries(val[
|
|
7123
|
+
const cssDeclarations = Object.entries(val["@css"]).map(_ref4 => {
|
|
7082
7124
|
let [key, value] = _ref4;
|
|
7083
7125
|
// Keep CSS values intact without any processing
|
|
7084
|
-
const cleanValue = typeof value ===
|
|
7126
|
+
const cleanValue = typeof value === "string" ? value.trim() : String(value);
|
|
7085
7127
|
return `${key}: ${cleanValue};`;
|
|
7086
7128
|
}).join(" ");
|
|
7087
7129
|
if (selector in styles) {
|
|
@@ -7094,7 +7136,7 @@ var tailwindToStyle = (function (exports) {
|
|
|
7094
7136
|
const otherProps = {
|
|
7095
7137
|
...val
|
|
7096
7138
|
};
|
|
7097
|
-
delete otherProps[
|
|
7139
|
+
delete otherProps["@css"];
|
|
7098
7140
|
if (Object.keys(otherProps).length > 0) {
|
|
7099
7141
|
processNestedSelectors(otherProps, selector, styles, walk);
|
|
7100
7142
|
}
|
|
@@ -7185,12 +7227,12 @@ var tailwindToStyle = (function (exports) {
|
|
|
7185
7227
|
return cssString.trim();
|
|
7186
7228
|
}
|
|
7187
7229
|
|
|
7188
|
-
/**
|
|
7189
|
-
* Generate CSS string from style object with SCSS-like syntax
|
|
7190
|
-
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
7191
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
7192
|
-
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
7193
|
-
* @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
|
|
7194
7236
|
*/
|
|
7195
7237
|
function twsx(obj) {
|
|
7196
7238
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -7332,19 +7374,19 @@ var tailwindToStyle = (function (exports) {
|
|
|
7332
7374
|
}
|
|
7333
7375
|
|
|
7334
7376
|
// Enhanced debounced functions with performance monitoring configuration
|
|
7335
|
-
/**
|
|
7336
|
-
* Debounced version of tws function with performance monitoring
|
|
7337
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
7338
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
7339
|
-
* @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
|
|
7340
7382
|
*/
|
|
7341
7383
|
const debouncedTws = debounce(tws, 50); // Faster debounce for tws
|
|
7342
7384
|
|
|
7343
|
-
/**
|
|
7344
|
-
* Debounced version of twsx function with performance monitoring
|
|
7345
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
7346
|
-
* @param {Object} [options] - Additional options
|
|
7347
|
-
* @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
|
|
7348
7390
|
*/
|
|
7349
7391
|
const debouncedTwsx = debounce(twsx, 100); // Standard debounce for twsx
|
|
7350
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 = {};
|
|
@@ -6489,7 +6523,8 @@ const breakpoints = {
|
|
|
6489
6523
|
const pseudoVariants = new Set(["hover", "focus", "focus-within", "active", "visited", "disabled", "first", "last", "checked", "invalid", "required"]);
|
|
6490
6524
|
const specialVariants = {
|
|
6491
6525
|
group: (state, sel) => `.group:${state} ${sel}`,
|
|
6492
|
-
peer: (state, sel) => `.peer:${state} ~ ${sel}
|
|
6526
|
+
peer: (state, sel) => `.peer:${state} ~ ${sel}`,
|
|
6527
|
+
dark: (state, sel) => `.dark ${sel}`
|
|
6493
6528
|
};
|
|
6494
6529
|
const selectorVariants = {
|
|
6495
6530
|
first: () => `> :first-child`,
|
|
@@ -6539,6 +6574,9 @@ function resolveVariants(selector, variants) {
|
|
|
6539
6574
|
media = breakpoints[v];
|
|
6540
6575
|
} else if (pseudoVariants.has(v)) {
|
|
6541
6576
|
finalSelector += `:${v}`;
|
|
6577
|
+
} else if (v === "dark") {
|
|
6578
|
+
// Special handling for dark variant
|
|
6579
|
+
finalSelector = `.dark ${finalSelector}`;
|
|
6542
6580
|
} else {
|
|
6543
6581
|
for (const key in specialVariants) {
|
|
6544
6582
|
if (v.startsWith(`${key}-`)) {
|
|
@@ -6684,11 +6722,11 @@ function separateAndResolveCSS(arr) {
|
|
|
6684
6722
|
}
|
|
6685
6723
|
}
|
|
6686
6724
|
|
|
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
|
|
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
|
|
6692
6730
|
*/
|
|
6693
6731
|
function processOpacityModifier(className, cssDeclaration) {
|
|
6694
6732
|
const opacityMatch = className.match(/\/(\d+)$/);
|
|
@@ -6749,11 +6787,11 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
6749
6787
|
return modifiedDeclaration;
|
|
6750
6788
|
}
|
|
6751
6789
|
|
|
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
|
|
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
|
|
6757
6795
|
*/
|
|
6758
6796
|
function tws(classNames, convertToJson) {
|
|
6759
6797
|
const totalMarker = performanceMonitor.start("tws:total");
|
|
@@ -6878,6 +6916,10 @@ const performanceMonitor = {
|
|
|
6878
6916
|
// Utility functions for class expansion
|
|
6879
6917
|
function expandDirectiveGroups(str) {
|
|
6880
6918
|
return str.replace(/(\w+)\(([^()]+)\)/g, (_, directive, content) => {
|
|
6919
|
+
// Special handling for dark mode syntax: dark:(classes)
|
|
6920
|
+
if (directive === "dark") {
|
|
6921
|
+
return content.trim().split(/\s+/).map(cls => `dark:${cls}`).join(" ");
|
|
6922
|
+
}
|
|
6881
6923
|
return content.trim().split(/\s+/).map(val => {
|
|
6882
6924
|
if (val.includes(":")) {
|
|
6883
6925
|
const [variant, v] = val.split(":");
|
|
@@ -7017,7 +7059,7 @@ function processNestedSelectors(nested, selector, styles, walk) {
|
|
|
7017
7059
|
const cssDeclarations = Object.entries(nestedVal).map(_ref3 => {
|
|
7018
7060
|
let [key, value] = _ref3;
|
|
7019
7061
|
// Ensure CSS values are properly formatted and not processed through Tailwind conversion
|
|
7020
|
-
const cleanValue = typeof value ===
|
|
7062
|
+
const cleanValue = typeof value === "string" ? value.trim() : String(value);
|
|
7021
7063
|
return `${key}: ${cleanValue};`;
|
|
7022
7064
|
}).join(" ");
|
|
7023
7065
|
if (selector in styles) {
|
|
@@ -7077,12 +7119,12 @@ function walkStyleTree(selector, val, styles, walk) {
|
|
|
7077
7119
|
}
|
|
7078
7120
|
|
|
7079
7121
|
// Check if this is a @css object within the current object
|
|
7080
|
-
if (val[
|
|
7122
|
+
if (val["@css"] && typeof val["@css"] === "object") {
|
|
7081
7123
|
// Handle object with @css directive - process the @css part specially
|
|
7082
|
-
const cssDeclarations = Object.entries(val[
|
|
7124
|
+
const cssDeclarations = Object.entries(val["@css"]).map(_ref4 => {
|
|
7083
7125
|
let [key, value] = _ref4;
|
|
7084
7126
|
// Keep CSS values intact without any processing
|
|
7085
|
-
const cleanValue = typeof value ===
|
|
7127
|
+
const cleanValue = typeof value === "string" ? value.trim() : String(value);
|
|
7086
7128
|
return `${key}: ${cleanValue};`;
|
|
7087
7129
|
}).join(" ");
|
|
7088
7130
|
if (selector in styles) {
|
|
@@ -7095,7 +7137,7 @@ function walkStyleTree(selector, val, styles, walk) {
|
|
|
7095
7137
|
const otherProps = {
|
|
7096
7138
|
...val
|
|
7097
7139
|
};
|
|
7098
|
-
delete otherProps[
|
|
7140
|
+
delete otherProps["@css"];
|
|
7099
7141
|
if (Object.keys(otherProps).length > 0) {
|
|
7100
7142
|
processNestedSelectors(otherProps, selector, styles, walk);
|
|
7101
7143
|
}
|
|
@@ -7186,12 +7228,12 @@ function generateCssString(styles) {
|
|
|
7186
7228
|
return cssString.trim();
|
|
7187
7229
|
}
|
|
7188
7230
|
|
|
7189
|
-
/**
|
|
7190
|
-
* Generate CSS string from style object with SCSS-like syntax
|
|
7191
|
-
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
7192
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
7193
|
-
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
7194
|
-
* @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
|
|
7195
7237
|
*/
|
|
7196
7238
|
function twsx(obj) {
|
|
7197
7239
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -7333,19 +7375,19 @@ function autoInjectCss(cssString) {
|
|
|
7333
7375
|
}
|
|
7334
7376
|
|
|
7335
7377
|
// Enhanced debounced functions with performance monitoring configuration
|
|
7336
|
-
/**
|
|
7337
|
-
* Debounced version of tws function with performance monitoring
|
|
7338
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
7339
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
7340
|
-
* @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
|
|
7341
7383
|
*/
|
|
7342
7384
|
const debouncedTws = debounce(tws, 50); // Faster debounce for tws
|
|
7343
7385
|
|
|
7344
|
-
/**
|
|
7345
|
-
* Debounced version of twsx function with performance monitoring
|
|
7346
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
7347
|
-
* @param {Object} [options] - Additional options
|
|
7348
|
-
* @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
|
|
7349
7391
|
*/
|
|
7350
7392
|
const debouncedTwsx = debounce(twsx, 100); // Standard debounce for twsx
|
|
7351
7393
|
|