tailwind-to-style 2.10.2 → 2.10.3
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.browser.js +125 -38
- package/dist/index.cjs +125 -38
- package/dist/index.esm.js +125 -38
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/react.cjs.js +127 -40
- package/dist/react.esm.js +127 -40
- package/package.json +1 -1
package/dist/index.browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tailwind-to-style v2.10.
|
|
2
|
+
* tailwind-to-style v2.10.3
|
|
3
3
|
* Convert tailwind classes to inline style
|
|
4
4
|
*
|
|
5
5
|
* @author Bigetion
|
|
@@ -25,6 +25,8 @@ var tailwindToStyle = (function (exports) {
|
|
|
25
25
|
ping: "ping 1s cubic-bezier(0, 0, 0.2, 1) infinite",
|
|
26
26
|
pulse: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
|
|
27
27
|
bounce: "bounce 1s infinite",
|
|
28
|
+
"fade-in": "fadeIn 2s ease-in-out infinite",
|
|
29
|
+
"slide-up": "slideUp 2s ease-in-out infinite",
|
|
28
30
|
custom: "custom_value"
|
|
29
31
|
},
|
|
30
32
|
aspectRatio: {
|
|
@@ -1541,6 +1543,31 @@ var tailwindToStyle = (function (exports) {
|
|
|
1541
1543
|
transform: "none",
|
|
1542
1544
|
animationTimingFunction: "cubic-bezier(0,0,0.2,1)"
|
|
1543
1545
|
}
|
|
1546
|
+
},
|
|
1547
|
+
fadeIn: {
|
|
1548
|
+
"0%": {
|
|
1549
|
+
opacity: "0"
|
|
1550
|
+
},
|
|
1551
|
+
"50%": {
|
|
1552
|
+
opacity: "1"
|
|
1553
|
+
},
|
|
1554
|
+
"100%": {
|
|
1555
|
+
opacity: "0"
|
|
1556
|
+
}
|
|
1557
|
+
},
|
|
1558
|
+
slideUp: {
|
|
1559
|
+
"0%": {
|
|
1560
|
+
transform: "translateY(20px)",
|
|
1561
|
+
opacity: "0"
|
|
1562
|
+
},
|
|
1563
|
+
"50%": {
|
|
1564
|
+
transform: "translateY(0)",
|
|
1565
|
+
opacity: "1"
|
|
1566
|
+
},
|
|
1567
|
+
"100%": {
|
|
1568
|
+
transform: "translateY(-20px)",
|
|
1569
|
+
opacity: "0"
|
|
1570
|
+
}
|
|
1544
1571
|
}
|
|
1545
1572
|
},
|
|
1546
1573
|
transitionProperty: {
|
|
@@ -2446,18 +2473,39 @@ var tailwindToStyle = (function (exports) {
|
|
|
2446
2473
|
} = configOptions;
|
|
2447
2474
|
const prefix = `${globalPrefix}animate`;
|
|
2448
2475
|
const {
|
|
2449
|
-
animation = {}
|
|
2476
|
+
animation = {},
|
|
2477
|
+
keyframes = {}
|
|
2450
2478
|
} = theme;
|
|
2451
2479
|
const responsiveCssString = generateCssString$1(_ref => {
|
|
2452
2480
|
let {
|
|
2453
2481
|
getCssByOptions
|
|
2454
2482
|
} = _ref;
|
|
2455
|
-
//
|
|
2483
|
+
// Generate keyframes first
|
|
2484
|
+
let keyframesCSS = "";
|
|
2485
|
+
for (const [name, keyframe] of Object.entries(keyframes)) {
|
|
2486
|
+
keyframesCSS += `@keyframes ${name} {\n`;
|
|
2487
|
+
for (const [percentage, styles] of Object.entries(keyframe)) {
|
|
2488
|
+
keyframesCSS += ` ${percentage} {\n`;
|
|
2489
|
+
for (const [prop, value] of Object.entries(styles)) {
|
|
2490
|
+
const cssProp = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
2491
|
+
keyframesCSS += ` ${cssProp}: ${value};\n`;
|
|
2492
|
+
}
|
|
2493
|
+
keyframesCSS += " }\n";
|
|
2494
|
+
}
|
|
2495
|
+
keyframesCSS += "}\n";
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2498
|
+
// Merge theme animations with inline animations (but skip inline if keyframes exist)
|
|
2456
2499
|
const allAnimations = {
|
|
2457
2500
|
...animation,
|
|
2458
|
-
// Add inline animations to the mix
|
|
2501
|
+
// Add inline animations to the mix, but skip if keyframes version exists
|
|
2459
2502
|
...Object.keys(INLINE_ANIMATIONS).reduce((acc, key) => {
|
|
2460
|
-
|
|
2503
|
+
// Check if keyframes version exists (both camelCase and kebab-case)
|
|
2504
|
+
const camelCaseKey = key.replace(/-([a-z])/g, (match, letter) => letter.toUpperCase());
|
|
2505
|
+
const hasKeyframes = keyframes[key] || keyframes[camelCaseKey];
|
|
2506
|
+
if (!hasKeyframes) {
|
|
2507
|
+
acc[key] = `inline-${key}`; // Special marker for inline animations
|
|
2508
|
+
}
|
|
2461
2509
|
return acc;
|
|
2462
2510
|
}, {})
|
|
2463
2511
|
};
|
|
@@ -2503,7 +2551,9 @@ var tailwindToStyle = (function (exports) {
|
|
|
2503
2551
|
}
|
|
2504
2552
|
`;
|
|
2505
2553
|
});
|
|
2506
|
-
|
|
2554
|
+
|
|
2555
|
+
// Combine keyframes and animation classes
|
|
2556
|
+
return keyframesCSS + cssString;
|
|
2507
2557
|
}, configOptions);
|
|
2508
2558
|
return responsiveCssString;
|
|
2509
2559
|
}
|
|
@@ -8324,10 +8374,10 @@ var tailwindToStyle = (function (exports) {
|
|
|
8324
8374
|
return null;
|
|
8325
8375
|
}
|
|
8326
8376
|
|
|
8327
|
-
/**
|
|
8328
|
-
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
8329
|
-
* @param {string} cssString
|
|
8330
|
-
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
8377
|
+
/**
|
|
8378
|
+
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
8379
|
+
* @param {string} cssString
|
|
8380
|
+
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
8331
8381
|
*/
|
|
8332
8382
|
function resolveCssToClearCss(cssString) {
|
|
8333
8383
|
const customVars = {};
|
|
@@ -8621,11 +8671,11 @@ var tailwindToStyle = (function (exports) {
|
|
|
8621
8671
|
}
|
|
8622
8672
|
}
|
|
8623
8673
|
|
|
8624
|
-
/**
|
|
8625
|
-
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
8626
|
-
* @param {string} className - Class name with potential opacity modifier
|
|
8627
|
-
* @param {string} cssDeclaration - CSS declaration to modify
|
|
8628
|
-
* @returns {string} Modified CSS declaration with opacity applied
|
|
8674
|
+
/**
|
|
8675
|
+
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
8676
|
+
* @param {string} className - Class name with potential opacity modifier
|
|
8677
|
+
* @param {string} cssDeclaration - CSS declaration to modify
|
|
8678
|
+
* @returns {string} Modified CSS declaration with opacity applied
|
|
8629
8679
|
*/
|
|
8630
8680
|
function processOpacityModifier(className, cssDeclaration) {
|
|
8631
8681
|
const opacityMatch = className.match(/\/(\d+)$/);
|
|
@@ -8686,11 +8736,11 @@ var tailwindToStyle = (function (exports) {
|
|
|
8686
8736
|
return modifiedDeclaration;
|
|
8687
8737
|
}
|
|
8688
8738
|
|
|
8689
|
-
/**
|
|
8690
|
-
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
8691
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
8692
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
8693
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
8739
|
+
/**
|
|
8740
|
+
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
8741
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
8742
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
8743
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
8694
8744
|
*/
|
|
8695
8745
|
function tws(classNames, convertToJson) {
|
|
8696
8746
|
const totalMarker = performanceMonitor.start("tws:total");
|
|
@@ -9134,17 +9184,18 @@ var tailwindToStyle = (function (exports) {
|
|
|
9134
9184
|
return cssString.trim();
|
|
9135
9185
|
}
|
|
9136
9186
|
|
|
9137
|
-
/**
|
|
9138
|
-
* Generate CSS string from style object with SCSS-like syntax
|
|
9139
|
-
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
9140
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
9141
|
-
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
9142
|
-
* @returns {string} Generated CSS string
|
|
9187
|
+
/**
|
|
9188
|
+
* Generate CSS string from style object with SCSS-like syntax
|
|
9189
|
+
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
9190
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
9191
|
+
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
9192
|
+
* @returns {string} Generated CSS string
|
|
9143
9193
|
*/
|
|
9144
9194
|
function twsx(obj) {
|
|
9145
9195
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
9146
9196
|
const totalMarker = performanceMonitor.start("twsx:total");
|
|
9147
9197
|
try {
|
|
9198
|
+
var _options$theme2, _userConfigData$theme2;
|
|
9148
9199
|
if (!obj || typeof obj !== "object") {
|
|
9149
9200
|
logger.warn("twsx: Expected an object but received:", obj);
|
|
9150
9201
|
return "";
|
|
@@ -9221,12 +9272,48 @@ var tailwindToStyle = (function (exports) {
|
|
|
9221
9272
|
// Generate CSS string
|
|
9222
9273
|
const cssString = performanceMonitor.measure(() => generateCssString(styles), "twsx:generate");
|
|
9223
9274
|
|
|
9275
|
+
// Generate keyframes CSS separately
|
|
9276
|
+
const keyframesMarker = performanceMonitor.start("twsx:keyframes");
|
|
9277
|
+
const userConfigData = getConfig();
|
|
9278
|
+
const mergedOptions = {
|
|
9279
|
+
...options,
|
|
9280
|
+
theme: {
|
|
9281
|
+
...options.theme,
|
|
9282
|
+
...userConfigData.theme,
|
|
9283
|
+
extend: {
|
|
9284
|
+
...((_options$theme2 = options.theme) === null || _options$theme2 === void 0 ? void 0 : _options$theme2.extend),
|
|
9285
|
+
...((_userConfigData$theme2 = userConfigData.theme) === null || _userConfigData$theme2 === void 0 ? void 0 : _userConfigData$theme2.extend)
|
|
9286
|
+
}
|
|
9287
|
+
}
|
|
9288
|
+
};
|
|
9289
|
+
const configOptions = getConfigOptions(mergedOptions, Object.keys(plugins));
|
|
9290
|
+
const {
|
|
9291
|
+
keyframes = {}
|
|
9292
|
+
} = configOptions.theme || {};
|
|
9293
|
+
let keyframesCSS = "";
|
|
9294
|
+
for (const [name, keyframe] of Object.entries(keyframes)) {
|
|
9295
|
+
keyframesCSS += `@keyframes ${name} {\n`;
|
|
9296
|
+
for (const [percentage, styles] of Object.entries(keyframe)) {
|
|
9297
|
+
keyframesCSS += ` ${percentage} {\n`;
|
|
9298
|
+
for (const [prop, value] of Object.entries(styles)) {
|
|
9299
|
+
const cssProp = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
9300
|
+
keyframesCSS += ` ${cssProp}: ${value};\n`;
|
|
9301
|
+
}
|
|
9302
|
+
keyframesCSS += ` }\n`;
|
|
9303
|
+
}
|
|
9304
|
+
keyframesCSS += `}\n`;
|
|
9305
|
+
}
|
|
9306
|
+
performanceMonitor.end(keyframesMarker);
|
|
9307
|
+
|
|
9308
|
+
// Combine keyframes and regular CSS
|
|
9309
|
+
const finalCSS = keyframesCSS + cssString;
|
|
9310
|
+
|
|
9224
9311
|
// Auto-inject if needed
|
|
9225
9312
|
if (inject && typeof window !== "undefined" && typeof document !== "undefined") {
|
|
9226
|
-
performanceMonitor.measure(() => autoInjectCss(
|
|
9313
|
+
performanceMonitor.measure(() => autoInjectCss(finalCSS), "twsx:inject");
|
|
9227
9314
|
}
|
|
9228
9315
|
performanceMonitor.end(totalMarker);
|
|
9229
|
-
return
|
|
9316
|
+
return finalCSS;
|
|
9230
9317
|
} catch (error) {
|
|
9231
9318
|
performanceMonitor.end(totalMarker);
|
|
9232
9319
|
handleError(error, {
|
|
@@ -9284,19 +9371,19 @@ var tailwindToStyle = (function (exports) {
|
|
|
9284
9371
|
}
|
|
9285
9372
|
|
|
9286
9373
|
// Enhanced debounced functions with performance monitoring configuration
|
|
9287
|
-
/**
|
|
9288
|
-
* Debounced version of tws function with performance monitoring
|
|
9289
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
9290
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
9291
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
9374
|
+
/**
|
|
9375
|
+
* Debounced version of tws function with performance monitoring
|
|
9376
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
9377
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
9378
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
9292
9379
|
*/
|
|
9293
9380
|
const debouncedTws = debounce(tws, 50); // Faster debounce for tws
|
|
9294
9381
|
|
|
9295
|
-
/**
|
|
9296
|
-
* Debounced version of twsx function with performance monitoring
|
|
9297
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
9298
|
-
* @param {Object} [options] - Additional options
|
|
9299
|
-
* @returns {string} Generated CSS string
|
|
9382
|
+
/**
|
|
9383
|
+
* Debounced version of twsx function with performance monitoring
|
|
9384
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
9385
|
+
* @param {Object} [options] - Additional options
|
|
9386
|
+
* @returns {string} Generated CSS string
|
|
9300
9387
|
*/
|
|
9301
9388
|
const debouncedTwsx = debounce(twsx, 100); // Standard debounce for twsx
|
|
9302
9389
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tailwind-to-style v2.10.
|
|
2
|
+
* tailwind-to-style v2.10.3
|
|
3
3
|
* Convert tailwind classes to inline style
|
|
4
4
|
*
|
|
5
5
|
* @author Bigetion
|
|
@@ -26,6 +26,8 @@ const theme = {
|
|
|
26
26
|
ping: "ping 1s cubic-bezier(0, 0, 0.2, 1) infinite",
|
|
27
27
|
pulse: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
|
|
28
28
|
bounce: "bounce 1s infinite",
|
|
29
|
+
"fade-in": "fadeIn 2s ease-in-out infinite",
|
|
30
|
+
"slide-up": "slideUp 2s ease-in-out infinite",
|
|
29
31
|
custom: "custom_value"
|
|
30
32
|
},
|
|
31
33
|
aspectRatio: {
|
|
@@ -1542,6 +1544,31 @@ const theme = {
|
|
|
1542
1544
|
transform: "none",
|
|
1543
1545
|
animationTimingFunction: "cubic-bezier(0,0,0.2,1)"
|
|
1544
1546
|
}
|
|
1547
|
+
},
|
|
1548
|
+
fadeIn: {
|
|
1549
|
+
"0%": {
|
|
1550
|
+
opacity: "0"
|
|
1551
|
+
},
|
|
1552
|
+
"50%": {
|
|
1553
|
+
opacity: "1"
|
|
1554
|
+
},
|
|
1555
|
+
"100%": {
|
|
1556
|
+
opacity: "0"
|
|
1557
|
+
}
|
|
1558
|
+
},
|
|
1559
|
+
slideUp: {
|
|
1560
|
+
"0%": {
|
|
1561
|
+
transform: "translateY(20px)",
|
|
1562
|
+
opacity: "0"
|
|
1563
|
+
},
|
|
1564
|
+
"50%": {
|
|
1565
|
+
transform: "translateY(0)",
|
|
1566
|
+
opacity: "1"
|
|
1567
|
+
},
|
|
1568
|
+
"100%": {
|
|
1569
|
+
transform: "translateY(-20px)",
|
|
1570
|
+
opacity: "0"
|
|
1571
|
+
}
|
|
1545
1572
|
}
|
|
1546
1573
|
},
|
|
1547
1574
|
transitionProperty: {
|
|
@@ -2447,18 +2474,39 @@ function generator$2H() {
|
|
|
2447
2474
|
} = configOptions;
|
|
2448
2475
|
const prefix = `${globalPrefix}animate`;
|
|
2449
2476
|
const {
|
|
2450
|
-
animation = {}
|
|
2477
|
+
animation = {},
|
|
2478
|
+
keyframes = {}
|
|
2451
2479
|
} = theme;
|
|
2452
2480
|
const responsiveCssString = generateCssString$1(_ref => {
|
|
2453
2481
|
let {
|
|
2454
2482
|
getCssByOptions
|
|
2455
2483
|
} = _ref;
|
|
2456
|
-
//
|
|
2484
|
+
// Generate keyframes first
|
|
2485
|
+
let keyframesCSS = "";
|
|
2486
|
+
for (const [name, keyframe] of Object.entries(keyframes)) {
|
|
2487
|
+
keyframesCSS += `@keyframes ${name} {\n`;
|
|
2488
|
+
for (const [percentage, styles] of Object.entries(keyframe)) {
|
|
2489
|
+
keyframesCSS += ` ${percentage} {\n`;
|
|
2490
|
+
for (const [prop, value] of Object.entries(styles)) {
|
|
2491
|
+
const cssProp = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
2492
|
+
keyframesCSS += ` ${cssProp}: ${value};\n`;
|
|
2493
|
+
}
|
|
2494
|
+
keyframesCSS += " }\n";
|
|
2495
|
+
}
|
|
2496
|
+
keyframesCSS += "}\n";
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
// Merge theme animations with inline animations (but skip inline if keyframes exist)
|
|
2457
2500
|
const allAnimations = {
|
|
2458
2501
|
...animation,
|
|
2459
|
-
// Add inline animations to the mix
|
|
2502
|
+
// Add inline animations to the mix, but skip if keyframes version exists
|
|
2460
2503
|
...Object.keys(INLINE_ANIMATIONS).reduce((acc, key) => {
|
|
2461
|
-
|
|
2504
|
+
// Check if keyframes version exists (both camelCase and kebab-case)
|
|
2505
|
+
const camelCaseKey = key.replace(/-([a-z])/g, (match, letter) => letter.toUpperCase());
|
|
2506
|
+
const hasKeyframes = keyframes[key] || keyframes[camelCaseKey];
|
|
2507
|
+
if (!hasKeyframes) {
|
|
2508
|
+
acc[key] = `inline-${key}`; // Special marker for inline animations
|
|
2509
|
+
}
|
|
2462
2510
|
return acc;
|
|
2463
2511
|
}, {})
|
|
2464
2512
|
};
|
|
@@ -2504,7 +2552,9 @@ function generator$2H() {
|
|
|
2504
2552
|
}
|
|
2505
2553
|
`;
|
|
2506
2554
|
});
|
|
2507
|
-
|
|
2555
|
+
|
|
2556
|
+
// Combine keyframes and animation classes
|
|
2557
|
+
return keyframesCSS + cssString;
|
|
2508
2558
|
}, configOptions);
|
|
2509
2559
|
return responsiveCssString;
|
|
2510
2560
|
}
|
|
@@ -8325,10 +8375,10 @@ function parseCustomClassWithPatterns(className) {
|
|
|
8325
8375
|
return null;
|
|
8326
8376
|
}
|
|
8327
8377
|
|
|
8328
|
-
/**
|
|
8329
|
-
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
8330
|
-
* @param {string} cssString
|
|
8331
|
-
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
8378
|
+
/**
|
|
8379
|
+
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
8380
|
+
* @param {string} cssString
|
|
8381
|
+
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
8332
8382
|
*/
|
|
8333
8383
|
function resolveCssToClearCss(cssString) {
|
|
8334
8384
|
const customVars = {};
|
|
@@ -8622,11 +8672,11 @@ function separateAndResolveCSS(arr) {
|
|
|
8622
8672
|
}
|
|
8623
8673
|
}
|
|
8624
8674
|
|
|
8625
|
-
/**
|
|
8626
|
-
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
8627
|
-
* @param {string} className - Class name with potential opacity modifier
|
|
8628
|
-
* @param {string} cssDeclaration - CSS declaration to modify
|
|
8629
|
-
* @returns {string} Modified CSS declaration with opacity applied
|
|
8675
|
+
/**
|
|
8676
|
+
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
8677
|
+
* @param {string} className - Class name with potential opacity modifier
|
|
8678
|
+
* @param {string} cssDeclaration - CSS declaration to modify
|
|
8679
|
+
* @returns {string} Modified CSS declaration with opacity applied
|
|
8630
8680
|
*/
|
|
8631
8681
|
function processOpacityModifier(className, cssDeclaration) {
|
|
8632
8682
|
const opacityMatch = className.match(/\/(\d+)$/);
|
|
@@ -8687,11 +8737,11 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
8687
8737
|
return modifiedDeclaration;
|
|
8688
8738
|
}
|
|
8689
8739
|
|
|
8690
|
-
/**
|
|
8691
|
-
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
8692
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
8693
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
8694
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
8740
|
+
/**
|
|
8741
|
+
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
8742
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
8743
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
8744
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
8695
8745
|
*/
|
|
8696
8746
|
function tws(classNames, convertToJson) {
|
|
8697
8747
|
const totalMarker = performanceMonitor.start("tws:total");
|
|
@@ -9135,17 +9185,18 @@ function generateCssString(styles) {
|
|
|
9135
9185
|
return cssString.trim();
|
|
9136
9186
|
}
|
|
9137
9187
|
|
|
9138
|
-
/**
|
|
9139
|
-
* Generate CSS string from style object with SCSS-like syntax
|
|
9140
|
-
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
9141
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
9142
|
-
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
9143
|
-
* @returns {string} Generated CSS string
|
|
9188
|
+
/**
|
|
9189
|
+
* Generate CSS string from style object with SCSS-like syntax
|
|
9190
|
+
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
9191
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
9192
|
+
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
9193
|
+
* @returns {string} Generated CSS string
|
|
9144
9194
|
*/
|
|
9145
9195
|
function twsx(obj) {
|
|
9146
9196
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
9147
9197
|
const totalMarker = performanceMonitor.start("twsx:total");
|
|
9148
9198
|
try {
|
|
9199
|
+
var _options$theme2, _userConfigData$theme2;
|
|
9149
9200
|
if (!obj || typeof obj !== "object") {
|
|
9150
9201
|
logger.warn("twsx: Expected an object but received:", obj);
|
|
9151
9202
|
return "";
|
|
@@ -9222,12 +9273,48 @@ function twsx(obj) {
|
|
|
9222
9273
|
// Generate CSS string
|
|
9223
9274
|
const cssString = performanceMonitor.measure(() => generateCssString(styles), "twsx:generate");
|
|
9224
9275
|
|
|
9276
|
+
// Generate keyframes CSS separately
|
|
9277
|
+
const keyframesMarker = performanceMonitor.start("twsx:keyframes");
|
|
9278
|
+
const userConfigData = getConfig();
|
|
9279
|
+
const mergedOptions = {
|
|
9280
|
+
...options,
|
|
9281
|
+
theme: {
|
|
9282
|
+
...options.theme,
|
|
9283
|
+
...userConfigData.theme,
|
|
9284
|
+
extend: {
|
|
9285
|
+
...((_options$theme2 = options.theme) === null || _options$theme2 === void 0 ? void 0 : _options$theme2.extend),
|
|
9286
|
+
...((_userConfigData$theme2 = userConfigData.theme) === null || _userConfigData$theme2 === void 0 ? void 0 : _userConfigData$theme2.extend)
|
|
9287
|
+
}
|
|
9288
|
+
}
|
|
9289
|
+
};
|
|
9290
|
+
const configOptions = getConfigOptions(mergedOptions, Object.keys(plugins));
|
|
9291
|
+
const {
|
|
9292
|
+
keyframes = {}
|
|
9293
|
+
} = configOptions.theme || {};
|
|
9294
|
+
let keyframesCSS = "";
|
|
9295
|
+
for (const [name, keyframe] of Object.entries(keyframes)) {
|
|
9296
|
+
keyframesCSS += `@keyframes ${name} {\n`;
|
|
9297
|
+
for (const [percentage, styles] of Object.entries(keyframe)) {
|
|
9298
|
+
keyframesCSS += ` ${percentage} {\n`;
|
|
9299
|
+
for (const [prop, value] of Object.entries(styles)) {
|
|
9300
|
+
const cssProp = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
9301
|
+
keyframesCSS += ` ${cssProp}: ${value};\n`;
|
|
9302
|
+
}
|
|
9303
|
+
keyframesCSS += ` }\n`;
|
|
9304
|
+
}
|
|
9305
|
+
keyframesCSS += `}\n`;
|
|
9306
|
+
}
|
|
9307
|
+
performanceMonitor.end(keyframesMarker);
|
|
9308
|
+
|
|
9309
|
+
// Combine keyframes and regular CSS
|
|
9310
|
+
const finalCSS = keyframesCSS + cssString;
|
|
9311
|
+
|
|
9225
9312
|
// Auto-inject if needed
|
|
9226
9313
|
if (inject && typeof window !== "undefined" && typeof document !== "undefined") {
|
|
9227
|
-
performanceMonitor.measure(() => autoInjectCss(
|
|
9314
|
+
performanceMonitor.measure(() => autoInjectCss(finalCSS), "twsx:inject");
|
|
9228
9315
|
}
|
|
9229
9316
|
performanceMonitor.end(totalMarker);
|
|
9230
|
-
return
|
|
9317
|
+
return finalCSS;
|
|
9231
9318
|
} catch (error) {
|
|
9232
9319
|
performanceMonitor.end(totalMarker);
|
|
9233
9320
|
handleError(error, {
|
|
@@ -9285,19 +9372,19 @@ function autoInjectCss(cssString) {
|
|
|
9285
9372
|
}
|
|
9286
9373
|
|
|
9287
9374
|
// Enhanced debounced functions with performance monitoring configuration
|
|
9288
|
-
/**
|
|
9289
|
-
* Debounced version of tws function with performance monitoring
|
|
9290
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
9291
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
9292
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
9375
|
+
/**
|
|
9376
|
+
* Debounced version of tws function with performance monitoring
|
|
9377
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
9378
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
9379
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
9293
9380
|
*/
|
|
9294
9381
|
const debouncedTws = debounce(tws, 50); // Faster debounce for tws
|
|
9295
9382
|
|
|
9296
|
-
/**
|
|
9297
|
-
* Debounced version of twsx function with performance monitoring
|
|
9298
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
9299
|
-
* @param {Object} [options] - Additional options
|
|
9300
|
-
* @returns {string} Generated CSS string
|
|
9383
|
+
/**
|
|
9384
|
+
* Debounced version of twsx function with performance monitoring
|
|
9385
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
9386
|
+
* @param {Object} [options] - Additional options
|
|
9387
|
+
* @returns {string} Generated CSS string
|
|
9301
9388
|
*/
|
|
9302
9389
|
const debouncedTwsx = debounce(twsx, 100); // Standard debounce for twsx
|
|
9303
9390
|
|