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.esm.js
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
|
|
@@ -1529,10 +1529,12 @@ function getConfigOptions() {
|
|
|
1529
1529
|
const themeKeys = Object.keys(configOptions.theme);
|
|
1530
1530
|
themeKeys.forEach(key => {
|
|
1531
1531
|
newTheme[key] = theme[key] || configOptions.theme[key];
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1532
|
+
if (isFunction(newTheme[key])) {
|
|
1533
|
+
newTheme[key] = newTheme[key]({
|
|
1534
|
+
theme: keyRef => {
|
|
1535
|
+
return configOptions.theme[keyRef];
|
|
1536
|
+
}
|
|
1537
|
+
});
|
|
1536
1538
|
}
|
|
1537
1539
|
});
|
|
1538
1540
|
themeKeys.forEach(key => {
|
|
@@ -1543,6 +1545,9 @@ function getConfigOptions() {
|
|
|
1543
1545
|
}
|
|
1544
1546
|
});
|
|
1545
1547
|
}
|
|
1548
|
+
if (themeExtend[key]) {
|
|
1549
|
+
newTheme[key] = Object.assign({}, newTheme[key], themeExtend[key]);
|
|
1550
|
+
}
|
|
1546
1551
|
});
|
|
1547
1552
|
return {
|
|
1548
1553
|
prefix: "",
|
|
@@ -1890,10 +1895,10 @@ function generator$2i() {
|
|
|
1890
1895
|
}
|
|
1891
1896
|
if (value === "custom_value") {
|
|
1892
1897
|
return `
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1898
|
+
${prefix}-${key} {
|
|
1899
|
+
${isValidCssColor(value) ? "background-color" : "background"}: ${value};
|
|
1900
|
+
}
|
|
1901
|
+
`;
|
|
1897
1902
|
}
|
|
1898
1903
|
return `
|
|
1899
1904
|
${prefix}-${key} {
|
|
@@ -1915,6 +1920,7 @@ function generator$2h() {
|
|
|
1915
1920
|
theme = {}
|
|
1916
1921
|
} = configOptions;
|
|
1917
1922
|
const prefix = `${globalPrefix}bg`;
|
|
1923
|
+
const customPrefix = `${globalPrefix}bg-image`;
|
|
1918
1924
|
const {
|
|
1919
1925
|
backgroundImage = {}
|
|
1920
1926
|
} = theme;
|
|
@@ -1922,11 +1928,20 @@ function generator$2h() {
|
|
|
1922
1928
|
let {
|
|
1923
1929
|
getCssByOptions
|
|
1924
1930
|
} = _ref;
|
|
1925
|
-
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 `
|
|
1926
1940
|
${prefix}-${key} {
|
|
1927
1941
|
background-image: ${value};
|
|
1928
1942
|
}
|
|
1929
|
-
|
|
1943
|
+
`;
|
|
1944
|
+
});
|
|
1930
1945
|
return cssString;
|
|
1931
1946
|
}, configOptions);
|
|
1932
1947
|
return responsiveCssString;
|
|
@@ -1989,6 +2004,7 @@ function generator$2e() {
|
|
|
1989
2004
|
theme = {}
|
|
1990
2005
|
} = configOptions;
|
|
1991
2006
|
const prefix = `${globalPrefix}bg`;
|
|
2007
|
+
const customPrefix = `${globalPrefix}bg-position`;
|
|
1992
2008
|
const {
|
|
1993
2009
|
backgroundPosition = {}
|
|
1994
2010
|
} = theme;
|
|
@@ -1996,11 +2012,20 @@ function generator$2e() {
|
|
|
1996
2012
|
let {
|
|
1997
2013
|
getCssByOptions
|
|
1998
2014
|
} = _ref;
|
|
1999
|
-
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 `
|
|
2000
2024
|
${prefix}-${key} {
|
|
2001
2025
|
background-position: ${value};
|
|
2002
2026
|
}
|
|
2003
|
-
|
|
2027
|
+
`;
|
|
2028
|
+
});
|
|
2004
2029
|
return cssString;
|
|
2005
2030
|
}, configOptions);
|
|
2006
2031
|
return responsiveCssString;
|
|
@@ -2041,6 +2066,7 @@ function generator$2c() {
|
|
|
2041
2066
|
theme = {}
|
|
2042
2067
|
} = configOptions;
|
|
2043
2068
|
const prefix = `${globalPrefix}bg`;
|
|
2069
|
+
const customPrefix = `${globalPrefix}bg-size`;
|
|
2044
2070
|
const {
|
|
2045
2071
|
backgroundSize = {}
|
|
2046
2072
|
} = theme;
|
|
@@ -2048,11 +2074,20 @@ function generator$2c() {
|
|
|
2048
2074
|
let {
|
|
2049
2075
|
getCssByOptions
|
|
2050
2076
|
} = _ref;
|
|
2051
|
-
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 `
|
|
2052
2086
|
${prefix}-${key} {
|
|
2053
2087
|
background-size: ${value};
|
|
2054
2088
|
}
|
|
2055
|
-
|
|
2089
|
+
`;
|
|
2090
|
+
});
|
|
2056
2091
|
return cssString;
|
|
2057
2092
|
}, configOptions);
|
|
2058
2093
|
return responsiveCssString;
|
|
@@ -2120,6 +2155,7 @@ function generator$29() {
|
|
|
2120
2155
|
theme = {}
|
|
2121
2156
|
} = configOptions;
|
|
2122
2157
|
const prefix = `${globalPrefix}border`;
|
|
2158
|
+
const customPrefix = `${globalPrefix}border-color`;
|
|
2123
2159
|
const {
|
|
2124
2160
|
borderColor = {}
|
|
2125
2161
|
} = theme;
|
|
@@ -2136,57 +2172,64 @@ function generator$29() {
|
|
|
2136
2172
|
if (rgbValue) {
|
|
2137
2173
|
rgbPropertyValue = `border-color: rgba(${rgbValue}, var(--border-opacity));`;
|
|
2138
2174
|
}
|
|
2175
|
+
if (value === "custom_value") {
|
|
2176
|
+
return `
|
|
2177
|
+
${customPrefix}${key} {
|
|
2178
|
+
border-color: ${value};
|
|
2179
|
+
}
|
|
2180
|
+
`;
|
|
2181
|
+
}
|
|
2139
2182
|
return `
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
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
|
-
|
|
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
|
+
`;
|
|
2190
2233
|
});
|
|
2191
2234
|
return cssString;
|
|
2192
2235
|
}, configOptions);
|
|
@@ -2355,6 +2398,7 @@ function generator$24() {
|
|
|
2355
2398
|
theme = {}
|
|
2356
2399
|
} = configOptions;
|
|
2357
2400
|
const prefix = `${globalPrefix}border`;
|
|
2401
|
+
const customPrefix = `${globalPrefix}border-width`;
|
|
2358
2402
|
const {
|
|
2359
2403
|
borderWidth = {}
|
|
2360
2404
|
} = theme;
|
|
@@ -2364,41 +2408,48 @@ function generator$24() {
|
|
|
2364
2408
|
} = _ref;
|
|
2365
2409
|
const cssString = getCssByOptions(borderWidth, (keyTmp, value) => {
|
|
2366
2410
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
border-
|
|
2371
|
-
border-bottom-width: ${value};
|
|
2372
|
-
border-left-width: ${value};
|
|
2373
|
-
border-right-width: ${value};
|
|
2374
|
-
}
|
|
2375
|
-
${prefix}-x${key} {
|
|
2376
|
-
border-left-width: ${value};
|
|
2377
|
-
border-right-width: ${value};
|
|
2378
|
-
}
|
|
2379
|
-
${prefix}-y${key} {
|
|
2380
|
-
border-top-width: ${value};
|
|
2381
|
-
border-bottom-width: ${value};
|
|
2382
|
-
}
|
|
2383
|
-
${prefix}-s${key} {
|
|
2384
|
-
border-inline-start-width: ${value};
|
|
2385
|
-
}
|
|
2386
|
-
${prefix}-e${key} {
|
|
2387
|
-
border-inline-end-width: ${value};
|
|
2388
|
-
}
|
|
2389
|
-
${prefix}-t${key} {
|
|
2390
|
-
border-top-width: ${value};
|
|
2391
|
-
}
|
|
2392
|
-
${prefix}-r${key} {
|
|
2393
|
-
border-right-width: ${value};
|
|
2394
|
-
}
|
|
2395
|
-
${prefix}-b${key} {
|
|
2396
|
-
border-bottom-width: ${value};
|
|
2397
|
-
}
|
|
2398
|
-
${prefix}-l${key} {
|
|
2399
|
-
border-left-width: ${value};
|
|
2411
|
+
if (value === "custom_value") {
|
|
2412
|
+
return `
|
|
2413
|
+
${customPrefix}-${key} {
|
|
2414
|
+
border-width: ${value};
|
|
2400
2415
|
}
|
|
2401
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
|
+
`;
|
|
2402
2453
|
});
|
|
2403
2454
|
return cssString;
|
|
2404
2455
|
}, configOptions);
|
|
@@ -2434,6 +2485,7 @@ function generator$22() {
|
|
|
2434
2485
|
theme = {}
|
|
2435
2486
|
} = configOptions;
|
|
2436
2487
|
const prefix = `${globalPrefix}shadow`;
|
|
2488
|
+
const customPrefix = `${globalPrefix}box-shadow`;
|
|
2437
2489
|
const {
|
|
2438
2490
|
boxShadowColor,
|
|
2439
2491
|
boxShadow = {}
|
|
@@ -2446,6 +2498,13 @@ function generator$22() {
|
|
|
2446
2498
|
let cssString = getCssByOptions(boxShadow, (keyTmp, value) => {
|
|
2447
2499
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
2448
2500
|
const valueSplit = value.split(" ");
|
|
2501
|
+
if (value === "custom_value") {
|
|
2502
|
+
return `
|
|
2503
|
+
${customPrefix}${key} {
|
|
2504
|
+
box-shadow: ${value};
|
|
2505
|
+
}
|
|
2506
|
+
`;
|
|
2507
|
+
}
|
|
2449
2508
|
return `
|
|
2450
2509
|
${prefix}${key} {
|
|
2451
2510
|
--shadow: ${value};
|
|
@@ -3078,6 +3137,7 @@ function generator$1G() {
|
|
|
3078
3137
|
theme = {}
|
|
3079
3138
|
} = configOptions;
|
|
3080
3139
|
const prefix = `${globalPrefix}text`;
|
|
3140
|
+
const customPrefix = `${globalPrefix}text-size`;
|
|
3081
3141
|
const {
|
|
3082
3142
|
fontSize = {}
|
|
3083
3143
|
} = theme;
|
|
@@ -3085,11 +3145,20 @@ function generator$1G() {
|
|
|
3085
3145
|
let {
|
|
3086
3146
|
getCssByOptions
|
|
3087
3147
|
} = _ref;
|
|
3088
|
-
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 `
|
|
3089
3157
|
${prefix}-${key} {
|
|
3090
3158
|
font-size: ${value};
|
|
3091
3159
|
}
|
|
3092
|
-
|
|
3160
|
+
`;
|
|
3161
|
+
});
|
|
3093
3162
|
return cssString;
|
|
3094
3163
|
}, configOptions);
|
|
3095
3164
|
return responsiveCssString;
|
|
@@ -4238,6 +4307,7 @@ function generator$$() {
|
|
|
4238
4307
|
theme = {}
|
|
4239
4308
|
} = configOptions;
|
|
4240
4309
|
const prefix = `${globalPrefix}outline`;
|
|
4310
|
+
const customPrefix = `${globalPrefix}outline-color`;
|
|
4241
4311
|
const {
|
|
4242
4312
|
outlineColor = {}
|
|
4243
4313
|
} = theme;
|
|
@@ -4254,6 +4324,13 @@ function generator$$() {
|
|
|
4254
4324
|
if (rgbValue) {
|
|
4255
4325
|
rgbPropertyValue = `outline-color: rgba(${rgbValue}, var(--outline-opacity));`;
|
|
4256
4326
|
}
|
|
4327
|
+
if (value === "custom_value") {
|
|
4328
|
+
return `
|
|
4329
|
+
${customPrefix}${key} {
|
|
4330
|
+
outline-color: ${value};
|
|
4331
|
+
}
|
|
4332
|
+
`;
|
|
4333
|
+
}
|
|
4257
4334
|
return `
|
|
4258
4335
|
${prefix}${key} {
|
|
4259
4336
|
--outline-opacity: 1;
|
|
@@ -4359,6 +4436,7 @@ function generator$X() {
|
|
|
4359
4436
|
theme = {}
|
|
4360
4437
|
} = configOptions;
|
|
4361
4438
|
const prefix = `${globalPrefix}outline`;
|
|
4439
|
+
const customPrefix = `${globalPrefix}outline-width`;
|
|
4362
4440
|
const {
|
|
4363
4441
|
outlineWidth = {}
|
|
4364
4442
|
} = theme;
|
|
@@ -4367,11 +4445,18 @@ function generator$X() {
|
|
|
4367
4445
|
getCssByOptions
|
|
4368
4446
|
} = _ref;
|
|
4369
4447
|
const cssString = getCssByOptions(outlineWidth, (key, value) => {
|
|
4370
|
-
|
|
4371
|
-
|
|
4448
|
+
if (value === "custom_value") {
|
|
4449
|
+
return `
|
|
4450
|
+
${customPrefix}-${key} {
|
|
4372
4451
|
outline-width: ${value};
|
|
4373
4452
|
}
|
|
4374
4453
|
`;
|
|
4454
|
+
}
|
|
4455
|
+
return `
|
|
4456
|
+
${prefix}-${key} {
|
|
4457
|
+
outline-width: ${value};
|
|
4458
|
+
}
|
|
4459
|
+
`;
|
|
4375
4460
|
});
|
|
4376
4461
|
return cssString;
|
|
4377
4462
|
}, configOptions);
|
|
@@ -5352,6 +5437,7 @@ function generator$r() {
|
|
|
5352
5437
|
theme = {}
|
|
5353
5438
|
} = configOptions;
|
|
5354
5439
|
const prefix = `${globalPrefix}text`;
|
|
5440
|
+
const customPrefix = `${globalPrefix}text-color`;
|
|
5355
5441
|
const {
|
|
5356
5442
|
textColor
|
|
5357
5443
|
} = theme;
|
|
@@ -5364,13 +5450,20 @@ function generator$r() {
|
|
|
5364
5450
|
if (rgbValue) {
|
|
5365
5451
|
rgbPropertyValue = `color: rgba(${rgbValue}, var(--text-opacity));`;
|
|
5366
5452
|
}
|
|
5453
|
+
if (value === "custom_value") {
|
|
5454
|
+
return `
|
|
5455
|
+
${customPrefix}-${key} {
|
|
5456
|
+
color: ${value};
|
|
5457
|
+
}
|
|
5458
|
+
`;
|
|
5459
|
+
}
|
|
5367
5460
|
return `
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5461
|
+
${prefix}-${key} {
|
|
5462
|
+
--text-opacity: 1;
|
|
5463
|
+
color: ${value};
|
|
5464
|
+
${rgbPropertyValue}
|
|
5465
|
+
}
|
|
5466
|
+
`;
|
|
5374
5467
|
});
|
|
5375
5468
|
return cssString;
|
|
5376
5469
|
}, configOptions);
|
|
@@ -6374,179 +6467,19 @@ function convertCssToObject(cssString) {
|
|
|
6374
6467
|
}
|
|
6375
6468
|
let twString = null;
|
|
6376
6469
|
let cssObject = null;
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
const CONFIG_STORAGE_KEY = "__tailwind_to_style_global_config__";
|
|
6380
|
-
|
|
6381
|
-
// Default configuration
|
|
6382
|
-
const defaultConfig = {
|
|
6383
|
-
theme: {
|
|
6384
|
-
extend: {
|
|
6385
|
-
colors: {}
|
|
6386
|
-
},
|
|
6387
|
-
screens: {
|
|
6388
|
-
sm: "640px",
|
|
6389
|
-
md: "768px",
|
|
6390
|
-
lg: "1024px",
|
|
6391
|
-
xl: "1280px",
|
|
6392
|
-
"2xl": "1536px"
|
|
6393
|
-
}
|
|
6394
|
-
},
|
|
6395
|
-
inject: true
|
|
6396
|
-
};
|
|
6397
|
-
class ConfigManager {
|
|
6398
|
-
constructor() {
|
|
6399
|
-
this.storage = null;
|
|
6400
|
-
this.initialized = false;
|
|
6401
|
-
}
|
|
6402
|
-
initialize() {
|
|
6403
|
-
if (this.initialized) return this.storage;
|
|
6404
|
-
if (typeof window !== "undefined") {
|
|
6405
|
-
if (!window[CONFIG_STORAGE_KEY]) {
|
|
6406
|
-
window[CONFIG_STORAGE_KEY] = JSON.parse(JSON.stringify(defaultConfig));
|
|
6407
|
-
}
|
|
6408
|
-
this.storage = window[CONFIG_STORAGE_KEY];
|
|
6409
|
-
} else if (typeof global !== "undefined") {
|
|
6410
|
-
// Node.js environment
|
|
6411
|
-
if (!global[CONFIG_STORAGE_KEY]) {
|
|
6412
|
-
global[CONFIG_STORAGE_KEY] = JSON.parse(JSON.stringify(defaultConfig));
|
|
6413
|
-
}
|
|
6414
|
-
this.storage = global[CONFIG_STORAGE_KEY];
|
|
6415
|
-
} else {
|
|
6416
|
-
// Fallback
|
|
6417
|
-
console.warn("tailwind-to-style: Unable to create global config storage. Config will only work within the same module.");
|
|
6418
|
-
this.storage = JSON.parse(JSON.stringify(defaultConfig));
|
|
6419
|
-
}
|
|
6420
|
-
this.initialized = true;
|
|
6421
|
-
return this.storage;
|
|
6422
|
-
}
|
|
6423
|
-
get() {
|
|
6424
|
-
return this.initialize();
|
|
6425
|
-
}
|
|
6426
|
-
set(config) {
|
|
6427
|
-
const storage = this.initialize();
|
|
6428
|
-
this.deepMerge(storage, config);
|
|
6429
|
-
return storage;
|
|
6430
|
-
}
|
|
6431
|
-
reset() {
|
|
6432
|
-
const storage = this.initialize();
|
|
6433
|
-
Object.keys(storage).forEach(key => delete storage[key]);
|
|
6434
|
-
Object.assign(storage, JSON.parse(JSON.stringify(defaultConfig)));
|
|
6435
|
-
return storage;
|
|
6436
|
-
}
|
|
6437
|
-
deepMerge(target, source) {
|
|
6438
|
-
for (const key in source) {
|
|
6439
|
-
if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
6440
|
-
if (!target[key] || typeof target[key] !== "object") {
|
|
6441
|
-
target[key] = {};
|
|
6442
|
-
}
|
|
6443
|
-
this.deepMerge(target[key], source[key]);
|
|
6444
|
-
} else {
|
|
6445
|
-
target[key] = source[key];
|
|
6446
|
-
}
|
|
6447
|
-
}
|
|
6448
|
-
}
|
|
6449
|
-
}
|
|
6450
|
-
const configManager = new ConfigManager();
|
|
6451
|
-
function getGlobalStorage() {
|
|
6452
|
-
return configManager.get();
|
|
6453
|
-
}
|
|
6454
|
-
let globalConfig = null;
|
|
6455
|
-
function initializeCss() {
|
|
6456
|
-
if (!twString) {
|
|
6457
|
-
// Always get fresh config from global storage
|
|
6458
|
-
const currentConfig = getGlobalStorage();
|
|
6459
|
-
const configForGeneration = {
|
|
6460
|
-
...currentConfig,
|
|
6461
|
-
theme: {
|
|
6462
|
-
...currentConfig.theme
|
|
6463
|
-
}
|
|
6464
|
-
};
|
|
6465
|
-
twString = generateTailwindCssString(configForGeneration).replace(/\s\s+/g, " ");
|
|
6466
|
-
}
|
|
6467
|
-
if (!cssObject) {
|
|
6468
|
-
cssObject = convertCssToObject(twString);
|
|
6469
|
-
}
|
|
6470
|
-
}
|
|
6471
|
-
initializeCss();
|
|
6472
|
-
function convertScreensToBreakpoints(screens) {
|
|
6473
|
-
const breakpoints = {};
|
|
6474
|
-
for (const [key, value] of Object.entries(screens)) {
|
|
6475
|
-
breakpoints[key] = `@media (min-width: ${value})`;
|
|
6476
|
-
}
|
|
6477
|
-
return breakpoints;
|
|
6470
|
+
if (!twString) {
|
|
6471
|
+
twString = generateTailwindCssString().replace(/\s\s+/g, " ");
|
|
6478
6472
|
}
|
|
6479
|
-
|
|
6480
|
-
/**
|
|
6481
|
-
* Set global configuration for both tws and twsx functions
|
|
6482
|
-
* @param {Object} config - Global configuration object
|
|
6483
|
-
* @returns {Object} Current global configuration
|
|
6484
|
-
*/
|
|
6485
|
-
function setConfig(config) {
|
|
6486
|
-
// Reset CSS object cache when config changes
|
|
6487
|
-
twString = null;
|
|
6488
|
-
cssObject = null;
|
|
6489
|
-
configOptionsCache.clear();
|
|
6490
|
-
|
|
6491
|
-
// Use ConfigManager to set config
|
|
6492
|
-
const globalStorage = configManager.set(config);
|
|
6493
|
-
|
|
6494
|
-
// Handle legacy breakpoints with deprecation warning
|
|
6495
|
-
if (config.breakpoints) {
|
|
6496
|
-
console.warn("Warning: config.breakpoints is deprecated. Use config.theme.screens instead.");
|
|
6497
|
-
|
|
6498
|
-
// Convert legacy breakpoints to screens format
|
|
6499
|
-
const screens = {};
|
|
6500
|
-
for (const [key, value] of Object.entries(config.breakpoints)) {
|
|
6501
|
-
// Extract min-width value from media query
|
|
6502
|
-
const match = value.match(/min-width:\s*([^)]+)/);
|
|
6503
|
-
if (match) {
|
|
6504
|
-
screens[key] = match[1].trim();
|
|
6505
|
-
}
|
|
6506
|
-
}
|
|
6507
|
-
if (!globalStorage.theme.screens) {
|
|
6508
|
-
globalStorage.theme.screens = {};
|
|
6509
|
-
}
|
|
6510
|
-
Object.assign(globalStorage.theme.screens, screens);
|
|
6511
|
-
}
|
|
6512
|
-
|
|
6513
|
-
// Update local reference
|
|
6514
|
-
globalConfig = globalStorage;
|
|
6515
|
-
initializeCss();
|
|
6516
|
-
return {
|
|
6517
|
-
...globalStorage
|
|
6518
|
-
};
|
|
6519
|
-
}
|
|
6520
|
-
|
|
6521
|
-
/**
|
|
6522
|
-
* Get current global configuration
|
|
6523
|
-
* @returns {Object} Current global configuration
|
|
6524
|
-
*/
|
|
6525
|
-
function getConfig() {
|
|
6526
|
-
globalConfig = configManager.get();
|
|
6527
|
-
return {
|
|
6528
|
-
...globalConfig
|
|
6529
|
-
};
|
|
6530
|
-
}
|
|
6531
|
-
|
|
6532
|
-
/**
|
|
6533
|
-
* Reset global configuration to default
|
|
6534
|
-
* @returns {Object} Default configuration
|
|
6535
|
-
*/
|
|
6536
|
-
function resetConfig() {
|
|
6537
|
-
twString = null;
|
|
6538
|
-
cssObject = null;
|
|
6539
|
-
configOptionsCache.clear();
|
|
6540
|
-
const globalStorage = configManager.reset();
|
|
6541
|
-
|
|
6542
|
-
// Update local reference
|
|
6543
|
-
globalConfig = globalStorage;
|
|
6544
|
-
twString = generateTailwindCssString(globalConfig).replace(/\s\s+/g, " ");
|
|
6473
|
+
if (!cssObject) {
|
|
6545
6474
|
cssObject = convertCssToObject(twString);
|
|
6546
|
-
return {
|
|
6547
|
-
...globalConfig
|
|
6548
|
-
};
|
|
6549
6475
|
}
|
|
6476
|
+
const breakpoints = {
|
|
6477
|
+
sm: "@media (min-width: 640px)",
|
|
6478
|
+
md: "@media (min-width: 768px)",
|
|
6479
|
+
lg: "@media (min-width: 1024px)",
|
|
6480
|
+
xl: "@media (min-width: 1280px)",
|
|
6481
|
+
"2xl": "@media (min-width: 1536px)"
|
|
6482
|
+
};
|
|
6550
6483
|
const pseudoVariants = new Set(["hover", "focus", "focus-within", "active", "visited", "disabled", "first", "last", "checked", "invalid", "required"]);
|
|
6551
6484
|
const specialVariants = {
|
|
6552
6485
|
group: (state, sel) => `.group:${state} ${sel}`,
|
|
@@ -6596,9 +6529,6 @@ function resolveVariants(selector, variants) {
|
|
|
6596
6529
|
let media = null;
|
|
6597
6530
|
let finalSelector = selector;
|
|
6598
6531
|
for (const v of variants) {
|
|
6599
|
-
// Always get fresh config from global storage
|
|
6600
|
-
const currentConfig = getGlobalStorage();
|
|
6601
|
-
const breakpoints = convertScreensToBreakpoints(currentConfig.theme.screens || {});
|
|
6602
6532
|
if (breakpoints[v]) {
|
|
6603
6533
|
media = breakpoints[v];
|
|
6604
6534
|
} else if (pseudoVariants.has(v)) {
|
|
@@ -6794,7 +6724,7 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
6794
6724
|
|
|
6795
6725
|
// Handle hex colors
|
|
6796
6726
|
const hexRegex = new RegExp(`(${prop}\\s*:\\s*)(#[0-9a-fA-F]{3,6})`, "gi");
|
|
6797
|
-
modifiedDeclaration = modifiedDeclaration.replace(hexRegex, (
|
|
6727
|
+
modifiedDeclaration = modifiedDeclaration.replace(hexRegex, (match, propPart, hexColor) => {
|
|
6798
6728
|
// Convert hex to rgba
|
|
6799
6729
|
const hex = hexColor.replace("#", "");
|
|
6800
6730
|
let r, g, b;
|
|
@@ -6822,8 +6752,6 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
6822
6752
|
function tws(classNames, convertToJson) {
|
|
6823
6753
|
const totalMarker = performanceMonitor.start("tws:total");
|
|
6824
6754
|
try {
|
|
6825
|
-
// Ensure CSS is initialized with current global config
|
|
6826
|
-
initializeCss();
|
|
6827
6755
|
if ([!classNames, typeof classNames !== "string", classNames.trim() === ""].includes(true)) {
|
|
6828
6756
|
performanceMonitor.end(totalMarker);
|
|
6829
6757
|
return convertToJson ? {} : "";
|
|
@@ -7202,7 +7130,7 @@ function generateCssString(styles) {
|
|
|
7202
7130
|
* Generate CSS string from style object with SCSS-like syntax
|
|
7203
7131
|
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
7204
7132
|
* @param {Object} obj - Object with SCSS-like style format
|
|
7205
|
-
* @param {Object} [options] - Additional options,
|
|
7133
|
+
* @param {Object} [options] - Additional options, e.g. { inject: true/false }
|
|
7206
7134
|
* @returns {string} Generated CSS string
|
|
7207
7135
|
*/
|
|
7208
7136
|
function twsx(obj) {
|
|
@@ -7213,13 +7141,9 @@ function twsx(obj) {
|
|
|
7213
7141
|
console.warn("twsx: Expected an object but received:", obj);
|
|
7214
7142
|
return "";
|
|
7215
7143
|
}
|
|
7216
|
-
const mergedOptions = {
|
|
7217
|
-
...getGlobalStorage(),
|
|
7218
|
-
...options
|
|
7219
|
-
};
|
|
7220
7144
|
const {
|
|
7221
7145
|
inject = true
|
|
7222
|
-
} =
|
|
7146
|
+
} = options;
|
|
7223
7147
|
const styles = {};
|
|
7224
7148
|
|
|
7225
7149
|
// Create walk function with closure over styles
|
|
@@ -7362,4 +7286,4 @@ const performanceUtils = {
|
|
|
7362
7286
|
}
|
|
7363
7287
|
};
|
|
7364
7288
|
|
|
7365
|
-
export { debouncedTws, debouncedTwsx,
|
|
7289
|
+
export { debouncedTws, debouncedTwsx, performanceUtils, tws, twsx };
|