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.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.10.2
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
  }
@@ -8321,10 +8371,10 @@ function parseCustomClassWithPatterns(className) {
8321
8371
  return null;
8322
8372
  }
8323
8373
 
8324
- /**
8325
- * Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
8326
- * @param {string} cssString
8327
- * @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
8374
+ /**
8375
+ * Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
8376
+ * @param {string} cssString
8377
+ * @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
8328
8378
  */
8329
8379
  function resolveCssToClearCss(cssString) {
8330
8380
  const customVars = {};
@@ -8618,11 +8668,11 @@ function separateAndResolveCSS(arr) {
8618
8668
  }
8619
8669
  }
8620
8670
 
8621
- /**
8622
- * Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
8623
- * @param {string} className - Class name with potential opacity modifier
8624
- * @param {string} cssDeclaration - CSS declaration to modify
8625
- * @returns {string} Modified CSS declaration with opacity applied
8671
+ /**
8672
+ * Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
8673
+ * @param {string} className - Class name with potential opacity modifier
8674
+ * @param {string} cssDeclaration - CSS declaration to modify
8675
+ * @returns {string} Modified CSS declaration with opacity applied
8626
8676
  */
8627
8677
  function processOpacityModifier(className, cssDeclaration) {
8628
8678
  const opacityMatch = className.match(/\/(\d+)$/);
@@ -8683,11 +8733,11 @@ function processOpacityModifier(className, cssDeclaration) {
8683
8733
  return modifiedDeclaration;
8684
8734
  }
8685
8735
 
8686
- /**
8687
- * Convert Tailwind class string to inline CSS styles or JSON object
8688
- * @param {string} classNames - String containing Tailwind classes to convert
8689
- * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
8690
- * @returns {string|Object} Inline CSS string or style JSON object
8736
+ /**
8737
+ * Convert Tailwind class string to inline CSS styles or JSON object
8738
+ * @param {string} classNames - String containing Tailwind classes to convert
8739
+ * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
8740
+ * @returns {string|Object} Inline CSS string or style JSON object
8691
8741
  */
8692
8742
  function tws(classNames, convertToJson) {
8693
8743
  const totalMarker = performanceMonitor.start("tws:total");
@@ -9131,17 +9181,18 @@ function generateCssString(styles) {
9131
9181
  return cssString.trim();
9132
9182
  }
9133
9183
 
9134
- /**
9135
- * Generate CSS string from style object with SCSS-like syntax
9136
- * Supports nested selectors, state variants, responsive variants, and @css directives
9137
- * @param {Object} obj - Object with SCSS-like style format
9138
- * @param {Object} [options] - Additional options, e.g. { inject: true/false }
9139
- * @returns {string} Generated CSS string
9184
+ /**
9185
+ * Generate CSS string from style object with SCSS-like syntax
9186
+ * Supports nested selectors, state variants, responsive variants, and @css directives
9187
+ * @param {Object} obj - Object with SCSS-like style format
9188
+ * @param {Object} [options] - Additional options, e.g. { inject: true/false }
9189
+ * @returns {string} Generated CSS string
9140
9190
  */
9141
9191
  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, {
@@ -9281,19 +9368,19 @@ function autoInjectCss(cssString) {
9281
9368
  }
9282
9369
 
9283
9370
  // Enhanced debounced functions with performance monitoring configuration
9284
- /**
9285
- * Debounced version of tws function with performance monitoring
9286
- * @param {string} classNames - String containing Tailwind classes to convert
9287
- * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
9288
- * @returns {string|Object} Inline CSS string or style JSON object
9371
+ /**
9372
+ * Debounced version of tws function with performance monitoring
9373
+ * @param {string} classNames - String containing Tailwind classes to convert
9374
+ * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
9375
+ * @returns {string|Object} Inline CSS string or style JSON object
9289
9376
  */
9290
9377
  const debouncedTws = debounce(tws, 50); // Faster debounce for tws
9291
9378
 
9292
- /**
9293
- * Debounced version of twsx function with performance monitoring
9294
- * @param {Object} obj - Object with SCSS-like style format
9295
- * @param {Object} [options] - Additional options
9296
- * @returns {string} Generated CSS string
9379
+ /**
9380
+ * Debounced version of twsx function with performance monitoring
9381
+ * @param {Object} obj - Object with SCSS-like style format
9382
+ * @param {Object} [options] - Additional options
9383
+ * @returns {string} Generated CSS string
9297
9384
  */
9298
9385
  const debouncedTwsx = debounce(twsx, 100); // Standard debounce for twsx
9299
9386