tailwind-to-style 2.5.2 → 2.6.1
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/README.md +19 -0
- package/dist/index.browser.js +153 -100
- package/{index.js → dist/index.cjs.js} +153 -100
- package/dist/index.esm.js +1144 -1108
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/package.json +2 -7
- package/index.min.js +0 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tailwind-to-style v2.
|
|
2
|
+
* tailwind-to-style v2.6.1
|
|
3
3
|
* Convert tailwind classes to inline style
|
|
4
4
|
*
|
|
5
5
|
* @author Bigetion
|
|
@@ -1247,8 +1247,15 @@ const theme = {
|
|
|
1247
1247
|
},
|
|
1248
1248
|
};
|
|
1249
1249
|
|
|
1250
|
+
const vars = {
|
|
1251
|
+
transform: `transform: translateX(var(--transform-translate-x, 0)) translateY(var(--transform-translate-y, 0)) rotate(var(--transform-rotate, 0)) skewX(var(--transform-skew-x, 0)) skewY(var(--transform-skew-y, 0)) scaleX(var(--transform-scale-x, 1)) scaleY(var(--transform-scale-y, 1));`,
|
|
1252
|
+
filter: `filter: blur(var(--blur, 0)) brightness(var(--brightness, 1)) contrast(var(--contrast, 1)) grayscale(var(--grayscale, 0)) hue-rotate(var(--hue-rotate, 0deg)) invert(var(--invert, 0)) saturate(var(--saturate, 1)) sepia(var(--sepia, 0)) drop-shadow(var(--drop-shadow, 0 0 #0000));`,
|
|
1253
|
+
backdropFilter: `-webkit-backdrop-filter: blur(var(--backdrop-blur, 0)) brightness(var(--backdrop-brightness, 1)) contrast(var(--backdrop-contrast, 1)) grayscale(var(--backdrop-grayscale, 0)) hue-rotate(var(--backdrop-hue-rotate, 0deg)) invert(var(--backdrop-invert, 0)) opacity(var(--backdrop-opacity, 1)) saturate(var(--backdrop-saturate, 1)) sepia(var(--backdrop-sepia, 0)); backdrop-filter: blur(var(--backdrop-blur, 0)) brightness(var(--backdrop-brightness, 1)) contrast(var(--backdrop-contrast, 1)) grayscale(var(--backdrop-grayscale, 0)) hue-rotate(var(--backdrop-hue-rotate, 0deg)) invert(var(--backdrop-invert, 0)) opacity(var(--backdrop-opacity, 1)) saturate(var(--backdrop-saturate, 1)) sepia(var(--backdrop-sepia, 0));`,
|
|
1254
|
+
};
|
|
1255
|
+
|
|
1250
1256
|
const configOptions = {
|
|
1251
1257
|
theme,
|
|
1258
|
+
vars,
|
|
1252
1259
|
};
|
|
1253
1260
|
|
|
1254
1261
|
function isFunction(functionToCheck) {
|
|
@@ -1290,6 +1297,7 @@ function getConfigOptions(options = {}) {
|
|
|
1290
1297
|
|
|
1291
1298
|
return {
|
|
1292
1299
|
prefix: "",
|
|
1300
|
+
...configOptions,
|
|
1293
1301
|
...options,
|
|
1294
1302
|
theme: newTheme,
|
|
1295
1303
|
};
|
|
@@ -1817,7 +1825,7 @@ function generator$2c(configOptions = {}) {
|
|
|
1817
1825
|
}
|
|
1818
1826
|
|
|
1819
1827
|
function generator$2b(configOptions = {}) {
|
|
1820
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
1828
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
1821
1829
|
|
|
1822
1830
|
const prefix = `${globalPrefix}blur`;
|
|
1823
1831
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -1829,10 +1837,12 @@ function generator$2b(configOptions = {}) {
|
|
|
1829
1837
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
1830
1838
|
return `
|
|
1831
1839
|
${prefix}${key} {
|
|
1832
|
-
--blur:
|
|
1840
|
+
--blur: ${value};
|
|
1841
|
+
${vars.filter}
|
|
1833
1842
|
}
|
|
1834
1843
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}${key} {
|
|
1835
|
-
--backdrop-blur:
|
|
1844
|
+
--backdrop-blur: ${value};
|
|
1845
|
+
${vars.backdropFilter}
|
|
1836
1846
|
}
|
|
1837
1847
|
`;
|
|
1838
1848
|
});
|
|
@@ -2226,7 +2236,7 @@ function generator$21(configOptions = {}) {
|
|
|
2226
2236
|
}
|
|
2227
2237
|
|
|
2228
2238
|
function generator$20(configOptions = {}) {
|
|
2229
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
2239
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
2230
2240
|
|
|
2231
2241
|
const prefix = `${globalPrefix}brightness`;
|
|
2232
2242
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -2238,10 +2248,12 @@ function generator$20(configOptions = {}) {
|
|
|
2238
2248
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
2239
2249
|
return `
|
|
2240
2250
|
${prefix}${key} {
|
|
2241
|
-
--brightness:
|
|
2251
|
+
--brightness: ${value};
|
|
2252
|
+
${vars.filter}
|
|
2242
2253
|
}
|
|
2243
2254
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}${key} {
|
|
2244
|
-
--backdrop-brightness:
|
|
2255
|
+
--backdrop-brightness: ${value};
|
|
2256
|
+
${vars.backdropFilter}
|
|
2245
2257
|
}
|
|
2246
2258
|
`;
|
|
2247
2259
|
});
|
|
@@ -2354,7 +2366,7 @@ function generator$1Y(configOptions = {}) {
|
|
|
2354
2366
|
}
|
|
2355
2367
|
|
|
2356
2368
|
function generator$1X(configOptions = {}) {
|
|
2357
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
2369
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
2358
2370
|
|
|
2359
2371
|
const prefix = `${globalPrefix}contrast`;
|
|
2360
2372
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -2366,10 +2378,12 @@ function generator$1X(configOptions = {}) {
|
|
|
2366
2378
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
2367
2379
|
return `
|
|
2368
2380
|
${prefix}${key} {
|
|
2369
|
-
--contrast:
|
|
2381
|
+
--contrast: ${value};
|
|
2382
|
+
${vars.filter}
|
|
2370
2383
|
}
|
|
2371
2384
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}${key} {
|
|
2372
|
-
--backdrop-contrast:
|
|
2385
|
+
--backdrop-contrast: ${value};
|
|
2386
|
+
${vars.backdropFilter}
|
|
2373
2387
|
}
|
|
2374
2388
|
`;
|
|
2375
2389
|
});
|
|
@@ -2639,34 +2653,11 @@ function generator$1P(configOptions = {}) {
|
|
|
2639
2653
|
}
|
|
2640
2654
|
|
|
2641
2655
|
function generator$1O({ prefix }) {
|
|
2642
|
-
return `
|
|
2643
|
-
${prefix}filter {
|
|
2644
|
-
--blur: ;
|
|
2645
|
-
--brightness: ;
|
|
2646
|
-
--contrast: ;
|
|
2647
|
-
--grayscale: ;
|
|
2648
|
-
--hue-rotate: ;
|
|
2649
|
-
--invert: ;
|
|
2650
|
-
--saturate: ;
|
|
2651
|
-
--sepia: ;
|
|
2652
|
-
--drop-shadow: ;
|
|
2653
|
-
filter: var(--blur) var(--brightness) var(--contrast) var(--grayscale) var(--hue-rotate) var(--invert) var(--saturate) var(--sepia) var(--drop-shadow);
|
|
2654
|
-
|
|
2655
|
-
--backdrop-blur: ;
|
|
2656
|
-
--backdrop-brightness: ;
|
|
2657
|
-
--backdrop-contrast: ;
|
|
2658
|
-
--backdrop-grayscale: ;
|
|
2659
|
-
--backdrop-hue-rotate: ;
|
|
2660
|
-
--backdrop-invert: ;
|
|
2661
|
-
--backdrop-opacity: ;
|
|
2662
|
-
--backdrop-saturate: ;
|
|
2663
|
-
--backdrop-sepia: ;
|
|
2664
|
-
-webkit-backdrop-filter: var(--backdrop-blur) var(--backdrop-brightness) var(--backdrop-contrast) var(--backdrop-grayscale) var(--backdrop-hue-rotate) var(--backdrop-invert) var(--backdrop-opacity) var(--backdrop-saturate) var(--backdrop-sepia);
|
|
2665
|
-
backdrop-filter: var(--backdrop-blur) var(--backdrop-brightness) var(--backdrop-contrast) var(--backdrop-grayscale) var(--backdrop-hue-rotate) var(--backdrop-invert) var(--backdrop-opacity) var(--backdrop-saturate) var(--backdrop-sepia);
|
|
2666
|
-
}
|
|
2656
|
+
return `
|
|
2667
2657
|
${prefix}filter-none {
|
|
2668
|
-
filter: none;
|
|
2669
|
-
backdrop-filter: none;
|
|
2658
|
+
filter: none !important;
|
|
2659
|
+
-webkit-backdrop-filter: none !important;
|
|
2660
|
+
backdrop-filter: none !important;
|
|
2670
2661
|
}
|
|
2671
2662
|
`;
|
|
2672
2663
|
}
|
|
@@ -3019,7 +3010,7 @@ function generator$1A(configOptions = {}) {
|
|
|
3019
3010
|
}
|
|
3020
3011
|
|
|
3021
3012
|
function generator$1z(configOptions = {}) {
|
|
3022
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
3013
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
3023
3014
|
|
|
3024
3015
|
const prefix = `${globalPrefix}grayscale`;
|
|
3025
3016
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -3031,10 +3022,12 @@ function generator$1z(configOptions = {}) {
|
|
|
3031
3022
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
3032
3023
|
return `
|
|
3033
3024
|
${prefix}${key} {
|
|
3034
|
-
--grayscale:
|
|
3025
|
+
--grayscale: ${value};
|
|
3026
|
+
${vars.filter}
|
|
3035
3027
|
}
|
|
3036
3028
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}${key} {
|
|
3037
|
-
--backdrop-grayscale:
|
|
3029
|
+
--backdrop-grayscale: ${value};
|
|
3030
|
+
${vars.backdropFilter}
|
|
3038
3031
|
}
|
|
3039
3032
|
`;
|
|
3040
3033
|
});
|
|
@@ -3318,7 +3311,7 @@ function generator$1n(configOptions = {}) {
|
|
|
3318
3311
|
}
|
|
3319
3312
|
|
|
3320
3313
|
function generator$1m(configOptions = {}) {
|
|
3321
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
3314
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
3322
3315
|
|
|
3323
3316
|
const { hueRotate = {} } = theme;
|
|
3324
3317
|
|
|
@@ -3333,10 +3326,12 @@ function generator$1m(configOptions = {}) {
|
|
|
3333
3326
|
}
|
|
3334
3327
|
return `
|
|
3335
3328
|
${prefix}-${key} {
|
|
3336
|
-
--hue-rotate:
|
|
3329
|
+
--hue-rotate: ${value};
|
|
3330
|
+
${vars.filter}
|
|
3337
3331
|
}
|
|
3338
3332
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}-${key} {
|
|
3339
|
-
--backdrop-hue-rotate:
|
|
3333
|
+
--backdrop-hue-rotate: ${value};
|
|
3334
|
+
${vars.backdropFilter}
|
|
3340
3335
|
}
|
|
3341
3336
|
`;
|
|
3342
3337
|
});
|
|
@@ -3422,7 +3417,7 @@ function generator$1k(configOptions = {}) {
|
|
|
3422
3417
|
}
|
|
3423
3418
|
|
|
3424
3419
|
function generator$1j(configOptions = {}) {
|
|
3425
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
3420
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
3426
3421
|
|
|
3427
3422
|
const prefix = `${globalPrefix}invert`;
|
|
3428
3423
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -3434,10 +3429,12 @@ function generator$1j(configOptions = {}) {
|
|
|
3434
3429
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
3435
3430
|
return `
|
|
3436
3431
|
${prefix}${key} {
|
|
3437
|
-
--invert:
|
|
3432
|
+
--invert: ${value};
|
|
3433
|
+
${vars.filter}
|
|
3438
3434
|
}
|
|
3439
3435
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}${key} {
|
|
3440
|
-
--backdrop-invert:
|
|
3436
|
+
--backdrop-invert: ${value};
|
|
3437
|
+
${vars.backdropFilter}
|
|
3441
3438
|
}
|
|
3442
3439
|
`;
|
|
3443
3440
|
});
|
|
@@ -3904,7 +3901,7 @@ function generator$12(configOptions = {}) {
|
|
|
3904
3901
|
}
|
|
3905
3902
|
|
|
3906
3903
|
function generator$11(configOptions = {}) {
|
|
3907
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
3904
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
3908
3905
|
|
|
3909
3906
|
const prefix = `${globalPrefix}opacity`;
|
|
3910
3907
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -3917,9 +3914,11 @@ function generator$11(configOptions = {}) {
|
|
|
3917
3914
|
(key, value) => `
|
|
3918
3915
|
${prefix}-${key} {
|
|
3919
3916
|
opacity: ${value};
|
|
3917
|
+
${vars.filter}
|
|
3920
3918
|
}
|
|
3921
3919
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}-${key} {
|
|
3922
|
-
--backdrop-opacity:
|
|
3920
|
+
--backdrop-opacity: ${value};
|
|
3921
|
+
${vars.backdropFilter}
|
|
3923
3922
|
}
|
|
3924
3923
|
`
|
|
3925
3924
|
);
|
|
@@ -4457,7 +4456,7 @@ function generator$J(configOptions = {}) {
|
|
|
4457
4456
|
}
|
|
4458
4457
|
|
|
4459
4458
|
function generator$I(configOptions = {}) {
|
|
4460
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
4459
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
4461
4460
|
|
|
4462
4461
|
const prefix = `${globalPrefix}saturate`;
|
|
4463
4462
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -4469,10 +4468,12 @@ function generator$I(configOptions = {}) {
|
|
|
4469
4468
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
4470
4469
|
return `
|
|
4471
4470
|
${prefix}${key} {
|
|
4472
|
-
--saturate:
|
|
4471
|
+
--saturate: ${value};
|
|
4472
|
+
${vars.filter}
|
|
4473
4473
|
}
|
|
4474
4474
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}${key} {
|
|
4475
|
-
--backdrop-saturate:
|
|
4475
|
+
--backdrop-saturate: ${value};
|
|
4476
|
+
${vars.backdropFilter}
|
|
4476
4477
|
}
|
|
4477
4478
|
`;
|
|
4478
4479
|
});
|
|
@@ -4482,62 +4483,66 @@ function generator$I(configOptions = {}) {
|
|
|
4482
4483
|
return responsiveCssString;
|
|
4483
4484
|
}
|
|
4484
4485
|
|
|
4485
|
-
function generator$H(configOptions = {}) {
|
|
4486
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
4487
|
-
|
|
4488
|
-
const { rotate = {} } = theme;
|
|
4489
|
-
|
|
4490
|
-
Object.entries(rotate).forEach(([key, value]) => {
|
|
4491
|
-
rotate[`-${key}`] = `-${value}`.replace("--", "-");
|
|
4492
|
-
});
|
|
4493
|
-
|
|
4494
|
-
const responsiveCssString = generateCssString(({ getCssByOptions }) => {
|
|
4495
|
-
const cssString = getCssByOptions(rotate, (keyTmp, value) => {
|
|
4496
|
-
let prefix = `${globalPrefix}rotate`;
|
|
4497
|
-
let key = keyTmp;
|
|
4498
|
-
if (`${key}`.indexOf("-") >= 0) {
|
|
4499
|
-
key = key.split("-").join("");
|
|
4500
|
-
prefix = `${globalPrefix}-rotate`;
|
|
4501
|
-
}
|
|
4502
|
-
return `
|
|
4503
|
-
${prefix}-${key} {
|
|
4504
|
-
--transform-rotate: ${value};
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
--transform-scale-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
}
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
}
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4486
|
+
function generator$H(configOptions = {}) {
|
|
4487
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
4488
|
+
|
|
4489
|
+
const { rotate = {} } = theme;
|
|
4490
|
+
|
|
4491
|
+
Object.entries(rotate).forEach(([key, value]) => {
|
|
4492
|
+
rotate[`-${key}`] = `-${value}`.replace("--", "-");
|
|
4493
|
+
});
|
|
4494
|
+
|
|
4495
|
+
const responsiveCssString = generateCssString(({ getCssByOptions }) => {
|
|
4496
|
+
const cssString = getCssByOptions(rotate, (keyTmp, value) => {
|
|
4497
|
+
let prefix = `${globalPrefix}rotate`;
|
|
4498
|
+
let key = keyTmp;
|
|
4499
|
+
if (`${key}`.indexOf("-") >= 0) {
|
|
4500
|
+
key = key.split("-").join("");
|
|
4501
|
+
prefix = `${globalPrefix}-rotate`;
|
|
4502
|
+
}
|
|
4503
|
+
return `
|
|
4504
|
+
${prefix}-${key} {
|
|
4505
|
+
--transform-rotate: ${value};
|
|
4506
|
+
${vars.transform}
|
|
4507
|
+
}
|
|
4508
|
+
`;
|
|
4509
|
+
});
|
|
4510
|
+
return cssString;
|
|
4511
|
+
});
|
|
4512
|
+
|
|
4513
|
+
return responsiveCssString;
|
|
4514
|
+
}
|
|
4515
|
+
|
|
4516
|
+
function generator$G(configOptions = {}) {
|
|
4517
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
4518
|
+
|
|
4519
|
+
const prefix = `${globalPrefix}scale`;
|
|
4520
|
+
|
|
4521
|
+
const { scale = {} } = theme;
|
|
4522
|
+
|
|
4523
|
+
const responsiveCssString = generateCssString(({ getCssByOptions }) => {
|
|
4524
|
+
const cssString = getCssByOptions(
|
|
4525
|
+
scale,
|
|
4526
|
+
(key, value) => `
|
|
4527
|
+
${prefix}-${key} {
|
|
4528
|
+
--transform-scale-x: ${value};
|
|
4529
|
+
--transform-scale-y: ${value};
|
|
4530
|
+
${vars.transform}
|
|
4531
|
+
}
|
|
4532
|
+
${prefix}-x-${key} {
|
|
4533
|
+
--transform-scale-x: ${value};
|
|
4534
|
+
${vars.transform}
|
|
4535
|
+
}
|
|
4536
|
+
${prefix}-y-${key} {
|
|
4537
|
+
--transform-scale-y: ${value};
|
|
4538
|
+
${vars.transform}
|
|
4539
|
+
}
|
|
4540
|
+
`
|
|
4541
|
+
);
|
|
4542
|
+
return cssString;
|
|
4543
|
+
});
|
|
4544
|
+
|
|
4545
|
+
return responsiveCssString;
|
|
4541
4546
|
}
|
|
4542
4547
|
|
|
4543
4548
|
function generator$F(configOptions = {}) {
|
|
@@ -4756,7 +4761,7 @@ function generator$A(configOptions = {}) {
|
|
|
4756
4761
|
}
|
|
4757
4762
|
|
|
4758
4763
|
function generator$z(configOptions = {}) {
|
|
4759
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
4764
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
4760
4765
|
|
|
4761
4766
|
const prefix = `${globalPrefix}sepia`;
|
|
4762
4767
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -4768,10 +4773,12 @@ function generator$z(configOptions = {}) {
|
|
|
4768
4773
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
4769
4774
|
return `
|
|
4770
4775
|
${prefix}${key} {
|
|
4771
|
-
--sepia:
|
|
4776
|
+
--sepia: ${value};
|
|
4777
|
+
${vars.filter}
|
|
4772
4778
|
}
|
|
4773
4779
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}${key} {
|
|
4774
|
-
--backdrop-sepia:
|
|
4780
|
+
--backdrop-sepia: ${value};
|
|
4781
|
+
${vars.backdropFilter}
|
|
4775
4782
|
}
|
|
4776
4783
|
`;
|
|
4777
4784
|
});
|
|
@@ -4804,36 +4811,38 @@ function generator$y(configOptions = {}) {
|
|
|
4804
4811
|
return responsiveCssString;
|
|
4805
4812
|
}
|
|
4806
4813
|
|
|
4807
|
-
function generator$x(configOptions = {}) {
|
|
4808
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
4809
|
-
|
|
4810
|
-
const { skew = {} } = theme;
|
|
4811
|
-
|
|
4812
|
-
Object.entries(skew).forEach(([key, value]) => {
|
|
4813
|
-
skew[`-${key}`] = `-${value}`.replace("--", "-");
|
|
4814
|
-
});
|
|
4815
|
-
|
|
4816
|
-
const responsiveCssString = generateCssString(({ getCssByOptions }) => {
|
|
4817
|
-
const cssString = getCssByOptions(skew, (keyTmp, value) => {
|
|
4818
|
-
let prefix = `${globalPrefix}skew`;
|
|
4819
|
-
let key = keyTmp;
|
|
4820
|
-
if (`${key}`.indexOf("-") >= 0) {
|
|
4821
|
-
key = key.split("-").join("");
|
|
4822
|
-
prefix = `${globalPrefix}-skew`;
|
|
4823
|
-
}
|
|
4824
|
-
return `
|
|
4825
|
-
${prefix}-x-${key} {
|
|
4826
|
-
--transform-skew-x: ${value};
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4814
|
+
function generator$x(configOptions = {}) {
|
|
4815
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
4816
|
+
|
|
4817
|
+
const { skew = {} } = theme;
|
|
4818
|
+
|
|
4819
|
+
Object.entries(skew).forEach(([key, value]) => {
|
|
4820
|
+
skew[`-${key}`] = `-${value}`.replace("--", "-");
|
|
4821
|
+
});
|
|
4822
|
+
|
|
4823
|
+
const responsiveCssString = generateCssString(({ getCssByOptions }) => {
|
|
4824
|
+
const cssString = getCssByOptions(skew, (keyTmp, value) => {
|
|
4825
|
+
let prefix = `${globalPrefix}skew`;
|
|
4826
|
+
let key = keyTmp;
|
|
4827
|
+
if (`${key}`.indexOf("-") >= 0) {
|
|
4828
|
+
key = key.split("-").join("");
|
|
4829
|
+
prefix = `${globalPrefix}-skew`;
|
|
4830
|
+
}
|
|
4831
|
+
return `
|
|
4832
|
+
${prefix}-x-${key} {
|
|
4833
|
+
--transform-skew-x: ${value};
|
|
4834
|
+
${vars.transform}
|
|
4835
|
+
}
|
|
4836
|
+
${prefix}-y-${key} {
|
|
4837
|
+
--transform-skew-y: ${value};
|
|
4838
|
+
${vars.transform}
|
|
4839
|
+
}
|
|
4840
|
+
`;
|
|
4841
|
+
});
|
|
4842
|
+
return cssString;
|
|
4843
|
+
});
|
|
4844
|
+
|
|
4845
|
+
return responsiveCssString;
|
|
4837
4846
|
}
|
|
4838
4847
|
|
|
4839
4848
|
function generator$w(configOptions = {}) {
|
|
@@ -5408,86 +5417,78 @@ function generator$b(configOptions = {}) {
|
|
|
5408
5417
|
return responsiveCssString;
|
|
5409
5418
|
}
|
|
5410
5419
|
|
|
5411
|
-
function generator$a({ prefix }) {
|
|
5412
|
-
return `
|
|
5413
|
-
${prefix}transform {
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
}
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
--transform-translate-y: ${value};
|
|
5484
|
-
}
|
|
5485
|
-
`;
|
|
5486
|
-
});
|
|
5487
|
-
return cssString;
|
|
5488
|
-
});
|
|
5489
|
-
|
|
5490
|
-
return responsiveCssString;
|
|
5420
|
+
function generator$a({ prefix }) {
|
|
5421
|
+
return `
|
|
5422
|
+
${prefix}transform-none {
|
|
5423
|
+
transform: none !important;
|
|
5424
|
+
}
|
|
5425
|
+
`;
|
|
5426
|
+
}
|
|
5427
|
+
|
|
5428
|
+
function generator$9(configOptions = {}) {
|
|
5429
|
+
const { prefix: globalPrefix } = configOptions;
|
|
5430
|
+
|
|
5431
|
+
const prefix = `${globalPrefix}origin`;
|
|
5432
|
+
|
|
5433
|
+
const propertyOptions = [
|
|
5434
|
+
"center",
|
|
5435
|
+
"top",
|
|
5436
|
+
"top-right",
|
|
5437
|
+
"right",
|
|
5438
|
+
"bottom-right",
|
|
5439
|
+
"bottom",
|
|
5440
|
+
"bottom-left",
|
|
5441
|
+
"left",
|
|
5442
|
+
"top-left",
|
|
5443
|
+
];
|
|
5444
|
+
|
|
5445
|
+
const responsiveCssString = generateCssString(({ getCssByOptions }) => {
|
|
5446
|
+
const cssString = getCssByOptions(
|
|
5447
|
+
propertyOptions,
|
|
5448
|
+
(key, value) => `
|
|
5449
|
+
${prefix}-${key} {
|
|
5450
|
+
transform-origin: ${value.replace("-", " ")};
|
|
5451
|
+
}
|
|
5452
|
+
`
|
|
5453
|
+
);
|
|
5454
|
+
return cssString;
|
|
5455
|
+
});
|
|
5456
|
+
|
|
5457
|
+
return responsiveCssString;
|
|
5458
|
+
}
|
|
5459
|
+
|
|
5460
|
+
function generator$8(configOptions = {}) {
|
|
5461
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
5462
|
+
|
|
5463
|
+
const { translate = {} } = theme;
|
|
5464
|
+
|
|
5465
|
+
Object.entries(translate).forEach(([key, value]) => {
|
|
5466
|
+
translate[`-${key}`] = `-${value}`.replace("--", "-");
|
|
5467
|
+
});
|
|
5468
|
+
|
|
5469
|
+
const responsiveCssString = generateCssString(({ getCssByOptions }) => {
|
|
5470
|
+
const cssString = getCssByOptions(translate, (keyTmp, value) => {
|
|
5471
|
+
let prefix = `${globalPrefix}translate`;
|
|
5472
|
+
let key = keyTmp;
|
|
5473
|
+
if (`${key}`.indexOf("-") >= 0) {
|
|
5474
|
+
key = key.split("-").join("");
|
|
5475
|
+
prefix = `${globalPrefix}-translate`;
|
|
5476
|
+
}
|
|
5477
|
+
return `
|
|
5478
|
+
${prefix}-x-${key} {
|
|
5479
|
+
--transform-translate-x: ${value};
|
|
5480
|
+
${vars.transform}
|
|
5481
|
+
}
|
|
5482
|
+
${prefix}-y-${key} {
|
|
5483
|
+
--transform-translate-y: ${value};
|
|
5484
|
+
${vars.transform}
|
|
5485
|
+
}
|
|
5486
|
+
`;
|
|
5487
|
+
});
|
|
5488
|
+
return cssString;
|
|
5489
|
+
});
|
|
5490
|
+
|
|
5491
|
+
return responsiveCssString;
|
|
5491
5492
|
}
|
|
5492
5493
|
|
|
5493
5494
|
function generator$7(configOptions = {}) {
|
|
@@ -5751,896 +5752,931 @@ const transition = {
|
|
|
5751
5752
|
},
|
|
5752
5753
|
};
|
|
5753
5754
|
|
|
5754
|
-
const patterns = {
|
|
5755
|
-
...transition,
|
|
5755
|
+
const patterns = {
|
|
5756
|
+
...transition,
|
|
5757
|
+
};
|
|
5758
|
+
|
|
5759
|
+
const plugins = {
|
|
5760
|
+
accentColor: generator$2r,
|
|
5761
|
+
accessibility: generator$2q,
|
|
5762
|
+
alignContent: generator$2p,
|
|
5763
|
+
alignItems: generator$2o,
|
|
5764
|
+
alignSelf: generator$2n,
|
|
5765
|
+
appearance: generator$2m,
|
|
5766
|
+
aspect: generator$2l,
|
|
5767
|
+
backgroundAttachment: generator$2k,
|
|
5768
|
+
backgroundClip: generator$2j,
|
|
5769
|
+
backgroundColor: generator$2i,
|
|
5770
|
+
backgroundImage: generator$2h,
|
|
5771
|
+
backgroundOpacity: generator$2g,
|
|
5772
|
+
backgroundOrigin: generator$2f,
|
|
5773
|
+
backgroundPosition: generator$2e,
|
|
5774
|
+
backgroundRepeat: generator$2d,
|
|
5775
|
+
backgroundSize: generator$2c,
|
|
5776
|
+
blur: generator$2b,
|
|
5777
|
+
borderCollapse: generator$2a,
|
|
5778
|
+
borderColor: generator$29,
|
|
5779
|
+
borderOpacity: generator$28,
|
|
5780
|
+
borderRadius: generator$27,
|
|
5781
|
+
borderSpacing: generator$26,
|
|
5782
|
+
borderStyle: generator$25,
|
|
5783
|
+
borderWidth: generator$24,
|
|
5784
|
+
boxDecorationBreak: generator$23,
|
|
5785
|
+
boxShadow: generator$22,
|
|
5786
|
+
boxSizing: generator$21,
|
|
5787
|
+
brightness: generator$20,
|
|
5788
|
+
captionSide: generator$1$,
|
|
5789
|
+
caretColor: generator$1_,
|
|
5790
|
+
clear: generator$1Z,
|
|
5791
|
+
content: generator$1Y,
|
|
5792
|
+
contrast: generator$1X,
|
|
5793
|
+
cursor: generator$1W,
|
|
5794
|
+
display: generator$1V,
|
|
5795
|
+
divideColor: generator$1U,
|
|
5796
|
+
divideOpacity: generator$1T,
|
|
5797
|
+
divideStyle: generator$1S,
|
|
5798
|
+
divideWidth: generator$1R,
|
|
5799
|
+
dropShadow: generator$1Q,
|
|
5800
|
+
fill: generator$1P,
|
|
5801
|
+
filter: generator$1O,
|
|
5802
|
+
flex: generator$1N,
|
|
5803
|
+
flexBasis: generator$1M,
|
|
5804
|
+
flexDirection: generator$1L,
|
|
5805
|
+
flexGrow: generator$1K,
|
|
5806
|
+
flexShrink: generator$1J,
|
|
5807
|
+
flexWrap: generator$1I,
|
|
5808
|
+
float: generator$1H,
|
|
5809
|
+
fontSize: generator$1G,
|
|
5810
|
+
fontSmoothing: generator$1F,
|
|
5811
|
+
fontStyle: generator$1E,
|
|
5812
|
+
fontVariantNumeric: generator$1D,
|
|
5813
|
+
fontWeight: generator$1C,
|
|
5814
|
+
gap: generator$1B,
|
|
5815
|
+
gradientColorStops: generator$1A,
|
|
5816
|
+
grayscale: generator$1z,
|
|
5817
|
+
gridAutoColumns: generator$1y,
|
|
5818
|
+
gridAutoFlow: generator$1x,
|
|
5819
|
+
gridAutoRows: generator$1w,
|
|
5820
|
+
gridColumn: generator$1v,
|
|
5821
|
+
gridColumnEnd: generator$1u,
|
|
5822
|
+
gridColumnStart: generator$1t,
|
|
5823
|
+
gridRow: generator$1s,
|
|
5824
|
+
gridRowEnd: generator$1r,
|
|
5825
|
+
gridRowStart: generator$1q,
|
|
5826
|
+
gridTemplateColumns: generator$1p,
|
|
5827
|
+
gridTemplateRows: generator$1o,
|
|
5828
|
+
height: generator$1n,
|
|
5829
|
+
hueRotate: generator$1m,
|
|
5830
|
+
hyphens: generator$1l,
|
|
5831
|
+
inset: generator$1k,
|
|
5832
|
+
invert: generator$1j,
|
|
5833
|
+
isolation: generator$1i,
|
|
5834
|
+
justifyContent: generator$1h,
|
|
5835
|
+
justifyItems: generator$1g,
|
|
5836
|
+
justifySelf: generator$1f,
|
|
5837
|
+
letterSpacing: generator$1e,
|
|
5838
|
+
lineClamp: generator$1d,
|
|
5839
|
+
lineHeight: generator$1c,
|
|
5840
|
+
listStylePosition: generator$1b,
|
|
5841
|
+
listStyleType: generator$1a,
|
|
5842
|
+
margin: generator$19,
|
|
5843
|
+
maxHeight: generator$18,
|
|
5844
|
+
maxWidth: generator$17,
|
|
5845
|
+
minHeight: generator$16,
|
|
5846
|
+
minWidth: generator$15,
|
|
5847
|
+
objectFit: generator$13,
|
|
5848
|
+
mixBlendMode: generator$14,
|
|
5849
|
+
objectPosition: generator$12,
|
|
5850
|
+
opacity: generator$11,
|
|
5851
|
+
order: generator$10,
|
|
5852
|
+
outlineColor: generator$$,
|
|
5853
|
+
outlineOffset: generator$_,
|
|
5854
|
+
outlineOpacity: generator$Z,
|
|
5855
|
+
outlineStyle: generator$Y,
|
|
5856
|
+
outlineWidth: generator$X,
|
|
5857
|
+
overflow: generator$W,
|
|
5858
|
+
overscrollBehavior: generator$V,
|
|
5859
|
+
padding: generator$U,
|
|
5860
|
+
placeContent: generator$T,
|
|
5861
|
+
placeItems: generator$S,
|
|
5862
|
+
placeSelf: generator$R,
|
|
5863
|
+
pointerEvents: generator$Q,
|
|
5864
|
+
position: generator$P,
|
|
5865
|
+
resize: generator$O,
|
|
5866
|
+
ringColor: generator$N,
|
|
5867
|
+
ringOffsetColor: generator$M,
|
|
5868
|
+
ringOffsetWidth: generator$L,
|
|
5869
|
+
ringOpacity: generator$K,
|
|
5870
|
+
ringWidth: generator$J,
|
|
5871
|
+
rotate: generator$H,
|
|
5872
|
+
saturate: generator$I,
|
|
5873
|
+
scale: generator$G,
|
|
5874
|
+
scrollBehavior: generator$F,
|
|
5875
|
+
scrollMargin: generator$E,
|
|
5876
|
+
scrollPadding: generator$D,
|
|
5877
|
+
scrollSnapAlign: generator$C,
|
|
5878
|
+
scrollSnapStop: generator$B,
|
|
5879
|
+
scrollSnapType: generator$A,
|
|
5880
|
+
sepia: generator$z,
|
|
5881
|
+
size: generator$y,
|
|
5882
|
+
skew: generator$x,
|
|
5883
|
+
space: generator$w,
|
|
5884
|
+
stroke: generator$v,
|
|
5885
|
+
strokeWidth: generator$u,
|
|
5886
|
+
tableLayout: generator$t,
|
|
5887
|
+
textAlign: generator$s,
|
|
5888
|
+
textColor: generator$r,
|
|
5889
|
+
textDecoration: generator$q,
|
|
5890
|
+
textDecorationColor: generator$p,
|
|
5891
|
+
textDecorationStyle: generator$o,
|
|
5892
|
+
textDecorationThickness: generator$n,
|
|
5893
|
+
textIndent: generator$m,
|
|
5894
|
+
textOpacity: generator$l,
|
|
5895
|
+
textOverflow: generator$k,
|
|
5896
|
+
textShadowBlur: generator$j,
|
|
5897
|
+
textShadowColor: generator$i,
|
|
5898
|
+
textShadowOpacity: generator$h,
|
|
5899
|
+
textShadowX: generator$g,
|
|
5900
|
+
textShadowY: generator$f,
|
|
5901
|
+
textTransform: generator$e,
|
|
5902
|
+
textUnderlineOffset: generator$d,
|
|
5903
|
+
textWrap: generator$c,
|
|
5904
|
+
touchAction: generator$b,
|
|
5905
|
+
transform: generator$a,
|
|
5906
|
+
transformOrigin: generator$9,
|
|
5907
|
+
translate: generator$8,
|
|
5908
|
+
userSelect: generator$7,
|
|
5909
|
+
verticalAlign: generator$6,
|
|
5910
|
+
visibility: generator$5,
|
|
5911
|
+
whitespace: generator$4,
|
|
5912
|
+
width: generator$3,
|
|
5913
|
+
willChange: generator$1,
|
|
5914
|
+
wordBreak: generator$2,
|
|
5915
|
+
zIndex: generator,
|
|
5916
|
+
};
|
|
5917
|
+
|
|
5918
|
+
function parseCustomClassWithPatterns(className) {
|
|
5919
|
+
for (const key in patterns) {
|
|
5920
|
+
const { regex, cssProp, formatter } = patterns[key];
|
|
5921
|
+
const match = className.match(regex);
|
|
5922
|
+
if (match) {
|
|
5923
|
+
const value = formatter(match[1]);
|
|
5924
|
+
return `${cssProp}: ${value};`;
|
|
5925
|
+
}
|
|
5926
|
+
}
|
|
5927
|
+
return null;
|
|
5928
|
+
}
|
|
5929
|
+
|
|
5930
|
+
/**
|
|
5931
|
+
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
5932
|
+
* @param {string} cssString
|
|
5933
|
+
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
5934
|
+
*/
|
|
5935
|
+
function resolveCssToClearCss(cssString) {
|
|
5936
|
+
const customVars = {};
|
|
5937
|
+
const props = {};
|
|
5938
|
+
cssString.split(";").forEach((decl) => {
|
|
5939
|
+
const [key, value] = decl.split(":").map((s) => s && s.trim());
|
|
5940
|
+
if (!key || !value) return;
|
|
5941
|
+
if (key.startsWith("--")) {
|
|
5942
|
+
customVars[key] = value;
|
|
5943
|
+
} else {
|
|
5944
|
+
props[key] = value;
|
|
5945
|
+
}
|
|
5946
|
+
});
|
|
5947
|
+
// Replace var(--foo) in all values
|
|
5948
|
+
Object.keys(props).forEach((key) => {
|
|
5949
|
+
let val = props[key];
|
|
5950
|
+
val = val.replace(/var\((--[a-zA-Z0-9-_]+)\)/g, (m, v) =>
|
|
5951
|
+
customVars[v] !== undefined ? customVars[v] : m
|
|
5952
|
+
);
|
|
5953
|
+
props[key] = val;
|
|
5954
|
+
});
|
|
5955
|
+
// Build CSS string
|
|
5956
|
+
return Object.entries(props)
|
|
5957
|
+
.map(([k, v]) => `${k}: ${v};`)
|
|
5958
|
+
.join(" ");
|
|
5959
|
+
}
|
|
5960
|
+
|
|
5961
|
+
// Cache untuk getConfigOptions
|
|
5962
|
+
const configOptionsCache = new Map();
|
|
5963
|
+
const cacheKey = (options) => JSON.stringify(options);
|
|
5964
|
+
|
|
5965
|
+
function generateTailwindCssString(options = {}) {
|
|
5966
|
+
// Menggunakan cache untuk mencegah pemrosesan ulang yang tidak perlu
|
|
5967
|
+
const key = cacheKey(options);
|
|
5968
|
+
if (!configOptionsCache.has(key)) {
|
|
5969
|
+
configOptionsCache.set(key, getConfigOptions(options));
|
|
5970
|
+
limitCacheSize(configOptionsCache);
|
|
5971
|
+
}
|
|
5972
|
+
|
|
5973
|
+
const configOptions = configOptionsCache.get(key);
|
|
5974
|
+
const { corePlugins = {} } = configOptions;
|
|
5975
|
+
const corePluginKeys = Object.keys(corePlugins);
|
|
5976
|
+
|
|
5977
|
+
let cssString = ``;
|
|
5978
|
+
Object.keys(plugins).forEach((key) => {
|
|
5979
|
+
if (corePluginKeys.indexOf(key) >= 0 && !corePlugins[key]) {
|
|
5980
|
+
cssString += "";
|
|
5981
|
+
} else {
|
|
5982
|
+
cssString += plugins[key](configOptions);
|
|
5983
|
+
}
|
|
5984
|
+
});
|
|
5985
|
+
return cssString;
|
|
5986
|
+
}
|
|
5987
|
+
|
|
5988
|
+
function convertCssToObject(cssString) {
|
|
5989
|
+
const obj = {};
|
|
5990
|
+
const regex = /([a-zA-Z0-9\-_\\/.]+)\s*{\s*([^}]+)\s*}/g;
|
|
5991
|
+
let match;
|
|
5992
|
+
|
|
5993
|
+
while ((match = regex.exec(cssString)) !== null) {
|
|
5994
|
+
const className = match[1].replace(/\\\\/g, "\\").replace(/^_/, "");
|
|
5995
|
+
const cssRules = match[2].trim().replace(/\s+/g, " ");
|
|
5996
|
+
obj[className] = cssRules;
|
|
5997
|
+
}
|
|
5998
|
+
|
|
5999
|
+
return obj;
|
|
6000
|
+
}
|
|
6001
|
+
|
|
6002
|
+
let twString = null;
|
|
6003
|
+
let cssObject = null;
|
|
6004
|
+
|
|
6005
|
+
if (!twString) {
|
|
6006
|
+
twString = generateTailwindCssString().replace(/\s\s+/g, " ");
|
|
6007
|
+
}
|
|
6008
|
+
|
|
6009
|
+
if (!cssObject) {
|
|
6010
|
+
cssObject = convertCssToObject(twString);
|
|
6011
|
+
}
|
|
6012
|
+
|
|
6013
|
+
const breakpoints = {
|
|
6014
|
+
sm: "@media (min-width: 640px)",
|
|
6015
|
+
md: "@media (min-width: 768px)",
|
|
6016
|
+
lg: "@media (min-width: 1024px)",
|
|
6017
|
+
xl: "@media (min-width: 1280px)",
|
|
6018
|
+
"2xl": "@media (min-width: 1536px)",
|
|
6019
|
+
};
|
|
6020
|
+
|
|
6021
|
+
const pseudoVariants = new Set([
|
|
6022
|
+
"hover",
|
|
6023
|
+
"focus",
|
|
6024
|
+
"focus-within",
|
|
6025
|
+
"active",
|
|
6026
|
+
"visited",
|
|
6027
|
+
"disabled",
|
|
6028
|
+
"first",
|
|
6029
|
+
"last",
|
|
6030
|
+
"checked",
|
|
6031
|
+
"invalid",
|
|
6032
|
+
"required",
|
|
6033
|
+
]);
|
|
6034
|
+
|
|
6035
|
+
const specialVariants = {
|
|
6036
|
+
group: (state, sel) => `.group:${state} ${sel}`,
|
|
6037
|
+
peer: (state, sel) => `.peer:${state} ~ ${sel}`,
|
|
5756
6038
|
};
|
|
5757
6039
|
|
|
5758
|
-
const
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
}
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
}
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
}
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
const
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
}
|
|
6038
|
-
|
|
6039
|
-
const
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
}
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
}
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
const
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
}
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
}
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
}
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
function
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
if (
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
)
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
)
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
}
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
pureClassName = className.slice(1);
|
|
6399
|
-
}
|
|
6400
|
-
|
|
6401
|
-
const { media, finalSelector } = resolveVariants(selector, rawVariants);
|
|
6402
|
-
|
|
6403
|
-
let declarations =
|
|
6404
|
-
cssObject[pureClassName] ||
|
|
6405
|
-
cssObject[pureClassName.replace(/(\/)/g, "\\$1")] ||
|
|
6406
|
-
cssObject[pureClassName.replace(/\./g, "\\.")];
|
|
6407
|
-
|
|
6408
|
-
if (!declarations && pureClassName.includes("[")) {
|
|
6409
|
-
const match = pureClassName.match(/^(.+?)\[(.+)\]$/);
|
|
6410
|
-
if (match) {
|
|
6411
|
-
const [, prefix, dynamicValue] = match;
|
|
6412
|
-
const customKey = `${prefix}custom`;
|
|
6413
|
-
const template = cssObject[customKey];
|
|
6414
|
-
if (template) {
|
|
6415
|
-
declarations = template.replace(
|
|
6416
|
-
/custom_value/g,
|
|
6417
|
-
decodeBracketValues(dynamicValue)
|
|
6418
|
-
);
|
|
6419
|
-
}
|
|
6420
|
-
}
|
|
6421
|
-
}
|
|
6422
|
-
|
|
6423
|
-
if (!declarations) {
|
|
6424
|
-
declarations = parseCustomClassWithPatterns(pureClassName);
|
|
6425
|
-
}
|
|
6426
|
-
|
|
6427
|
-
if (!declarations) {
|
|
6428
|
-
continue;
|
|
6429
|
-
}
|
|
6430
|
-
|
|
6431
|
-
if (isImportant) {
|
|
6432
|
-
declarations = declarations.replace(
|
|
6433
|
-
/([^:;]+):([^;]+)(;?)/g,
|
|
6434
|
-
(_, prop, value) => {
|
|
6435
|
-
return prop.trim().startsWith("--")
|
|
6436
|
-
? `${prop}:${value};`
|
|
6437
|
-
: `${prop}:${value.trim()} !important;`;
|
|
6438
|
-
}
|
|
6439
|
-
);
|
|
6440
|
-
}
|
|
6441
|
-
|
|
6442
|
-
const isSpaceOrDivide = [
|
|
6443
|
-
"space-x-",
|
|
6444
|
-
"-space-x-",
|
|
6445
|
-
"space-y-",
|
|
6446
|
-
"-space-y-",
|
|
6447
|
-
"divide-",
|
|
6448
|
-
].some((prefix) => pureClassName.startsWith(prefix));
|
|
6449
|
-
|
|
6450
|
-
const expandedSelector = replaceSelector(finalSelector);
|
|
6451
|
-
const targetSelector = isSpaceOrDivide
|
|
6452
|
-
? `${expandedSelector} > :not([hidden]) ~ :not([hidden])`
|
|
6453
|
-
: expandedSelector;
|
|
6454
|
-
|
|
6455
|
-
if (media) {
|
|
6456
|
-
styles[media] = styles[media] || {};
|
|
6457
|
-
styles[media][targetSelector] = styles[media][targetSelector] || "";
|
|
6458
|
-
styles[media][targetSelector] += declarations + "\n";
|
|
6459
|
-
} else {
|
|
6460
|
-
styles[targetSelector] = styles[targetSelector] || "";
|
|
6461
|
-
styles[targetSelector] += declarations + "\n";
|
|
6462
|
-
}
|
|
6463
|
-
}
|
|
6464
|
-
|
|
6465
|
-
for (const nestedSel in nested) {
|
|
6466
|
-
const nestedVal = nested[nestedSel];
|
|
6467
|
-
if (nestedSel === "@css" && typeof nestedVal === "object") {
|
|
6468
|
-
const cssDeclarations = Object.entries(nestedVal)
|
|
6469
|
-
.map(([key, value]) => `${key}: ${value};`)
|
|
6470
|
-
.join(" ");
|
|
6471
|
-
|
|
6472
|
-
if (selector in styles) {
|
|
6473
|
-
styles[selector] += cssDeclarations + "\n";
|
|
6474
|
-
} else {
|
|
6475
|
-
styles[selector] = cssDeclarations + "\n";
|
|
6476
|
-
}
|
|
6477
|
-
continue;
|
|
6478
|
-
}
|
|
6479
|
-
|
|
6480
|
-
const combinedSel = nestedSel.includes("&")
|
|
6481
|
-
? nestedSel.replace(/&/g, selector)
|
|
6482
|
-
: `${selector} ${nestedSel}`;
|
|
6483
|
-
walk(combinedSel, nestedVal);
|
|
6484
|
-
}
|
|
6485
|
-
} else if (typeof val === "string") {
|
|
6486
|
-
if (val.trim() === "") return;
|
|
6487
|
-
|
|
6488
|
-
walk(selector, [expandGroupedClass(val)]);
|
|
6489
|
-
} else if (typeof val === "object" && val !== null) {
|
|
6490
|
-
const { baseSelector, cssProperty } = parseSelector(selector);
|
|
6491
|
-
if (cssProperty) {
|
|
6492
|
-
const cssValue = Object.values(val).join(" ");
|
|
6493
|
-
styles[baseSelector] = styles[baseSelector] || "";
|
|
6494
|
-
styles[baseSelector] += `${cssProperty}: ${cssValue};\n`;
|
|
6495
|
-
return;
|
|
6496
|
-
}
|
|
6497
|
-
|
|
6498
|
-
const cssDeclarations = Object.entries(val)
|
|
6499
|
-
.map(([key, value]) => `${key}: ${value};`)
|
|
6500
|
-
.join(" ");
|
|
6501
|
-
|
|
6502
|
-
if (selector in styles) {
|
|
6503
|
-
styles[selector] += cssDeclarations + "\n";
|
|
6504
|
-
} else {
|
|
6505
|
-
styles[selector] = cssDeclarations + "\n";
|
|
6506
|
-
}
|
|
6507
|
-
}
|
|
6508
|
-
}
|
|
6509
|
-
|
|
6510
|
-
// Menambahkan memoization untuk parseSelector
|
|
6511
|
-
const parseSelectorCache = new Map();
|
|
6512
|
-
function parseSelector(selector) {
|
|
6513
|
-
if (parseSelectorCache.has(selector)) {
|
|
6514
|
-
return parseSelectorCache.get(selector);
|
|
6515
|
-
}
|
|
6516
|
-
|
|
6517
|
-
let result;
|
|
6518
|
-
if (selector.includes("@css")) {
|
|
6519
|
-
const parts = selector.split("@css");
|
|
6520
|
-
const baseSelector = parts[0].trim();
|
|
6521
|
-
const cssProperty = parts[1]?.trim();
|
|
6522
|
-
result = { baseSelector, cssProperty };
|
|
6523
|
-
} else {
|
|
6524
|
-
result = { baseSelector: selector, cssProperty: null };
|
|
6525
|
-
}
|
|
6526
|
-
|
|
6527
|
-
parseSelectorCache.set(selector, result);
|
|
6528
|
-
limitCacheSize(parseSelectorCache);
|
|
6529
|
-
return result;
|
|
6530
|
-
}
|
|
6531
|
-
|
|
6532
|
-
function isSelectorObject(val) {
|
|
6533
|
-
return typeof val === "object" && val !== null && !Array.isArray(val);
|
|
6534
|
-
}
|
|
6535
|
-
|
|
6536
|
-
function flatten(obj, parentSelector = "") {
|
|
6537
|
-
const result = {};
|
|
6538
|
-
|
|
6539
|
-
for (const selector in obj) {
|
|
6540
|
-
const val = obj[selector];
|
|
6541
|
-
const currentSelector = parentSelector
|
|
6542
|
-
? selector.includes("&")
|
|
6543
|
-
? selector.replace(/&/g, parentSelector)
|
|
6544
|
-
: `${parentSelector} ${selector}`
|
|
6545
|
-
: selector;
|
|
6546
|
-
|
|
6547
|
-
if (typeof val === "string") {
|
|
6548
|
-
result[currentSelector] = val;
|
|
6549
|
-
} else if (Array.isArray(val)) {
|
|
6550
|
-
const flatArray = [];
|
|
6551
|
-
for (const item of val) {
|
|
6552
|
-
if (typeof item === "string") {
|
|
6553
|
-
flatArray.push(item);
|
|
6554
|
-
} else if (isSelectorObject(item)) {
|
|
6555
|
-
const nested = flatten(item, currentSelector);
|
|
6556
|
-
Object.assign(result, nested);
|
|
6557
|
-
}
|
|
6558
|
-
}
|
|
6559
|
-
if (flatArray.length > 0) {
|
|
6560
|
-
result[currentSelector] = result[currentSelector] || [];
|
|
6561
|
-
result[currentSelector].push(...flatArray);
|
|
6562
|
-
}
|
|
6563
|
-
} else if (isSelectorObject(val)) {
|
|
6564
|
-
const nested = flatten(val, currentSelector);
|
|
6565
|
-
Object.assign(result, nested);
|
|
6566
|
-
}
|
|
6567
|
-
}
|
|
6568
|
-
|
|
6569
|
-
return result;
|
|
6570
|
-
}
|
|
6571
|
-
|
|
6572
|
-
const flattened = flatten(obj);
|
|
6573
|
-
|
|
6574
|
-
for (const selector in flattened) {
|
|
6575
|
-
let val = flattened[selector];
|
|
6576
|
-
let baseClass = "";
|
|
6577
|
-
let nested = {};
|
|
6578
|
-
|
|
6579
|
-
if (typeof val === "string") {
|
|
6580
|
-
baseClass = expandGroupedClass(val);
|
|
6581
|
-
} else if (Array.isArray(val)) {
|
|
6582
|
-
for (const item of val) {
|
|
6583
|
-
if (typeof item === "string") {
|
|
6584
|
-
baseClass += (baseClass ? " " : "") + expandGroupedClass(item);
|
|
6585
|
-
} else if (typeof item === "object" && item !== null) {
|
|
6586
|
-
Object.assign(nested, item);
|
|
6587
|
-
}
|
|
6588
|
-
}
|
|
6589
|
-
}
|
|
6590
|
-
|
|
6591
|
-
walk(selector, [baseClass, nested]);
|
|
6592
|
-
}
|
|
6593
|
-
|
|
6594
|
-
let cssString = "";
|
|
6595
|
-
|
|
6596
|
-
const baseStyles = [];
|
|
6597
|
-
const mediaStyles = [];
|
|
6598
|
-
|
|
6599
|
-
for (const sel in styles) {
|
|
6600
|
-
if (!sel.startsWith("@media")) {
|
|
6601
|
-
baseStyles.push({ sel, css: styles[sel] });
|
|
6602
|
-
} else {
|
|
6603
|
-
mediaStyles.push({ sel, content: styles[sel] });
|
|
6604
|
-
}
|
|
6605
|
-
}
|
|
6606
|
-
|
|
6607
|
-
for (const { sel, css } of baseStyles) {
|
|
6608
|
-
cssString += `${sel}{${css.trim().replace(/\n/g, "")}}`;
|
|
6609
|
-
}
|
|
6610
|
-
|
|
6611
|
-
function mediaPriority(sel) {
|
|
6612
|
-
const match = sel.match(/@media \(min-width: (\d+)px\)/);
|
|
6613
|
-
return match ? parseInt(match[1], 10) : 99999;
|
|
6614
|
-
}
|
|
6615
|
-
|
|
6616
|
-
mediaStyles.sort((a, b) => mediaPriority(a.sel) - mediaPriority(b.sel));
|
|
6617
|
-
|
|
6618
|
-
for (const { sel, content } of mediaStyles) {
|
|
6619
|
-
cssString += `${sel}{`;
|
|
6620
|
-
for (const subSel in content) {
|
|
6621
|
-
cssString += `${subSel}{${content[subSel].trim().replace(/\n/g, "")}}`;
|
|
6622
|
-
}
|
|
6623
|
-
cssString += `}`;
|
|
6624
|
-
}
|
|
6625
|
-
return cssString.trim();
|
|
6626
|
-
}
|
|
6627
|
-
|
|
6628
|
-
// Daftarkan versi debounced dari fungsi-fungsi export
|
|
6629
|
-
/**
|
|
6630
|
-
* Versi debounced dari fungsi tws
|
|
6631
|
-
* Membantu mengoptimalkan performa ketika memanggil tws berulang kali
|
|
6632
|
-
* @param {string} classNames - String berisi kelas Tailwind yang akan dikonversi
|
|
6633
|
-
* @param {boolean} convertToJson - Jika true, hasil akan menjadi objek JSON, jika false menjadi string CSS
|
|
6634
|
-
* @returns {string|Object} String CSS inline atau objek style JSON
|
|
6635
|
-
*/
|
|
6636
|
-
const debouncedTws = debounce(tws);
|
|
6637
|
-
|
|
6638
|
-
/**
|
|
6639
|
-
* Versi debounced dari fungsi twsx
|
|
6640
|
-
* Membantu mengoptimalkan performa ketika memanggil twsx berulang kali
|
|
6641
|
-
* @param {Object} obj - Objek dengan format style mirip SCSS
|
|
6642
|
-
* @returns {string} String CSS yang dihasilkan
|
|
6643
|
-
*/
|
|
6040
|
+
const selectorVariants = {
|
|
6041
|
+
first: () => `> :first-child`,
|
|
6042
|
+
last: () => `> :last-child`,
|
|
6043
|
+
odd: () => `> :nth-child(odd)`,
|
|
6044
|
+
even: () => `> :nth-child(even)`,
|
|
6045
|
+
not: (arg) => `> :not(${arg})`,
|
|
6046
|
+
number: (arg) => `> :nth-child(${arg})`,
|
|
6047
|
+
};
|
|
6048
|
+
|
|
6049
|
+
// Mengoptimalkan encoding/decoding bracket values dengan memoization
|
|
6050
|
+
const encodeBracketCache = new Map();
|
|
6051
|
+
function encodeBracketValues(input) {
|
|
6052
|
+
if (!input) return input;
|
|
6053
|
+
if (encodeBracketCache.has(input)) return encodeBracketCache.get(input);
|
|
6054
|
+
|
|
6055
|
+
const result = input.replace(/\[([^\]]+)\]/g, (_, content) => {
|
|
6056
|
+
const encoded = encodeURIComponent(content)
|
|
6057
|
+
.replace(/\(/g, "__P__")
|
|
6058
|
+
.replace(/\)/g, "__C__");
|
|
6059
|
+
return `[${encoded}]`;
|
|
6060
|
+
});
|
|
6061
|
+
|
|
6062
|
+
encodeBracketCache.set(input, result);
|
|
6063
|
+
limitCacheSize(encodeBracketCache);
|
|
6064
|
+
return result;
|
|
6065
|
+
}
|
|
6066
|
+
|
|
6067
|
+
const decodeBracketCache = new Map();
|
|
6068
|
+
function decodeBracketValues(input) {
|
|
6069
|
+
if (!input) return input;
|
|
6070
|
+
if (decodeBracketCache.has(input)) return decodeBracketCache.get(input);
|
|
6071
|
+
|
|
6072
|
+
const result = decodeURIComponent(input)
|
|
6073
|
+
.replace(/__P__/g, "(")
|
|
6074
|
+
.replace(/__C__/g, ")");
|
|
6075
|
+
|
|
6076
|
+
decodeBracketCache.set(input, result);
|
|
6077
|
+
limitCacheSize(decodeBracketCache);
|
|
6078
|
+
return result;
|
|
6079
|
+
}
|
|
6080
|
+
|
|
6081
|
+
function replaceSelector(selector) {
|
|
6082
|
+
return selector.replace(
|
|
6083
|
+
/c-(first|last|odd|even|\d+|not\([^)]+\))/g,
|
|
6084
|
+
(_, raw) => {
|
|
6085
|
+
if (/^\d+$/.test(raw)) return selectorVariants.number(raw);
|
|
6086
|
+
const notMatch = raw.match(/^not\(([^)]+)\)$/);
|
|
6087
|
+
if (notMatch) return selectorVariants.not(notMatch[1]);
|
|
6088
|
+
if (selectorVariants[raw]) return selectorVariants[raw]();
|
|
6089
|
+
return raw;
|
|
6090
|
+
}
|
|
6091
|
+
);
|
|
6092
|
+
}
|
|
6093
|
+
|
|
6094
|
+
function resolveVariants(selector, variants) {
|
|
6095
|
+
let media = null;
|
|
6096
|
+
let finalSelector = selector;
|
|
6097
|
+
|
|
6098
|
+
for (const v of variants) {
|
|
6099
|
+
if (breakpoints[v]) {
|
|
6100
|
+
media = breakpoints[v];
|
|
6101
|
+
} else if (pseudoVariants.has(v)) {
|
|
6102
|
+
finalSelector += `:${v}`;
|
|
6103
|
+
} else {
|
|
6104
|
+
for (const key in specialVariants) {
|
|
6105
|
+
if (v.startsWith(`${key}-`)) {
|
|
6106
|
+
const state = v.slice(key.length + 1);
|
|
6107
|
+
finalSelector = specialVariants[key](state, finalSelector);
|
|
6108
|
+
break;
|
|
6109
|
+
}
|
|
6110
|
+
}
|
|
6111
|
+
}
|
|
6112
|
+
}
|
|
6113
|
+
|
|
6114
|
+
return { media, finalSelector };
|
|
6115
|
+
}
|
|
6116
|
+
|
|
6117
|
+
function inlineStyleToJson(styleString) {
|
|
6118
|
+
const styles = styleString.split(";").filter((style) => style.trim() !== "");
|
|
6119
|
+
const styleObject = {};
|
|
6120
|
+
|
|
6121
|
+
styles.forEach((style) => {
|
|
6122
|
+
const [key, value] = style.split(":").map((s) => s.trim());
|
|
6123
|
+
if (key && value) {
|
|
6124
|
+
const camelCaseKey = key.replace(/-([a-z])/g, (_, letter) =>
|
|
6125
|
+
letter.toUpperCase()
|
|
6126
|
+
);
|
|
6127
|
+
styleObject[camelCaseKey] = value;
|
|
6128
|
+
}
|
|
6129
|
+
});
|
|
6130
|
+
|
|
6131
|
+
return styleObject;
|
|
6132
|
+
}
|
|
6133
|
+
|
|
6134
|
+
// Cache untuk CSS resolusi
|
|
6135
|
+
const cssResolutionCache = new Map();
|
|
6136
|
+
|
|
6137
|
+
function separateAndResolveCSS(arr) {
|
|
6138
|
+
// Perbaiki: cacheKey harus unik untuk setiap input array
|
|
6139
|
+
const cacheKey = Array.isArray(arr) ? arr.join("|") : String(arr);
|
|
6140
|
+
if (cssResolutionCache.has(cacheKey)) {
|
|
6141
|
+
return cssResolutionCache.get(cacheKey);
|
|
6142
|
+
}
|
|
6143
|
+
|
|
6144
|
+
// Batasi ukuran cache untuk menghindari memory leak
|
|
6145
|
+
limitCacheSize(cssResolutionCache);
|
|
6146
|
+
|
|
6147
|
+
const cssProperties = {};
|
|
6148
|
+
arr.forEach((item) => {
|
|
6149
|
+
if (!item) return;
|
|
6150
|
+
|
|
6151
|
+
const declarations = item
|
|
6152
|
+
.split(";")
|
|
6153
|
+
.map((decl) => decl.trim())
|
|
6154
|
+
.filter((decl) => decl);
|
|
6155
|
+
|
|
6156
|
+
declarations.forEach((declaration) => {
|
|
6157
|
+
const colonIndex = declaration.indexOf(":");
|
|
6158
|
+
if (colonIndex === -1) return;
|
|
6159
|
+
|
|
6160
|
+
const key = declaration.substring(0, colonIndex).trim();
|
|
6161
|
+
const value = declaration.substring(colonIndex + 1).trim();
|
|
6162
|
+
|
|
6163
|
+
if (key && value) {
|
|
6164
|
+
// Prioritaskan nilai yang lebih spesifik (misalnya !important)
|
|
6165
|
+
if (value.includes("!important") || !cssProperties[key]) {
|
|
6166
|
+
cssProperties[key] = value;
|
|
6167
|
+
}
|
|
6168
|
+
}
|
|
6169
|
+
});
|
|
6170
|
+
});
|
|
6171
|
+
|
|
6172
|
+
const resolvedProperties = { ...cssProperties };
|
|
6173
|
+
|
|
6174
|
+
const resolveValue = (value, variables) => {
|
|
6175
|
+
if (!value || !value.includes("var(")) return value;
|
|
6176
|
+
|
|
6177
|
+
return value.replace(
|
|
6178
|
+
/var\((--[a-zA-Z0-9-]+)(?:,\s*([^)]+))?\)/g,
|
|
6179
|
+
(match, variable, fallback) => {
|
|
6180
|
+
return variables[variable] || fallback || match;
|
|
6181
|
+
}
|
|
6182
|
+
);
|
|
6183
|
+
};
|
|
6184
|
+
|
|
6185
|
+
// Resolve variables
|
|
6186
|
+
Object.keys(resolvedProperties).forEach((key) => {
|
|
6187
|
+
resolvedProperties[key] = resolveValue(
|
|
6188
|
+
resolvedProperties[key],
|
|
6189
|
+
resolvedProperties
|
|
6190
|
+
);
|
|
6191
|
+
});
|
|
6192
|
+
|
|
6193
|
+
// Remove CSS variables after resolution
|
|
6194
|
+
Object.keys(resolvedProperties).forEach((key) => {
|
|
6195
|
+
if (key.startsWith("--")) {
|
|
6196
|
+
delete resolvedProperties[key];
|
|
6197
|
+
}
|
|
6198
|
+
});
|
|
6199
|
+
|
|
6200
|
+
const result = Object.entries(resolvedProperties)
|
|
6201
|
+
.map(([key, value]) => `${key}: ${value};`)
|
|
6202
|
+
.join(" ");
|
|
6203
|
+
|
|
6204
|
+
cssResolutionCache.set(cacheKey, result);
|
|
6205
|
+
return result;
|
|
6206
|
+
}
|
|
6207
|
+
|
|
6208
|
+
// Fungsi untuk membatasi ukuran cache untuk mencegah memory leak
|
|
6209
|
+
function limitCacheSize(cache, maxSize = 1000) {
|
|
6210
|
+
if (cache.size > maxSize) {
|
|
6211
|
+
// Hapus 20% entri yang paling lama
|
|
6212
|
+
const entriesToRemove = Math.floor(cache.size * 0.2);
|
|
6213
|
+
const keys = Array.from(cache.keys()).slice(0, entriesToRemove);
|
|
6214
|
+
keys.forEach((key) => cache.delete(key));
|
|
6215
|
+
}
|
|
6216
|
+
}
|
|
6217
|
+
|
|
6218
|
+
// Implementasi fungsi debounce untuk mengoptimalkan panggilan berulang
|
|
6219
|
+
function debounce(func, wait = 100) {
|
|
6220
|
+
let timeout;
|
|
6221
|
+
return function (...args) {
|
|
6222
|
+
const context = this;
|
|
6223
|
+
clearTimeout(timeout);
|
|
6224
|
+
timeout = setTimeout(() => func.apply(context, args), wait);
|
|
6225
|
+
};
|
|
6226
|
+
}
|
|
6227
|
+
|
|
6228
|
+
/**
|
|
6229
|
+
* Mengkonversi string kelas Tailwind menjadi inline styles CSS atau objek JSON
|
|
6230
|
+
* @param {string} classNames - String berisi kelas Tailwind yang akan dikonversi
|
|
6231
|
+
* @param {boolean} convertToJson - Jika true, hasil akan menjadi objek JSON, jika false menjadi string CSS
|
|
6232
|
+
* @returns {string|Object} String CSS inline atau objek style JSON
|
|
6233
|
+
*/
|
|
6234
|
+
function tws(classNames, convertToJson) {
|
|
6235
|
+
if (
|
|
6236
|
+
[
|
|
6237
|
+
!classNames,
|
|
6238
|
+
typeof classNames !== "string",
|
|
6239
|
+
classNames.trim() === "",
|
|
6240
|
+
].includes(true)
|
|
6241
|
+
) {
|
|
6242
|
+
return convertToJson ? {} : "";
|
|
6243
|
+
}
|
|
6244
|
+
|
|
6245
|
+
let classes;
|
|
6246
|
+
try {
|
|
6247
|
+
classes = classNames.match(/[\w-\/]+(?:\[[^\]]+\])?/g);
|
|
6248
|
+
|
|
6249
|
+
// Jika tidak ada class yang valid ditemukan
|
|
6250
|
+
if (!classes || classes.length === 0) {
|
|
6251
|
+
console.warn(`No valid Tailwind classes found in input: "${classNames}"`);
|
|
6252
|
+
return convertToJson ? {} : "";
|
|
6253
|
+
}
|
|
6254
|
+
} catch (error) {
|
|
6255
|
+
console.error(`Error parsing Tailwind classes: ${error.message}`);
|
|
6256
|
+
return convertToJson ? {} : "";
|
|
6257
|
+
}
|
|
6258
|
+
|
|
6259
|
+
let cssResult = classes.map((className) => {
|
|
6260
|
+
let result =
|
|
6261
|
+
cssObject[className] ||
|
|
6262
|
+
cssObject[className.replace(/(\/)/g, "\\$1")] ||
|
|
6263
|
+
cssObject[className.replace(/\./g, "\\.")];
|
|
6264
|
+
|
|
6265
|
+
if (result) {
|
|
6266
|
+
return resolveCssToClearCss(result);
|
|
6267
|
+
} else if (className.includes("[")) {
|
|
6268
|
+
const match = className.match(/\[([^\]]+)\]/);
|
|
6269
|
+
if (match) {
|
|
6270
|
+
const customValue = match[1];
|
|
6271
|
+
const baseKey = className.split("[")[0];
|
|
6272
|
+
if (cssObject[`${baseKey}custom`]) {
|
|
6273
|
+
return cssObject[`${baseKey}custom`].replace(
|
|
6274
|
+
/custom_value/g,
|
|
6275
|
+
customValue
|
|
6276
|
+
);
|
|
6277
|
+
}
|
|
6278
|
+
}
|
|
6279
|
+
}
|
|
6280
|
+
return "";
|
|
6281
|
+
});
|
|
6282
|
+
|
|
6283
|
+
cssResult = separateAndResolveCSS(cssResult);
|
|
6284
|
+
|
|
6285
|
+
if (convertToJson) {
|
|
6286
|
+
cssResult = inlineStyleToJson(cssResult);
|
|
6287
|
+
}
|
|
6288
|
+
|
|
6289
|
+
return cssResult;
|
|
6290
|
+
}
|
|
6291
|
+
|
|
6292
|
+
/**
|
|
6293
|
+
* Menghasilkan string CSS dari objek style dengan sintaks mirip SCSS
|
|
6294
|
+
* Mendukung nested selectors, state variants, responsive variants, dan @css directives
|
|
6295
|
+
* @param {Object} obj - Objek dengan format style mirip SCSS
|
|
6296
|
+
* @param {Object} [options] - Opsi tambahan, misal { inject: true/false }
|
|
6297
|
+
* @returns {string} String CSS yang dihasilkan
|
|
6298
|
+
*/
|
|
6299
|
+
function twsx(obj, options = {}) {
|
|
6300
|
+
if (!obj || typeof obj !== "object") {
|
|
6301
|
+
console.warn("twsx: Expected an object but received:", obj);
|
|
6302
|
+
return "";
|
|
6303
|
+
}
|
|
6304
|
+
const { inject = true } = options;
|
|
6305
|
+
|
|
6306
|
+
const styles = {};
|
|
6307
|
+
|
|
6308
|
+
function expandGroupedClass(input) {
|
|
6309
|
+
function expandDirectiveGroups(str) {
|
|
6310
|
+
return str.replace(/(\w+)\(([^()]+)\)/g, (_, directive, content) => {
|
|
6311
|
+
return content
|
|
6312
|
+
.trim()
|
|
6313
|
+
.split(/\s+/)
|
|
6314
|
+
.map((val) => {
|
|
6315
|
+
if (val.includes(":")) {
|
|
6316
|
+
const [variant, v] = val.split(":");
|
|
6317
|
+
const prefix = v.startsWith("-") ? "-" : "";
|
|
6318
|
+
const value = v.startsWith("-") ? v.slice(1) : v;
|
|
6319
|
+
return `${variant}:${prefix}${directive}-${value}`;
|
|
6320
|
+
}
|
|
6321
|
+
const prefix = val.startsWith("-") ? "-" : "";
|
|
6322
|
+
const value = val.startsWith("-") ? val.slice(1) : val;
|
|
6323
|
+
return `${prefix}${directive}-${value}`;
|
|
6324
|
+
})
|
|
6325
|
+
.join(" ");
|
|
6326
|
+
});
|
|
6327
|
+
}
|
|
6328
|
+
|
|
6329
|
+
function expandVariants(str, parent = "") {
|
|
6330
|
+
return str.replace(
|
|
6331
|
+
/(\w+):\(([^()]+(?:\((?:[^()]+)\))?[^()]*)\)/g,
|
|
6332
|
+
(_, variant, content) => {
|
|
6333
|
+
return content
|
|
6334
|
+
.trim()
|
|
6335
|
+
.split(/\s+/)
|
|
6336
|
+
.map((c) => {
|
|
6337
|
+
if (/\w+:\(.*\)/.test(c)) {
|
|
6338
|
+
return expandVariants(
|
|
6339
|
+
c,
|
|
6340
|
+
parent ? `${parent}:${variant}` : variant
|
|
6341
|
+
);
|
|
6342
|
+
}
|
|
6343
|
+
return `${parent ? `${parent}:${variant}` : variant}:${c}`;
|
|
6344
|
+
})
|
|
6345
|
+
.join(" ");
|
|
6346
|
+
}
|
|
6347
|
+
);
|
|
6348
|
+
}
|
|
6349
|
+
|
|
6350
|
+
let result = encodeBracketValues(input);
|
|
6351
|
+
let prev;
|
|
6352
|
+
|
|
6353
|
+
do {
|
|
6354
|
+
prev = result;
|
|
6355
|
+
result = expandVariants(result);
|
|
6356
|
+
result = expandDirectiveGroups(result);
|
|
6357
|
+
} while (result !== prev);
|
|
6358
|
+
|
|
6359
|
+
return result;
|
|
6360
|
+
}
|
|
6361
|
+
function walk(selector, val) {
|
|
6362
|
+
if (!selector || typeof selector !== "string") {
|
|
6363
|
+
console.warn("Invalid selector in walk function:", selector);
|
|
6364
|
+
return;
|
|
6365
|
+
}
|
|
6366
|
+
|
|
6367
|
+
const { baseSelector, cssProperty } = parseSelector(selector);
|
|
6368
|
+
if (
|
|
6369
|
+
cssProperty &&
|
|
6370
|
+
typeof val === "object" &&
|
|
6371
|
+
Array.isArray(val) &&
|
|
6372
|
+
val.length > 0
|
|
6373
|
+
) {
|
|
6374
|
+
const cssValue = val[0];
|
|
6375
|
+
if (typeof cssValue === "string") {
|
|
6376
|
+
styles[baseSelector] = styles[baseSelector] || "";
|
|
6377
|
+
styles[baseSelector] += `${cssProperty}: ${cssValue};\n`;
|
|
6378
|
+
return;
|
|
6379
|
+
}
|
|
6380
|
+
}
|
|
6381
|
+
|
|
6382
|
+
if (Array.isArray(val)) {
|
|
6383
|
+
const [base, nested] = val;
|
|
6384
|
+
|
|
6385
|
+
if (typeof base !== "string") {
|
|
6386
|
+
return;
|
|
6387
|
+
}
|
|
6388
|
+
|
|
6389
|
+
for (const cls of base.split(" ")) {
|
|
6390
|
+
if (cls.trim() === "") continue;
|
|
6391
|
+
|
|
6392
|
+
const [rawVariants, className] = cls.includes(":")
|
|
6393
|
+
? [cls.split(":").slice(0, -1), cls.split(":").slice(-1)[0]]
|
|
6394
|
+
: [[], cls];
|
|
6395
|
+
|
|
6396
|
+
let isImportant = false;
|
|
6397
|
+
let pureClassName = className;
|
|
6398
|
+
|
|
6399
|
+
if (className.startsWith("!")) {
|
|
6400
|
+
isImportant = true;
|
|
6401
|
+
pureClassName = className.slice(1);
|
|
6402
|
+
}
|
|
6403
|
+
|
|
6404
|
+
const { media, finalSelector } = resolveVariants(selector, rawVariants);
|
|
6405
|
+
|
|
6406
|
+
let declarations =
|
|
6407
|
+
cssObject[pureClassName] ||
|
|
6408
|
+
cssObject[pureClassName.replace(/(\/)/g, "\\$1")] ||
|
|
6409
|
+
cssObject[pureClassName.replace(/\./g, "\\.")];
|
|
6410
|
+
|
|
6411
|
+
if (!declarations && pureClassName.includes("[")) {
|
|
6412
|
+
const match = pureClassName.match(/^(.+?)\[(.+)\]$/);
|
|
6413
|
+
if (match) {
|
|
6414
|
+
const [, prefix, dynamicValue] = match;
|
|
6415
|
+
const customKey = `${prefix}custom`;
|
|
6416
|
+
const template = cssObject[customKey];
|
|
6417
|
+
if (template) {
|
|
6418
|
+
declarations = template.replace(
|
|
6419
|
+
/custom_value/g,
|
|
6420
|
+
decodeBracketValues(dynamicValue)
|
|
6421
|
+
);
|
|
6422
|
+
}
|
|
6423
|
+
}
|
|
6424
|
+
}
|
|
6425
|
+
|
|
6426
|
+
if (!declarations) {
|
|
6427
|
+
declarations = parseCustomClassWithPatterns(pureClassName);
|
|
6428
|
+
}
|
|
6429
|
+
|
|
6430
|
+
if (!declarations) {
|
|
6431
|
+
continue;
|
|
6432
|
+
}
|
|
6433
|
+
|
|
6434
|
+
if (isImportant) {
|
|
6435
|
+
declarations = declarations.replace(
|
|
6436
|
+
/([^:;]+):([^;]+)(;?)/g,
|
|
6437
|
+
(_, prop, value) => {
|
|
6438
|
+
return prop.trim().startsWith("--")
|
|
6439
|
+
? `${prop}:${value};`
|
|
6440
|
+
: `${prop}:${value.trim()} !important;`;
|
|
6441
|
+
}
|
|
6442
|
+
);
|
|
6443
|
+
}
|
|
6444
|
+
|
|
6445
|
+
const isSpaceOrDivide = [
|
|
6446
|
+
"space-x-",
|
|
6447
|
+
"-space-x-",
|
|
6448
|
+
"space-y-",
|
|
6449
|
+
"-space-y-",
|
|
6450
|
+
"divide-",
|
|
6451
|
+
].some((prefix) => pureClassName.startsWith(prefix));
|
|
6452
|
+
|
|
6453
|
+
const expandedSelector = replaceSelector(finalSelector);
|
|
6454
|
+
const targetSelector = isSpaceOrDivide
|
|
6455
|
+
? `${expandedSelector} > :not([hidden]) ~ :not([hidden])`
|
|
6456
|
+
: expandedSelector;
|
|
6457
|
+
|
|
6458
|
+
if (media) {
|
|
6459
|
+
styles[media] = styles[media] || {};
|
|
6460
|
+
styles[media][targetSelector] = styles[media][targetSelector] || "";
|
|
6461
|
+
styles[media][targetSelector] += declarations + "\n";
|
|
6462
|
+
} else {
|
|
6463
|
+
styles[targetSelector] = styles[targetSelector] || "";
|
|
6464
|
+
styles[targetSelector] += declarations + "\n";
|
|
6465
|
+
}
|
|
6466
|
+
}
|
|
6467
|
+
|
|
6468
|
+
for (const nestedSel in nested) {
|
|
6469
|
+
const nestedVal = nested[nestedSel];
|
|
6470
|
+
if (nestedSel === "@css" && typeof nestedVal === "object") {
|
|
6471
|
+
const cssDeclarations = Object.entries(nestedVal)
|
|
6472
|
+
.map(([key, value]) => `${key}: ${value};`)
|
|
6473
|
+
.join(" ");
|
|
6474
|
+
|
|
6475
|
+
if (selector in styles) {
|
|
6476
|
+
styles[selector] += cssDeclarations + "\n";
|
|
6477
|
+
} else {
|
|
6478
|
+
styles[selector] = cssDeclarations + "\n";
|
|
6479
|
+
}
|
|
6480
|
+
continue;
|
|
6481
|
+
}
|
|
6482
|
+
|
|
6483
|
+
const combinedSel = nestedSel.includes("&")
|
|
6484
|
+
? nestedSel.replace(/&/g, selector)
|
|
6485
|
+
: `${selector} ${nestedSel}`;
|
|
6486
|
+
walk(combinedSel, nestedVal);
|
|
6487
|
+
}
|
|
6488
|
+
} else if (typeof val === "string") {
|
|
6489
|
+
if (val.trim() === "") return;
|
|
6490
|
+
|
|
6491
|
+
walk(selector, [expandGroupedClass(val)]);
|
|
6492
|
+
} else if (typeof val === "object" && val !== null) {
|
|
6493
|
+
const { baseSelector, cssProperty } = parseSelector(selector);
|
|
6494
|
+
if (cssProperty) {
|
|
6495
|
+
const cssValue = Object.values(val).join(" ");
|
|
6496
|
+
styles[baseSelector] = styles[baseSelector] || "";
|
|
6497
|
+
styles[baseSelector] += `${cssProperty}: ${cssValue};\n`;
|
|
6498
|
+
return;
|
|
6499
|
+
}
|
|
6500
|
+
|
|
6501
|
+
const cssDeclarations = Object.entries(val)
|
|
6502
|
+
.map(([key, value]) => `${key}: ${value};`)
|
|
6503
|
+
.join(" ");
|
|
6504
|
+
|
|
6505
|
+
if (selector in styles) {
|
|
6506
|
+
styles[selector] += cssDeclarations + "\n";
|
|
6507
|
+
} else {
|
|
6508
|
+
styles[selector] = cssDeclarations + "\n";
|
|
6509
|
+
}
|
|
6510
|
+
}
|
|
6511
|
+
}
|
|
6512
|
+
|
|
6513
|
+
// Menambahkan memoization untuk parseSelector
|
|
6514
|
+
const parseSelectorCache = new Map();
|
|
6515
|
+
function parseSelector(selector) {
|
|
6516
|
+
if (parseSelectorCache.has(selector)) {
|
|
6517
|
+
return parseSelectorCache.get(selector);
|
|
6518
|
+
}
|
|
6519
|
+
|
|
6520
|
+
let result;
|
|
6521
|
+
if (selector.includes("@css")) {
|
|
6522
|
+
const parts = selector.split("@css");
|
|
6523
|
+
const baseSelector = parts[0].trim();
|
|
6524
|
+
const cssProperty = parts[1]?.trim();
|
|
6525
|
+
result = { baseSelector, cssProperty };
|
|
6526
|
+
} else {
|
|
6527
|
+
result = { baseSelector: selector, cssProperty: null };
|
|
6528
|
+
}
|
|
6529
|
+
|
|
6530
|
+
parseSelectorCache.set(selector, result);
|
|
6531
|
+
limitCacheSize(parseSelectorCache);
|
|
6532
|
+
return result;
|
|
6533
|
+
}
|
|
6534
|
+
|
|
6535
|
+
function isSelectorObject(val) {
|
|
6536
|
+
return typeof val === "object" && val !== null && !Array.isArray(val);
|
|
6537
|
+
}
|
|
6538
|
+
|
|
6539
|
+
function flatten(obj, parentSelector = "") {
|
|
6540
|
+
const result = {};
|
|
6541
|
+
|
|
6542
|
+
for (const selector in obj) {
|
|
6543
|
+
const val = obj[selector];
|
|
6544
|
+
const currentSelector = parentSelector
|
|
6545
|
+
? selector.includes("&")
|
|
6546
|
+
? selector.replace(/&/g, parentSelector)
|
|
6547
|
+
: `${parentSelector} ${selector}`
|
|
6548
|
+
: selector;
|
|
6549
|
+
|
|
6550
|
+
if (typeof val === "string") {
|
|
6551
|
+
result[currentSelector] = val;
|
|
6552
|
+
} else if (Array.isArray(val)) {
|
|
6553
|
+
const flatArray = [];
|
|
6554
|
+
for (const item of val) {
|
|
6555
|
+
if (typeof item === "string") {
|
|
6556
|
+
flatArray.push(item);
|
|
6557
|
+
} else if (isSelectorObject(item)) {
|
|
6558
|
+
const nested = flatten(item, currentSelector);
|
|
6559
|
+
Object.assign(result, nested);
|
|
6560
|
+
}
|
|
6561
|
+
}
|
|
6562
|
+
if (flatArray.length > 0) {
|
|
6563
|
+
result[currentSelector] = result[currentSelector] || [];
|
|
6564
|
+
result[currentSelector].push(...flatArray);
|
|
6565
|
+
}
|
|
6566
|
+
} else if (isSelectorObject(val)) {
|
|
6567
|
+
const nested = flatten(val, currentSelector);
|
|
6568
|
+
Object.assign(result, nested);
|
|
6569
|
+
}
|
|
6570
|
+
}
|
|
6571
|
+
|
|
6572
|
+
return result;
|
|
6573
|
+
}
|
|
6574
|
+
|
|
6575
|
+
const flattened = flatten(obj);
|
|
6576
|
+
|
|
6577
|
+
for (const selector in flattened) {
|
|
6578
|
+
let val = flattened[selector];
|
|
6579
|
+
let baseClass = "";
|
|
6580
|
+
let nested = {};
|
|
6581
|
+
|
|
6582
|
+
if (typeof val === "string") {
|
|
6583
|
+
baseClass = expandGroupedClass(val);
|
|
6584
|
+
} else if (Array.isArray(val)) {
|
|
6585
|
+
for (const item of val) {
|
|
6586
|
+
if (typeof item === "string") {
|
|
6587
|
+
baseClass += (baseClass ? " " : "") + expandGroupedClass(item);
|
|
6588
|
+
} else if (typeof item === "object" && item !== null) {
|
|
6589
|
+
Object.assign(nested, item);
|
|
6590
|
+
}
|
|
6591
|
+
}
|
|
6592
|
+
}
|
|
6593
|
+
|
|
6594
|
+
walk(selector, [baseClass, nested]);
|
|
6595
|
+
}
|
|
6596
|
+
|
|
6597
|
+
let cssString = "";
|
|
6598
|
+
|
|
6599
|
+
const baseStyles = [];
|
|
6600
|
+
const mediaStyles = [];
|
|
6601
|
+
|
|
6602
|
+
for (const sel in styles) {
|
|
6603
|
+
if (!sel.startsWith("@media")) {
|
|
6604
|
+
baseStyles.push({ sel, css: styles[sel] });
|
|
6605
|
+
} else {
|
|
6606
|
+
mediaStyles.push({ sel, content: styles[sel] });
|
|
6607
|
+
}
|
|
6608
|
+
}
|
|
6609
|
+
|
|
6610
|
+
for (const { sel, css } of baseStyles) {
|
|
6611
|
+
cssString += `${sel}{${css.trim().replace(/\n/g, "")}}`;
|
|
6612
|
+
}
|
|
6613
|
+
|
|
6614
|
+
function mediaPriority(sel) {
|
|
6615
|
+
const match = sel.match(/@media \(min-width: (\d+)px\)/);
|
|
6616
|
+
return match ? parseInt(match[1], 10) : 99999;
|
|
6617
|
+
}
|
|
6618
|
+
|
|
6619
|
+
mediaStyles.sort((a, b) => mediaPriority(a.sel) - mediaPriority(b.sel));
|
|
6620
|
+
|
|
6621
|
+
for (const { sel, content } of mediaStyles) {
|
|
6622
|
+
cssString += `${sel}{`;
|
|
6623
|
+
for (const subSel in content) {
|
|
6624
|
+
cssString += `${subSel}{${content[subSel].trim().replace(/\n/g, "")}}`;
|
|
6625
|
+
}
|
|
6626
|
+
cssString += `}`;
|
|
6627
|
+
}
|
|
6628
|
+
cssString = cssString.trim();
|
|
6629
|
+
if (inject && typeof window !== "undefined" && typeof document !== "undefined") {
|
|
6630
|
+
autoInjectCss(cssString);
|
|
6631
|
+
}
|
|
6632
|
+
return cssString;
|
|
6633
|
+
}
|
|
6634
|
+
|
|
6635
|
+
// Fungsi hashCode sederhana untuk deduplikasi CSS
|
|
6636
|
+
function getCssHash(str) {
|
|
6637
|
+
let hash = 0, i, chr;
|
|
6638
|
+
if (str.length === 0) return hash;
|
|
6639
|
+
for (i = 0; i < str.length; i++) {
|
|
6640
|
+
chr = str.charCodeAt(i);
|
|
6641
|
+
hash = ((hash << 5) - hash) + chr;
|
|
6642
|
+
hash |= 0; // Convert to 32bit integer
|
|
6643
|
+
}
|
|
6644
|
+
return hash;
|
|
6645
|
+
}
|
|
6646
|
+
|
|
6647
|
+
// Cache untuk deduplikasi auto-inject CSS pakai hash
|
|
6648
|
+
const injectedCssHashSet = new Set();
|
|
6649
|
+
function autoInjectCss(cssString) {
|
|
6650
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
6651
|
+
const cssHash = getCssHash(cssString);
|
|
6652
|
+
if (injectedCssHashSet.has(cssHash)) return;
|
|
6653
|
+
injectedCssHashSet.add(cssHash);
|
|
6654
|
+
let styleTag = document.getElementById("twsx-auto-style");
|
|
6655
|
+
if (!styleTag) {
|
|
6656
|
+
styleTag = document.createElement("style");
|
|
6657
|
+
styleTag.id = "twsx-auto-style";
|
|
6658
|
+
document.head.appendChild(styleTag);
|
|
6659
|
+
}
|
|
6660
|
+
styleTag.textContent += `\n${cssString}`;
|
|
6661
|
+
}
|
|
6662
|
+
}
|
|
6663
|
+
|
|
6664
|
+
// Daftarkan versi debounced dari fungsi-fungsi export
|
|
6665
|
+
/**
|
|
6666
|
+
* Versi debounced dari fungsi tws
|
|
6667
|
+
* Membantu mengoptimalkan performa ketika memanggil tws berulang kali
|
|
6668
|
+
* @param {string} classNames - String berisi kelas Tailwind yang akan dikonversi
|
|
6669
|
+
* @param {boolean} convertToJson - Jika true, hasil akan menjadi objek JSON, jika false menjadi string CSS
|
|
6670
|
+
* @returns {string|Object} String CSS inline atau objek style JSON
|
|
6671
|
+
*/
|
|
6672
|
+
const debouncedTws = debounce(tws);
|
|
6673
|
+
|
|
6674
|
+
/**
|
|
6675
|
+
* Versi debounced dari fungsi twsx
|
|
6676
|
+
* Membantu mengoptimalkan performa ketika memanggil twsx berulang kali
|
|
6677
|
+
* @param {Object} obj - Objek dengan format style mirip SCSS
|
|
6678
|
+
* @returns {string} String CSS yang dihasilkan
|
|
6679
|
+
*/
|
|
6644
6680
|
const debouncedTwsx = debounce(twsx);
|
|
6645
6681
|
|
|
6646
6682
|
export { debouncedTws, debouncedTwsx, tws, twsx };
|