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