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.esm.js 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
@@ -1895,10 +1895,10 @@ function generator$2i() {
1895
1895
  }
1896
1896
  if (value === "custom_value") {
1897
1897
  return `
1898
- ${prefix}-${key} {
1899
- ${isValidCssColor(value) ? "background-color" : "background"}: ${value};
1900
- }
1901
- `;
1898
+ ${prefix}-${key} {
1899
+ ${isValidCssColor(value) ? "background-color" : "background"}: ${value};
1900
+ }
1901
+ `;
1902
1902
  }
1903
1903
  return `
1904
1904
  ${prefix}-${key} {
@@ -1920,6 +1920,7 @@ function generator$2h() {
1920
1920
  theme = {}
1921
1921
  } = configOptions;
1922
1922
  const prefix = `${globalPrefix}bg`;
1923
+ const customPrefix = `${globalPrefix}bg-image`;
1923
1924
  const {
1924
1925
  backgroundImage = {}
1925
1926
  } = theme;
@@ -1927,11 +1928,20 @@ function generator$2h() {
1927
1928
  let {
1928
1929
  getCssByOptions
1929
1930
  } = _ref;
1930
- const cssString = getCssByOptions(backgroundImage, (key, value) => `
1931
+ const cssString = getCssByOptions(backgroundImage, (key, value) => {
1932
+ if (value === "custom_value") {
1933
+ return `
1934
+ ${customPrefix}-${key} {
1935
+ background-image: ${value};
1936
+ }
1937
+ `;
1938
+ }
1939
+ return `
1931
1940
  ${prefix}-${key} {
1932
1941
  background-image: ${value};
1933
1942
  }
1934
- `);
1943
+ `;
1944
+ });
1935
1945
  return cssString;
1936
1946
  }, configOptions);
1937
1947
  return responsiveCssString;
@@ -1994,6 +2004,7 @@ function generator$2e() {
1994
2004
  theme = {}
1995
2005
  } = configOptions;
1996
2006
  const prefix = `${globalPrefix}bg`;
2007
+ const customPrefix = `${globalPrefix}bg-position`;
1997
2008
  const {
1998
2009
  backgroundPosition = {}
1999
2010
  } = theme;
@@ -2001,11 +2012,20 @@ function generator$2e() {
2001
2012
  let {
2002
2013
  getCssByOptions
2003
2014
  } = _ref;
2004
- const cssString = getCssByOptions(backgroundPosition, (key, value) => `
2015
+ const cssString = getCssByOptions(backgroundPosition, (key, value) => {
2016
+ if (value === "custom_value") {
2017
+ return `
2018
+ ${customPrefix}-${key} {
2019
+ background-position: ${value};
2020
+ }
2021
+ `;
2022
+ }
2023
+ return `
2005
2024
  ${prefix}-${key} {
2006
2025
  background-position: ${value};
2007
2026
  }
2008
- `);
2027
+ `;
2028
+ });
2009
2029
  return cssString;
2010
2030
  }, configOptions);
2011
2031
  return responsiveCssString;
@@ -2046,6 +2066,7 @@ function generator$2c() {
2046
2066
  theme = {}
2047
2067
  } = configOptions;
2048
2068
  const prefix = `${globalPrefix}bg`;
2069
+ const customPrefix = `${globalPrefix}bg-size`;
2049
2070
  const {
2050
2071
  backgroundSize = {}
2051
2072
  } = theme;
@@ -2053,11 +2074,20 @@ function generator$2c() {
2053
2074
  let {
2054
2075
  getCssByOptions
2055
2076
  } = _ref;
2056
- const cssString = getCssByOptions(backgroundSize, (key, value) => `
2077
+ const cssString = getCssByOptions(backgroundSize, (key, value) => {
2078
+ if (value === "custom_value") {
2079
+ return `
2080
+ ${customPrefix}-${key} {
2081
+ background-size: ${value};
2082
+ }
2083
+ `;
2084
+ }
2085
+ return `
2057
2086
  ${prefix}-${key} {
2058
2087
  background-size: ${value};
2059
2088
  }
2060
- `);
2089
+ `;
2090
+ });
2061
2091
  return cssString;
2062
2092
  }, configOptions);
2063
2093
  return responsiveCssString;
@@ -2125,6 +2155,7 @@ function generator$29() {
2125
2155
  theme = {}
2126
2156
  } = configOptions;
2127
2157
  const prefix = `${globalPrefix}border`;
2158
+ const customPrefix = `${globalPrefix}border-color`;
2128
2159
  const {
2129
2160
  borderColor = {}
2130
2161
  } = theme;
@@ -2141,57 +2172,64 @@ function generator$29() {
2141
2172
  if (rgbValue) {
2142
2173
  rgbPropertyValue = `border-color: rgba(${rgbValue}, var(--border-opacity));`;
2143
2174
  }
2175
+ if (value === "custom_value") {
2176
+ return `
2177
+ ${customPrefix}${key} {
2178
+ border-color: ${value};
2179
+ }
2180
+ `;
2181
+ }
2144
2182
  return `
2145
- ${prefix}${key} {
2146
- --border-opacity: 1;
2147
- border-color: ${value};
2148
- ${rgbPropertyValue}
2149
- }
2150
- ${prefix}-x${key} {
2151
- --border-opacity: 1;
2152
- border-left-color: ${value};
2153
- ${rgbPropertyValue}
2154
- border-right-color: ${value};
2155
- ${rgbPropertyValue}
2156
- }
2157
- ${prefix}-y${key} {
2158
- --border-opacity: 1;
2159
- border-top-color: ${value};
2160
- ${rgbPropertyValue}
2161
- border-bottom-color: ${value};
2162
- ${rgbPropertyValue}
2163
- }
2164
- ${prefix}-s${key} {
2165
- --border-opacity: 1;
2166
- border-inline-start-color: ${value};
2167
- ${rgbPropertyValue}
2168
- }
2169
- ${prefix}-e${key} {
2170
- --border-opacity: 1;
2171
- border-inline-end-color: ${value};
2172
- ${rgbPropertyValue}
2173
- }
2174
- ${prefix}-t${key} {
2175
- --border-opacity: 1;
2176
- border-top-color: ${value};
2177
- ${rgbPropertyValue}
2178
- }
2179
- ${prefix}-r${key} {
2180
- --border-opacity: 1;
2181
- border-right-color: ${value};
2182
- ${rgbPropertyValue}
2183
- }
2184
- ${prefix}-b${key} {
2185
- --border-opacity: 1;
2186
- border-bottom-color: ${value};
2187
- ${rgbPropertyValue}
2188
- }
2189
- ${prefix}-l${key} {
2190
- --border-opacity: 1;
2191
- border-left-color: ${value};
2192
- ${rgbPropertyValue}
2193
- }
2194
- `;
2183
+ ${prefix}${key} {
2184
+ --border-opacity: 1;
2185
+ border-color: ${value};
2186
+ ${rgbPropertyValue}
2187
+ }
2188
+ ${prefix}-x${key} {
2189
+ --border-opacity: 1;
2190
+ border-left-color: ${value};
2191
+ ${rgbPropertyValue}
2192
+ border-right-color: ${value};
2193
+ ${rgbPropertyValue}
2194
+ }
2195
+ ${prefix}-y${key} {
2196
+ --border-opacity: 1;
2197
+ border-top-color: ${value};
2198
+ ${rgbPropertyValue}
2199
+ border-bottom-color: ${value};
2200
+ ${rgbPropertyValue}
2201
+ }
2202
+ ${prefix}-s${key} {
2203
+ --border-opacity: 1;
2204
+ border-inline-start-color: ${value};
2205
+ ${rgbPropertyValue}
2206
+ }
2207
+ ${prefix}-e${key} {
2208
+ --border-opacity: 1;
2209
+ border-inline-end-color: ${value};
2210
+ ${rgbPropertyValue}
2211
+ }
2212
+ ${prefix}-t${key} {
2213
+ --border-opacity: 1;
2214
+ border-top-color: ${value};
2215
+ ${rgbPropertyValue}
2216
+ }
2217
+ ${prefix}-r${key} {
2218
+ --border-opacity: 1;
2219
+ border-right-color: ${value};
2220
+ ${rgbPropertyValue}
2221
+ }
2222
+ ${prefix}-b${key} {
2223
+ --border-opacity: 1;
2224
+ border-bottom-color: ${value};
2225
+ ${rgbPropertyValue}
2226
+ }
2227
+ ${prefix}-l${key} {
2228
+ --border-opacity: 1;
2229
+ border-left-color: ${value};
2230
+ ${rgbPropertyValue}
2231
+ }
2232
+ `;
2195
2233
  });
2196
2234
  return cssString;
2197
2235
  }, configOptions);
@@ -2360,6 +2398,7 @@ function generator$24() {
2360
2398
  theme = {}
2361
2399
  } = configOptions;
2362
2400
  const prefix = `${globalPrefix}border`;
2401
+ const customPrefix = `${globalPrefix}border-width`;
2363
2402
  const {
2364
2403
  borderWidth = {}
2365
2404
  } = theme;
@@ -2369,41 +2408,48 @@ function generator$24() {
2369
2408
  } = _ref;
2370
2409
  const cssString = getCssByOptions(borderWidth, (keyTmp, value) => {
2371
2410
  const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
2372
- return `
2373
- ${prefix}${key} {
2374
- border-style: solid;
2375
- border-top-width: ${value};
2376
- border-bottom-width: ${value};
2377
- border-left-width: ${value};
2378
- border-right-width: ${value};
2379
- }
2380
- ${prefix}-x${key} {
2381
- border-left-width: ${value};
2382
- border-right-width: ${value};
2383
- }
2384
- ${prefix}-y${key} {
2385
- border-top-width: ${value};
2386
- border-bottom-width: ${value};
2387
- }
2388
- ${prefix}-s${key} {
2389
- border-inline-start-width: ${value};
2390
- }
2391
- ${prefix}-e${key} {
2392
- border-inline-end-width: ${value};
2393
- }
2394
- ${prefix}-t${key} {
2395
- border-top-width: ${value};
2396
- }
2397
- ${prefix}-r${key} {
2398
- border-right-width: ${value};
2399
- }
2400
- ${prefix}-b${key} {
2401
- border-bottom-width: ${value};
2402
- }
2403
- ${prefix}-l${key} {
2404
- border-left-width: ${value};
2411
+ if (value === "custom_value") {
2412
+ return `
2413
+ ${customPrefix}-${key} {
2414
+ border-width: ${value};
2405
2415
  }
2406
2416
  `;
2417
+ }
2418
+ return `
2419
+ ${prefix}${key} {
2420
+ border-style: solid;
2421
+ border-top-width: ${value};
2422
+ border-bottom-width: ${value};
2423
+ border-left-width: ${value};
2424
+ border-right-width: ${value};
2425
+ }
2426
+ ${prefix}-x${key} {
2427
+ border-left-width: ${value};
2428
+ border-right-width: ${value};
2429
+ }
2430
+ ${prefix}-y${key} {
2431
+ border-top-width: ${value};
2432
+ border-bottom-width: ${value};
2433
+ }
2434
+ ${prefix}-s${key} {
2435
+ border-inline-start-width: ${value};
2436
+ }
2437
+ ${prefix}-e${key} {
2438
+ border-inline-end-width: ${value};
2439
+ }
2440
+ ${prefix}-t${key} {
2441
+ border-top-width: ${value};
2442
+ }
2443
+ ${prefix}-r${key} {
2444
+ border-right-width: ${value};
2445
+ }
2446
+ ${prefix}-b${key} {
2447
+ border-bottom-width: ${value};
2448
+ }
2449
+ ${prefix}-l${key} {
2450
+ border-left-width: ${value};
2451
+ }
2452
+ `;
2407
2453
  });
2408
2454
  return cssString;
2409
2455
  }, configOptions);
@@ -2439,6 +2485,7 @@ function generator$22() {
2439
2485
  theme = {}
2440
2486
  } = configOptions;
2441
2487
  const prefix = `${globalPrefix}shadow`;
2488
+ const customPrefix = `${globalPrefix}box-shadow`;
2442
2489
  const {
2443
2490
  boxShadowColor,
2444
2491
  boxShadow = {}
@@ -2451,6 +2498,13 @@ function generator$22() {
2451
2498
  let cssString = getCssByOptions(boxShadow, (keyTmp, value) => {
2452
2499
  const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
2453
2500
  const valueSplit = value.split(" ");
2501
+ if (value === "custom_value") {
2502
+ return `
2503
+ ${customPrefix}${key} {
2504
+ box-shadow: ${value};
2505
+ }
2506
+ `;
2507
+ }
2454
2508
  return `
2455
2509
  ${prefix}${key} {
2456
2510
  --shadow: ${value};
@@ -3083,6 +3137,7 @@ function generator$1G() {
3083
3137
  theme = {}
3084
3138
  } = configOptions;
3085
3139
  const prefix = `${globalPrefix}text`;
3140
+ const customPrefix = `${globalPrefix}text-size`;
3086
3141
  const {
3087
3142
  fontSize = {}
3088
3143
  } = theme;
@@ -3090,11 +3145,20 @@ function generator$1G() {
3090
3145
  let {
3091
3146
  getCssByOptions
3092
3147
  } = _ref;
3093
- const cssString = getCssByOptions(fontSize, (key, value) => `
3148
+ const cssString = getCssByOptions(fontSize, (key, value) => {
3149
+ if (value === "custom_value") {
3150
+ return `
3151
+ ${customPrefix}${key} {
3152
+ font-size: ${value};
3153
+ }
3154
+ `;
3155
+ }
3156
+ return `
3094
3157
  ${prefix}-${key} {
3095
3158
  font-size: ${value};
3096
3159
  }
3097
- `);
3160
+ `;
3161
+ });
3098
3162
  return cssString;
3099
3163
  }, configOptions);
3100
3164
  return responsiveCssString;
@@ -4243,6 +4307,7 @@ function generator$$() {
4243
4307
  theme = {}
4244
4308
  } = configOptions;
4245
4309
  const prefix = `${globalPrefix}outline`;
4310
+ const customPrefix = `${globalPrefix}outline-color`;
4246
4311
  const {
4247
4312
  outlineColor = {}
4248
4313
  } = theme;
@@ -4259,6 +4324,13 @@ function generator$$() {
4259
4324
  if (rgbValue) {
4260
4325
  rgbPropertyValue = `outline-color: rgba(${rgbValue}, var(--outline-opacity));`;
4261
4326
  }
4327
+ if (value === "custom_value") {
4328
+ return `
4329
+ ${customPrefix}${key} {
4330
+ outline-color: ${value};
4331
+ }
4332
+ `;
4333
+ }
4262
4334
  return `
4263
4335
  ${prefix}${key} {
4264
4336
  --outline-opacity: 1;
@@ -4364,6 +4436,7 @@ function generator$X() {
4364
4436
  theme = {}
4365
4437
  } = configOptions;
4366
4438
  const prefix = `${globalPrefix}outline`;
4439
+ const customPrefix = `${globalPrefix}outline-width`;
4367
4440
  const {
4368
4441
  outlineWidth = {}
4369
4442
  } = theme;
@@ -4372,11 +4445,18 @@ function generator$X() {
4372
4445
  getCssByOptions
4373
4446
  } = _ref;
4374
4447
  const cssString = getCssByOptions(outlineWidth, (key, value) => {
4375
- return `
4376
- ${prefix}-${key} {
4448
+ if (value === "custom_value") {
4449
+ return `
4450
+ ${customPrefix}-${key} {
4377
4451
  outline-width: ${value};
4378
4452
  }
4379
4453
  `;
4454
+ }
4455
+ return `
4456
+ ${prefix}-${key} {
4457
+ outline-width: ${value};
4458
+ }
4459
+ `;
4380
4460
  });
4381
4461
  return cssString;
4382
4462
  }, configOptions);
@@ -5357,6 +5437,7 @@ function generator$r() {
5357
5437
  theme = {}
5358
5438
  } = configOptions;
5359
5439
  const prefix = `${globalPrefix}text`;
5440
+ const customPrefix = `${globalPrefix}text-color`;
5360
5441
  const {
5361
5442
  textColor
5362
5443
  } = theme;
@@ -5369,13 +5450,20 @@ function generator$r() {
5369
5450
  if (rgbValue) {
5370
5451
  rgbPropertyValue = `color: rgba(${rgbValue}, var(--text-opacity));`;
5371
5452
  }
5453
+ if (value === "custom_value") {
5454
+ return `
5455
+ ${customPrefix}-${key} {
5456
+ color: ${value};
5457
+ }
5458
+ `;
5459
+ }
5372
5460
  return `
5373
- ${prefix}-${key} {
5374
- --text-opacity: 1;
5375
- color: ${value};
5376
- ${rgbPropertyValue}
5377
- }
5378
- `;
5461
+ ${prefix}-${key} {
5462
+ --text-opacity: 1;
5463
+ color: ${value};
5464
+ ${rgbPropertyValue}
5465
+ }
5466
+ `;
5379
5467
  });
5380
5468
  return cssString;
5381
5469
  }, configOptions);
@@ -6309,10 +6397,10 @@ function parseCustomClassWithPatterns(className) {
6309
6397
  return null;
6310
6398
  }
6311
6399
 
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;'
6400
+ /**
6401
+ * Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
6402
+ * @param {string} cssString
6403
+ * @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
6316
6404
  */
6317
6405
  function resolveCssToClearCss(cssString) {
6318
6406
  const customVars = {};
@@ -6590,11 +6678,11 @@ function separateAndResolveCSS(arr) {
6590
6678
  }
6591
6679
  }
6592
6680
 
6593
- /**
6594
- * Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
6595
- * @param {string} className - Class name with potential opacity modifier
6596
- * @param {string} cssDeclaration - CSS declaration to modify
6597
- * @returns {string} Modified CSS declaration with opacity applied
6681
+ /**
6682
+ * Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
6683
+ * @param {string} className - Class name with potential opacity modifier
6684
+ * @param {string} cssDeclaration - CSS declaration to modify
6685
+ * @returns {string} Modified CSS declaration with opacity applied
6598
6686
  */
6599
6687
  function processOpacityModifier(className, cssDeclaration) {
6600
6688
  const opacityMatch = className.match(/\/(\d+)$/);
@@ -6655,11 +6743,11 @@ function processOpacityModifier(className, cssDeclaration) {
6655
6743
  return modifiedDeclaration;
6656
6744
  }
6657
6745
 
6658
- /**
6659
- * Convert Tailwind class string to inline CSS styles or JSON object
6660
- * @param {string} classNames - String containing Tailwind classes to convert
6661
- * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
6662
- * @returns {string|Object} Inline CSS string or style JSON object
6746
+ /**
6747
+ * Convert Tailwind class string to inline CSS styles or JSON object
6748
+ * @param {string} classNames - String containing Tailwind classes to convert
6749
+ * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
6750
+ * @returns {string|Object} Inline CSS string or style JSON object
6663
6751
  */
6664
6752
  function tws(classNames, convertToJson) {
6665
6753
  const totalMarker = performanceMonitor.start("tws:total");
@@ -7038,12 +7126,12 @@ function generateCssString(styles) {
7038
7126
  return cssString.trim();
7039
7127
  }
7040
7128
 
7041
- /**
7042
- * Generate CSS string from style object with SCSS-like syntax
7043
- * Supports nested selectors, state variants, responsive variants, and @css directives
7044
- * @param {Object} obj - Object with SCSS-like style format
7045
- * @param {Object} [options] - Additional options, e.g. { inject: true/false }
7046
- * @returns {string} Generated CSS string
7129
+ /**
7130
+ * Generate CSS string from style object with SCSS-like syntax
7131
+ * Supports nested selectors, state variants, responsive variants, and @css directives
7132
+ * @param {Object} obj - Object with SCSS-like style format
7133
+ * @param {Object} [options] - Additional options, e.g. { inject: true/false }
7134
+ * @returns {string} Generated CSS string
7047
7135
  */
7048
7136
  function twsx(obj) {
7049
7137
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -7150,19 +7238,19 @@ function autoInjectCss(cssString) {
7150
7238
  }
7151
7239
 
7152
7240
  // Enhanced debounced functions with performance monitoring configuration
7153
- /**
7154
- * Debounced version of tws function with performance monitoring
7155
- * @param {string} classNames - String containing Tailwind classes to convert
7156
- * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
7157
- * @returns {string|Object} Inline CSS string or style JSON object
7241
+ /**
7242
+ * Debounced version of tws function with performance monitoring
7243
+ * @param {string} classNames - String containing Tailwind classes to convert
7244
+ * @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
7245
+ * @returns {string|Object} Inline CSS string or style JSON object
7158
7246
  */
7159
7247
  const debouncedTws = debounce(tws, 50); // Faster debounce for tws
7160
7248
 
7161
- /**
7162
- * Debounced version of twsx function with performance monitoring
7163
- * @param {Object} obj - Object with SCSS-like style format
7164
- * @param {Object} [options] - Additional options
7165
- * @returns {string} Generated CSS string
7249
+ /**
7250
+ * Debounced version of twsx function with performance monitoring
7251
+ * @param {Object} obj - Object with SCSS-like style format
7252
+ * @param {Object} [options] - Additional options
7253
+ * @returns {string} Generated CSS string
7166
7254
  */
7167
7255
  const debouncedTwsx = debounce(twsx, 100); // Standard debounce for twsx
7168
7256