tailwind-to-style 2.7.1 → 2.7.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.7.1
2
+ * tailwind-to-style v2.7.2
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
@@ -6342,13 +6342,13 @@ var tailwindToStyle = (function (exports) {
6342
6342
  }).join(" ");
6343
6343
  }
6344
6344
 
6345
- // Cache untuk getConfigOptions
6345
+ // Cache for getConfigOptions
6346
6346
  const configOptionsCache = new Map();
6347
6347
  const cacheKey = options => JSON.stringify(options);
6348
6348
  function generateTailwindCssString() {
6349
6349
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6350
6350
  const pluginKeys = Object.keys(plugins);
6351
- // Menggunakan cache untuk mencegah pemrosesan ulang yang tidak perlu
6351
+ // Use cache to prevent unnecessary reprocessing
6352
6352
  const key = cacheKey(options);
6353
6353
  if (!configOptionsCache.has(key)) {
6354
6354
  configOptionsCache.set(key, getConfigOptions(options, pluginKeys));
@@ -6409,7 +6409,7 @@ var tailwindToStyle = (function (exports) {
6409
6409
  number: arg => `> :nth-child(${arg})`
6410
6410
  };
6411
6411
 
6412
- // Mengoptimalkan encoding/decoding bracket values dengan memoization
6412
+ // Optimize encoding/decoding bracket values with memoization
6413
6413
  const encodeBracketCache = new Map();
6414
6414
  function encodeBracketValues(input) {
6415
6415
  if (!input) return input;
@@ -6476,7 +6476,7 @@ var tailwindToStyle = (function (exports) {
6476
6476
  return styleObject;
6477
6477
  }
6478
6478
 
6479
- // Cache untuk CSS resolusi
6479
+ // Cache for CSS resolution
6480
6480
  const cssResolutionCache = new Map();
6481
6481
 
6482
6482
  // Enhanced cache management with performance monitoring
@@ -6484,7 +6484,7 @@ var tailwindToStyle = (function (exports) {
6484
6484
  let maxSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
6485
6485
  if (cache.size > maxSize) {
6486
6486
  const cleanupMarker = performanceMonitor.start("cache:cleanup");
6487
- // Hapus 20% entri yang paling lama
6487
+ // Remove 20% of the oldest entries
6488
6488
  const entriesToRemove = Math.floor(cache.size * 0.2);
6489
6489
  const keys = Array.from(cache.keys()).slice(0, entriesToRemove);
6490
6490
  keys.forEach(key => cache.delete(key));
@@ -6523,14 +6523,14 @@ var tailwindToStyle = (function (exports) {
6523
6523
  function separateAndResolveCSS(arr) {
6524
6524
  const marker = performanceMonitor.start("css:resolve");
6525
6525
  try {
6526
- // Perbaiki: cacheKey harus unik untuk setiap input array
6526
+ // Fix: cacheKey must be unique for each input array
6527
6527
  const cacheKey = Array.isArray(arr) ? arr.join("|") : String(arr);
6528
6528
  if (cssResolutionCache.has(cacheKey)) {
6529
6529
  performanceMonitor.end(marker);
6530
6530
  return cssResolutionCache.get(cacheKey);
6531
6531
  }
6532
6532
 
6533
- // Batasi ukuran cache untuk menghindari memory leak
6533
+ // Limit cache size to avoid memory leaks
6534
6534
  limitCacheSize(cssResolutionCache);
6535
6535
  const cssProperties = {};
6536
6536
  arr.forEach(item => {
@@ -6543,7 +6543,7 @@ var tailwindToStyle = (function (exports) {
6543
6543
  const key = declaration.substring(0, colonIndex).trim();
6544
6544
  const value = declaration.substring(colonIndex + 1).trim();
6545
6545
  if (key && value) {
6546
- // Prioritaskan nilai yang lebih spesifik (misalnya !important)
6546
+ // Prioritize more specific values (e.g., !important)
6547
6547
  if (value.includes("!important") || !cssProperties[key]) {
6548
6548
  cssProperties[key] = value;
6549
6549
  }
@@ -6594,10 +6594,75 @@ var tailwindToStyle = (function (exports) {
6594
6594
  }
6595
6595
 
6596
6596
  /**
6597
- * Mengkonversi string kelas Tailwind menjadi inline styles CSS atau objek JSON
6598
- * @param {string} classNames - String berisi kelas Tailwind yang akan dikonversi
6599
- * @param {boolean} convertToJson - Jika true, hasil akan menjadi objek JSON, jika false menjadi string CSS
6600
- * @returns {string|Object} String CSS inline atau objek style JSON
6597
+ * Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
6598
+ * @param {string} className - Class name with potential opacity modifier
6599
+ * @param {string} cssDeclaration - CSS declaration to modify
6600
+ * @returns {string} Modified CSS declaration with opacity applied
6601
+ */
6602
+ function processOpacityModifier(className, cssDeclaration) {
6603
+ const opacityMatch = className.match(/\/(\d+)$/);
6604
+ if (!opacityMatch) return cssDeclaration;
6605
+ const opacityValue = parseInt(opacityMatch[1], 10);
6606
+ if (opacityValue < 0 || opacityValue > 100) return cssDeclaration;
6607
+ const alphaValue = (opacityValue / 100).toString();
6608
+
6609
+ // Handle Tailwind's CSS custom property pattern
6610
+ let modifiedDeclaration = cssDeclaration;
6611
+
6612
+ // Replace opacity custom properties
6613
+ const opacityProperties = ['--text-opacity', '--bg-opacity', '--border-opacity', '--ring-opacity', '--divide-opacity', '--placeholder-opacity', '--text-decoration-opacity', '--outline-opacity', '--accent-opacity', '--caret-opacity'];
6614
+ opacityProperties.forEach(prop => {
6615
+ const propRegex = new RegExp(`${prop}\\s*:\\s*[\\d.]+`, 'gi');
6616
+ modifiedDeclaration = modifiedDeclaration.replace(propRegex, `${prop}: ${alphaValue}`);
6617
+ });
6618
+
6619
+ // Also handle direct color values that might not use CSS variables
6620
+ const colorProperties = ['color', 'background-color', 'border-color', 'text-decoration-color', 'outline-color', 'fill', 'stroke', 'caret-color', 'accent-color'];
6621
+ colorProperties.forEach(prop => {
6622
+ // Match rgb(), rgba(), hsl(), hsla() functions
6623
+ const rgbRegex = new RegExp(`(${prop}\\s*:\\s*)rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)`, 'gi');
6624
+ const rgbaRegex = new RegExp(`(${prop}\\s*:\\s*)rgba\\((\\d+),\\s*(\\d+),\\s*(\\d+),\\s*[\\d.]+\\)`, 'gi');
6625
+ const hslRegex = new RegExp(`(${prop}\\s*:\\s*)hsl\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%)\\)`, 'gi');
6626
+ const hslaRegex = new RegExp(`(${prop}\\s*:\\s*)hsla\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%),\\s*[\\d.]+\\)`, 'gi');
6627
+
6628
+ // Convert rgb to rgba with opacity
6629
+ modifiedDeclaration = modifiedDeclaration.replace(rgbRegex, `$1rgba($2, $3, $4, ${alphaValue})`);
6630
+
6631
+ // Update existing rgba opacity
6632
+ modifiedDeclaration = modifiedDeclaration.replace(rgbaRegex, `$1rgba($2, $3, $4, ${alphaValue})`);
6633
+
6634
+ // Convert hsl to hsla with opacity
6635
+ modifiedDeclaration = modifiedDeclaration.replace(hslRegex, `$1hsla($2, $3, $4, ${alphaValue})`);
6636
+
6637
+ // Update existing hsla opacity
6638
+ modifiedDeclaration = modifiedDeclaration.replace(hslaRegex, `$1hsla($2, $3, $4, ${alphaValue})`);
6639
+
6640
+ // Handle hex colors
6641
+ const hexRegex = new RegExp(`(${prop}\\s*:\\s*)(#[0-9a-fA-F]{3,6})`, 'gi');
6642
+ modifiedDeclaration = modifiedDeclaration.replace(hexRegex, (match, propPart, hexColor) => {
6643
+ // Convert hex to rgba
6644
+ const hex = hexColor.replace('#', '');
6645
+ let r, g, b;
6646
+ if (hex.length === 3) {
6647
+ r = parseInt(hex[0] + hex[0], 16);
6648
+ g = parseInt(hex[1] + hex[1], 16);
6649
+ b = parseInt(hex[2] + hex[2], 16);
6650
+ } else {
6651
+ r = parseInt(hex.substring(0, 2), 16);
6652
+ g = parseInt(hex.substring(2, 4), 16);
6653
+ b = parseInt(hex.substring(4, 6), 16);
6654
+ }
6655
+ return `${propPart}rgba(${r}, ${g}, ${b}, ${alphaValue})`;
6656
+ });
6657
+ });
6658
+ return modifiedDeclaration;
6659
+ }
6660
+
6661
+ /**
6662
+ * Convert Tailwind class string to inline CSS styles or JSON object
6663
+ * @param {string} classNames - String containing Tailwind classes to convert
6664
+ * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
6665
+ * @returns {string|Object} Inline CSS string or style JSON object
6601
6666
  */
6602
6667
  function tws(classNames, convertToJson) {
6603
6668
  const totalMarker = performanceMonitor.start("tws:total");
@@ -6609,10 +6674,10 @@ var tailwindToStyle = (function (exports) {
6609
6674
  let classes;
6610
6675
  try {
6611
6676
  const parseMarker = performanceMonitor.start("tws:parse");
6612
- classes = classNames.match(/[\w-\/]+(?:\[[^\]]+\])?/g);
6677
+ classes = classNames.match(/[\w-\/]+(?:\/\d+)?(?:\[[^\]]+\])?/g);
6613
6678
  performanceMonitor.end(parseMarker);
6614
6679
 
6615
- // Jika tidak ada class yang valid ditemukan
6680
+ // If no valid classes are found
6616
6681
  if (!classes || classes.length === 0) {
6617
6682
  console.warn(`No valid Tailwind classes found in input: "${classNames}"`);
6618
6683
  performanceMonitor.end(totalMarker);
@@ -6627,16 +6692,27 @@ var tailwindToStyle = (function (exports) {
6627
6692
  // Process classes with performance monitoring
6628
6693
  const processMarker = performanceMonitor.start("tws:process");
6629
6694
  let cssResult = classes.map(className => {
6630
- let result = cssObject[className] || cssObject[className.replace(/(\/)/g, "\\$1")] || cssObject[className.replace(/\./g, "\\.")];
6695
+ // Extract base class name without opacity modifier
6696
+ const baseClassName = className.replace(/\/\d+$/, '');
6697
+ let result = cssObject[baseClassName] || cssObject[baseClassName.replace(/(\/)/g, "\\$1")] || cssObject[baseClassName.replace(/\./g, "\\.")];
6631
6698
  if (result) {
6699
+ // Apply opacity modifier if present
6700
+ if (className.includes('/') && /\/\d+$/.test(className)) {
6701
+ result = processOpacityModifier(className, result);
6702
+ }
6632
6703
  return resolveCssToClearCss(result);
6633
- } else if (className.includes("[")) {
6634
- const match = className.match(/\[([^\]]+)\]/);
6704
+ } else if (baseClassName.includes("[")) {
6705
+ const match = baseClassName.match(/\[([^\]]+)\]/);
6635
6706
  if (match) {
6636
6707
  const customValue = match[1];
6637
- const baseKey = className.split("[")[0];
6708
+ const baseKey = baseClassName.split("[")[0];
6638
6709
  if (cssObject[`${baseKey}custom`]) {
6639
- return cssObject[`${baseKey}custom`].replace(/custom_value/g, customValue);
6710
+ let customResult = cssObject[`${baseKey}custom`].replace(/custom_value/g, customValue);
6711
+ // Apply opacity modifier to custom values too
6712
+ if (className.includes('/') && /\/\d+$/.test(className)) {
6713
+ customResult = processOpacityModifier(className, customResult);
6714
+ }
6715
+ return customResult;
6640
6716
  }
6641
6717
  }
6642
6718
  }
@@ -6767,9 +6843,12 @@ var tailwindToStyle = (function (exports) {
6767
6843
  media,
6768
6844
  finalSelector
6769
6845
  } = resolveVariants(selector, rawVariants);
6770
- let declarations = cssObject[pureClassName] || cssObject[pureClassName.replace(/(\/)/g, "\\$1")] || cssObject[pureClassName.replace(/\./g, "\\.")];
6771
- if (!declarations && pureClassName.includes("[")) {
6772
- const match = pureClassName.match(/^(.+?)\[(.+)\]$/);
6846
+
6847
+ // Extract base class name without opacity modifier for CSS lookup
6848
+ const baseClassName = pureClassName.replace(/\/\d+$/, '');
6849
+ let declarations = cssObject[baseClassName] || cssObject[baseClassName.replace(/(\/)/g, "\\$1")] || cssObject[baseClassName.replace(/\./g, "\\.")];
6850
+ if (!declarations && baseClassName.includes("[")) {
6851
+ const match = baseClassName.match(/^(.+?)\[(.+)\]$/);
6773
6852
  if (match) {
6774
6853
  const [, prefix, dynamicValue] = match;
6775
6854
  const customKey = `${prefix}custom`;
@@ -6780,17 +6859,22 @@ var tailwindToStyle = (function (exports) {
6780
6859
  }
6781
6860
  }
6782
6861
  if (!declarations) {
6783
- declarations = parseCustomClassWithPatterns(pureClassName);
6862
+ declarations = parseCustomClassWithPatterns(baseClassName);
6784
6863
  }
6785
6864
  if (!declarations) {
6786
6865
  return;
6787
6866
  }
6867
+
6868
+ // Apply opacity modifier if present
6869
+ if (pureClassName.includes('/') && /\/\d+$/.test(pureClassName)) {
6870
+ declarations = processOpacityModifier(pureClassName, declarations);
6871
+ }
6788
6872
  if (isImportant) {
6789
6873
  declarations = declarations.replace(/([^:;]+):([^;]+)(;?)/g, (_, prop, value) => {
6790
6874
  return prop.trim().startsWith("--") ? `${prop}:${value};` : `${prop}:${value.trim()} !important;`;
6791
6875
  });
6792
6876
  }
6793
- const isSpaceOrDivide = ["space-x-", "-space-x-", "space-y-", "-space-y-", "divide-"].some(prefix => pureClassName.startsWith(prefix));
6877
+ const isSpaceOrDivide = ["space-x-", "-space-x-", "space-y-", "-space-y-", "divide-"].some(prefix => baseClassName.startsWith(prefix));
6794
6878
  const expandedSelector = replaceSelector(finalSelector);
6795
6879
  const targetSelector = isSpaceOrDivide ? `${expandedSelector} > :not([hidden]) ~ :not([hidden])` : expandedSelector;
6796
6880
  if (media) {
@@ -6958,11 +7042,11 @@ var tailwindToStyle = (function (exports) {
6958
7042
  }
6959
7043
 
6960
7044
  /**
6961
- * Menghasilkan string CSS dari objek style dengan sintaks mirip SCSS
6962
- * Mendukung nested selectors, state variants, responsive variants, dan @css directives
6963
- * @param {Object} obj - Objek dengan format style mirip SCSS
6964
- * @param {Object} [options] - Opsi tambahan, misal { inject: true/false }
6965
- * @returns {string} String CSS yang dihasilkan
7045
+ * Generate CSS string from style object with SCSS-like syntax
7046
+ * Supports nested selectors, state variants, responsive variants, and @css directives
7047
+ * @param {Object} obj - Object with SCSS-like style format
7048
+ * @param {Object} [options] - Additional options, e.g. { inject: true/false }
7049
+ * @returns {string} Generated CSS string
6966
7050
  */
6967
7051
  function twsx(obj) {
6968
7052
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -7022,7 +7106,7 @@ var tailwindToStyle = (function (exports) {
7022
7106
  }
7023
7107
  }
7024
7108
 
7025
- // Fungsi hashCode sederhana untuk deduplikasi CSS
7109
+ // Simple hashCode function for CSS deduplication
7026
7110
  function getCssHash(str) {
7027
7111
  let hash = 0,
7028
7112
  i,
@@ -7036,7 +7120,7 @@ var tailwindToStyle = (function (exports) {
7036
7120
  return hash;
7037
7121
  }
7038
7122
 
7039
- // Enhanced auto-inject CSS dengan performance monitoring
7123
+ // Enhanced auto-inject CSS with performance monitoring
7040
7124
  const injectedCssHashSet = new Set();
7041
7125
  function autoInjectCss(cssString) {
7042
7126
  const marker = performanceMonitor.start("css:inject");
@@ -7068,24 +7152,24 @@ var tailwindToStyle = (function (exports) {
7068
7152
  }
7069
7153
  }
7070
7154
 
7071
- // Enhanced debounced functions dengan konfigurasi performance monitoring
7155
+ // Enhanced debounced functions with performance monitoring configuration
7072
7156
  /**
7073
- * Versi debounced dari fungsi tws dengan performance monitoring
7074
- * @param {string} classNames - String berisi kelas Tailwind yang akan dikonversi
7075
- * @param {boolean} convertToJson - Jika true, hasil akan menjadi objek JSON, jika false menjadi string CSS
7076
- * @returns {string|Object} String CSS inline atau objek style JSON
7157
+ * Debounced version of tws function with performance monitoring
7158
+ * @param {string} classNames - String containing Tailwind classes to convert
7159
+ * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
7160
+ * @returns {string|Object} Inline CSS string or style JSON object
7077
7161
  */
7078
7162
  const debouncedTws = debounce(tws, 50); // Faster debounce for tws
7079
7163
 
7080
7164
  /**
7081
- * Versi debounced dari fungsi twsx dengan performance monitoring
7082
- * @param {Object} obj - Objek dengan format style mirip SCSS
7083
- * @param {Object} [options] - Opsi tambahan
7084
- * @returns {string} String CSS yang dihasilkan
7165
+ * Debounced version of twsx function with performance monitoring
7166
+ * @param {Object} obj - Object with SCSS-like style format
7167
+ * @param {Object} [options] - Additional options
7168
+ * @returns {string} Generated CSS string
7085
7169
  */
7086
7170
  const debouncedTwsx = debounce(twsx, 100); // Standard debounce for twsx
7087
7171
 
7088
- // Export performance utilities untuk debugging
7172
+ // Export performance utilities for debugging
7089
7173
  const performanceUtils = {
7090
7174
  getStats() {
7091
7175
  return {
package/dist/index.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.7.1
2
+ * tailwind-to-style v2.7.2
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
@@ -6343,13 +6343,13 @@ function resolveCssToClearCss(cssString) {
6343
6343
  }).join(" ");
6344
6344
  }
6345
6345
 
6346
- // Cache untuk getConfigOptions
6346
+ // Cache for getConfigOptions
6347
6347
  const configOptionsCache = new Map();
6348
6348
  const cacheKey = options => JSON.stringify(options);
6349
6349
  function generateTailwindCssString() {
6350
6350
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6351
6351
  const pluginKeys = Object.keys(plugins);
6352
- // Menggunakan cache untuk mencegah pemrosesan ulang yang tidak perlu
6352
+ // Use cache to prevent unnecessary reprocessing
6353
6353
  const key = cacheKey(options);
6354
6354
  if (!configOptionsCache.has(key)) {
6355
6355
  configOptionsCache.set(key, getConfigOptions(options, pluginKeys));
@@ -6410,7 +6410,7 @@ const selectorVariants = {
6410
6410
  number: arg => `> :nth-child(${arg})`
6411
6411
  };
6412
6412
 
6413
- // Mengoptimalkan encoding/decoding bracket values dengan memoization
6413
+ // Optimize encoding/decoding bracket values with memoization
6414
6414
  const encodeBracketCache = new Map();
6415
6415
  function encodeBracketValues(input) {
6416
6416
  if (!input) return input;
@@ -6477,7 +6477,7 @@ function inlineStyleToJson(styleString) {
6477
6477
  return styleObject;
6478
6478
  }
6479
6479
 
6480
- // Cache untuk CSS resolusi
6480
+ // Cache for CSS resolution
6481
6481
  const cssResolutionCache = new Map();
6482
6482
 
6483
6483
  // Enhanced cache management with performance monitoring
@@ -6485,7 +6485,7 @@ function limitCacheSize(cache) {
6485
6485
  let maxSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
6486
6486
  if (cache.size > maxSize) {
6487
6487
  const cleanupMarker = performanceMonitor.start("cache:cleanup");
6488
- // Hapus 20% entri yang paling lama
6488
+ // Remove 20% of the oldest entries
6489
6489
  const entriesToRemove = Math.floor(cache.size * 0.2);
6490
6490
  const keys = Array.from(cache.keys()).slice(0, entriesToRemove);
6491
6491
  keys.forEach(key => cache.delete(key));
@@ -6524,14 +6524,14 @@ function debounce(func) {
6524
6524
  function separateAndResolveCSS(arr) {
6525
6525
  const marker = performanceMonitor.start("css:resolve");
6526
6526
  try {
6527
- // Perbaiki: cacheKey harus unik untuk setiap input array
6527
+ // Fix: cacheKey must be unique for each input array
6528
6528
  const cacheKey = Array.isArray(arr) ? arr.join("|") : String(arr);
6529
6529
  if (cssResolutionCache.has(cacheKey)) {
6530
6530
  performanceMonitor.end(marker);
6531
6531
  return cssResolutionCache.get(cacheKey);
6532
6532
  }
6533
6533
 
6534
- // Batasi ukuran cache untuk menghindari memory leak
6534
+ // Limit cache size to avoid memory leaks
6535
6535
  limitCacheSize(cssResolutionCache);
6536
6536
  const cssProperties = {};
6537
6537
  arr.forEach(item => {
@@ -6544,7 +6544,7 @@ function separateAndResolveCSS(arr) {
6544
6544
  const key = declaration.substring(0, colonIndex).trim();
6545
6545
  const value = declaration.substring(colonIndex + 1).trim();
6546
6546
  if (key && value) {
6547
- // Prioritaskan nilai yang lebih spesifik (misalnya !important)
6547
+ // Prioritize more specific values (e.g., !important)
6548
6548
  if (value.includes("!important") || !cssProperties[key]) {
6549
6549
  cssProperties[key] = value;
6550
6550
  }
@@ -6595,10 +6595,75 @@ function separateAndResolveCSS(arr) {
6595
6595
  }
6596
6596
 
6597
6597
  /**
6598
- * Mengkonversi string kelas Tailwind menjadi inline styles CSS atau objek JSON
6599
- * @param {string} classNames - String berisi kelas Tailwind yang akan dikonversi
6600
- * @param {boolean} convertToJson - Jika true, hasil akan menjadi objek JSON, jika false menjadi string CSS
6601
- * @returns {string|Object} String CSS inline atau objek style JSON
6598
+ * Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
6599
+ * @param {string} className - Class name with potential opacity modifier
6600
+ * @param {string} cssDeclaration - CSS declaration to modify
6601
+ * @returns {string} Modified CSS declaration with opacity applied
6602
+ */
6603
+ function processOpacityModifier(className, cssDeclaration) {
6604
+ const opacityMatch = className.match(/\/(\d+)$/);
6605
+ if (!opacityMatch) return cssDeclaration;
6606
+ const opacityValue = parseInt(opacityMatch[1], 10);
6607
+ if (opacityValue < 0 || opacityValue > 100) return cssDeclaration;
6608
+ const alphaValue = (opacityValue / 100).toString();
6609
+
6610
+ // Handle Tailwind's CSS custom property pattern
6611
+ let modifiedDeclaration = cssDeclaration;
6612
+
6613
+ // Replace opacity custom properties
6614
+ const opacityProperties = ['--text-opacity', '--bg-opacity', '--border-opacity', '--ring-opacity', '--divide-opacity', '--placeholder-opacity', '--text-decoration-opacity', '--outline-opacity', '--accent-opacity', '--caret-opacity'];
6615
+ opacityProperties.forEach(prop => {
6616
+ const propRegex = new RegExp(`${prop}\\s*:\\s*[\\d.]+`, 'gi');
6617
+ modifiedDeclaration = modifiedDeclaration.replace(propRegex, `${prop}: ${alphaValue}`);
6618
+ });
6619
+
6620
+ // Also handle direct color values that might not use CSS variables
6621
+ const colorProperties = ['color', 'background-color', 'border-color', 'text-decoration-color', 'outline-color', 'fill', 'stroke', 'caret-color', 'accent-color'];
6622
+ colorProperties.forEach(prop => {
6623
+ // Match rgb(), rgba(), hsl(), hsla() functions
6624
+ const rgbRegex = new RegExp(`(${prop}\\s*:\\s*)rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)`, 'gi');
6625
+ const rgbaRegex = new RegExp(`(${prop}\\s*:\\s*)rgba\\((\\d+),\\s*(\\d+),\\s*(\\d+),\\s*[\\d.]+\\)`, 'gi');
6626
+ const hslRegex = new RegExp(`(${prop}\\s*:\\s*)hsl\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%)\\)`, 'gi');
6627
+ const hslaRegex = new RegExp(`(${prop}\\s*:\\s*)hsla\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%),\\s*[\\d.]+\\)`, 'gi');
6628
+
6629
+ // Convert rgb to rgba with opacity
6630
+ modifiedDeclaration = modifiedDeclaration.replace(rgbRegex, `$1rgba($2, $3, $4, ${alphaValue})`);
6631
+
6632
+ // Update existing rgba opacity
6633
+ modifiedDeclaration = modifiedDeclaration.replace(rgbaRegex, `$1rgba($2, $3, $4, ${alphaValue})`);
6634
+
6635
+ // Convert hsl to hsla with opacity
6636
+ modifiedDeclaration = modifiedDeclaration.replace(hslRegex, `$1hsla($2, $3, $4, ${alphaValue})`);
6637
+
6638
+ // Update existing hsla opacity
6639
+ modifiedDeclaration = modifiedDeclaration.replace(hslaRegex, `$1hsla($2, $3, $4, ${alphaValue})`);
6640
+
6641
+ // Handle hex colors
6642
+ const hexRegex = new RegExp(`(${prop}\\s*:\\s*)(#[0-9a-fA-F]{3,6})`, 'gi');
6643
+ modifiedDeclaration = modifiedDeclaration.replace(hexRegex, (match, propPart, hexColor) => {
6644
+ // Convert hex to rgba
6645
+ const hex = hexColor.replace('#', '');
6646
+ let r, g, b;
6647
+ if (hex.length === 3) {
6648
+ r = parseInt(hex[0] + hex[0], 16);
6649
+ g = parseInt(hex[1] + hex[1], 16);
6650
+ b = parseInt(hex[2] + hex[2], 16);
6651
+ } else {
6652
+ r = parseInt(hex.substring(0, 2), 16);
6653
+ g = parseInt(hex.substring(2, 4), 16);
6654
+ b = parseInt(hex.substring(4, 6), 16);
6655
+ }
6656
+ return `${propPart}rgba(${r}, ${g}, ${b}, ${alphaValue})`;
6657
+ });
6658
+ });
6659
+ return modifiedDeclaration;
6660
+ }
6661
+
6662
+ /**
6663
+ * Convert Tailwind class string to inline CSS styles or JSON object
6664
+ * @param {string} classNames - String containing Tailwind classes to convert
6665
+ * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
6666
+ * @returns {string|Object} Inline CSS string or style JSON object
6602
6667
  */
6603
6668
  function tws(classNames, convertToJson) {
6604
6669
  const totalMarker = performanceMonitor.start("tws:total");
@@ -6610,10 +6675,10 @@ function tws(classNames, convertToJson) {
6610
6675
  let classes;
6611
6676
  try {
6612
6677
  const parseMarker = performanceMonitor.start("tws:parse");
6613
- classes = classNames.match(/[\w-\/]+(?:\[[^\]]+\])?/g);
6678
+ classes = classNames.match(/[\w-\/]+(?:\/\d+)?(?:\[[^\]]+\])?/g);
6614
6679
  performanceMonitor.end(parseMarker);
6615
6680
 
6616
- // Jika tidak ada class yang valid ditemukan
6681
+ // If no valid classes are found
6617
6682
  if (!classes || classes.length === 0) {
6618
6683
  console.warn(`No valid Tailwind classes found in input: "${classNames}"`);
6619
6684
  performanceMonitor.end(totalMarker);
@@ -6628,16 +6693,27 @@ function tws(classNames, convertToJson) {
6628
6693
  // Process classes with performance monitoring
6629
6694
  const processMarker = performanceMonitor.start("tws:process");
6630
6695
  let cssResult = classes.map(className => {
6631
- let result = cssObject[className] || cssObject[className.replace(/(\/)/g, "\\$1")] || cssObject[className.replace(/\./g, "\\.")];
6696
+ // Extract base class name without opacity modifier
6697
+ const baseClassName = className.replace(/\/\d+$/, '');
6698
+ let result = cssObject[baseClassName] || cssObject[baseClassName.replace(/(\/)/g, "\\$1")] || cssObject[baseClassName.replace(/\./g, "\\.")];
6632
6699
  if (result) {
6700
+ // Apply opacity modifier if present
6701
+ if (className.includes('/') && /\/\d+$/.test(className)) {
6702
+ result = processOpacityModifier(className, result);
6703
+ }
6633
6704
  return resolveCssToClearCss(result);
6634
- } else if (className.includes("[")) {
6635
- const match = className.match(/\[([^\]]+)\]/);
6705
+ } else if (baseClassName.includes("[")) {
6706
+ const match = baseClassName.match(/\[([^\]]+)\]/);
6636
6707
  if (match) {
6637
6708
  const customValue = match[1];
6638
- const baseKey = className.split("[")[0];
6709
+ const baseKey = baseClassName.split("[")[0];
6639
6710
  if (cssObject[`${baseKey}custom`]) {
6640
- return cssObject[`${baseKey}custom`].replace(/custom_value/g, customValue);
6711
+ let customResult = cssObject[`${baseKey}custom`].replace(/custom_value/g, customValue);
6712
+ // Apply opacity modifier to custom values too
6713
+ if (className.includes('/') && /\/\d+$/.test(className)) {
6714
+ customResult = processOpacityModifier(className, customResult);
6715
+ }
6716
+ return customResult;
6641
6717
  }
6642
6718
  }
6643
6719
  }
@@ -6768,9 +6844,12 @@ function processClass(cls, selector, styles) {
6768
6844
  media,
6769
6845
  finalSelector
6770
6846
  } = resolveVariants(selector, rawVariants);
6771
- let declarations = cssObject[pureClassName] || cssObject[pureClassName.replace(/(\/)/g, "\\$1")] || cssObject[pureClassName.replace(/\./g, "\\.")];
6772
- if (!declarations && pureClassName.includes("[")) {
6773
- const match = pureClassName.match(/^(.+?)\[(.+)\]$/);
6847
+
6848
+ // Extract base class name without opacity modifier for CSS lookup
6849
+ const baseClassName = pureClassName.replace(/\/\d+$/, '');
6850
+ let declarations = cssObject[baseClassName] || cssObject[baseClassName.replace(/(\/)/g, "\\$1")] || cssObject[baseClassName.replace(/\./g, "\\.")];
6851
+ if (!declarations && baseClassName.includes("[")) {
6852
+ const match = baseClassName.match(/^(.+?)\[(.+)\]$/);
6774
6853
  if (match) {
6775
6854
  const [, prefix, dynamicValue] = match;
6776
6855
  const customKey = `${prefix}custom`;
@@ -6781,17 +6860,22 @@ function processClass(cls, selector, styles) {
6781
6860
  }
6782
6861
  }
6783
6862
  if (!declarations) {
6784
- declarations = parseCustomClassWithPatterns(pureClassName);
6863
+ declarations = parseCustomClassWithPatterns(baseClassName);
6785
6864
  }
6786
6865
  if (!declarations) {
6787
6866
  return;
6788
6867
  }
6868
+
6869
+ // Apply opacity modifier if present
6870
+ if (pureClassName.includes('/') && /\/\d+$/.test(pureClassName)) {
6871
+ declarations = processOpacityModifier(pureClassName, declarations);
6872
+ }
6789
6873
  if (isImportant) {
6790
6874
  declarations = declarations.replace(/([^:;]+):([^;]+)(;?)/g, (_, prop, value) => {
6791
6875
  return prop.trim().startsWith("--") ? `${prop}:${value};` : `${prop}:${value.trim()} !important;`;
6792
6876
  });
6793
6877
  }
6794
- const isSpaceOrDivide = ["space-x-", "-space-x-", "space-y-", "-space-y-", "divide-"].some(prefix => pureClassName.startsWith(prefix));
6878
+ const isSpaceOrDivide = ["space-x-", "-space-x-", "space-y-", "-space-y-", "divide-"].some(prefix => baseClassName.startsWith(prefix));
6795
6879
  const expandedSelector = replaceSelector(finalSelector);
6796
6880
  const targetSelector = isSpaceOrDivide ? `${expandedSelector} > :not([hidden]) ~ :not([hidden])` : expandedSelector;
6797
6881
  if (media) {
@@ -6959,11 +7043,11 @@ function generateCssString(styles) {
6959
7043
  }
6960
7044
 
6961
7045
  /**
6962
- * Menghasilkan string CSS dari objek style dengan sintaks mirip SCSS
6963
- * Mendukung nested selectors, state variants, responsive variants, dan @css directives
6964
- * @param {Object} obj - Objek dengan format style mirip SCSS
6965
- * @param {Object} [options] - Opsi tambahan, misal { inject: true/false }
6966
- * @returns {string} String CSS yang dihasilkan
7046
+ * Generate CSS string from style object with SCSS-like syntax
7047
+ * Supports nested selectors, state variants, responsive variants, and @css directives
7048
+ * @param {Object} obj - Object with SCSS-like style format
7049
+ * @param {Object} [options] - Additional options, e.g. { inject: true/false }
7050
+ * @returns {string} Generated CSS string
6967
7051
  */
6968
7052
  function twsx(obj) {
6969
7053
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -7023,7 +7107,7 @@ function twsx(obj) {
7023
7107
  }
7024
7108
  }
7025
7109
 
7026
- // Fungsi hashCode sederhana untuk deduplikasi CSS
7110
+ // Simple hashCode function for CSS deduplication
7027
7111
  function getCssHash(str) {
7028
7112
  let hash = 0,
7029
7113
  i,
@@ -7037,7 +7121,7 @@ function getCssHash(str) {
7037
7121
  return hash;
7038
7122
  }
7039
7123
 
7040
- // Enhanced auto-inject CSS dengan performance monitoring
7124
+ // Enhanced auto-inject CSS with performance monitoring
7041
7125
  const injectedCssHashSet = new Set();
7042
7126
  function autoInjectCss(cssString) {
7043
7127
  const marker = performanceMonitor.start("css:inject");
@@ -7069,24 +7153,24 @@ function autoInjectCss(cssString) {
7069
7153
  }
7070
7154
  }
7071
7155
 
7072
- // Enhanced debounced functions dengan konfigurasi performance monitoring
7156
+ // Enhanced debounced functions with performance monitoring configuration
7073
7157
  /**
7074
- * Versi debounced dari fungsi tws dengan performance monitoring
7075
- * @param {string} classNames - String berisi kelas Tailwind yang akan dikonversi
7076
- * @param {boolean} convertToJson - Jika true, hasil akan menjadi objek JSON, jika false menjadi string CSS
7077
- * @returns {string|Object} String CSS inline atau objek style JSON
7158
+ * Debounced version of tws function with performance monitoring
7159
+ * @param {string} classNames - String containing Tailwind classes to convert
7160
+ * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
7161
+ * @returns {string|Object} Inline CSS string or style JSON object
7078
7162
  */
7079
7163
  const debouncedTws = debounce(tws, 50); // Faster debounce for tws
7080
7164
 
7081
7165
  /**
7082
- * Versi debounced dari fungsi twsx dengan performance monitoring
7083
- * @param {Object} obj - Objek dengan format style mirip SCSS
7084
- * @param {Object} [options] - Opsi tambahan
7085
- * @returns {string} String CSS yang dihasilkan
7166
+ * Debounced version of twsx function with performance monitoring
7167
+ * @param {Object} obj - Object with SCSS-like style format
7168
+ * @param {Object} [options] - Additional options
7169
+ * @returns {string} Generated CSS string
7086
7170
  */
7087
7171
  const debouncedTwsx = debounce(twsx, 100); // Standard debounce for twsx
7088
7172
 
7089
- // Export performance utilities untuk debugging
7173
+ // Export performance utilities for debugging
7090
7174
  const performanceUtils = {
7091
7175
  getStats() {
7092
7176
  return {