tailwind-to-style 2.7.1 → 2.7.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.7.1
2
+ * tailwind-to-style v2.7.3
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
@@ -1529,12 +1529,10 @@ function getConfigOptions() {
1529
1529
  const themeKeys = Object.keys(configOptions.theme);
1530
1530
  themeKeys.forEach(key => {
1531
1531
  newTheme[key] = theme[key] || configOptions.theme[key];
1532
- if (isFunction(newTheme[key])) {
1533
- newTheme[key] = newTheme[key]({
1534
- theme: keyRef => {
1535
- return configOptions.theme[keyRef];
1536
- }
1537
- });
1532
+ });
1533
+ themeKeys.forEach(key => {
1534
+ if (themeExtend[key] && newTheme[key]) {
1535
+ newTheme[key] = Object.assign({}, newTheme[key], themeExtend[key]);
1538
1536
  }
1539
1537
  });
1540
1538
  themeKeys.forEach(key => {
@@ -1545,9 +1543,6 @@ function getConfigOptions() {
1545
1543
  }
1546
1544
  });
1547
1545
  }
1548
- if (themeExtend[key]) {
1549
- newTheme[key] = Object.assign({}, newTheme[key], themeExtend[key]);
1550
- }
1551
1546
  });
1552
1547
  return {
1553
1548
  prefix: "",
@@ -6309,10 +6304,10 @@ function parseCustomClassWithPatterns(className) {
6309
6304
  return null;
6310
6305
  }
6311
6306
 
6312
- /**
6313
- * Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
6314
- * @param {string} cssString
6315
- * @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
6307
+ /**
6308
+ * Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
6309
+ * @param {string} cssString
6310
+ * @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
6316
6311
  */
6317
6312
  function resolveCssToClearCss(cssString) {
6318
6313
  const customVars = {};
@@ -6339,13 +6334,13 @@ function resolveCssToClearCss(cssString) {
6339
6334
  }).join(" ");
6340
6335
  }
6341
6336
 
6342
- // Cache untuk getConfigOptions
6337
+ // Cache for getConfigOptions
6343
6338
  const configOptionsCache = new Map();
6344
6339
  const cacheKey = options => JSON.stringify(options);
6345
6340
  function generateTailwindCssString() {
6346
6341
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6347
6342
  const pluginKeys = Object.keys(plugins);
6348
- // Menggunakan cache untuk mencegah pemrosesan ulang yang tidak perlu
6343
+ // Use cache to prevent unnecessary reprocessing
6349
6344
  const key = cacheKey(options);
6350
6345
  if (!configOptionsCache.has(key)) {
6351
6346
  configOptionsCache.set(key, getConfigOptions(options, pluginKeys));
@@ -6379,19 +6374,120 @@ function convertCssToObject(cssString) {
6379
6374
  }
6380
6375
  let twString = null;
6381
6376
  let cssObject = null;
6382
- if (!twString) {
6383
- twString = generateTailwindCssString().replace(/\s\s+/g, " ");
6377
+ let globalConfig = {
6378
+ theme: {
6379
+ extend: {
6380
+ colors: {}
6381
+ },
6382
+ screens: {
6383
+ sm: "640px",
6384
+ md: "768px",
6385
+ lg: "1024px",
6386
+ xl: "1280px",
6387
+ "2xl": "1536px"
6388
+ }
6389
+ },
6390
+ inject: true
6391
+ };
6392
+ function initializeCss() {
6393
+ if (!twString) {
6394
+ const configForGeneration = {
6395
+ ...globalConfig,
6396
+ theme: {
6397
+ ...globalConfig.theme
6398
+ }
6399
+ };
6400
+ twString = generateTailwindCssString(configForGeneration).replace(/\s\s+/g, " ");
6401
+ }
6402
+ if (!cssObject) {
6403
+ cssObject = convertCssToObject(twString);
6404
+ }
6405
+ }
6406
+ initializeCss();
6407
+ function convertScreensToBreakpoints(screens) {
6408
+ const breakpoints = {};
6409
+ for (const [key, value] of Object.entries(screens)) {
6410
+ breakpoints[key] = `@media (min-width: ${value})`;
6411
+ }
6412
+ return breakpoints;
6413
+ }
6414
+
6415
+ /**
6416
+ * Set global configuration for both tws and twsx functions
6417
+ * @param {Object} config - Global configuration object
6418
+ * @returns {Object} Current global configuration
6419
+ */
6420
+ function setConfig(config) {
6421
+ var _config$theme, _config$theme2, _config$theme2$extend, _config$theme3;
6422
+ // Reset CSS object cache when config changes
6423
+ twString = null;
6424
+ cssObject = null;
6425
+ configOptionsCache.clear();
6426
+ globalConfig = {
6427
+ ...globalConfig,
6428
+ ...config,
6429
+ theme: {
6430
+ ...globalConfig.theme,
6431
+ ...(config.theme || {}),
6432
+ extend: {
6433
+ ...globalConfig.theme.extend,
6434
+ ...(((_config$theme = config.theme) === null || _config$theme === void 0 ? void 0 : _config$theme.extend) || {}),
6435
+ colors: {
6436
+ ...globalConfig.theme.extend.colors,
6437
+ ...(((_config$theme2 = config.theme) === null || _config$theme2 === void 0 ? void 0 : (_config$theme2$extend = _config$theme2.extend) === null || _config$theme2$extend === void 0 ? void 0 : _config$theme2$extend.colors) || {})
6438
+ }
6439
+ }
6440
+ }
6441
+ };
6442
+
6443
+ // Handle screens configuration
6444
+ if ((_config$theme3 = config.theme) !== null && _config$theme3 !== void 0 && _config$theme3.screens) {
6445
+ globalConfig.theme.screens = {
6446
+ ...globalConfig.theme.screens,
6447
+ ...config.theme.screens
6448
+ };
6449
+ }
6450
+ initializeCss();
6451
+ return globalConfig;
6452
+ }
6453
+
6454
+ /**
6455
+ * Get current global configuration
6456
+ * @returns {Object} Current global configuration
6457
+ */
6458
+ function getConfig() {
6459
+ return {
6460
+ ...globalConfig
6461
+ };
6384
6462
  }
6385
- if (!cssObject) {
6463
+
6464
+ /**
6465
+ * Reset global configuration to default
6466
+ * @returns {Object} Default configuration
6467
+ */
6468
+ function resetConfig() {
6469
+ twString = null;
6470
+ cssObject = null;
6471
+ configOptionsCache.clear();
6472
+ globalConfig = {
6473
+ theme: {
6474
+ extend: {
6475
+ colors: {}
6476
+ },
6477
+ screens: {
6478
+ sm: "640px",
6479
+ md: "768px",
6480
+ lg: "1024px",
6481
+ xl: "1280px",
6482
+ "2xl": "1536px"
6483
+ }
6484
+ },
6485
+ inject: true
6486
+ };
6487
+ twString = generateTailwindCssString(globalConfig).replace(/\s\s+/g, " ");
6386
6488
  cssObject = convertCssToObject(twString);
6489
+ return globalConfig;
6387
6490
  }
6388
- const breakpoints = {
6389
- sm: "@media (min-width: 640px)",
6390
- md: "@media (min-width: 768px)",
6391
- lg: "@media (min-width: 1024px)",
6392
- xl: "@media (min-width: 1280px)",
6393
- "2xl": "@media (min-width: 1536px)"
6394
- };
6395
6491
  const pseudoVariants = new Set(["hover", "focus", "focus-within", "active", "visited", "disabled", "first", "last", "checked", "invalid", "required"]);
6396
6492
  const specialVariants = {
6397
6493
  group: (state, sel) => `.group:${state} ${sel}`,
@@ -6406,7 +6502,7 @@ const selectorVariants = {
6406
6502
  number: arg => `> :nth-child(${arg})`
6407
6503
  };
6408
6504
 
6409
- // Mengoptimalkan encoding/decoding bracket values dengan memoization
6505
+ // Optimize encoding/decoding bracket values with memoization
6410
6506
  const encodeBracketCache = new Map();
6411
6507
  function encodeBracketValues(input) {
6412
6508
  if (!input) return input;
@@ -6441,6 +6537,7 @@ function resolveVariants(selector, variants) {
6441
6537
  let media = null;
6442
6538
  let finalSelector = selector;
6443
6539
  for (const v of variants) {
6540
+ const breakpoints = convertScreensToBreakpoints(globalConfig.theme.screens || {});
6444
6541
  if (breakpoints[v]) {
6445
6542
  media = breakpoints[v];
6446
6543
  } else if (pseudoVariants.has(v)) {
@@ -6473,7 +6570,7 @@ function inlineStyleToJson(styleString) {
6473
6570
  return styleObject;
6474
6571
  }
6475
6572
 
6476
- // Cache untuk CSS resolusi
6573
+ // Cache for CSS resolution
6477
6574
  const cssResolutionCache = new Map();
6478
6575
 
6479
6576
  // Enhanced cache management with performance monitoring
@@ -6481,7 +6578,7 @@ function limitCacheSize(cache) {
6481
6578
  let maxSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
6482
6579
  if (cache.size > maxSize) {
6483
6580
  const cleanupMarker = performanceMonitor.start("cache:cleanup");
6484
- // Hapus 20% entri yang paling lama
6581
+ // Remove 20% of the oldest entries
6485
6582
  const entriesToRemove = Math.floor(cache.size * 0.2);
6486
6583
  const keys = Array.from(cache.keys()).slice(0, entriesToRemove);
6487
6584
  keys.forEach(key => cache.delete(key));
@@ -6502,7 +6599,7 @@ function debounce(func) {
6502
6599
  callCount++;
6503
6600
  clearTimeout(timeout);
6504
6601
  timeout = setTimeout(() => {
6505
- const marker = performanceMonitor.start(`debounced:${func.name || 'anonymous'}`);
6602
+ const marker = performanceMonitor.start(`debounced:${func.name || "anonymous"}`);
6506
6603
  try {
6507
6604
  const result = func.apply(context, args);
6508
6605
  performanceMonitor.end(marker);
@@ -6520,14 +6617,14 @@ function debounce(func) {
6520
6617
  function separateAndResolveCSS(arr) {
6521
6618
  const marker = performanceMonitor.start("css:resolve");
6522
6619
  try {
6523
- // Perbaiki: cacheKey harus unik untuk setiap input array
6620
+ // Fix: cacheKey must be unique for each input array
6524
6621
  const cacheKey = Array.isArray(arr) ? arr.join("|") : String(arr);
6525
6622
  if (cssResolutionCache.has(cacheKey)) {
6526
6623
  performanceMonitor.end(marker);
6527
6624
  return cssResolutionCache.get(cacheKey);
6528
6625
  }
6529
6626
 
6530
- // Batasi ukuran cache untuk menghindari memory leak
6627
+ // Limit cache size to avoid memory leaks
6531
6628
  limitCacheSize(cssResolutionCache);
6532
6629
  const cssProperties = {};
6533
6630
  arr.forEach(item => {
@@ -6540,7 +6637,7 @@ function separateAndResolveCSS(arr) {
6540
6637
  const key = declaration.substring(0, colonIndex).trim();
6541
6638
  const value = declaration.substring(colonIndex + 1).trim();
6542
6639
  if (key && value) {
6543
- // Prioritaskan nilai yang lebih spesifik (misalnya !important)
6640
+ // Prioritize more specific values (e.g., !important)
6544
6641
  if (value.includes("!important") || !cssProperties[key]) {
6545
6642
  cssProperties[key] = value;
6546
6643
  }
@@ -6590,15 +6687,82 @@ function separateAndResolveCSS(arr) {
6590
6687
  }
6591
6688
  }
6592
6689
 
6593
- /**
6594
- * Mengkonversi string kelas Tailwind menjadi inline styles CSS atau objek JSON
6595
- * @param {string} classNames - String berisi kelas Tailwind yang akan dikonversi
6596
- * @param {boolean} convertToJson - Jika true, hasil akan menjadi objek JSON, jika false menjadi string CSS
6597
- * @returns {string|Object} String CSS inline atau objek style JSON
6690
+ /**
6691
+ * Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
6692
+ * @param {string} className - Class name with potential opacity modifier
6693
+ * @param {string} cssDeclaration - CSS declaration to modify
6694
+ * @returns {string} Modified CSS declaration with opacity applied
6695
+ */
6696
+ function processOpacityModifier(className, cssDeclaration) {
6697
+ const opacityMatch = className.match(/\/(\d+)$/);
6698
+ if (!opacityMatch) return cssDeclaration;
6699
+ const opacityValue = parseInt(opacityMatch[1], 10);
6700
+ if (opacityValue < 0 || opacityValue > 100) return cssDeclaration;
6701
+ const alphaValue = (opacityValue / 100).toString();
6702
+
6703
+ // Handle Tailwind's CSS custom property pattern
6704
+ let modifiedDeclaration = cssDeclaration;
6705
+
6706
+ // Replace opacity custom properties
6707
+ const opacityProperties = ["--text-opacity", "--bg-opacity", "--border-opacity", "--ring-opacity", "--divide-opacity", "--placeholder-opacity", "--text-decoration-opacity", "--outline-opacity", "--accent-opacity", "--caret-opacity"];
6708
+ opacityProperties.forEach(prop => {
6709
+ const propRegex = new RegExp(`${prop}\\s*:\\s*[\\d.]+`, "gi");
6710
+ modifiedDeclaration = modifiedDeclaration.replace(propRegex, `${prop}: ${alphaValue}`);
6711
+ });
6712
+
6713
+ // Also handle direct color values that might not use CSS variables
6714
+ const colorProperties = ["color", "background-color", "border-color", "text-decoration-color", "outline-color", "fill", "stroke", "caret-color", "accent-color"];
6715
+ colorProperties.forEach(prop => {
6716
+ // Match rgb(), rgba(), hsl(), hsla() functions
6717
+ const rgbRegex = new RegExp(`(${prop}\\s*:\\s*)rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)`, "gi");
6718
+ const rgbaRegex = new RegExp(`(${prop}\\s*:\\s*)rgba\\((\\d+),\\s*(\\d+),\\s*(\\d+),\\s*[\\d.]+\\)`, "gi");
6719
+ const hslRegex = new RegExp(`(${prop}\\s*:\\s*)hsl\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%)\\)`, "gi");
6720
+ const hslaRegex = new RegExp(`(${prop}\\s*:\\s*)hsla\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%),\\s*[\\d.]+\\)`, "gi");
6721
+
6722
+ // Convert rgb to rgba with opacity
6723
+ modifiedDeclaration = modifiedDeclaration.replace(rgbRegex, `$1rgba($2, $3, $4, ${alphaValue})`);
6724
+
6725
+ // Update existing rgba opacity
6726
+ modifiedDeclaration = modifiedDeclaration.replace(rgbaRegex, `$1rgba($2, $3, $4, ${alphaValue})`);
6727
+
6728
+ // Convert hsl to hsla with opacity
6729
+ modifiedDeclaration = modifiedDeclaration.replace(hslRegex, `$1hsla($2, $3, $4, ${alphaValue})`);
6730
+
6731
+ // Update existing hsla opacity
6732
+ modifiedDeclaration = modifiedDeclaration.replace(hslaRegex, `$1hsla($2, $3, $4, ${alphaValue})`);
6733
+
6734
+ // Handle hex colors
6735
+ const hexRegex = new RegExp(`(${prop}\\s*:\\s*)(#[0-9a-fA-F]{3,6})`, "gi");
6736
+ modifiedDeclaration = modifiedDeclaration.replace(hexRegex, (_, propPart, hexColor) => {
6737
+ // Convert hex to rgba
6738
+ const hex = hexColor.replace("#", "");
6739
+ let r, g, b;
6740
+ if (hex.length === 3) {
6741
+ r = parseInt(hex[0] + hex[0], 16);
6742
+ g = parseInt(hex[1] + hex[1], 16);
6743
+ b = parseInt(hex[2] + hex[2], 16);
6744
+ } else {
6745
+ r = parseInt(hex.substring(0, 2), 16);
6746
+ g = parseInt(hex.substring(2, 4), 16);
6747
+ b = parseInt(hex.substring(4, 6), 16);
6748
+ }
6749
+ return `${propPart}rgba(${r}, ${g}, ${b}, ${alphaValue})`;
6750
+ });
6751
+ });
6752
+ return modifiedDeclaration;
6753
+ }
6754
+
6755
+ /**
6756
+ * Convert Tailwind class string to inline CSS styles or JSON object
6757
+ * @param {string} classNames - String containing Tailwind classes to convert
6758
+ * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
6759
+ * @returns {string|Object} Inline CSS string or style JSON object
6598
6760
  */
6599
6761
  function tws(classNames, convertToJson) {
6600
6762
  const totalMarker = performanceMonitor.start("tws:total");
6601
6763
  try {
6764
+ // Ensure CSS is initialized with current global config
6765
+ initializeCss();
6602
6766
  if ([!classNames, typeof classNames !== "string", classNames.trim() === ""].includes(true)) {
6603
6767
  performanceMonitor.end(totalMarker);
6604
6768
  return convertToJson ? {} : "";
@@ -6606,10 +6770,10 @@ function tws(classNames, convertToJson) {
6606
6770
  let classes;
6607
6771
  try {
6608
6772
  const parseMarker = performanceMonitor.start("tws:parse");
6609
- classes = classNames.match(/[\w-\/]+(?:\[[^\]]+\])?/g);
6773
+ classes = classNames.match(/[\w-\/]+(?:\/\d+)?(?:\[[^\]]+\])?/g);
6610
6774
  performanceMonitor.end(parseMarker);
6611
6775
 
6612
- // Jika tidak ada class yang valid ditemukan
6776
+ // If no valid classes are found
6613
6777
  if (!classes || classes.length === 0) {
6614
6778
  console.warn(`No valid Tailwind classes found in input: "${classNames}"`);
6615
6779
  performanceMonitor.end(totalMarker);
@@ -6624,16 +6788,27 @@ function tws(classNames, convertToJson) {
6624
6788
  // Process classes with performance monitoring
6625
6789
  const processMarker = performanceMonitor.start("tws:process");
6626
6790
  let cssResult = classes.map(className => {
6627
- let result = cssObject[className] || cssObject[className.replace(/(\/)/g, "\\$1")] || cssObject[className.replace(/\./g, "\\.")];
6791
+ // Extract base class name without opacity modifier
6792
+ const baseClassName = className.replace(/\/\d+$/, "");
6793
+ let result = cssObject[baseClassName] || cssObject[baseClassName.replace(/(\/)/g, "\\$1")] || cssObject[baseClassName.replace(/\./g, "\\.")];
6628
6794
  if (result) {
6795
+ // Apply opacity modifier if present
6796
+ if (className.includes("/") && /\/\d+$/.test(className)) {
6797
+ result = processOpacityModifier(className, result);
6798
+ }
6629
6799
  return resolveCssToClearCss(result);
6630
- } else if (className.includes("[")) {
6631
- const match = className.match(/\[([^\]]+)\]/);
6800
+ } else if (baseClassName.includes("[")) {
6801
+ const match = baseClassName.match(/\[([^\]]+)\]/);
6632
6802
  if (match) {
6633
6803
  const customValue = match[1];
6634
- const baseKey = className.split("[")[0];
6804
+ const baseKey = baseClassName.split("[")[0];
6635
6805
  if (cssObject[`${baseKey}custom`]) {
6636
- return cssObject[`${baseKey}custom`].replace(/custom_value/g, customValue);
6806
+ let customResult = cssObject[`${baseKey}custom`].replace(/custom_value/g, customValue);
6807
+ // Apply opacity modifier to custom values too
6808
+ if (className.includes("/") && /\/\d+$/.test(className)) {
6809
+ customResult = processOpacityModifier(className, customResult);
6810
+ }
6811
+ return customResult;
6637
6812
  }
6638
6813
  }
6639
6814
  }
@@ -6764,9 +6939,12 @@ function processClass(cls, selector, styles) {
6764
6939
  media,
6765
6940
  finalSelector
6766
6941
  } = resolveVariants(selector, rawVariants);
6767
- let declarations = cssObject[pureClassName] || cssObject[pureClassName.replace(/(\/)/g, "\\$1")] || cssObject[pureClassName.replace(/\./g, "\\.")];
6768
- if (!declarations && pureClassName.includes("[")) {
6769
- const match = pureClassName.match(/^(.+?)\[(.+)\]$/);
6942
+
6943
+ // Extract base class name without opacity modifier for CSS lookup
6944
+ const baseClassName = pureClassName.replace(/\/\d+$/, "");
6945
+ let declarations = cssObject[baseClassName] || cssObject[baseClassName.replace(/(\/)/g, "\\$1")] || cssObject[baseClassName.replace(/\./g, "\\.")];
6946
+ if (!declarations && baseClassName.includes("[")) {
6947
+ const match = baseClassName.match(/^(.+?)\[(.+)\]$/);
6770
6948
  if (match) {
6771
6949
  const [, prefix, dynamicValue] = match;
6772
6950
  const customKey = `${prefix}custom`;
@@ -6777,17 +6955,22 @@ function processClass(cls, selector, styles) {
6777
6955
  }
6778
6956
  }
6779
6957
  if (!declarations) {
6780
- declarations = parseCustomClassWithPatterns(pureClassName);
6958
+ declarations = parseCustomClassWithPatterns(baseClassName);
6781
6959
  }
6782
6960
  if (!declarations) {
6783
6961
  return;
6784
6962
  }
6963
+
6964
+ // Apply opacity modifier if present
6965
+ if (pureClassName.includes("/") && /\/\d+$/.test(pureClassName)) {
6966
+ declarations = processOpacityModifier(pureClassName, declarations);
6967
+ }
6785
6968
  if (isImportant) {
6786
6969
  declarations = declarations.replace(/([^:;]+):([^;]+)(;?)/g, (_, prop, value) => {
6787
6970
  return prop.trim().startsWith("--") ? `${prop}:${value};` : `${prop}:${value.trim()} !important;`;
6788
6971
  });
6789
6972
  }
6790
- const isSpaceOrDivide = ["space-x-", "-space-x-", "space-y-", "-space-y-", "divide-"].some(prefix => pureClassName.startsWith(prefix));
6973
+ const isSpaceOrDivide = ["space-x-", "-space-x-", "space-y-", "-space-y-", "divide-"].some(prefix => baseClassName.startsWith(prefix));
6791
6974
  const expandedSelector = replaceSelector(finalSelector);
6792
6975
  const targetSelector = isSpaceOrDivide ? `${expandedSelector} > :not([hidden]) ~ :not([hidden])` : expandedSelector;
6793
6976
  if (media) {
@@ -6954,12 +7137,12 @@ function generateCssString(styles) {
6954
7137
  return cssString.trim();
6955
7138
  }
6956
7139
 
6957
- /**
6958
- * Menghasilkan string CSS dari objek style dengan sintaks mirip SCSS
6959
- * Mendukung nested selectors, state variants, responsive variants, dan @css directives
6960
- * @param {Object} obj - Objek dengan format style mirip SCSS
6961
- * @param {Object} [options] - Opsi tambahan, misal { inject: true/false }
6962
- * @returns {string} String CSS yang dihasilkan
7140
+ /**
7141
+ * Generate CSS string from style object with SCSS-like syntax
7142
+ * Supports nested selectors, state variants, responsive variants, and @css directives
7143
+ * @param {Object} obj - Object with SCSS-like style format
7144
+ * @param {Object} [options] - Additional options, merges with global config
7145
+ * @returns {string} Generated CSS string
6963
7146
  */
6964
7147
  function twsx(obj) {
6965
7148
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -6969,9 +7152,13 @@ function twsx(obj) {
6969
7152
  console.warn("twsx: Expected an object but received:", obj);
6970
7153
  return "";
6971
7154
  }
7155
+ const mergedOptions = {
7156
+ ...globalConfig,
7157
+ ...options
7158
+ };
6972
7159
  const {
6973
7160
  inject = true
6974
- } = options;
7161
+ } = mergedOptions;
6975
7162
  const styles = {};
6976
7163
 
6977
7164
  // Create walk function with closure over styles
@@ -7019,7 +7206,7 @@ function twsx(obj) {
7019
7206
  }
7020
7207
  }
7021
7208
 
7022
- // Fungsi hashCode sederhana untuk deduplikasi CSS
7209
+ // Simple hashCode function for CSS deduplication
7023
7210
  function getCssHash(str) {
7024
7211
  let hash = 0,
7025
7212
  i,
@@ -7033,7 +7220,7 @@ function getCssHash(str) {
7033
7220
  return hash;
7034
7221
  }
7035
7222
 
7036
- // Enhanced auto-inject CSS dengan performance monitoring
7223
+ // Enhanced auto-inject CSS with performance monitoring
7037
7224
  const injectedCssHashSet = new Set();
7038
7225
  function autoInjectCss(cssString) {
7039
7226
  const marker = performanceMonitor.start("css:inject");
@@ -7065,24 +7252,24 @@ function autoInjectCss(cssString) {
7065
7252
  }
7066
7253
  }
7067
7254
 
7068
- // Enhanced debounced functions dengan konfigurasi performance monitoring
7069
- /**
7070
- * Versi debounced dari fungsi tws dengan performance monitoring
7071
- * @param {string} classNames - String berisi kelas Tailwind yang akan dikonversi
7072
- * @param {boolean} convertToJson - Jika true, hasil akan menjadi objek JSON, jika false menjadi string CSS
7073
- * @returns {string|Object} String CSS inline atau objek style JSON
7255
+ // Enhanced debounced functions with performance monitoring configuration
7256
+ /**
7257
+ * Debounced version of tws function with performance monitoring
7258
+ * @param {string} classNames - String containing Tailwind classes to convert
7259
+ * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
7260
+ * @returns {string|Object} Inline CSS string or style JSON object
7074
7261
  */
7075
7262
  const debouncedTws = debounce(tws, 50); // Faster debounce for tws
7076
7263
 
7077
- /**
7078
- * Versi debounced dari fungsi twsx dengan performance monitoring
7079
- * @param {Object} obj - Objek dengan format style mirip SCSS
7080
- * @param {Object} [options] - Opsi tambahan
7081
- * @returns {string} String CSS yang dihasilkan
7264
+ /**
7265
+ * Debounced version of twsx function with performance monitoring
7266
+ * @param {Object} obj - Object with SCSS-like style format
7267
+ * @param {Object} [options] - Additional options
7268
+ * @returns {string} Generated CSS string
7082
7269
  */
7083
7270
  const debouncedTwsx = debounce(twsx, 100); // Standard debounce for twsx
7084
7271
 
7085
- // Export performance utilities untuk debugging
7272
+ // Export performance utilities for debugging
7086
7273
  const performanceUtils = {
7087
7274
  getStats() {
7088
7275
  return {
@@ -7110,8 +7297,8 @@ const performanceUtils = {
7110
7297
  enablePerformanceLogging() {
7111
7298
  let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
7112
7299
  performanceMonitor.enabled = enabled && typeof performance !== "undefined";
7113
- console.log(`Performance monitoring ${enabled ? 'enabled' : 'disabled'}`);
7300
+ console.log(`Performance monitoring ${enabled ? "enabled" : "disabled"}`);
7114
7301
  }
7115
7302
  };
7116
7303
 
7117
- export { debouncedTws, debouncedTwsx, performanceUtils, tws, twsx };
7304
+ export { debouncedTws, debouncedTwsx, getConfig, performanceUtils, resetConfig, setConfig, tws, twsx };