tailwind-to-style 2.7.6 → 2.7.8

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.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.7.6
2
+ * tailwind-to-style v2.7.8
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
@@ -1899,10 +1899,10 @@ function generator$2i() {
1899
1899
  }
1900
1900
  if (value === "custom_value") {
1901
1901
  return `
1902
- ${prefix}-${key} {
1903
- ${isValidCssColor(value) ? "background-color" : "background"}: ${value};
1904
- }
1905
- `;
1902
+ ${prefix}-${key} {
1903
+ ${isValidCssColor(value) ? "background-color" : "background"}: ${value};
1904
+ }
1905
+ `;
1906
1906
  }
1907
1907
  return `
1908
1908
  ${prefix}-${key} {
@@ -1924,6 +1924,7 @@ function generator$2h() {
1924
1924
  theme = {}
1925
1925
  } = configOptions;
1926
1926
  const prefix = `${globalPrefix}bg`;
1927
+ const customPrefix = `${globalPrefix}bg-image`;
1927
1928
  const {
1928
1929
  backgroundImage = {}
1929
1930
  } = theme;
@@ -1931,11 +1932,20 @@ function generator$2h() {
1931
1932
  let {
1932
1933
  getCssByOptions
1933
1934
  } = _ref;
1934
- const cssString = getCssByOptions(backgroundImage, (key, value) => `
1935
+ const cssString = getCssByOptions(backgroundImage, (key, value) => {
1936
+ if (value === "custom_value") {
1937
+ return `
1938
+ ${customPrefix}-${key} {
1939
+ background-image: ${value};
1940
+ }
1941
+ `;
1942
+ }
1943
+ return `
1935
1944
  ${prefix}-${key} {
1936
1945
  background-image: ${value};
1937
1946
  }
1938
- `);
1947
+ `;
1948
+ });
1939
1949
  return cssString;
1940
1950
  }, configOptions);
1941
1951
  return responsiveCssString;
@@ -1998,6 +2008,7 @@ function generator$2e() {
1998
2008
  theme = {}
1999
2009
  } = configOptions;
2000
2010
  const prefix = `${globalPrefix}bg`;
2011
+ const customPrefix = `${globalPrefix}bg-position`;
2001
2012
  const {
2002
2013
  backgroundPosition = {}
2003
2014
  } = theme;
@@ -2005,11 +2016,20 @@ function generator$2e() {
2005
2016
  let {
2006
2017
  getCssByOptions
2007
2018
  } = _ref;
2008
- const cssString = getCssByOptions(backgroundPosition, (key, value) => `
2019
+ const cssString = getCssByOptions(backgroundPosition, (key, value) => {
2020
+ if (value === "custom_value") {
2021
+ return `
2022
+ ${customPrefix}-${key} {
2023
+ background-position: ${value};
2024
+ }
2025
+ `;
2026
+ }
2027
+ return `
2009
2028
  ${prefix}-${key} {
2010
2029
  background-position: ${value};
2011
2030
  }
2012
- `);
2031
+ `;
2032
+ });
2013
2033
  return cssString;
2014
2034
  }, configOptions);
2015
2035
  return responsiveCssString;
@@ -2050,6 +2070,7 @@ function generator$2c() {
2050
2070
  theme = {}
2051
2071
  } = configOptions;
2052
2072
  const prefix = `${globalPrefix}bg`;
2073
+ const customPrefix = `${globalPrefix}bg-size`;
2053
2074
  const {
2054
2075
  backgroundSize = {}
2055
2076
  } = theme;
@@ -2057,11 +2078,20 @@ function generator$2c() {
2057
2078
  let {
2058
2079
  getCssByOptions
2059
2080
  } = _ref;
2060
- const cssString = getCssByOptions(backgroundSize, (key, value) => `
2081
+ const cssString = getCssByOptions(backgroundSize, (key, value) => {
2082
+ if (value === "custom_value") {
2083
+ return `
2084
+ ${customPrefix}-${key} {
2085
+ background-size: ${value};
2086
+ }
2087
+ `;
2088
+ }
2089
+ return `
2061
2090
  ${prefix}-${key} {
2062
2091
  background-size: ${value};
2063
2092
  }
2064
- `);
2093
+ `;
2094
+ });
2065
2095
  return cssString;
2066
2096
  }, configOptions);
2067
2097
  return responsiveCssString;
@@ -2129,6 +2159,7 @@ function generator$29() {
2129
2159
  theme = {}
2130
2160
  } = configOptions;
2131
2161
  const prefix = `${globalPrefix}border`;
2162
+ const customPrefix = `${globalPrefix}border-color`;
2132
2163
  const {
2133
2164
  borderColor = {}
2134
2165
  } = theme;
@@ -2145,57 +2176,64 @@ function generator$29() {
2145
2176
  if (rgbValue) {
2146
2177
  rgbPropertyValue = `border-color: rgba(${rgbValue}, var(--border-opacity));`;
2147
2178
  }
2179
+ if (value === "custom_value") {
2180
+ return `
2181
+ ${customPrefix}${key} {
2182
+ border-color: ${value};
2183
+ }
2184
+ `;
2185
+ }
2148
2186
  return `
2149
- ${prefix}${key} {
2150
- --border-opacity: 1;
2151
- border-color: ${value};
2152
- ${rgbPropertyValue}
2153
- }
2154
- ${prefix}-x${key} {
2155
- --border-opacity: 1;
2156
- border-left-color: ${value};
2157
- ${rgbPropertyValue}
2158
- border-right-color: ${value};
2159
- ${rgbPropertyValue}
2160
- }
2161
- ${prefix}-y${key} {
2162
- --border-opacity: 1;
2163
- border-top-color: ${value};
2164
- ${rgbPropertyValue}
2165
- border-bottom-color: ${value};
2166
- ${rgbPropertyValue}
2167
- }
2168
- ${prefix}-s${key} {
2169
- --border-opacity: 1;
2170
- border-inline-start-color: ${value};
2171
- ${rgbPropertyValue}
2172
- }
2173
- ${prefix}-e${key} {
2174
- --border-opacity: 1;
2175
- border-inline-end-color: ${value};
2176
- ${rgbPropertyValue}
2177
- }
2178
- ${prefix}-t${key} {
2179
- --border-opacity: 1;
2180
- border-top-color: ${value};
2181
- ${rgbPropertyValue}
2182
- }
2183
- ${prefix}-r${key} {
2184
- --border-opacity: 1;
2185
- border-right-color: ${value};
2186
- ${rgbPropertyValue}
2187
- }
2188
- ${prefix}-b${key} {
2189
- --border-opacity: 1;
2190
- border-bottom-color: ${value};
2191
- ${rgbPropertyValue}
2192
- }
2193
- ${prefix}-l${key} {
2194
- --border-opacity: 1;
2195
- border-left-color: ${value};
2196
- ${rgbPropertyValue}
2197
- }
2198
- `;
2187
+ ${prefix}${key} {
2188
+ --border-opacity: 1;
2189
+ border-color: ${value};
2190
+ ${rgbPropertyValue}
2191
+ }
2192
+ ${prefix}-x${key} {
2193
+ --border-opacity: 1;
2194
+ border-left-color: ${value};
2195
+ ${rgbPropertyValue}
2196
+ border-right-color: ${value};
2197
+ ${rgbPropertyValue}
2198
+ }
2199
+ ${prefix}-y${key} {
2200
+ --border-opacity: 1;
2201
+ border-top-color: ${value};
2202
+ ${rgbPropertyValue}
2203
+ border-bottom-color: ${value};
2204
+ ${rgbPropertyValue}
2205
+ }
2206
+ ${prefix}-s${key} {
2207
+ --border-opacity: 1;
2208
+ border-inline-start-color: ${value};
2209
+ ${rgbPropertyValue}
2210
+ }
2211
+ ${prefix}-e${key} {
2212
+ --border-opacity: 1;
2213
+ border-inline-end-color: ${value};
2214
+ ${rgbPropertyValue}
2215
+ }
2216
+ ${prefix}-t${key} {
2217
+ --border-opacity: 1;
2218
+ border-top-color: ${value};
2219
+ ${rgbPropertyValue}
2220
+ }
2221
+ ${prefix}-r${key} {
2222
+ --border-opacity: 1;
2223
+ border-right-color: ${value};
2224
+ ${rgbPropertyValue}
2225
+ }
2226
+ ${prefix}-b${key} {
2227
+ --border-opacity: 1;
2228
+ border-bottom-color: ${value};
2229
+ ${rgbPropertyValue}
2230
+ }
2231
+ ${prefix}-l${key} {
2232
+ --border-opacity: 1;
2233
+ border-left-color: ${value};
2234
+ ${rgbPropertyValue}
2235
+ }
2236
+ `;
2199
2237
  });
2200
2238
  return cssString;
2201
2239
  }, configOptions);
@@ -2364,6 +2402,7 @@ function generator$24() {
2364
2402
  theme = {}
2365
2403
  } = configOptions;
2366
2404
  const prefix = `${globalPrefix}border`;
2405
+ const customPrefix = `${globalPrefix}border-width`;
2367
2406
  const {
2368
2407
  borderWidth = {}
2369
2408
  } = theme;
@@ -2373,41 +2412,48 @@ function generator$24() {
2373
2412
  } = _ref;
2374
2413
  const cssString = getCssByOptions(borderWidth, (keyTmp, value) => {
2375
2414
  const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
2376
- return `
2377
- ${prefix}${key} {
2378
- border-style: solid;
2379
- border-top-width: ${value};
2380
- border-bottom-width: ${value};
2381
- border-left-width: ${value};
2382
- border-right-width: ${value};
2383
- }
2384
- ${prefix}-x${key} {
2385
- border-left-width: ${value};
2386
- border-right-width: ${value};
2387
- }
2388
- ${prefix}-y${key} {
2389
- border-top-width: ${value};
2390
- border-bottom-width: ${value};
2391
- }
2392
- ${prefix}-s${key} {
2393
- border-inline-start-width: ${value};
2394
- }
2395
- ${prefix}-e${key} {
2396
- border-inline-end-width: ${value};
2397
- }
2398
- ${prefix}-t${key} {
2399
- border-top-width: ${value};
2400
- }
2401
- ${prefix}-r${key} {
2402
- border-right-width: ${value};
2403
- }
2404
- ${prefix}-b${key} {
2405
- border-bottom-width: ${value};
2406
- }
2407
- ${prefix}-l${key} {
2408
- border-left-width: ${value};
2415
+ if (value === "custom_value") {
2416
+ return `
2417
+ ${customPrefix}-${key} {
2418
+ border-width: ${value};
2409
2419
  }
2410
2420
  `;
2421
+ }
2422
+ return `
2423
+ ${prefix}${key} {
2424
+ border-style: solid;
2425
+ border-top-width: ${value};
2426
+ border-bottom-width: ${value};
2427
+ border-left-width: ${value};
2428
+ border-right-width: ${value};
2429
+ }
2430
+ ${prefix}-x${key} {
2431
+ border-left-width: ${value};
2432
+ border-right-width: ${value};
2433
+ }
2434
+ ${prefix}-y${key} {
2435
+ border-top-width: ${value};
2436
+ border-bottom-width: ${value};
2437
+ }
2438
+ ${prefix}-s${key} {
2439
+ border-inline-start-width: ${value};
2440
+ }
2441
+ ${prefix}-e${key} {
2442
+ border-inline-end-width: ${value};
2443
+ }
2444
+ ${prefix}-t${key} {
2445
+ border-top-width: ${value};
2446
+ }
2447
+ ${prefix}-r${key} {
2448
+ border-right-width: ${value};
2449
+ }
2450
+ ${prefix}-b${key} {
2451
+ border-bottom-width: ${value};
2452
+ }
2453
+ ${prefix}-l${key} {
2454
+ border-left-width: ${value};
2455
+ }
2456
+ `;
2411
2457
  });
2412
2458
  return cssString;
2413
2459
  }, configOptions);
@@ -2443,6 +2489,7 @@ function generator$22() {
2443
2489
  theme = {}
2444
2490
  } = configOptions;
2445
2491
  const prefix = `${globalPrefix}shadow`;
2492
+ const customPrefix = `${globalPrefix}box-shadow`;
2446
2493
  const {
2447
2494
  boxShadowColor,
2448
2495
  boxShadow = {}
@@ -2455,6 +2502,13 @@ function generator$22() {
2455
2502
  let cssString = getCssByOptions(boxShadow, (keyTmp, value) => {
2456
2503
  const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
2457
2504
  const valueSplit = value.split(" ");
2505
+ if (value === "custom_value") {
2506
+ return `
2507
+ ${customPrefix}${key} {
2508
+ box-shadow: ${value};
2509
+ }
2510
+ `;
2511
+ }
2458
2512
  return `
2459
2513
  ${prefix}${key} {
2460
2514
  --shadow: ${value};
@@ -3087,6 +3141,7 @@ function generator$1G() {
3087
3141
  theme = {}
3088
3142
  } = configOptions;
3089
3143
  const prefix = `${globalPrefix}text`;
3144
+ const customPrefix = `${globalPrefix}text-size`;
3090
3145
  const {
3091
3146
  fontSize = {}
3092
3147
  } = theme;
@@ -3094,11 +3149,20 @@ function generator$1G() {
3094
3149
  let {
3095
3150
  getCssByOptions
3096
3151
  } = _ref;
3097
- const cssString = getCssByOptions(fontSize, (key, value) => `
3152
+ const cssString = getCssByOptions(fontSize, (key, value) => {
3153
+ if (value === "custom_value") {
3154
+ return `
3155
+ ${customPrefix}${key} {
3156
+ font-size: ${value};
3157
+ }
3158
+ `;
3159
+ }
3160
+ return `
3098
3161
  ${prefix}-${key} {
3099
3162
  font-size: ${value};
3100
3163
  }
3101
- `);
3164
+ `;
3165
+ });
3102
3166
  return cssString;
3103
3167
  }, configOptions);
3104
3168
  return responsiveCssString;
@@ -4247,6 +4311,7 @@ function generator$$() {
4247
4311
  theme = {}
4248
4312
  } = configOptions;
4249
4313
  const prefix = `${globalPrefix}outline`;
4314
+ const customPrefix = `${globalPrefix}outline-color`;
4250
4315
  const {
4251
4316
  outlineColor = {}
4252
4317
  } = theme;
@@ -4263,6 +4328,13 @@ function generator$$() {
4263
4328
  if (rgbValue) {
4264
4329
  rgbPropertyValue = `outline-color: rgba(${rgbValue}, var(--outline-opacity));`;
4265
4330
  }
4331
+ if (value === "custom_value") {
4332
+ return `
4333
+ ${customPrefix}${key} {
4334
+ outline-color: ${value};
4335
+ }
4336
+ `;
4337
+ }
4266
4338
  return `
4267
4339
  ${prefix}${key} {
4268
4340
  --outline-opacity: 1;
@@ -4368,6 +4440,7 @@ function generator$X() {
4368
4440
  theme = {}
4369
4441
  } = configOptions;
4370
4442
  const prefix = `${globalPrefix}outline`;
4443
+ const customPrefix = `${globalPrefix}outline-width`;
4371
4444
  const {
4372
4445
  outlineWidth = {}
4373
4446
  } = theme;
@@ -4376,11 +4449,18 @@ function generator$X() {
4376
4449
  getCssByOptions
4377
4450
  } = _ref;
4378
4451
  const cssString = getCssByOptions(outlineWidth, (key, value) => {
4379
- return `
4380
- ${prefix}-${key} {
4452
+ if (value === "custom_value") {
4453
+ return `
4454
+ ${customPrefix}-${key} {
4381
4455
  outline-width: ${value};
4382
4456
  }
4383
4457
  `;
4458
+ }
4459
+ return `
4460
+ ${prefix}-${key} {
4461
+ outline-width: ${value};
4462
+ }
4463
+ `;
4384
4464
  });
4385
4465
  return cssString;
4386
4466
  }, configOptions);
@@ -5361,6 +5441,7 @@ function generator$r() {
5361
5441
  theme = {}
5362
5442
  } = configOptions;
5363
5443
  const prefix = `${globalPrefix}text`;
5444
+ const customPrefix = `${globalPrefix}text-color`;
5364
5445
  const {
5365
5446
  textColor
5366
5447
  } = theme;
@@ -5373,13 +5454,20 @@ function generator$r() {
5373
5454
  if (rgbValue) {
5374
5455
  rgbPropertyValue = `color: rgba(${rgbValue}, var(--text-opacity));`;
5375
5456
  }
5457
+ if (value === "custom_value") {
5458
+ return `
5459
+ ${customPrefix}-${key} {
5460
+ color: ${value};
5461
+ }
5462
+ `;
5463
+ }
5376
5464
  return `
5377
- ${prefix}-${key} {
5378
- --text-opacity: 1;
5379
- color: ${value};
5380
- ${rgbPropertyValue}
5381
- }
5382
- `;
5465
+ ${prefix}-${key} {
5466
+ --text-opacity: 1;
5467
+ color: ${value};
5468
+ ${rgbPropertyValue}
5469
+ }
5470
+ `;
5383
5471
  });
5384
5472
  return cssString;
5385
5473
  }, configOptions);
@@ -6694,11 +6782,29 @@ function tws(classNames, convertToJson) {
6694
6782
  const processMarker = performanceMonitor.start("tws:process");
6695
6783
  let cssResult = classes.map(className => {
6696
6784
  // 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, "\\.")];
6785
+ // Only remove /digits if it's an opacity modifier (not a fraction like w-2/3)
6786
+ // Opacity modifiers are typically /0-100, fractions are /2, /3, /4, /5, /6, /12
6787
+ const opacityMatch = className.match(/\/(\d+)$/);
6788
+ let baseClassName = className;
6789
+ let hasOpacityModifier = false;
6790
+ if (opacityMatch) {
6791
+ const opacityValue = parseInt(opacityMatch[1], 10);
6792
+ // If it's a valid opacity value (0-100), treat it as opacity modifier
6793
+ if (opacityValue >= 0 && opacityValue <= 100) {
6794
+ // Check if this could be a fraction (e.g., w-2/3, h-1/2)
6795
+ // Fractions typically have denominators of 2, 3, 4, 5, 6, 12
6796
+ const fractionDenominators = [2, 3, 4, 5, 6, 12];
6797
+ const couldBeFraction = fractionDenominators.includes(opacityValue) && (className.startsWith('w-') || className.startsWith('h-') || className.startsWith('max-w-') || className.startsWith('max-h-') || className.startsWith('min-w-') || className.startsWith('min-h-'));
6798
+ if (!couldBeFraction) {
6799
+ baseClassName = className.replace(/\/\d+$/, "");
6800
+ hasOpacityModifier = true;
6801
+ }
6802
+ }
6803
+ }
6804
+ let result = cssObject[baseClassName] || cssObject[baseClassName.replace(/\//g, "\\/")] || cssObject[baseClassName.replace(/\./g, "\\.")];
6699
6805
  if (result) {
6700
6806
  // Apply opacity modifier if present
6701
- if (className.includes("/") && /\/\d+$/.test(className)) {
6807
+ if (hasOpacityModifier && className.includes("/") && /\/\d+$/.test(className)) {
6702
6808
  result = processOpacityModifier(className, result);
6703
6809
  }
6704
6810
  return resolveCssToClearCss(result);
@@ -6710,7 +6816,7 @@ function tws(classNames, convertToJson) {
6710
6816
  if (cssObject[`${baseKey}custom`]) {
6711
6817
  let customResult = cssObject[`${baseKey}custom`].replace(/custom_value/g, customValue);
6712
6818
  // Apply opacity modifier to custom values too
6713
- if (className.includes("/") && /\/\d+$/.test(className)) {
6819
+ if (hasOpacityModifier && className.includes("/") && /\/\d+$/.test(className)) {
6714
6820
  customResult = processOpacityModifier(className, customResult);
6715
6821
  }
6716
6822
  return customResult;
@@ -6846,7 +6952,23 @@ function processClass(cls, selector, styles) {
6846
6952
  } = resolveVariants(selector, rawVariants);
6847
6953
 
6848
6954
  // Extract base class name without opacity modifier for CSS lookup
6849
- const baseClassName = pureClassName.replace(/\/\d+$/, "");
6955
+ // Only remove /digits if it's an opacity modifier (not a fraction like w-2/3)
6956
+ const opacityMatch = pureClassName.match(/\/(\d+)$/);
6957
+ let baseClassName = pureClassName;
6958
+ let hasOpacityModifier = false;
6959
+ if (opacityMatch) {
6960
+ const opacityValue = parseInt(opacityMatch[1], 10);
6961
+ // If it's a valid opacity value (0-100), treat it as opacity modifier
6962
+ if (opacityValue >= 0 && opacityValue <= 100) {
6963
+ // Check if this could be a fraction (e.g., w-2/3, h-1/2)
6964
+ const fractionDenominators = [2, 3, 4, 5, 6, 12];
6965
+ const couldBeFraction = fractionDenominators.includes(opacityValue) && (pureClassName.startsWith('w-') || pureClassName.startsWith('h-') || pureClassName.startsWith('max-w-') || pureClassName.startsWith('max-h-') || pureClassName.startsWith('min-w-') || pureClassName.startsWith('min-h-'));
6966
+ if (!couldBeFraction) {
6967
+ baseClassName = pureClassName.replace(/\/\d+$/, "");
6968
+ hasOpacityModifier = true;
6969
+ }
6970
+ }
6971
+ }
6850
6972
  let declarations = cssObject[baseClassName] || cssObject[baseClassName.replace(/(\/)/g, "\\$1")] || cssObject[baseClassName.replace(/\./g, "\\.")];
6851
6973
  if (!declarations && baseClassName.includes("[")) {
6852
6974
  const match = baseClassName.match(/^(.+?)\[(.+)\]$/);
@@ -6867,7 +6989,7 @@ function processClass(cls, selector, styles) {
6867
6989
  }
6868
6990
 
6869
6991
  // Apply opacity modifier if present
6870
- if (pureClassName.includes("/") && /\/\d+$/.test(pureClassName)) {
6992
+ if (hasOpacityModifier && pureClassName.includes("/") && /\/\d+$/.test(pureClassName)) {
6871
6993
  declarations = processOpacityModifier(pureClassName, declarations);
6872
6994
  }
6873
6995
  if (isImportant) {