tailwind-to-style 2.7.6 → 2.7.7

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.7
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);
@@ -6313,10 +6401,10 @@ function parseCustomClassWithPatterns(className) {
6313
6401
  return null;
6314
6402
  }
6315
6403
 
6316
- /**
6317
- * Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
6318
- * @param {string} cssString
6319
- * @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
6404
+ /**
6405
+ * Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
6406
+ * @param {string} cssString
6407
+ * @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
6320
6408
  */
6321
6409
  function resolveCssToClearCss(cssString) {
6322
6410
  const customVars = {};
@@ -6594,11 +6682,11 @@ function separateAndResolveCSS(arr) {
6594
6682
  }
6595
6683
  }
6596
6684
 
6597
- /**
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
6685
+ /**
6686
+ * Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
6687
+ * @param {string} className - Class name with potential opacity modifier
6688
+ * @param {string} cssDeclaration - CSS declaration to modify
6689
+ * @returns {string} Modified CSS declaration with opacity applied
6602
6690
  */
6603
6691
  function processOpacityModifier(className, cssDeclaration) {
6604
6692
  const opacityMatch = className.match(/\/(\d+)$/);
@@ -6659,11 +6747,11 @@ function processOpacityModifier(className, cssDeclaration) {
6659
6747
  return modifiedDeclaration;
6660
6748
  }
6661
6749
 
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
6750
+ /**
6751
+ * Convert Tailwind class string to inline CSS styles or JSON object
6752
+ * @param {string} classNames - String containing Tailwind classes to convert
6753
+ * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
6754
+ * @returns {string|Object} Inline CSS string or style JSON object
6667
6755
  */
6668
6756
  function tws(classNames, convertToJson) {
6669
6757
  const totalMarker = performanceMonitor.start("tws:total");
@@ -7042,12 +7130,12 @@ function generateCssString(styles) {
7042
7130
  return cssString.trim();
7043
7131
  }
7044
7132
 
7045
- /**
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
7133
+ /**
7134
+ * Generate CSS string from style object with SCSS-like syntax
7135
+ * Supports nested selectors, state variants, responsive variants, and @css directives
7136
+ * @param {Object} obj - Object with SCSS-like style format
7137
+ * @param {Object} [options] - Additional options, e.g. { inject: true/false }
7138
+ * @returns {string} Generated CSS string
7051
7139
  */
7052
7140
  function twsx(obj) {
7053
7141
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -7154,19 +7242,19 @@ function autoInjectCss(cssString) {
7154
7242
  }
7155
7243
 
7156
7244
  // Enhanced debounced functions with performance monitoring configuration
7157
- /**
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
7245
+ /**
7246
+ * Debounced version of tws function with performance monitoring
7247
+ * @param {string} classNames - String containing Tailwind classes to convert
7248
+ * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
7249
+ * @returns {string|Object} Inline CSS string or style JSON object
7162
7250
  */
7163
7251
  const debouncedTws = debounce(tws, 50); // Faster debounce for tws
7164
7252
 
7165
- /**
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
7253
+ /**
7254
+ * Debounced version of twsx function with performance monitoring
7255
+ * @param {Object} obj - Object with SCSS-like style format
7256
+ * @param {Object} [options] - Additional options
7257
+ * @returns {string} Generated CSS string
7170
7258
  */
7171
7259
  const debouncedTwsx = debounce(twsx, 100); // Standard debounce for twsx
7172
7260