tailwind-to-style 2.10.1 → 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.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.10.1
2
+ * tailwind-to-style v2.10.3
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
@@ -22,6 +22,8 @@ const theme = {
22
22
  ping: "ping 1s cubic-bezier(0, 0, 0.2, 1) infinite",
23
23
  pulse: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
24
24
  bounce: "bounce 1s infinite",
25
+ "fade-in": "fadeIn 2s ease-in-out infinite",
26
+ "slide-up": "slideUp 2s ease-in-out infinite",
25
27
  custom: "custom_value"
26
28
  },
27
29
  aspectRatio: {
@@ -1538,6 +1540,31 @@ const theme = {
1538
1540
  transform: "none",
1539
1541
  animationTimingFunction: "cubic-bezier(0,0,0.2,1)"
1540
1542
  }
1543
+ },
1544
+ fadeIn: {
1545
+ "0%": {
1546
+ opacity: "0"
1547
+ },
1548
+ "50%": {
1549
+ opacity: "1"
1550
+ },
1551
+ "100%": {
1552
+ opacity: "0"
1553
+ }
1554
+ },
1555
+ slideUp: {
1556
+ "0%": {
1557
+ transform: "translateY(20px)",
1558
+ opacity: "0"
1559
+ },
1560
+ "50%": {
1561
+ transform: "translateY(0)",
1562
+ opacity: "1"
1563
+ },
1564
+ "100%": {
1565
+ transform: "translateY(-20px)",
1566
+ opacity: "0"
1567
+ }
1541
1568
  }
1542
1569
  },
1543
1570
  transitionProperty: {
@@ -2443,18 +2470,39 @@ function generator$2H() {
2443
2470
  } = configOptions;
2444
2471
  const prefix = `${globalPrefix}animate`;
2445
2472
  const {
2446
- animation = {}
2473
+ animation = {},
2474
+ keyframes = {}
2447
2475
  } = theme;
2448
2476
  const responsiveCssString = generateCssString$1(_ref => {
2449
2477
  let {
2450
2478
  getCssByOptions
2451
2479
  } = _ref;
2452
- // Merge theme animations with inline animations
2480
+ // Generate keyframes first
2481
+ let keyframesCSS = "";
2482
+ for (const [name, keyframe] of Object.entries(keyframes)) {
2483
+ keyframesCSS += `@keyframes ${name} {\n`;
2484
+ for (const [percentage, styles] of Object.entries(keyframe)) {
2485
+ keyframesCSS += ` ${percentage} {\n`;
2486
+ for (const [prop, value] of Object.entries(styles)) {
2487
+ const cssProp = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
2488
+ keyframesCSS += ` ${cssProp}: ${value};\n`;
2489
+ }
2490
+ keyframesCSS += " }\n";
2491
+ }
2492
+ keyframesCSS += "}\n";
2493
+ }
2494
+
2495
+ // Merge theme animations with inline animations (but skip inline if keyframes exist)
2453
2496
  const allAnimations = {
2454
2497
  ...animation,
2455
- // Add inline animations to the mix
2498
+ // Add inline animations to the mix, but skip if keyframes version exists
2456
2499
  ...Object.keys(INLINE_ANIMATIONS).reduce((acc, key) => {
2457
- acc[key] = `inline-${key}`; // Special marker for inline animations
2500
+ // Check if keyframes version exists (both camelCase and kebab-case)
2501
+ const camelCaseKey = key.replace(/-([a-z])/g, (match, letter) => letter.toUpperCase());
2502
+ const hasKeyframes = keyframes[key] || keyframes[camelCaseKey];
2503
+ if (!hasKeyframes) {
2504
+ acc[key] = `inline-${key}`; // Special marker for inline animations
2505
+ }
2458
2506
  return acc;
2459
2507
  }, {})
2460
2508
  };
@@ -2500,7 +2548,9 @@ function generator$2H() {
2500
2548
  }
2501
2549
  `;
2502
2550
  });
2503
- return cssString;
2551
+
2552
+ // Combine keyframes and animation classes
2553
+ return keyframesCSS + cssString;
2504
2554
  }, configOptions);
2505
2555
  return responsiveCssString;
2506
2556
  }
@@ -9142,6 +9192,7 @@ function twsx(obj) {
9142
9192
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
9143
9193
  const totalMarker = performanceMonitor.start("twsx:total");
9144
9194
  try {
9195
+ var _options$theme2, _userConfigData$theme2;
9145
9196
  if (!obj || typeof obj !== "object") {
9146
9197
  logger.warn("twsx: Expected an object but received:", obj);
9147
9198
  return "";
@@ -9218,12 +9269,48 @@ function twsx(obj) {
9218
9269
  // Generate CSS string
9219
9270
  const cssString = performanceMonitor.measure(() => generateCssString(styles), "twsx:generate");
9220
9271
 
9272
+ // Generate keyframes CSS separately
9273
+ const keyframesMarker = performanceMonitor.start("twsx:keyframes");
9274
+ const userConfigData = getConfig();
9275
+ const mergedOptions = {
9276
+ ...options,
9277
+ theme: {
9278
+ ...options.theme,
9279
+ ...userConfigData.theme,
9280
+ extend: {
9281
+ ...((_options$theme2 = options.theme) === null || _options$theme2 === void 0 ? void 0 : _options$theme2.extend),
9282
+ ...((_userConfigData$theme2 = userConfigData.theme) === null || _userConfigData$theme2 === void 0 ? void 0 : _userConfigData$theme2.extend)
9283
+ }
9284
+ }
9285
+ };
9286
+ const configOptions = getConfigOptions(mergedOptions, Object.keys(plugins));
9287
+ const {
9288
+ keyframes = {}
9289
+ } = configOptions.theme || {};
9290
+ let keyframesCSS = "";
9291
+ for (const [name, keyframe] of Object.entries(keyframes)) {
9292
+ keyframesCSS += `@keyframes ${name} {\n`;
9293
+ for (const [percentage, styles] of Object.entries(keyframe)) {
9294
+ keyframesCSS += ` ${percentage} {\n`;
9295
+ for (const [prop, value] of Object.entries(styles)) {
9296
+ const cssProp = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
9297
+ keyframesCSS += ` ${cssProp}: ${value};\n`;
9298
+ }
9299
+ keyframesCSS += ` }\n`;
9300
+ }
9301
+ keyframesCSS += `}\n`;
9302
+ }
9303
+ performanceMonitor.end(keyframesMarker);
9304
+
9305
+ // Combine keyframes and regular CSS
9306
+ const finalCSS = keyframesCSS + cssString;
9307
+
9221
9308
  // Auto-inject if needed
9222
9309
  if (inject && typeof window !== "undefined" && typeof document !== "undefined") {
9223
- performanceMonitor.measure(() => autoInjectCss(cssString), "twsx:inject");
9310
+ performanceMonitor.measure(() => autoInjectCss(finalCSS), "twsx:inject");
9224
9311
  }
9225
9312
  performanceMonitor.end(totalMarker);
9226
- return cssString;
9313
+ return finalCSS;
9227
9314
  } catch (error) {
9228
9315
  performanceMonitor.end(totalMarker);
9229
9316
  handleError(error, {