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/react.cjs.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
|
|
@@ -28,6 +28,8 @@ const theme = {
|
|
|
28
28
|
ping: "ping 1s cubic-bezier(0, 0, 0.2, 1) infinite",
|
|
29
29
|
pulse: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
|
|
30
30
|
bounce: "bounce 1s infinite",
|
|
31
|
+
"fade-in": "fadeIn 2s ease-in-out infinite",
|
|
32
|
+
"slide-up": "slideUp 2s ease-in-out infinite",
|
|
31
33
|
custom: "custom_value"
|
|
32
34
|
},
|
|
33
35
|
aspectRatio: {
|
|
@@ -1544,6 +1546,31 @@ const theme = {
|
|
|
1544
1546
|
transform: "none",
|
|
1545
1547
|
animationTimingFunction: "cubic-bezier(0,0,0.2,1)"
|
|
1546
1548
|
}
|
|
1549
|
+
},
|
|
1550
|
+
fadeIn: {
|
|
1551
|
+
"0%": {
|
|
1552
|
+
opacity: "0"
|
|
1553
|
+
},
|
|
1554
|
+
"50%": {
|
|
1555
|
+
opacity: "1"
|
|
1556
|
+
},
|
|
1557
|
+
"100%": {
|
|
1558
|
+
opacity: "0"
|
|
1559
|
+
}
|
|
1560
|
+
},
|
|
1561
|
+
slideUp: {
|
|
1562
|
+
"0%": {
|
|
1563
|
+
transform: "translateY(20px)",
|
|
1564
|
+
opacity: "0"
|
|
1565
|
+
},
|
|
1566
|
+
"50%": {
|
|
1567
|
+
transform: "translateY(0)",
|
|
1568
|
+
opacity: "1"
|
|
1569
|
+
},
|
|
1570
|
+
"100%": {
|
|
1571
|
+
transform: "translateY(-20px)",
|
|
1572
|
+
opacity: "0"
|
|
1573
|
+
}
|
|
1547
1574
|
}
|
|
1548
1575
|
},
|
|
1549
1576
|
transitionProperty: {
|
|
@@ -2319,18 +2346,39 @@ function generator$2H() {
|
|
|
2319
2346
|
} = configOptions;
|
|
2320
2347
|
const prefix = `${globalPrefix}animate`;
|
|
2321
2348
|
const {
|
|
2322
|
-
animation = {}
|
|
2349
|
+
animation = {},
|
|
2350
|
+
keyframes = {}
|
|
2323
2351
|
} = theme;
|
|
2324
2352
|
const responsiveCssString = generateCssString$1(_ref => {
|
|
2325
2353
|
let {
|
|
2326
2354
|
getCssByOptions
|
|
2327
2355
|
} = _ref;
|
|
2328
|
-
//
|
|
2356
|
+
// Generate keyframes first
|
|
2357
|
+
let keyframesCSS = "";
|
|
2358
|
+
for (const [name, keyframe] of Object.entries(keyframes)) {
|
|
2359
|
+
keyframesCSS += `@keyframes ${name} {\n`;
|
|
2360
|
+
for (const [percentage, styles] of Object.entries(keyframe)) {
|
|
2361
|
+
keyframesCSS += ` ${percentage} {\n`;
|
|
2362
|
+
for (const [prop, value] of Object.entries(styles)) {
|
|
2363
|
+
const cssProp = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
2364
|
+
keyframesCSS += ` ${cssProp}: ${value};\n`;
|
|
2365
|
+
}
|
|
2366
|
+
keyframesCSS += " }\n";
|
|
2367
|
+
}
|
|
2368
|
+
keyframesCSS += "}\n";
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
// Merge theme animations with inline animations (but skip inline if keyframes exist)
|
|
2329
2372
|
const allAnimations = {
|
|
2330
2373
|
...animation,
|
|
2331
|
-
// Add inline animations to the mix
|
|
2374
|
+
// Add inline animations to the mix, but skip if keyframes version exists
|
|
2332
2375
|
...Object.keys(INLINE_ANIMATIONS).reduce((acc, key) => {
|
|
2333
|
-
|
|
2376
|
+
// Check if keyframes version exists (both camelCase and kebab-case)
|
|
2377
|
+
const camelCaseKey = key.replace(/-([a-z])/g, (match, letter) => letter.toUpperCase());
|
|
2378
|
+
const hasKeyframes = keyframes[key] || keyframes[camelCaseKey];
|
|
2379
|
+
if (!hasKeyframes) {
|
|
2380
|
+
acc[key] = `inline-${key}`; // Special marker for inline animations
|
|
2381
|
+
}
|
|
2334
2382
|
return acc;
|
|
2335
2383
|
}, {})
|
|
2336
2384
|
};
|
|
@@ -2376,7 +2424,9 @@ function generator$2H() {
|
|
|
2376
2424
|
}
|
|
2377
2425
|
`;
|
|
2378
2426
|
});
|
|
2379
|
-
|
|
2427
|
+
|
|
2428
|
+
// Combine keyframes and animation classes
|
|
2429
|
+
return keyframesCSS + cssString;
|
|
2380
2430
|
}, configOptions);
|
|
2381
2431
|
return responsiveCssString;
|
|
2382
2432
|
}
|
|
@@ -7792,10 +7842,10 @@ function parseCustomClassWithPatterns(className) {
|
|
|
7792
7842
|
return null;
|
|
7793
7843
|
}
|
|
7794
7844
|
|
|
7795
|
-
/**
|
|
7796
|
-
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
7797
|
-
* @param {string} cssString
|
|
7798
|
-
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
7845
|
+
/**
|
|
7846
|
+
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
7847
|
+
* @param {string} cssString
|
|
7848
|
+
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
7799
7849
|
*/
|
|
7800
7850
|
function resolveCssToClearCss(cssString) {
|
|
7801
7851
|
const customVars = {};
|
|
@@ -8059,11 +8109,11 @@ function separateAndResolveCSS(arr) {
|
|
|
8059
8109
|
}
|
|
8060
8110
|
}
|
|
8061
8111
|
|
|
8062
|
-
/**
|
|
8063
|
-
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
8064
|
-
* @param {string} className - Class name with potential opacity modifier
|
|
8065
|
-
* @param {string} cssDeclaration - CSS declaration to modify
|
|
8066
|
-
* @returns {string} Modified CSS declaration with opacity applied
|
|
8112
|
+
/**
|
|
8113
|
+
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
8114
|
+
* @param {string} className - Class name with potential opacity modifier
|
|
8115
|
+
* @param {string} cssDeclaration - CSS declaration to modify
|
|
8116
|
+
* @returns {string} Modified CSS declaration with opacity applied
|
|
8067
8117
|
*/
|
|
8068
8118
|
function processOpacityModifier(className, cssDeclaration) {
|
|
8069
8119
|
const opacityMatch = className.match(/\/(\d+)$/);
|
|
@@ -8124,11 +8174,11 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
8124
8174
|
return modifiedDeclaration;
|
|
8125
8175
|
}
|
|
8126
8176
|
|
|
8127
|
-
/**
|
|
8128
|
-
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
8129
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
8130
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
8131
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
8177
|
+
/**
|
|
8178
|
+
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
8179
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
8180
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
8181
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
8132
8182
|
*/
|
|
8133
8183
|
function tws(classNames, convertToJson) {
|
|
8134
8184
|
const totalMarker = performanceMonitor.start("tws:total");
|
|
@@ -8572,17 +8622,18 @@ function generateCssString(styles) {
|
|
|
8572
8622
|
return cssString.trim();
|
|
8573
8623
|
}
|
|
8574
8624
|
|
|
8575
|
-
/**
|
|
8576
|
-
* Generate CSS string from style object with SCSS-like syntax
|
|
8577
|
-
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
8578
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
8579
|
-
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
8580
|
-
* @returns {string} Generated CSS string
|
|
8625
|
+
/**
|
|
8626
|
+
* Generate CSS string from style object with SCSS-like syntax
|
|
8627
|
+
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
8628
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
8629
|
+
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
8630
|
+
* @returns {string} Generated CSS string
|
|
8581
8631
|
*/
|
|
8582
8632
|
function twsx(obj) {
|
|
8583
8633
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
8584
8634
|
const totalMarker = performanceMonitor.start("twsx:total");
|
|
8585
8635
|
try {
|
|
8636
|
+
var _options$theme2, _userConfigData$theme2;
|
|
8586
8637
|
if (!obj || typeof obj !== "object") {
|
|
8587
8638
|
logger.warn("twsx: Expected an object but received:", obj);
|
|
8588
8639
|
return "";
|
|
@@ -8659,12 +8710,48 @@ function twsx(obj) {
|
|
|
8659
8710
|
// Generate CSS string
|
|
8660
8711
|
const cssString = performanceMonitor.measure(() => generateCssString(styles), "twsx:generate");
|
|
8661
8712
|
|
|
8713
|
+
// Generate keyframes CSS separately
|
|
8714
|
+
const keyframesMarker = performanceMonitor.start("twsx:keyframes");
|
|
8715
|
+
const userConfigData = getConfig();
|
|
8716
|
+
const mergedOptions = {
|
|
8717
|
+
...options,
|
|
8718
|
+
theme: {
|
|
8719
|
+
...options.theme,
|
|
8720
|
+
...userConfigData.theme,
|
|
8721
|
+
extend: {
|
|
8722
|
+
...((_options$theme2 = options.theme) === null || _options$theme2 === void 0 ? void 0 : _options$theme2.extend),
|
|
8723
|
+
...((_userConfigData$theme2 = userConfigData.theme) === null || _userConfigData$theme2 === void 0 ? void 0 : _userConfigData$theme2.extend)
|
|
8724
|
+
}
|
|
8725
|
+
}
|
|
8726
|
+
};
|
|
8727
|
+
const configOptions = getConfigOptions(mergedOptions, Object.keys(plugins));
|
|
8728
|
+
const {
|
|
8729
|
+
keyframes = {}
|
|
8730
|
+
} = configOptions.theme || {};
|
|
8731
|
+
let keyframesCSS = "";
|
|
8732
|
+
for (const [name, keyframe] of Object.entries(keyframes)) {
|
|
8733
|
+
keyframesCSS += `@keyframes ${name} {\n`;
|
|
8734
|
+
for (const [percentage, styles] of Object.entries(keyframe)) {
|
|
8735
|
+
keyframesCSS += ` ${percentage} {\n`;
|
|
8736
|
+
for (const [prop, value] of Object.entries(styles)) {
|
|
8737
|
+
const cssProp = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
8738
|
+
keyframesCSS += ` ${cssProp}: ${value};\n`;
|
|
8739
|
+
}
|
|
8740
|
+
keyframesCSS += ` }\n`;
|
|
8741
|
+
}
|
|
8742
|
+
keyframesCSS += `}\n`;
|
|
8743
|
+
}
|
|
8744
|
+
performanceMonitor.end(keyframesMarker);
|
|
8745
|
+
|
|
8746
|
+
// Combine keyframes and regular CSS
|
|
8747
|
+
const finalCSS = keyframesCSS + cssString;
|
|
8748
|
+
|
|
8662
8749
|
// Auto-inject if needed
|
|
8663
8750
|
if (inject && typeof window !== "undefined" && typeof document !== "undefined") {
|
|
8664
|
-
performanceMonitor.measure(() => autoInjectCss(
|
|
8751
|
+
performanceMonitor.measure(() => autoInjectCss(finalCSS), "twsx:inject");
|
|
8665
8752
|
}
|
|
8666
8753
|
performanceMonitor.end(totalMarker);
|
|
8667
|
-
return
|
|
8754
|
+
return finalCSS;
|
|
8668
8755
|
} catch (error) {
|
|
8669
8756
|
performanceMonitor.end(totalMarker);
|
|
8670
8757
|
handleError(error, {
|
|
@@ -8721,20 +8808,20 @@ function autoInjectCss(cssString) {
|
|
|
8721
8808
|
}
|
|
8722
8809
|
}
|
|
8723
8810
|
|
|
8724
|
-
/**
|
|
8725
|
-
* React Hook for TWSX Integration
|
|
8726
|
-
* Provides seamless integration between TWSX and React components
|
|
8811
|
+
/**
|
|
8812
|
+
* React Hook for TWSX Integration
|
|
8813
|
+
* Provides seamless integration between TWSX and React components
|
|
8727
8814
|
*/
|
|
8728
8815
|
|
|
8729
|
-
/**
|
|
8730
|
-
* Custom hook for using TWSX in React components
|
|
8731
|
-
* @param {Object|string} styles - TWSX style object or class string
|
|
8732
|
-
* @param {Object} options - TWSX options (inject: true by default)
|
|
8733
|
-
* @returns {string} Generated CSS string
|
|
8734
|
-
*
|
|
8735
|
-
* Examples:
|
|
8736
|
-
* - Auto-inject CSS: useTwsx({ '.card': 'bg-white p-4' })
|
|
8737
|
-
* - Get CSS only: useTwsx({ '.card': 'bg-white p-4' }, { inject: false })
|
|
8816
|
+
/**
|
|
8817
|
+
* Custom hook for using TWSX in React components
|
|
8818
|
+
* @param {Object|string} styles - TWSX style object or class string
|
|
8819
|
+
* @param {Object} options - TWSX options (inject: true by default)
|
|
8820
|
+
* @returns {string} Generated CSS string
|
|
8821
|
+
*
|
|
8822
|
+
* Examples:
|
|
8823
|
+
* - Auto-inject CSS: useTwsx({ '.card': 'bg-white p-4' })
|
|
8824
|
+
* - Get CSS only: useTwsx({ '.card': 'bg-white p-4' }, { inject: false })
|
|
8738
8825
|
*/
|
|
8739
8826
|
function useTwsx(styles) {
|
|
8740
8827
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
package/dist/react.esm.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
|
|
@@ -24,6 +24,8 @@ const theme = {
|
|
|
24
24
|
ping: "ping 1s cubic-bezier(0, 0, 0.2, 1) infinite",
|
|
25
25
|
pulse: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
|
|
26
26
|
bounce: "bounce 1s infinite",
|
|
27
|
+
"fade-in": "fadeIn 2s ease-in-out infinite",
|
|
28
|
+
"slide-up": "slideUp 2s ease-in-out infinite",
|
|
27
29
|
custom: "custom_value"
|
|
28
30
|
},
|
|
29
31
|
aspectRatio: {
|
|
@@ -1540,6 +1542,31 @@ const theme = {
|
|
|
1540
1542
|
transform: "none",
|
|
1541
1543
|
animationTimingFunction: "cubic-bezier(0,0,0.2,1)"
|
|
1542
1544
|
}
|
|
1545
|
+
},
|
|
1546
|
+
fadeIn: {
|
|
1547
|
+
"0%": {
|
|
1548
|
+
opacity: "0"
|
|
1549
|
+
},
|
|
1550
|
+
"50%": {
|
|
1551
|
+
opacity: "1"
|
|
1552
|
+
},
|
|
1553
|
+
"100%": {
|
|
1554
|
+
opacity: "0"
|
|
1555
|
+
}
|
|
1556
|
+
},
|
|
1557
|
+
slideUp: {
|
|
1558
|
+
"0%": {
|
|
1559
|
+
transform: "translateY(20px)",
|
|
1560
|
+
opacity: "0"
|
|
1561
|
+
},
|
|
1562
|
+
"50%": {
|
|
1563
|
+
transform: "translateY(0)",
|
|
1564
|
+
opacity: "1"
|
|
1565
|
+
},
|
|
1566
|
+
"100%": {
|
|
1567
|
+
transform: "translateY(-20px)",
|
|
1568
|
+
opacity: "0"
|
|
1569
|
+
}
|
|
1543
1570
|
}
|
|
1544
1571
|
},
|
|
1545
1572
|
transitionProperty: {
|
|
@@ -2315,18 +2342,39 @@ function generator$2H() {
|
|
|
2315
2342
|
} = configOptions;
|
|
2316
2343
|
const prefix = `${globalPrefix}animate`;
|
|
2317
2344
|
const {
|
|
2318
|
-
animation = {}
|
|
2345
|
+
animation = {},
|
|
2346
|
+
keyframes = {}
|
|
2319
2347
|
} = theme;
|
|
2320
2348
|
const responsiveCssString = generateCssString$1(_ref => {
|
|
2321
2349
|
let {
|
|
2322
2350
|
getCssByOptions
|
|
2323
2351
|
} = _ref;
|
|
2324
|
-
//
|
|
2352
|
+
// Generate keyframes first
|
|
2353
|
+
let keyframesCSS = "";
|
|
2354
|
+
for (const [name, keyframe] of Object.entries(keyframes)) {
|
|
2355
|
+
keyframesCSS += `@keyframes ${name} {\n`;
|
|
2356
|
+
for (const [percentage, styles] of Object.entries(keyframe)) {
|
|
2357
|
+
keyframesCSS += ` ${percentage} {\n`;
|
|
2358
|
+
for (const [prop, value] of Object.entries(styles)) {
|
|
2359
|
+
const cssProp = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
2360
|
+
keyframesCSS += ` ${cssProp}: ${value};\n`;
|
|
2361
|
+
}
|
|
2362
|
+
keyframesCSS += " }\n";
|
|
2363
|
+
}
|
|
2364
|
+
keyframesCSS += "}\n";
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
// Merge theme animations with inline animations (but skip inline if keyframes exist)
|
|
2325
2368
|
const allAnimations = {
|
|
2326
2369
|
...animation,
|
|
2327
|
-
// Add inline animations to the mix
|
|
2370
|
+
// Add inline animations to the mix, but skip if keyframes version exists
|
|
2328
2371
|
...Object.keys(INLINE_ANIMATIONS).reduce((acc, key) => {
|
|
2329
|
-
|
|
2372
|
+
// Check if keyframes version exists (both camelCase and kebab-case)
|
|
2373
|
+
const camelCaseKey = key.replace(/-([a-z])/g, (match, letter) => letter.toUpperCase());
|
|
2374
|
+
const hasKeyframes = keyframes[key] || keyframes[camelCaseKey];
|
|
2375
|
+
if (!hasKeyframes) {
|
|
2376
|
+
acc[key] = `inline-${key}`; // Special marker for inline animations
|
|
2377
|
+
}
|
|
2330
2378
|
return acc;
|
|
2331
2379
|
}, {})
|
|
2332
2380
|
};
|
|
@@ -2372,7 +2420,9 @@ function generator$2H() {
|
|
|
2372
2420
|
}
|
|
2373
2421
|
`;
|
|
2374
2422
|
});
|
|
2375
|
-
|
|
2423
|
+
|
|
2424
|
+
// Combine keyframes and animation classes
|
|
2425
|
+
return keyframesCSS + cssString;
|
|
2376
2426
|
}, configOptions);
|
|
2377
2427
|
return responsiveCssString;
|
|
2378
2428
|
}
|
|
@@ -7788,10 +7838,10 @@ function parseCustomClassWithPatterns(className) {
|
|
|
7788
7838
|
return null;
|
|
7789
7839
|
}
|
|
7790
7840
|
|
|
7791
|
-
/**
|
|
7792
|
-
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
7793
|
-
* @param {string} cssString
|
|
7794
|
-
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
7841
|
+
/**
|
|
7842
|
+
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
7843
|
+
* @param {string} cssString
|
|
7844
|
+
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
7795
7845
|
*/
|
|
7796
7846
|
function resolveCssToClearCss(cssString) {
|
|
7797
7847
|
const customVars = {};
|
|
@@ -8055,11 +8105,11 @@ function separateAndResolveCSS(arr) {
|
|
|
8055
8105
|
}
|
|
8056
8106
|
}
|
|
8057
8107
|
|
|
8058
|
-
/**
|
|
8059
|
-
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
8060
|
-
* @param {string} className - Class name with potential opacity modifier
|
|
8061
|
-
* @param {string} cssDeclaration - CSS declaration to modify
|
|
8062
|
-
* @returns {string} Modified CSS declaration with opacity applied
|
|
8108
|
+
/**
|
|
8109
|
+
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
8110
|
+
* @param {string} className - Class name with potential opacity modifier
|
|
8111
|
+
* @param {string} cssDeclaration - CSS declaration to modify
|
|
8112
|
+
* @returns {string} Modified CSS declaration with opacity applied
|
|
8063
8113
|
*/
|
|
8064
8114
|
function processOpacityModifier(className, cssDeclaration) {
|
|
8065
8115
|
const opacityMatch = className.match(/\/(\d+)$/);
|
|
@@ -8120,11 +8170,11 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
8120
8170
|
return modifiedDeclaration;
|
|
8121
8171
|
}
|
|
8122
8172
|
|
|
8123
|
-
/**
|
|
8124
|
-
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
8125
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
8126
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
8127
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
8173
|
+
/**
|
|
8174
|
+
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
8175
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
8176
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
8177
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
8128
8178
|
*/
|
|
8129
8179
|
function tws(classNames, convertToJson) {
|
|
8130
8180
|
const totalMarker = performanceMonitor.start("tws:total");
|
|
@@ -8568,17 +8618,18 @@ function generateCssString(styles) {
|
|
|
8568
8618
|
return cssString.trim();
|
|
8569
8619
|
}
|
|
8570
8620
|
|
|
8571
|
-
/**
|
|
8572
|
-
* Generate CSS string from style object with SCSS-like syntax
|
|
8573
|
-
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
8574
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
8575
|
-
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
8576
|
-
* @returns {string} Generated CSS string
|
|
8621
|
+
/**
|
|
8622
|
+
* Generate CSS string from style object with SCSS-like syntax
|
|
8623
|
+
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
8624
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
8625
|
+
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
8626
|
+
* @returns {string} Generated CSS string
|
|
8577
8627
|
*/
|
|
8578
8628
|
function twsx(obj) {
|
|
8579
8629
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
8580
8630
|
const totalMarker = performanceMonitor.start("twsx:total");
|
|
8581
8631
|
try {
|
|
8632
|
+
var _options$theme2, _userConfigData$theme2;
|
|
8582
8633
|
if (!obj || typeof obj !== "object") {
|
|
8583
8634
|
logger.warn("twsx: Expected an object but received:", obj);
|
|
8584
8635
|
return "";
|
|
@@ -8655,12 +8706,48 @@ function twsx(obj) {
|
|
|
8655
8706
|
// Generate CSS string
|
|
8656
8707
|
const cssString = performanceMonitor.measure(() => generateCssString(styles), "twsx:generate");
|
|
8657
8708
|
|
|
8709
|
+
// Generate keyframes CSS separately
|
|
8710
|
+
const keyframesMarker = performanceMonitor.start("twsx:keyframes");
|
|
8711
|
+
const userConfigData = getConfig();
|
|
8712
|
+
const mergedOptions = {
|
|
8713
|
+
...options,
|
|
8714
|
+
theme: {
|
|
8715
|
+
...options.theme,
|
|
8716
|
+
...userConfigData.theme,
|
|
8717
|
+
extend: {
|
|
8718
|
+
...((_options$theme2 = options.theme) === null || _options$theme2 === void 0 ? void 0 : _options$theme2.extend),
|
|
8719
|
+
...((_userConfigData$theme2 = userConfigData.theme) === null || _userConfigData$theme2 === void 0 ? void 0 : _userConfigData$theme2.extend)
|
|
8720
|
+
}
|
|
8721
|
+
}
|
|
8722
|
+
};
|
|
8723
|
+
const configOptions = getConfigOptions(mergedOptions, Object.keys(plugins));
|
|
8724
|
+
const {
|
|
8725
|
+
keyframes = {}
|
|
8726
|
+
} = configOptions.theme || {};
|
|
8727
|
+
let keyframesCSS = "";
|
|
8728
|
+
for (const [name, keyframe] of Object.entries(keyframes)) {
|
|
8729
|
+
keyframesCSS += `@keyframes ${name} {\n`;
|
|
8730
|
+
for (const [percentage, styles] of Object.entries(keyframe)) {
|
|
8731
|
+
keyframesCSS += ` ${percentage} {\n`;
|
|
8732
|
+
for (const [prop, value] of Object.entries(styles)) {
|
|
8733
|
+
const cssProp = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
8734
|
+
keyframesCSS += ` ${cssProp}: ${value};\n`;
|
|
8735
|
+
}
|
|
8736
|
+
keyframesCSS += ` }\n`;
|
|
8737
|
+
}
|
|
8738
|
+
keyframesCSS += `}\n`;
|
|
8739
|
+
}
|
|
8740
|
+
performanceMonitor.end(keyframesMarker);
|
|
8741
|
+
|
|
8742
|
+
// Combine keyframes and regular CSS
|
|
8743
|
+
const finalCSS = keyframesCSS + cssString;
|
|
8744
|
+
|
|
8658
8745
|
// Auto-inject if needed
|
|
8659
8746
|
if (inject && typeof window !== "undefined" && typeof document !== "undefined") {
|
|
8660
|
-
performanceMonitor.measure(() => autoInjectCss(
|
|
8747
|
+
performanceMonitor.measure(() => autoInjectCss(finalCSS), "twsx:inject");
|
|
8661
8748
|
}
|
|
8662
8749
|
performanceMonitor.end(totalMarker);
|
|
8663
|
-
return
|
|
8750
|
+
return finalCSS;
|
|
8664
8751
|
} catch (error) {
|
|
8665
8752
|
performanceMonitor.end(totalMarker);
|
|
8666
8753
|
handleError(error, {
|
|
@@ -8717,20 +8804,20 @@ function autoInjectCss(cssString) {
|
|
|
8717
8804
|
}
|
|
8718
8805
|
}
|
|
8719
8806
|
|
|
8720
|
-
/**
|
|
8721
|
-
* React Hook for TWSX Integration
|
|
8722
|
-
* Provides seamless integration between TWSX and React components
|
|
8807
|
+
/**
|
|
8808
|
+
* React Hook for TWSX Integration
|
|
8809
|
+
* Provides seamless integration between TWSX and React components
|
|
8723
8810
|
*/
|
|
8724
8811
|
|
|
8725
|
-
/**
|
|
8726
|
-
* Custom hook for using TWSX in React components
|
|
8727
|
-
* @param {Object|string} styles - TWSX style object or class string
|
|
8728
|
-
* @param {Object} options - TWSX options (inject: true by default)
|
|
8729
|
-
* @returns {string} Generated CSS string
|
|
8730
|
-
*
|
|
8731
|
-
* Examples:
|
|
8732
|
-
* - Auto-inject CSS: useTwsx({ '.card': 'bg-white p-4' })
|
|
8733
|
-
* - Get CSS only: useTwsx({ '.card': 'bg-white p-4' }, { inject: false })
|
|
8812
|
+
/**
|
|
8813
|
+
* Custom hook for using TWSX in React components
|
|
8814
|
+
* @param {Object|string} styles - TWSX style object or class string
|
|
8815
|
+
* @param {Object} options - TWSX options (inject: true by default)
|
|
8816
|
+
* @returns {string} Generated CSS string
|
|
8817
|
+
*
|
|
8818
|
+
* Examples:
|
|
8819
|
+
* - Auto-inject CSS: useTwsx({ '.card': 'bg-white p-4' })
|
|
8820
|
+
* - Get CSS only: useTwsx({ '.card': 'bg-white p-4' }, { inject: false })
|
|
8734
8821
|
*/
|
|
8735
8822
|
function useTwsx(styles) {
|
|
8736
8823
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|