tailwind-to-style 2.7.5 → 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.browser.js +214 -293
- package/dist/index.cjs +214 -293
- package/dist/index.d.ts +7 -32
- package/dist/index.esm.js +215 -291
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tailwind-to-style v2.7.
|
|
2
|
+
* tailwind-to-style v2.7.7
|
|
3
3
|
* Convert tailwind classes to inline style
|
|
4
4
|
*
|
|
5
5
|
* @author Bigetion
|
|
@@ -1533,10 +1533,12 @@ function getConfigOptions() {
|
|
|
1533
1533
|
const themeKeys = Object.keys(configOptions.theme);
|
|
1534
1534
|
themeKeys.forEach(key => {
|
|
1535
1535
|
newTheme[key] = theme[key] || configOptions.theme[key];
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1536
|
+
if (isFunction(newTheme[key])) {
|
|
1537
|
+
newTheme[key] = newTheme[key]({
|
|
1538
|
+
theme: keyRef => {
|
|
1539
|
+
return configOptions.theme[keyRef];
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1540
1542
|
}
|
|
1541
1543
|
});
|
|
1542
1544
|
themeKeys.forEach(key => {
|
|
@@ -1547,6 +1549,9 @@ function getConfigOptions() {
|
|
|
1547
1549
|
}
|
|
1548
1550
|
});
|
|
1549
1551
|
}
|
|
1552
|
+
if (themeExtend[key]) {
|
|
1553
|
+
newTheme[key] = Object.assign({}, newTheme[key], themeExtend[key]);
|
|
1554
|
+
}
|
|
1550
1555
|
});
|
|
1551
1556
|
return {
|
|
1552
1557
|
prefix: "",
|
|
@@ -1894,10 +1899,10 @@ function generator$2i() {
|
|
|
1894
1899
|
}
|
|
1895
1900
|
if (value === "custom_value") {
|
|
1896
1901
|
return `
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1902
|
+
${prefix}-${key} {
|
|
1903
|
+
${isValidCssColor(value) ? "background-color" : "background"}: ${value};
|
|
1904
|
+
}
|
|
1905
|
+
`;
|
|
1901
1906
|
}
|
|
1902
1907
|
return `
|
|
1903
1908
|
${prefix}-${key} {
|
|
@@ -1919,6 +1924,7 @@ function generator$2h() {
|
|
|
1919
1924
|
theme = {}
|
|
1920
1925
|
} = configOptions;
|
|
1921
1926
|
const prefix = `${globalPrefix}bg`;
|
|
1927
|
+
const customPrefix = `${globalPrefix}bg-image`;
|
|
1922
1928
|
const {
|
|
1923
1929
|
backgroundImage = {}
|
|
1924
1930
|
} = theme;
|
|
@@ -1926,11 +1932,20 @@ function generator$2h() {
|
|
|
1926
1932
|
let {
|
|
1927
1933
|
getCssByOptions
|
|
1928
1934
|
} = _ref;
|
|
1929
|
-
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 `
|
|
1930
1944
|
${prefix}-${key} {
|
|
1931
1945
|
background-image: ${value};
|
|
1932
1946
|
}
|
|
1933
|
-
|
|
1947
|
+
`;
|
|
1948
|
+
});
|
|
1934
1949
|
return cssString;
|
|
1935
1950
|
}, configOptions);
|
|
1936
1951
|
return responsiveCssString;
|
|
@@ -1993,6 +2008,7 @@ function generator$2e() {
|
|
|
1993
2008
|
theme = {}
|
|
1994
2009
|
} = configOptions;
|
|
1995
2010
|
const prefix = `${globalPrefix}bg`;
|
|
2011
|
+
const customPrefix = `${globalPrefix}bg-position`;
|
|
1996
2012
|
const {
|
|
1997
2013
|
backgroundPosition = {}
|
|
1998
2014
|
} = theme;
|
|
@@ -2000,11 +2016,20 @@ function generator$2e() {
|
|
|
2000
2016
|
let {
|
|
2001
2017
|
getCssByOptions
|
|
2002
2018
|
} = _ref;
|
|
2003
|
-
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 `
|
|
2004
2028
|
${prefix}-${key} {
|
|
2005
2029
|
background-position: ${value};
|
|
2006
2030
|
}
|
|
2007
|
-
|
|
2031
|
+
`;
|
|
2032
|
+
});
|
|
2008
2033
|
return cssString;
|
|
2009
2034
|
}, configOptions);
|
|
2010
2035
|
return responsiveCssString;
|
|
@@ -2045,6 +2070,7 @@ function generator$2c() {
|
|
|
2045
2070
|
theme = {}
|
|
2046
2071
|
} = configOptions;
|
|
2047
2072
|
const prefix = `${globalPrefix}bg`;
|
|
2073
|
+
const customPrefix = `${globalPrefix}bg-size`;
|
|
2048
2074
|
const {
|
|
2049
2075
|
backgroundSize = {}
|
|
2050
2076
|
} = theme;
|
|
@@ -2052,11 +2078,20 @@ function generator$2c() {
|
|
|
2052
2078
|
let {
|
|
2053
2079
|
getCssByOptions
|
|
2054
2080
|
} = _ref;
|
|
2055
|
-
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 `
|
|
2056
2090
|
${prefix}-${key} {
|
|
2057
2091
|
background-size: ${value};
|
|
2058
2092
|
}
|
|
2059
|
-
|
|
2093
|
+
`;
|
|
2094
|
+
});
|
|
2060
2095
|
return cssString;
|
|
2061
2096
|
}, configOptions);
|
|
2062
2097
|
return responsiveCssString;
|
|
@@ -2124,6 +2159,7 @@ function generator$29() {
|
|
|
2124
2159
|
theme = {}
|
|
2125
2160
|
} = configOptions;
|
|
2126
2161
|
const prefix = `${globalPrefix}border`;
|
|
2162
|
+
const customPrefix = `${globalPrefix}border-color`;
|
|
2127
2163
|
const {
|
|
2128
2164
|
borderColor = {}
|
|
2129
2165
|
} = theme;
|
|
@@ -2140,57 +2176,64 @@ function generator$29() {
|
|
|
2140
2176
|
if (rgbValue) {
|
|
2141
2177
|
rgbPropertyValue = `border-color: rgba(${rgbValue}, var(--border-opacity));`;
|
|
2142
2178
|
}
|
|
2179
|
+
if (value === "custom_value") {
|
|
2180
|
+
return `
|
|
2181
|
+
${customPrefix}${key} {
|
|
2182
|
+
border-color: ${value};
|
|
2183
|
+
}
|
|
2184
|
+
`;
|
|
2185
|
+
}
|
|
2143
2186
|
return `
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
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
|
+
`;
|
|
2194
2237
|
});
|
|
2195
2238
|
return cssString;
|
|
2196
2239
|
}, configOptions);
|
|
@@ -2359,6 +2402,7 @@ function generator$24() {
|
|
|
2359
2402
|
theme = {}
|
|
2360
2403
|
} = configOptions;
|
|
2361
2404
|
const prefix = `${globalPrefix}border`;
|
|
2405
|
+
const customPrefix = `${globalPrefix}border-width`;
|
|
2362
2406
|
const {
|
|
2363
2407
|
borderWidth = {}
|
|
2364
2408
|
} = theme;
|
|
@@ -2368,41 +2412,48 @@ function generator$24() {
|
|
|
2368
2412
|
} = _ref;
|
|
2369
2413
|
const cssString = getCssByOptions(borderWidth, (keyTmp, value) => {
|
|
2370
2414
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
border-
|
|
2375
|
-
border-bottom-width: ${value};
|
|
2376
|
-
border-left-width: ${value};
|
|
2377
|
-
border-right-width: ${value};
|
|
2378
|
-
}
|
|
2379
|
-
${prefix}-x${key} {
|
|
2380
|
-
border-left-width: ${value};
|
|
2381
|
-
border-right-width: ${value};
|
|
2382
|
-
}
|
|
2383
|
-
${prefix}-y${key} {
|
|
2384
|
-
border-top-width: ${value};
|
|
2385
|
-
border-bottom-width: ${value};
|
|
2386
|
-
}
|
|
2387
|
-
${prefix}-s${key} {
|
|
2388
|
-
border-inline-start-width: ${value};
|
|
2389
|
-
}
|
|
2390
|
-
${prefix}-e${key} {
|
|
2391
|
-
border-inline-end-width: ${value};
|
|
2392
|
-
}
|
|
2393
|
-
${prefix}-t${key} {
|
|
2394
|
-
border-top-width: ${value};
|
|
2395
|
-
}
|
|
2396
|
-
${prefix}-r${key} {
|
|
2397
|
-
border-right-width: ${value};
|
|
2398
|
-
}
|
|
2399
|
-
${prefix}-b${key} {
|
|
2400
|
-
border-bottom-width: ${value};
|
|
2401
|
-
}
|
|
2402
|
-
${prefix}-l${key} {
|
|
2403
|
-
border-left-width: ${value};
|
|
2415
|
+
if (value === "custom_value") {
|
|
2416
|
+
return `
|
|
2417
|
+
${customPrefix}-${key} {
|
|
2418
|
+
border-width: ${value};
|
|
2404
2419
|
}
|
|
2405
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
|
+
`;
|
|
2406
2457
|
});
|
|
2407
2458
|
return cssString;
|
|
2408
2459
|
}, configOptions);
|
|
@@ -2438,6 +2489,7 @@ function generator$22() {
|
|
|
2438
2489
|
theme = {}
|
|
2439
2490
|
} = configOptions;
|
|
2440
2491
|
const prefix = `${globalPrefix}shadow`;
|
|
2492
|
+
const customPrefix = `${globalPrefix}box-shadow`;
|
|
2441
2493
|
const {
|
|
2442
2494
|
boxShadowColor,
|
|
2443
2495
|
boxShadow = {}
|
|
@@ -2450,6 +2502,13 @@ function generator$22() {
|
|
|
2450
2502
|
let cssString = getCssByOptions(boxShadow, (keyTmp, value) => {
|
|
2451
2503
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
2452
2504
|
const valueSplit = value.split(" ");
|
|
2505
|
+
if (value === "custom_value") {
|
|
2506
|
+
return `
|
|
2507
|
+
${customPrefix}${key} {
|
|
2508
|
+
box-shadow: ${value};
|
|
2509
|
+
}
|
|
2510
|
+
`;
|
|
2511
|
+
}
|
|
2453
2512
|
return `
|
|
2454
2513
|
${prefix}${key} {
|
|
2455
2514
|
--shadow: ${value};
|
|
@@ -3082,6 +3141,7 @@ function generator$1G() {
|
|
|
3082
3141
|
theme = {}
|
|
3083
3142
|
} = configOptions;
|
|
3084
3143
|
const prefix = `${globalPrefix}text`;
|
|
3144
|
+
const customPrefix = `${globalPrefix}text-size`;
|
|
3085
3145
|
const {
|
|
3086
3146
|
fontSize = {}
|
|
3087
3147
|
} = theme;
|
|
@@ -3089,11 +3149,20 @@ function generator$1G() {
|
|
|
3089
3149
|
let {
|
|
3090
3150
|
getCssByOptions
|
|
3091
3151
|
} = _ref;
|
|
3092
|
-
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 `
|
|
3093
3161
|
${prefix}-${key} {
|
|
3094
3162
|
font-size: ${value};
|
|
3095
3163
|
}
|
|
3096
|
-
|
|
3164
|
+
`;
|
|
3165
|
+
});
|
|
3097
3166
|
return cssString;
|
|
3098
3167
|
}, configOptions);
|
|
3099
3168
|
return responsiveCssString;
|
|
@@ -4242,6 +4311,7 @@ function generator$$() {
|
|
|
4242
4311
|
theme = {}
|
|
4243
4312
|
} = configOptions;
|
|
4244
4313
|
const prefix = `${globalPrefix}outline`;
|
|
4314
|
+
const customPrefix = `${globalPrefix}outline-color`;
|
|
4245
4315
|
const {
|
|
4246
4316
|
outlineColor = {}
|
|
4247
4317
|
} = theme;
|
|
@@ -4258,6 +4328,13 @@ function generator$$() {
|
|
|
4258
4328
|
if (rgbValue) {
|
|
4259
4329
|
rgbPropertyValue = `outline-color: rgba(${rgbValue}, var(--outline-opacity));`;
|
|
4260
4330
|
}
|
|
4331
|
+
if (value === "custom_value") {
|
|
4332
|
+
return `
|
|
4333
|
+
${customPrefix}${key} {
|
|
4334
|
+
outline-color: ${value};
|
|
4335
|
+
}
|
|
4336
|
+
`;
|
|
4337
|
+
}
|
|
4261
4338
|
return `
|
|
4262
4339
|
${prefix}${key} {
|
|
4263
4340
|
--outline-opacity: 1;
|
|
@@ -4363,6 +4440,7 @@ function generator$X() {
|
|
|
4363
4440
|
theme = {}
|
|
4364
4441
|
} = configOptions;
|
|
4365
4442
|
const prefix = `${globalPrefix}outline`;
|
|
4443
|
+
const customPrefix = `${globalPrefix}outline-width`;
|
|
4366
4444
|
const {
|
|
4367
4445
|
outlineWidth = {}
|
|
4368
4446
|
} = theme;
|
|
@@ -4371,11 +4449,18 @@ function generator$X() {
|
|
|
4371
4449
|
getCssByOptions
|
|
4372
4450
|
} = _ref;
|
|
4373
4451
|
const cssString = getCssByOptions(outlineWidth, (key, value) => {
|
|
4374
|
-
|
|
4375
|
-
|
|
4452
|
+
if (value === "custom_value") {
|
|
4453
|
+
return `
|
|
4454
|
+
${customPrefix}-${key} {
|
|
4376
4455
|
outline-width: ${value};
|
|
4377
4456
|
}
|
|
4378
4457
|
`;
|
|
4458
|
+
}
|
|
4459
|
+
return `
|
|
4460
|
+
${prefix}-${key} {
|
|
4461
|
+
outline-width: ${value};
|
|
4462
|
+
}
|
|
4463
|
+
`;
|
|
4379
4464
|
});
|
|
4380
4465
|
return cssString;
|
|
4381
4466
|
}, configOptions);
|
|
@@ -5356,6 +5441,7 @@ function generator$r() {
|
|
|
5356
5441
|
theme = {}
|
|
5357
5442
|
} = configOptions;
|
|
5358
5443
|
const prefix = `${globalPrefix}text`;
|
|
5444
|
+
const customPrefix = `${globalPrefix}text-color`;
|
|
5359
5445
|
const {
|
|
5360
5446
|
textColor
|
|
5361
5447
|
} = theme;
|
|
@@ -5368,13 +5454,20 @@ function generator$r() {
|
|
|
5368
5454
|
if (rgbValue) {
|
|
5369
5455
|
rgbPropertyValue = `color: rgba(${rgbValue}, var(--text-opacity));`;
|
|
5370
5456
|
}
|
|
5457
|
+
if (value === "custom_value") {
|
|
5458
|
+
return `
|
|
5459
|
+
${customPrefix}-${key} {
|
|
5460
|
+
color: ${value};
|
|
5461
|
+
}
|
|
5462
|
+
`;
|
|
5463
|
+
}
|
|
5371
5464
|
return `
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5465
|
+
${prefix}-${key} {
|
|
5466
|
+
--text-opacity: 1;
|
|
5467
|
+
color: ${value};
|
|
5468
|
+
${rgbPropertyValue}
|
|
5469
|
+
}
|
|
5470
|
+
`;
|
|
5378
5471
|
});
|
|
5379
5472
|
return cssString;
|
|
5380
5473
|
}, configOptions);
|
|
@@ -6378,179 +6471,19 @@ function convertCssToObject(cssString) {
|
|
|
6378
6471
|
}
|
|
6379
6472
|
let twString = null;
|
|
6380
6473
|
let cssObject = null;
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
const CONFIG_STORAGE_KEY = "__tailwind_to_style_global_config__";
|
|
6384
|
-
|
|
6385
|
-
// Default configuration
|
|
6386
|
-
const defaultConfig = {
|
|
6387
|
-
theme: {
|
|
6388
|
-
extend: {
|
|
6389
|
-
colors: {}
|
|
6390
|
-
},
|
|
6391
|
-
screens: {
|
|
6392
|
-
sm: "640px",
|
|
6393
|
-
md: "768px",
|
|
6394
|
-
lg: "1024px",
|
|
6395
|
-
xl: "1280px",
|
|
6396
|
-
"2xl": "1536px"
|
|
6397
|
-
}
|
|
6398
|
-
},
|
|
6399
|
-
inject: true
|
|
6400
|
-
};
|
|
6401
|
-
class ConfigManager {
|
|
6402
|
-
constructor() {
|
|
6403
|
-
this.storage = null;
|
|
6404
|
-
this.initialized = false;
|
|
6405
|
-
}
|
|
6406
|
-
initialize() {
|
|
6407
|
-
if (this.initialized) return this.storage;
|
|
6408
|
-
if (typeof window !== "undefined") {
|
|
6409
|
-
if (!window[CONFIG_STORAGE_KEY]) {
|
|
6410
|
-
window[CONFIG_STORAGE_KEY] = JSON.parse(JSON.stringify(defaultConfig));
|
|
6411
|
-
}
|
|
6412
|
-
this.storage = window[CONFIG_STORAGE_KEY];
|
|
6413
|
-
} else if (typeof global !== "undefined") {
|
|
6414
|
-
// Node.js environment
|
|
6415
|
-
if (!global[CONFIG_STORAGE_KEY]) {
|
|
6416
|
-
global[CONFIG_STORAGE_KEY] = JSON.parse(JSON.stringify(defaultConfig));
|
|
6417
|
-
}
|
|
6418
|
-
this.storage = global[CONFIG_STORAGE_KEY];
|
|
6419
|
-
} else {
|
|
6420
|
-
// Fallback
|
|
6421
|
-
console.warn("tailwind-to-style: Unable to create global config storage. Config will only work within the same module.");
|
|
6422
|
-
this.storage = JSON.parse(JSON.stringify(defaultConfig));
|
|
6423
|
-
}
|
|
6424
|
-
this.initialized = true;
|
|
6425
|
-
return this.storage;
|
|
6426
|
-
}
|
|
6427
|
-
get() {
|
|
6428
|
-
return this.initialize();
|
|
6429
|
-
}
|
|
6430
|
-
set(config) {
|
|
6431
|
-
const storage = this.initialize();
|
|
6432
|
-
this.deepMerge(storage, config);
|
|
6433
|
-
return storage;
|
|
6434
|
-
}
|
|
6435
|
-
reset() {
|
|
6436
|
-
const storage = this.initialize();
|
|
6437
|
-
Object.keys(storage).forEach(key => delete storage[key]);
|
|
6438
|
-
Object.assign(storage, JSON.parse(JSON.stringify(defaultConfig)));
|
|
6439
|
-
return storage;
|
|
6440
|
-
}
|
|
6441
|
-
deepMerge(target, source) {
|
|
6442
|
-
for (const key in source) {
|
|
6443
|
-
if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
6444
|
-
if (!target[key] || typeof target[key] !== "object") {
|
|
6445
|
-
target[key] = {};
|
|
6446
|
-
}
|
|
6447
|
-
this.deepMerge(target[key], source[key]);
|
|
6448
|
-
} else {
|
|
6449
|
-
target[key] = source[key];
|
|
6450
|
-
}
|
|
6451
|
-
}
|
|
6452
|
-
}
|
|
6453
|
-
}
|
|
6454
|
-
const configManager = new ConfigManager();
|
|
6455
|
-
function getGlobalStorage() {
|
|
6456
|
-
return configManager.get();
|
|
6457
|
-
}
|
|
6458
|
-
let globalConfig = null;
|
|
6459
|
-
function initializeCss() {
|
|
6460
|
-
if (!twString) {
|
|
6461
|
-
// Always get fresh config from global storage
|
|
6462
|
-
const currentConfig = getGlobalStorage();
|
|
6463
|
-
const configForGeneration = {
|
|
6464
|
-
...currentConfig,
|
|
6465
|
-
theme: {
|
|
6466
|
-
...currentConfig.theme
|
|
6467
|
-
}
|
|
6468
|
-
};
|
|
6469
|
-
twString = generateTailwindCssString(configForGeneration).replace(/\s\s+/g, " ");
|
|
6470
|
-
}
|
|
6471
|
-
if (!cssObject) {
|
|
6472
|
-
cssObject = convertCssToObject(twString);
|
|
6473
|
-
}
|
|
6474
|
-
}
|
|
6475
|
-
initializeCss();
|
|
6476
|
-
function convertScreensToBreakpoints(screens) {
|
|
6477
|
-
const breakpoints = {};
|
|
6478
|
-
for (const [key, value] of Object.entries(screens)) {
|
|
6479
|
-
breakpoints[key] = `@media (min-width: ${value})`;
|
|
6480
|
-
}
|
|
6481
|
-
return breakpoints;
|
|
6474
|
+
if (!twString) {
|
|
6475
|
+
twString = generateTailwindCssString().replace(/\s\s+/g, " ");
|
|
6482
6476
|
}
|
|
6483
|
-
|
|
6484
|
-
/**
|
|
6485
|
-
* Set global configuration for both tws and twsx functions
|
|
6486
|
-
* @param {Object} config - Global configuration object
|
|
6487
|
-
* @returns {Object} Current global configuration
|
|
6488
|
-
*/
|
|
6489
|
-
function setConfig(config) {
|
|
6490
|
-
// Reset CSS object cache when config changes
|
|
6491
|
-
twString = null;
|
|
6492
|
-
cssObject = null;
|
|
6493
|
-
configOptionsCache.clear();
|
|
6494
|
-
|
|
6495
|
-
// Use ConfigManager to set config
|
|
6496
|
-
const globalStorage = configManager.set(config);
|
|
6497
|
-
|
|
6498
|
-
// Handle legacy breakpoints with deprecation warning
|
|
6499
|
-
if (config.breakpoints) {
|
|
6500
|
-
console.warn("Warning: config.breakpoints is deprecated. Use config.theme.screens instead.");
|
|
6501
|
-
|
|
6502
|
-
// Convert legacy breakpoints to screens format
|
|
6503
|
-
const screens = {};
|
|
6504
|
-
for (const [key, value] of Object.entries(config.breakpoints)) {
|
|
6505
|
-
// Extract min-width value from media query
|
|
6506
|
-
const match = value.match(/min-width:\s*([^)]+)/);
|
|
6507
|
-
if (match) {
|
|
6508
|
-
screens[key] = match[1].trim();
|
|
6509
|
-
}
|
|
6510
|
-
}
|
|
6511
|
-
if (!globalStorage.theme.screens) {
|
|
6512
|
-
globalStorage.theme.screens = {};
|
|
6513
|
-
}
|
|
6514
|
-
Object.assign(globalStorage.theme.screens, screens);
|
|
6515
|
-
}
|
|
6516
|
-
|
|
6517
|
-
// Update local reference
|
|
6518
|
-
globalConfig = globalStorage;
|
|
6519
|
-
initializeCss();
|
|
6520
|
-
return {
|
|
6521
|
-
...globalStorage
|
|
6522
|
-
};
|
|
6523
|
-
}
|
|
6524
|
-
|
|
6525
|
-
/**
|
|
6526
|
-
* Get current global configuration
|
|
6527
|
-
* @returns {Object} Current global configuration
|
|
6528
|
-
*/
|
|
6529
|
-
function getConfig() {
|
|
6530
|
-
globalConfig = configManager.get();
|
|
6531
|
-
return {
|
|
6532
|
-
...globalConfig
|
|
6533
|
-
};
|
|
6534
|
-
}
|
|
6535
|
-
|
|
6536
|
-
/**
|
|
6537
|
-
* Reset global configuration to default
|
|
6538
|
-
* @returns {Object} Default configuration
|
|
6539
|
-
*/
|
|
6540
|
-
function resetConfig() {
|
|
6541
|
-
twString = null;
|
|
6542
|
-
cssObject = null;
|
|
6543
|
-
configOptionsCache.clear();
|
|
6544
|
-
const globalStorage = configManager.reset();
|
|
6545
|
-
|
|
6546
|
-
// Update local reference
|
|
6547
|
-
globalConfig = globalStorage;
|
|
6548
|
-
twString = generateTailwindCssString(globalConfig).replace(/\s\s+/g, " ");
|
|
6477
|
+
if (!cssObject) {
|
|
6549
6478
|
cssObject = convertCssToObject(twString);
|
|
6550
|
-
return {
|
|
6551
|
-
...globalConfig
|
|
6552
|
-
};
|
|
6553
6479
|
}
|
|
6480
|
+
const breakpoints = {
|
|
6481
|
+
sm: "@media (min-width: 640px)",
|
|
6482
|
+
md: "@media (min-width: 768px)",
|
|
6483
|
+
lg: "@media (min-width: 1024px)",
|
|
6484
|
+
xl: "@media (min-width: 1280px)",
|
|
6485
|
+
"2xl": "@media (min-width: 1536px)"
|
|
6486
|
+
};
|
|
6554
6487
|
const pseudoVariants = new Set(["hover", "focus", "focus-within", "active", "visited", "disabled", "first", "last", "checked", "invalid", "required"]);
|
|
6555
6488
|
const specialVariants = {
|
|
6556
6489
|
group: (state, sel) => `.group:${state} ${sel}`,
|
|
@@ -6600,9 +6533,6 @@ function resolveVariants(selector, variants) {
|
|
|
6600
6533
|
let media = null;
|
|
6601
6534
|
let finalSelector = selector;
|
|
6602
6535
|
for (const v of variants) {
|
|
6603
|
-
// Always get fresh config from global storage
|
|
6604
|
-
const currentConfig = getGlobalStorage();
|
|
6605
|
-
const breakpoints = convertScreensToBreakpoints(currentConfig.theme.screens || {});
|
|
6606
6536
|
if (breakpoints[v]) {
|
|
6607
6537
|
media = breakpoints[v];
|
|
6608
6538
|
} else if (pseudoVariants.has(v)) {
|
|
@@ -6798,7 +6728,7 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
6798
6728
|
|
|
6799
6729
|
// Handle hex colors
|
|
6800
6730
|
const hexRegex = new RegExp(`(${prop}\\s*:\\s*)(#[0-9a-fA-F]{3,6})`, "gi");
|
|
6801
|
-
modifiedDeclaration = modifiedDeclaration.replace(hexRegex, (
|
|
6731
|
+
modifiedDeclaration = modifiedDeclaration.replace(hexRegex, (match, propPart, hexColor) => {
|
|
6802
6732
|
// Convert hex to rgba
|
|
6803
6733
|
const hex = hexColor.replace("#", "");
|
|
6804
6734
|
let r, g, b;
|
|
@@ -6826,8 +6756,6 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
6826
6756
|
function tws(classNames, convertToJson) {
|
|
6827
6757
|
const totalMarker = performanceMonitor.start("tws:total");
|
|
6828
6758
|
try {
|
|
6829
|
-
// Ensure CSS is initialized with current global config
|
|
6830
|
-
initializeCss();
|
|
6831
6759
|
if ([!classNames, typeof classNames !== "string", classNames.trim() === ""].includes(true)) {
|
|
6832
6760
|
performanceMonitor.end(totalMarker);
|
|
6833
6761
|
return convertToJson ? {} : "";
|
|
@@ -7206,7 +7134,7 @@ function generateCssString(styles) {
|
|
|
7206
7134
|
* Generate CSS string from style object with SCSS-like syntax
|
|
7207
7135
|
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
7208
7136
|
* @param {Object} obj - Object with SCSS-like style format
|
|
7209
|
-
* @param {Object} [options] - Additional options,
|
|
7137
|
+
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
7210
7138
|
* @returns {string} Generated CSS string
|
|
7211
7139
|
*/
|
|
7212
7140
|
function twsx(obj) {
|
|
@@ -7217,13 +7145,9 @@ function twsx(obj) {
|
|
|
7217
7145
|
console.warn("twsx: Expected an object but received:", obj);
|
|
7218
7146
|
return "";
|
|
7219
7147
|
}
|
|
7220
|
-
const mergedOptions = {
|
|
7221
|
-
...getGlobalStorage(),
|
|
7222
|
-
...options
|
|
7223
|
-
};
|
|
7224
7148
|
const {
|
|
7225
7149
|
inject = true
|
|
7226
|
-
} =
|
|
7150
|
+
} = options;
|
|
7227
7151
|
const styles = {};
|
|
7228
7152
|
|
|
7229
7153
|
// Create walk function with closure over styles
|
|
@@ -7368,9 +7292,6 @@ const performanceUtils = {
|
|
|
7368
7292
|
|
|
7369
7293
|
exports.debouncedTws = debouncedTws;
|
|
7370
7294
|
exports.debouncedTwsx = debouncedTwsx;
|
|
7371
|
-
exports.getConfig = getConfig;
|
|
7372
7295
|
exports.performanceUtils = performanceUtils;
|
|
7373
|
-
exports.resetConfig = resetConfig;
|
|
7374
|
-
exports.setConfig = setConfig;
|
|
7375
7296
|
exports.tws = tws;
|
|
7376
7297
|
exports.twsx = twsx;
|