tailwind-to-style 2.5.1 → 2.5.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.
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.5.0
2
+ * tailwind-to-style v2.5.2
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
@@ -1349,9 +1349,11 @@ function generateCssString(getCssString = () => {}) {
1349
1349
 
1350
1350
  const hexColor = /^#(?:[0-9a-fA-F]{3}){1,2}$/;
1351
1351
  const rgbColor = /^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/;
1352
- const rgbaColor = /^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*(0|1|0?\.\d+)\s*\)$/;
1352
+ const rgbaColor =
1353
+ /^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*(0|1|0?\.\d+)\s*\)$/;
1353
1354
  const hslColor = /^hsl\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*\)$/;
1354
- const hslaColor = /^hsla\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*,\s*(0|1|0?\.\d+)\s*\)$/;
1355
+ const hslaColor =
1356
+ /^hsla\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*,\s*(0|1|0?\.\d+)\s*\)$/;
1355
1357
 
1356
1358
  return [
1357
1359
  hexColor.test(value),
@@ -4480,62 +4482,62 @@ function generator$I(configOptions = {}) {
4480
4482
  return responsiveCssString;
4481
4483
  }
4482
4484
 
4483
- function generator$H(configOptions = {}) {
4484
- const { prefix: globalPrefix, theme = {} } = configOptions;
4485
-
4486
- const { rotate = {} } = theme;
4487
-
4488
- Object.entries(rotate).forEach(([key, value]) => {
4489
- rotate[`-${key}`] = `-${value}`.replace("--", "-");
4490
- });
4491
-
4492
- const responsiveCssString = generateCssString(({ getCssByOptions }) => {
4493
- const cssString = getCssByOptions(rotate, (keyTmp, value) => {
4494
- let prefix = `${globalPrefix}rotate`;
4495
- let key = keyTmp;
4496
- if (`${key}`.indexOf("-") >= 0) {
4497
- key = key.split("-").join("");
4498
- prefix = `${globalPrefix}-rotate`;
4499
- }
4500
- return `
4501
- ${prefix}-${key} {
4502
- --transform-rotate: ${value};
4503
- }
4504
- `;
4505
- });
4506
- return cssString;
4507
- });
4508
-
4509
- return responsiveCssString;
4485
+ function generator$H(configOptions = {}) {
4486
+ const { prefix: globalPrefix, theme = {} } = configOptions;
4487
+
4488
+ const { rotate = {} } = theme;
4489
+
4490
+ Object.entries(rotate).forEach(([key, value]) => {
4491
+ rotate[`-${key}`] = `-${value}`.replace("--", "-");
4492
+ });
4493
+
4494
+ const responsiveCssString = generateCssString(({ getCssByOptions }) => {
4495
+ const cssString = getCssByOptions(rotate, (keyTmp, value) => {
4496
+ let prefix = `${globalPrefix}rotate`;
4497
+ let key = keyTmp;
4498
+ if (`${key}`.indexOf("-") >= 0) {
4499
+ key = key.split("-").join("");
4500
+ prefix = `${globalPrefix}-rotate`;
4501
+ }
4502
+ return `
4503
+ ${prefix}-${key} {
4504
+ --transform-rotate: ${value};
4505
+ }
4506
+ `;
4507
+ });
4508
+ return cssString;
4509
+ });
4510
+
4511
+ return responsiveCssString;
4510
4512
  }
4511
4513
 
4512
- function generator$G(configOptions = {}) {
4513
- const { prefix: globalPrefix, theme = {} } = configOptions;
4514
-
4515
- const prefix = `${globalPrefix}scale`;
4516
-
4517
- const { scale = {} } = theme;
4518
-
4519
- const responsiveCssString = generateCssString(({ getCssByOptions }) => {
4520
- const cssString = getCssByOptions(
4521
- scale,
4522
- (key, value) => `
4523
- ${prefix}-${key} {
4524
- --transform-scale-x: ${value};
4525
- --transform-scale-y: ${value};
4526
- }
4527
- ${prefix}-x-${key} {
4528
- --transform-scale-x: ${value};
4529
- }
4530
- ${prefix}-y-${key} {
4531
- --transform-scale-y: ${value};
4532
- }
4533
- `
4534
- );
4535
- return cssString;
4536
- });
4537
-
4538
- return responsiveCssString;
4514
+ function generator$G(configOptions = {}) {
4515
+ const { prefix: globalPrefix, theme = {} } = configOptions;
4516
+
4517
+ const prefix = `${globalPrefix}scale`;
4518
+
4519
+ const { scale = {} } = theme;
4520
+
4521
+ const responsiveCssString = generateCssString(({ getCssByOptions }) => {
4522
+ const cssString = getCssByOptions(
4523
+ scale,
4524
+ (key, value) => `
4525
+ ${prefix}-${key} {
4526
+ --transform-scale-x: ${value};
4527
+ --transform-scale-y: ${value};
4528
+ }
4529
+ ${prefix}-x-${key} {
4530
+ --transform-scale-x: ${value};
4531
+ }
4532
+ ${prefix}-y-${key} {
4533
+ --transform-scale-y: ${value};
4534
+ }
4535
+ `
4536
+ );
4537
+ return cssString;
4538
+ });
4539
+
4540
+ return responsiveCssString;
4539
4541
  }
4540
4542
 
4541
4543
  function generator$F(configOptions = {}) {
@@ -4802,36 +4804,36 @@ function generator$y(configOptions = {}) {
4802
4804
  return responsiveCssString;
4803
4805
  }
4804
4806
 
4805
- function generator$x(configOptions = {}) {
4806
- const { prefix: globalPrefix, theme = {} } = configOptions;
4807
-
4808
- const { skew = {} } = theme;
4809
-
4810
- Object.entries(skew).forEach(([key, value]) => {
4811
- skew[`-${key}`] = `-${value}`.replace("--", "-");
4812
- });
4813
-
4814
- const responsiveCssString = generateCssString(({ getCssByOptions }) => {
4815
- const cssString = getCssByOptions(skew, (keyTmp, value) => {
4816
- let prefix = `${globalPrefix}skew`;
4817
- let key = keyTmp;
4818
- if (`${key}`.indexOf("-") >= 0) {
4819
- key = key.split("-").join("");
4820
- prefix = `${globalPrefix}-skew`;
4821
- }
4822
- return `
4823
- ${prefix}-x-${key} {
4824
- --transform-skew-x: ${value};
4825
- }
4826
- ${prefix}-y-${key} {
4827
- --transform-skew-y: ${value};
4828
- }
4829
- `;
4830
- });
4831
- return cssString;
4832
- });
4833
-
4834
- return responsiveCssString;
4807
+ function generator$x(configOptions = {}) {
4808
+ const { prefix: globalPrefix, theme = {} } = configOptions;
4809
+
4810
+ const { skew = {} } = theme;
4811
+
4812
+ Object.entries(skew).forEach(([key, value]) => {
4813
+ skew[`-${key}`] = `-${value}`.replace("--", "-");
4814
+ });
4815
+
4816
+ const responsiveCssString = generateCssString(({ getCssByOptions }) => {
4817
+ const cssString = getCssByOptions(skew, (keyTmp, value) => {
4818
+ let prefix = `${globalPrefix}skew`;
4819
+ let key = keyTmp;
4820
+ if (`${key}`.indexOf("-") >= 0) {
4821
+ key = key.split("-").join("");
4822
+ prefix = `${globalPrefix}-skew`;
4823
+ }
4824
+ return `
4825
+ ${prefix}-x-${key} {
4826
+ --transform-skew-x: ${value};
4827
+ }
4828
+ ${prefix}-y-${key} {
4829
+ --transform-skew-y: ${value};
4830
+ }
4831
+ `;
4832
+ });
4833
+ return cssString;
4834
+ });
4835
+
4836
+ return responsiveCssString;
4835
4837
  }
4836
4838
 
4837
4839
  function generator$w(configOptions = {}) {
@@ -5406,86 +5408,86 @@ function generator$b(configOptions = {}) {
5406
5408
  return responsiveCssString;
5407
5409
  }
5408
5410
 
5409
- function generator$a({ prefix }) {
5410
- return `
5411
- ${prefix}transform {
5412
- --transform-translate-x: 0;
5413
- --transform-translate-y: 0;
5414
- --transform-rotate: 0;
5415
- --transform-skew-x: 0;
5416
- --transform-skew-y: 0;
5417
- --transform-scale-x: 1;
5418
- --transform-scale-y: 1;
5419
- transform: translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) rotate(var(--transform-rotate)) skewX(var(--transform-skew-x)) skewY(var(--transform-skew-y)) scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y));
5420
- }
5421
- ${prefix}transform-none {
5422
- transform: none;
5423
- }
5424
- `;
5411
+ function generator$a({ prefix }) {
5412
+ return `
5413
+ ${prefix}transform {
5414
+ --transform-translate-x: 0;
5415
+ --transform-translate-y: 0;
5416
+ --transform-rotate: 0;
5417
+ --transform-skew-x: 0;
5418
+ --transform-skew-y: 0;
5419
+ --transform-scale-x: 1;
5420
+ --transform-scale-y: 1;
5421
+ transform: translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) rotate(var(--transform-rotate)) skewX(var(--transform-skew-x)) skewY(var(--transform-skew-y)) scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y));
5422
+ }
5423
+ ${prefix}transform-none {
5424
+ transform: none;
5425
+ }
5426
+ `;
5425
5427
  }
5426
5428
 
5427
- function generator$9(configOptions = {}) {
5428
- const { prefix: globalPrefix } = configOptions;
5429
-
5430
- const prefix = `${globalPrefix}origin`;
5431
-
5432
- const propertyOptions = [
5433
- "center",
5434
- "top",
5435
- "top-right",
5436
- "right",
5437
- "bottom-right",
5438
- "bottom",
5439
- "bottom-left",
5440
- "left",
5441
- "top-left",
5442
- ];
5443
-
5444
- const responsiveCssString = generateCssString(({ getCssByOptions }) => {
5445
- const cssString = getCssByOptions(
5446
- propertyOptions,
5447
- (key, value) => `
5448
- ${prefix}-${key} {
5449
- transform-origin: ${value.replace("-", " ")} !important;
5450
- }
5451
- `
5452
- );
5453
- return cssString;
5454
- });
5455
-
5456
- return responsiveCssString;
5429
+ function generator$9(configOptions = {}) {
5430
+ const { prefix: globalPrefix } = configOptions;
5431
+
5432
+ const prefix = `${globalPrefix}origin`;
5433
+
5434
+ const propertyOptions = [
5435
+ "center",
5436
+ "top",
5437
+ "top-right",
5438
+ "right",
5439
+ "bottom-right",
5440
+ "bottom",
5441
+ "bottom-left",
5442
+ "left",
5443
+ "top-left",
5444
+ ];
5445
+
5446
+ const responsiveCssString = generateCssString(({ getCssByOptions }) => {
5447
+ const cssString = getCssByOptions(
5448
+ propertyOptions,
5449
+ (key, value) => `
5450
+ ${prefix}-${key} {
5451
+ transform-origin: ${value.replace("-", " ")} !important;
5452
+ }
5453
+ `
5454
+ );
5455
+ return cssString;
5456
+ });
5457
+
5458
+ return responsiveCssString;
5457
5459
  }
5458
5460
 
5459
- function generator$8(configOptions = {}) {
5460
- const { prefix: globalPrefix, theme = {} } = configOptions;
5461
-
5462
- const { translate = {} } = theme;
5463
-
5464
- Object.entries(translate).forEach(([key, value]) => {
5465
- translate[`-${key}`] = `-${value}`.replace("--", "-");
5466
- });
5467
-
5468
- const responsiveCssString = generateCssString(({ getCssByOptions }) => {
5469
- const cssString = getCssByOptions(translate, (keyTmp, value) => {
5470
- let prefix = `${globalPrefix}translate`;
5471
- let key = keyTmp;
5472
- if (`${key}`.indexOf("-") >= 0) {
5473
- key = key.split("-").join("");
5474
- prefix = `${globalPrefix}-translate`;
5475
- }
5476
- return `
5477
- ${prefix}-x-${key} {
5478
- --transform-translate-x: ${value};
5479
- }
5480
- ${prefix}-y-${key} {
5481
- --transform-translate-y: ${value};
5482
- }
5483
- `;
5484
- });
5485
- return cssString;
5486
- });
5487
-
5488
- return responsiveCssString;
5461
+ function generator$8(configOptions = {}) {
5462
+ const { prefix: globalPrefix, theme = {} } = configOptions;
5463
+
5464
+ const { translate = {} } = theme;
5465
+
5466
+ Object.entries(translate).forEach(([key, value]) => {
5467
+ translate[`-${key}`] = `-${value}`.replace("--", "-");
5468
+ });
5469
+
5470
+ const responsiveCssString = generateCssString(({ getCssByOptions }) => {
5471
+ const cssString = getCssByOptions(translate, (keyTmp, value) => {
5472
+ let prefix = `${globalPrefix}translate`;
5473
+ let key = keyTmp;
5474
+ if (`${key}`.indexOf("-") >= 0) {
5475
+ key = key.split("-").join("");
5476
+ prefix = `${globalPrefix}-translate`;
5477
+ }
5478
+ return `
5479
+ ${prefix}-x-${key} {
5480
+ --transform-translate-x: ${value};
5481
+ }
5482
+ ${prefix}-y-${key} {
5483
+ --transform-translate-y: ${value};
5484
+ }
5485
+ `;
5486
+ });
5487
+ return cssString;
5488
+ });
5489
+
5490
+ return responsiveCssString;
5489
5491
  }
5490
5492
 
5491
5493
  function generator$7(configOptions = {}) {
@@ -5697,59 +5699,60 @@ function generator(configOptions = {}) {
5697
5699
  return responsiveCssString;
5698
5700
  }
5699
5701
 
5700
- const patterns$1 = {
5701
- transitionNone: {
5702
- regex: /^transition-none$/,
5703
- cssProp: "transition-property",
5704
- formatter: () => "none",
5705
- },
5706
- transitionAll: {
5707
- regex: /^transition$/,
5708
- cssProp: "transition-property",
5709
- formatter: () => "all",
5710
- },
5711
- transitionProp: {
5712
- regex: /^transition-(opacity|colors|color|background|background-color|transform|shadow|opacity|all|none)$/,
5713
- cssProp: "transition-property",
5714
- formatter: (value) => {
5715
- if (value === "colors")
5716
- return "color, background-color, border-color, text-decoration-color, fill, stroke";
5717
- if (value === "color") return "color";
5718
- if (value === "background") return "background-color";
5719
- return value;
5720
- },
5721
- },
5722
- duration: {
5723
- regex: /^duration-(\d+)$/,
5724
- cssProp: "transition-duration",
5725
- formatter: (value) => `${value}ms`,
5726
- },
5727
- delay: {
5728
- regex: /^delay-(\d+)$/,
5729
- cssProp: "transition-delay",
5730
- formatter: (value) => `${value}ms`,
5731
- },
5732
- ease: {
5733
- regex: /^ease-(linear|in|out|in-out)$/,
5734
- cssProp: "transition-timing-function",
5735
- formatter: (value) => {
5736
- switch (value) {
5737
- case "in":
5738
- return "cubic-bezier(0.4, 0, 1, 1)";
5739
- case "out":
5740
- return "cubic-bezier(0, 0, 0.2, 1)";
5741
- case "in-out":
5742
- return "cubic-bezier(0.4, 0, 0.2, 1)";
5743
- case "linear":
5744
- default:
5745
- return "linear";
5746
- }
5747
- },
5748
- },
5702
+ const transition = {
5703
+ transitionNone: {
5704
+ regex: /^transition-none$/,
5705
+ cssProp: "transition-property",
5706
+ formatter: () => "none",
5707
+ },
5708
+ transitionAll: {
5709
+ regex: /^transition$/,
5710
+ cssProp: "transition-property",
5711
+ formatter: () => "all",
5712
+ },
5713
+ transitionProp: {
5714
+ regex:
5715
+ /^transition-(opacity|colors|color|background|background-color|transform|shadow|opacity|all|none)$/,
5716
+ cssProp: "transition-property",
5717
+ formatter: (value) => {
5718
+ if (value === "colors")
5719
+ return "color, background-color, border-color, text-decoration-color, fill, stroke";
5720
+ if (value === "color") return "color";
5721
+ if (value === "background") return "background-color";
5722
+ return value;
5723
+ },
5724
+ },
5725
+ duration: {
5726
+ regex: /^duration-(\d+)$/,
5727
+ cssProp: "transition-duration",
5728
+ formatter: (value) => `${value}ms`,
5729
+ },
5730
+ delay: {
5731
+ regex: /^delay-(\d+)$/,
5732
+ cssProp: "transition-delay",
5733
+ formatter: (value) => `${value}ms`,
5734
+ },
5735
+ ease: {
5736
+ regex: /^ease-(linear|in|out|in-out)$/,
5737
+ cssProp: "transition-timing-function",
5738
+ formatter: (value) => {
5739
+ switch (value) {
5740
+ case "in":
5741
+ return "cubic-bezier(0.4, 0, 1, 1)";
5742
+ case "out":
5743
+ return "cubic-bezier(0, 0, 0.2, 1)";
5744
+ case "in-out":
5745
+ return "cubic-bezier(0.4, 0, 0.2, 1)";
5746
+ case "linear":
5747
+ default:
5748
+ return "linear";
5749
+ }
5750
+ },
5751
+ },
5749
5752
  };
5750
5753
 
5751
5754
  const patterns = {
5752
- ...patterns$1,
5755
+ ...transition,
5753
5756
  };
5754
5757
 
5755
5758
  const plugins = {
@@ -5923,18 +5926,49 @@ function parseCustomClassWithPatterns(className) {
5923
5926
  return null;
5924
5927
  }
5925
5928
 
5929
+ /**
5930
+ * Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
5931
+ * @param {string} cssString
5932
+ * @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
5933
+ */
5934
+ function resolveCssToClearCss(cssString) {
5935
+ const customVars = {};
5936
+ const props = {};
5937
+ cssString.split(";").forEach((decl) => {
5938
+ const [key, value] = decl.split(":").map((s) => s && s.trim());
5939
+ if (!key || !value) return;
5940
+ if (key.startsWith("--")) {
5941
+ customVars[key] = value;
5942
+ } else {
5943
+ props[key] = value;
5944
+ }
5945
+ });
5946
+ // Replace var(--foo) in all values
5947
+ Object.keys(props).forEach((key) => {
5948
+ let val = props[key];
5949
+ val = val.replace(/var\((--[a-zA-Z0-9-_]+)\)/g, (m, v) =>
5950
+ customVars[v] !== undefined ? customVars[v] : m
5951
+ );
5952
+ props[key] = val;
5953
+ });
5954
+ // Build CSS string
5955
+ return Object.entries(props)
5956
+ .map(([k, v]) => `${k}: ${v};`)
5957
+ .join(" ");
5958
+ }
5959
+
5926
5960
  // Cache untuk getConfigOptions
5927
5961
  const configOptionsCache = new Map();
5928
5962
  const cacheKey = (options) => JSON.stringify(options);
5929
5963
 
5930
5964
  function generateTailwindCssString(options = {}) {
5931
- // Menggunakan cache untuk mencegah pemrosesan ulang yang tidak perlu
5965
+ // Menggunakan cache untuk mencegah pemrosesan ulang yang tidak perlu
5932
5966
  const key = cacheKey(options);
5933
5967
  if (!configOptionsCache.has(key)) {
5934
5968
  configOptionsCache.set(key, getConfigOptions(options));
5935
5969
  limitCacheSize(configOptionsCache);
5936
5970
  }
5937
-
5971
+
5938
5972
  const configOptions = configOptionsCache.get(key);
5939
5973
  const { corePlugins = {} } = configOptions;
5940
5974
  const corePluginKeys = Object.keys(corePlugins);
@@ -6016,14 +6050,14 @@ const encodeBracketCache = new Map();
6016
6050
  function encodeBracketValues(input) {
6017
6051
  if (!input) return input;
6018
6052
  if (encodeBracketCache.has(input)) return encodeBracketCache.get(input);
6019
-
6053
+
6020
6054
  const result = input.replace(/\[([^\]]+)\]/g, (_, content) => {
6021
6055
  const encoded = encodeURIComponent(content)
6022
6056
  .replace(/\(/g, "__P__")
6023
6057
  .replace(/\)/g, "__C__");
6024
6058
  return `[${encoded}]`;
6025
6059
  });
6026
-
6060
+
6027
6061
  encodeBracketCache.set(input, result);
6028
6062
  limitCacheSize(encodeBracketCache);
6029
6063
  return result;
@@ -6033,11 +6067,11 @@ const decodeBracketCache = new Map();
6033
6067
  function decodeBracketValues(input) {
6034
6068
  if (!input) return input;
6035
6069
  if (decodeBracketCache.has(input)) return decodeBracketCache.get(input);
6036
-
6070
+
6037
6071
  const result = decodeURIComponent(input)
6038
6072
  .replace(/__P__/g, "(")
6039
6073
  .replace(/__C__/g, ")");
6040
-
6074
+
6041
6075
  decodeBracketCache.set(input, result);
6042
6076
  limitCacheSize(decodeBracketCache);
6043
6077
  return result;
@@ -6100,33 +6134,34 @@ function inlineStyleToJson(styleString) {
6100
6134
  const cssResolutionCache = new Map();
6101
6135
 
6102
6136
  function separateAndResolveCSS(arr) {
6103
- // Membuat kunci cache const cacheKey = arr.join('|');
6137
+ // Perbaiki: cacheKey harus unik untuk setiap input array
6138
+ const cacheKey = Array.isArray(arr) ? arr.join('|') : String(arr);
6104
6139
  if (cssResolutionCache.has(cacheKey)) {
6105
6140
  return cssResolutionCache.get(cacheKey);
6106
6141
  }
6107
-
6142
+
6108
6143
  // Batasi ukuran cache untuk menghindari memory leak
6109
6144
  limitCacheSize(cssResolutionCache);
6110
-
6145
+
6111
6146
  const cssProperties = {};
6112
6147
  arr.forEach((item) => {
6113
6148
  if (!item) return;
6114
-
6149
+
6115
6150
  const declarations = item
6116
6151
  .split(";")
6117
6152
  .map((decl) => decl.trim())
6118
6153
  .filter((decl) => decl);
6119
6154
 
6120
6155
  declarations.forEach((declaration) => {
6121
- const colonIndex = declaration.indexOf(':');
6156
+ const colonIndex = declaration.indexOf(":");
6122
6157
  if (colonIndex === -1) return;
6123
-
6158
+
6124
6159
  const key = declaration.substring(0, colonIndex).trim();
6125
6160
  const value = declaration.substring(colonIndex + 1).trim();
6126
-
6161
+
6127
6162
  if (key && value) {
6128
6163
  // Prioritaskan nilai yang lebih spesifik (misalnya !important)
6129
- if (value.includes('!important') || !cssProperties[key]) {
6164
+ if (value.includes("!important") || !cssProperties[key]) {
6130
6165
  cssProperties[key] = value;
6131
6166
  }
6132
6167
  }
@@ -6136,8 +6171,8 @@ function separateAndResolveCSS(arr) {
6136
6171
  const resolvedProperties = { ...cssProperties };
6137
6172
 
6138
6173
  const resolveValue = (value, variables) => {
6139
- if (!value || !value.includes('var(')) return value;
6140
-
6174
+ if (!value || !value.includes("var(")) return value;
6175
+
6141
6176
  return value.replace(
6142
6177
  /var\((--[a-zA-Z0-9-]+)(?:,\s*([^)]+))?\)/g,
6143
6178
  (match, variable, fallback) => {
@@ -6164,7 +6199,7 @@ function separateAndResolveCSS(arr) {
6164
6199
  const result = Object.entries(resolvedProperties)
6165
6200
  .map(([key, value]) => `${key}: ${value};`)
6166
6201
  .join(" ");
6167
-
6202
+
6168
6203
  cssResolutionCache.set(cacheKey, result);
6169
6204
  return result;
6170
6205
  }
@@ -6175,14 +6210,14 @@ function limitCacheSize(cache, maxSize = 1000) {
6175
6210
  // Hapus 20% entri yang paling lama
6176
6211
  const entriesToRemove = Math.floor(cache.size * 0.2);
6177
6212
  const keys = Array.from(cache.keys()).slice(0, entriesToRemove);
6178
- keys.forEach(key => cache.delete(key));
6213
+ keys.forEach((key) => cache.delete(key));
6179
6214
  }
6180
6215
  }
6181
6216
 
6182
6217
  // Implementasi fungsi debounce untuk mengoptimalkan panggilan berulang
6183
6218
  function debounce(func, wait = 100) {
6184
6219
  let timeout;
6185
- return function(...args) {
6220
+ return function (...args) {
6186
6221
  const context = this;
6187
6222
  clearTimeout(timeout);
6188
6223
  timeout = setTimeout(() => func.apply(context, args), wait);
@@ -6208,8 +6243,8 @@ function tws(classNames, convertToJson) {
6208
6243
 
6209
6244
  let classes;
6210
6245
  try {
6211
- classes = classNames.match(/[\w-]+\[[^\]]+\]|[\w-]+\.\d+|[\w-]+/g);
6212
-
6246
+ classes = classNames.match(/[\w-\/]+(?:\[[^\]]+\])?/g);
6247
+
6213
6248
  // Jika tidak ada class yang valid ditemukan
6214
6249
  if (!classes || classes.length === 0) {
6215
6250
  console.warn(`No valid Tailwind classes found in input: "${classNames}"`);
@@ -6221,8 +6256,13 @@ function tws(classNames, convertToJson) {
6221
6256
  }
6222
6257
 
6223
6258
  let cssResult = classes.map((className) => {
6224
- if (cssObject[className]) {
6225
- return cssObject[className];
6259
+ let result =
6260
+ cssObject[className] ||
6261
+ cssObject[className.replace(/(\/)/g, "\\$1")] ||
6262
+ cssObject[className.replace(/\./g, "\\.")];
6263
+
6264
+ if (result) {
6265
+ return resolveCssToClearCss(result);
6226
6266
  } else if (className.includes("[")) {
6227
6267
  const match = className.match(/\[([^\]]+)\]/);
6228
6268
  if (match) {
@@ -6255,11 +6295,11 @@ function tws(classNames, convertToJson) {
6255
6295
  * @returns {string} String CSS yang dihasilkan
6256
6296
  */
6257
6297
  function twsx(obj) {
6258
- if (!obj || typeof obj !== 'object') {
6259
- console.warn('twsx: Expected an object but received:', obj);
6260
- return '';
6298
+ if (!obj || typeof obj !== "object") {
6299
+ console.warn("twsx: Expected an object but received:", obj);
6300
+ return "";
6261
6301
  }
6262
-
6302
+
6263
6303
  const styles = {};
6264
6304
 
6265
6305
  function expandGroupedClass(input) {
@@ -6314,26 +6354,27 @@ function twsx(obj) {
6314
6354
  } while (result !== prev);
6315
6355
 
6316
6356
  return result;
6317
- } function walk(selector, val) {
6318
- if (!selector || typeof selector !== 'string') {
6319
- console.warn('Invalid selector in walk function:', selector);
6357
+ }
6358
+ function walk(selector, val) {
6359
+ if (!selector || typeof selector !== "string") {
6360
+ console.warn("Invalid selector in walk function:", selector);
6320
6361
  return;
6321
6362
  }
6322
-
6363
+
6323
6364
  const { baseSelector, cssProperty } = parseSelector(selector);
6324
- if (
6325
- cssProperty &&
6326
- typeof val === "object" &&
6327
- Array.isArray(val) &&
6328
- val.length > 0
6329
- ) {
6330
- const cssValue = val[0];
6331
- if (typeof cssValue === "string") {
6332
- styles[baseSelector] = styles[baseSelector] || "";
6333
- styles[baseSelector] += `${cssProperty}: ${cssValue};\n`;
6334
- return;
6335
- }
6365
+ if (
6366
+ cssProperty &&
6367
+ typeof val === "object" &&
6368
+ Array.isArray(val) &&
6369
+ val.length > 0
6370
+ ) {
6371
+ const cssValue = val[0];
6372
+ if (typeof cssValue === "string") {
6373
+ styles[baseSelector] = styles[baseSelector] || "";
6374
+ styles[baseSelector] += `${cssProperty}: ${cssValue};\n`;
6375
+ return;
6336
6376
  }
6377
+ }
6337
6378
 
6338
6379
  if (Array.isArray(val)) {
6339
6380
  const [base, nested] = val;
@@ -6472,17 +6513,17 @@ function twsx(obj) {
6472
6513
  if (parseSelectorCache.has(selector)) {
6473
6514
  return parseSelectorCache.get(selector);
6474
6515
  }
6475
-
6516
+
6476
6517
  let result;
6477
- if (selector.includes('@css')) {
6478
- const parts = selector.split('@css');
6518
+ if (selector.includes("@css")) {
6519
+ const parts = selector.split("@css");
6479
6520
  const baseSelector = parts[0].trim();
6480
6521
  const cssProperty = parts[1]?.trim();
6481
6522
  result = { baseSelector, cssProperty };
6482
6523
  } else {
6483
6524
  result = { baseSelector: selector, cssProperty: null };
6484
6525
  }
6485
-
6526
+
6486
6527
  parseSelectorCache.set(selector, result);
6487
6528
  limitCacheSize(parseSelectorCache);
6488
6529
  return result;