tailwind-to-style 2.5.1 → 2.5.3
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 +152 -109
- package/{index.js → dist/index.cjs.js} +152 -109
- package/dist/index.esm.js +1014 -972
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/package.json +6 -8
- package/index.min.js +0 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tailwind-to-style v2.5.
|
|
2
|
+
* tailwind-to-style v2.5.3
|
|
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
|
};
|
|
@@ -1349,9 +1357,11 @@ function generateCssString(getCssString = () => {}) {
|
|
|
1349
1357
|
|
|
1350
1358
|
const hexColor = /^#(?:[0-9a-fA-F]{3}){1,2}$/;
|
|
1351
1359
|
const rgbColor = /^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/;
|
|
1352
|
-
const rgbaColor =
|
|
1360
|
+
const rgbaColor =
|
|
1361
|
+
/^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*(0|1|0?\.\d+)\s*\)$/;
|
|
1353
1362
|
const hslColor = /^hsl\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*\)$/;
|
|
1354
|
-
const hslaColor =
|
|
1363
|
+
const hslaColor =
|
|
1364
|
+
/^hsla\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*,\s*(0|1|0?\.\d+)\s*\)$/;
|
|
1355
1365
|
|
|
1356
1366
|
return [
|
|
1357
1367
|
hexColor.test(value),
|
|
@@ -1815,7 +1825,7 @@ function generator$2c(configOptions = {}) {
|
|
|
1815
1825
|
}
|
|
1816
1826
|
|
|
1817
1827
|
function generator$2b(configOptions = {}) {
|
|
1818
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
1828
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
1819
1829
|
|
|
1820
1830
|
const prefix = `${globalPrefix}blur`;
|
|
1821
1831
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -1827,10 +1837,12 @@ function generator$2b(configOptions = {}) {
|
|
|
1827
1837
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
1828
1838
|
return `
|
|
1829
1839
|
${prefix}${key} {
|
|
1830
|
-
--blur:
|
|
1840
|
+
--blur: ${value};
|
|
1841
|
+
${vars.filter}
|
|
1831
1842
|
}
|
|
1832
1843
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}${key} {
|
|
1833
|
-
--backdrop-blur:
|
|
1844
|
+
--backdrop-blur: ${value};
|
|
1845
|
+
${vars.backdropFilter}
|
|
1834
1846
|
}
|
|
1835
1847
|
`;
|
|
1836
1848
|
});
|
|
@@ -2224,7 +2236,7 @@ function generator$21(configOptions = {}) {
|
|
|
2224
2236
|
}
|
|
2225
2237
|
|
|
2226
2238
|
function generator$20(configOptions = {}) {
|
|
2227
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
2239
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
2228
2240
|
|
|
2229
2241
|
const prefix = `${globalPrefix}brightness`;
|
|
2230
2242
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -2236,10 +2248,12 @@ function generator$20(configOptions = {}) {
|
|
|
2236
2248
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
2237
2249
|
return `
|
|
2238
2250
|
${prefix}${key} {
|
|
2239
|
-
--brightness:
|
|
2251
|
+
--brightness: ${value};
|
|
2252
|
+
${vars.filter}
|
|
2240
2253
|
}
|
|
2241
2254
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}${key} {
|
|
2242
|
-
--backdrop-brightness:
|
|
2255
|
+
--backdrop-brightness: ${value};
|
|
2256
|
+
${vars.backdropFilter}
|
|
2243
2257
|
}
|
|
2244
2258
|
`;
|
|
2245
2259
|
});
|
|
@@ -2352,7 +2366,7 @@ function generator$1Y(configOptions = {}) {
|
|
|
2352
2366
|
}
|
|
2353
2367
|
|
|
2354
2368
|
function generator$1X(configOptions = {}) {
|
|
2355
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
2369
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
2356
2370
|
|
|
2357
2371
|
const prefix = `${globalPrefix}contrast`;
|
|
2358
2372
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -2364,10 +2378,12 @@ function generator$1X(configOptions = {}) {
|
|
|
2364
2378
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
2365
2379
|
return `
|
|
2366
2380
|
${prefix}${key} {
|
|
2367
|
-
--contrast:
|
|
2381
|
+
--contrast: ${value};
|
|
2382
|
+
${vars.filter}
|
|
2368
2383
|
}
|
|
2369
2384
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}${key} {
|
|
2370
|
-
--backdrop-contrast:
|
|
2385
|
+
--backdrop-contrast: ${value};
|
|
2386
|
+
${vars.backdropFilter}
|
|
2371
2387
|
}
|
|
2372
2388
|
`;
|
|
2373
2389
|
});
|
|
@@ -2637,34 +2653,11 @@ function generator$1P(configOptions = {}) {
|
|
|
2637
2653
|
}
|
|
2638
2654
|
|
|
2639
2655
|
function generator$1O({ prefix }) {
|
|
2640
|
-
return `
|
|
2641
|
-
${prefix}filter {
|
|
2642
|
-
--blur: ;
|
|
2643
|
-
--brightness: ;
|
|
2644
|
-
--contrast: ;
|
|
2645
|
-
--grayscale: ;
|
|
2646
|
-
--hue-rotate: ;
|
|
2647
|
-
--invert: ;
|
|
2648
|
-
--saturate: ;
|
|
2649
|
-
--sepia: ;
|
|
2650
|
-
--drop-shadow: ;
|
|
2651
|
-
filter: var(--blur) var(--brightness) var(--contrast) var(--grayscale) var(--hue-rotate) var(--invert) var(--saturate) var(--sepia) var(--drop-shadow);
|
|
2652
|
-
|
|
2653
|
-
--backdrop-blur: ;
|
|
2654
|
-
--backdrop-brightness: ;
|
|
2655
|
-
--backdrop-contrast: ;
|
|
2656
|
-
--backdrop-grayscale: ;
|
|
2657
|
-
--backdrop-hue-rotate: ;
|
|
2658
|
-
--backdrop-invert: ;
|
|
2659
|
-
--backdrop-opacity: ;
|
|
2660
|
-
--backdrop-saturate: ;
|
|
2661
|
-
--backdrop-sepia: ;
|
|
2662
|
-
-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);
|
|
2663
|
-
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);
|
|
2664
|
-
}
|
|
2656
|
+
return `
|
|
2665
2657
|
${prefix}filter-none {
|
|
2666
|
-
filter: none;
|
|
2667
|
-
backdrop-filter: none;
|
|
2658
|
+
filter: none !important;
|
|
2659
|
+
-webkit-backdrop-filter: none !important;
|
|
2660
|
+
backdrop-filter: none !important;
|
|
2668
2661
|
}
|
|
2669
2662
|
`;
|
|
2670
2663
|
}
|
|
@@ -3017,7 +3010,7 @@ function generator$1A(configOptions = {}) {
|
|
|
3017
3010
|
}
|
|
3018
3011
|
|
|
3019
3012
|
function generator$1z(configOptions = {}) {
|
|
3020
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
3013
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
3021
3014
|
|
|
3022
3015
|
const prefix = `${globalPrefix}grayscale`;
|
|
3023
3016
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -3029,10 +3022,12 @@ function generator$1z(configOptions = {}) {
|
|
|
3029
3022
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
3030
3023
|
return `
|
|
3031
3024
|
${prefix}${key} {
|
|
3032
|
-
--grayscale:
|
|
3025
|
+
--grayscale: ${value};
|
|
3026
|
+
${vars.filter}
|
|
3033
3027
|
}
|
|
3034
3028
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}${key} {
|
|
3035
|
-
--backdrop-grayscale:
|
|
3029
|
+
--backdrop-grayscale: ${value};
|
|
3030
|
+
${vars.backdropFilter}
|
|
3036
3031
|
}
|
|
3037
3032
|
`;
|
|
3038
3033
|
});
|
|
@@ -3316,7 +3311,7 @@ function generator$1n(configOptions = {}) {
|
|
|
3316
3311
|
}
|
|
3317
3312
|
|
|
3318
3313
|
function generator$1m(configOptions = {}) {
|
|
3319
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
3314
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
3320
3315
|
|
|
3321
3316
|
const { hueRotate = {} } = theme;
|
|
3322
3317
|
|
|
@@ -3331,10 +3326,12 @@ function generator$1m(configOptions = {}) {
|
|
|
3331
3326
|
}
|
|
3332
3327
|
return `
|
|
3333
3328
|
${prefix}-${key} {
|
|
3334
|
-
--hue-rotate:
|
|
3329
|
+
--hue-rotate: ${value};
|
|
3330
|
+
${vars.filter}
|
|
3335
3331
|
}
|
|
3336
3332
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}-${key} {
|
|
3337
|
-
--backdrop-hue-rotate:
|
|
3333
|
+
--backdrop-hue-rotate: ${value};
|
|
3334
|
+
${vars.backdropFilter}
|
|
3338
3335
|
}
|
|
3339
3336
|
`;
|
|
3340
3337
|
});
|
|
@@ -3420,7 +3417,7 @@ function generator$1k(configOptions = {}) {
|
|
|
3420
3417
|
}
|
|
3421
3418
|
|
|
3422
3419
|
function generator$1j(configOptions = {}) {
|
|
3423
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
3420
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
3424
3421
|
|
|
3425
3422
|
const prefix = `${globalPrefix}invert`;
|
|
3426
3423
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -3432,10 +3429,12 @@ function generator$1j(configOptions = {}) {
|
|
|
3432
3429
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
3433
3430
|
return `
|
|
3434
3431
|
${prefix}${key} {
|
|
3435
|
-
--invert:
|
|
3432
|
+
--invert: ${value};
|
|
3433
|
+
${vars.filter}
|
|
3436
3434
|
}
|
|
3437
3435
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}${key} {
|
|
3438
|
-
--backdrop-invert:
|
|
3436
|
+
--backdrop-invert: ${value};
|
|
3437
|
+
${vars.backdropFilter}
|
|
3439
3438
|
}
|
|
3440
3439
|
`;
|
|
3441
3440
|
});
|
|
@@ -3902,7 +3901,7 @@ function generator$12(configOptions = {}) {
|
|
|
3902
3901
|
}
|
|
3903
3902
|
|
|
3904
3903
|
function generator$11(configOptions = {}) {
|
|
3905
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
3904
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
3906
3905
|
|
|
3907
3906
|
const prefix = `${globalPrefix}opacity`;
|
|
3908
3907
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -3915,9 +3914,11 @@ function generator$11(configOptions = {}) {
|
|
|
3915
3914
|
(key, value) => `
|
|
3916
3915
|
${prefix}-${key} {
|
|
3917
3916
|
opacity: ${value};
|
|
3917
|
+
${vars.filter}
|
|
3918
3918
|
}
|
|
3919
3919
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}-${key} {
|
|
3920
|
-
--backdrop-opacity:
|
|
3920
|
+
--backdrop-opacity: ${value};
|
|
3921
|
+
${vars.backdropFilter}
|
|
3921
3922
|
}
|
|
3922
3923
|
`
|
|
3923
3924
|
);
|
|
@@ -4455,7 +4456,7 @@ function generator$J(configOptions = {}) {
|
|
|
4455
4456
|
}
|
|
4456
4457
|
|
|
4457
4458
|
function generator$I(configOptions = {}) {
|
|
4458
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
4459
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
4459
4460
|
|
|
4460
4461
|
const prefix = `${globalPrefix}saturate`;
|
|
4461
4462
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -4467,10 +4468,12 @@ function generator$I(configOptions = {}) {
|
|
|
4467
4468
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
4468
4469
|
return `
|
|
4469
4470
|
${prefix}${key} {
|
|
4470
|
-
--saturate:
|
|
4471
|
+
--saturate: ${value};
|
|
4472
|
+
${vars.filter}
|
|
4471
4473
|
}
|
|
4472
4474
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}${key} {
|
|
4473
|
-
--backdrop-saturate:
|
|
4475
|
+
--backdrop-saturate: ${value};
|
|
4476
|
+
${vars.backdropFilter}
|
|
4474
4477
|
}
|
|
4475
4478
|
`;
|
|
4476
4479
|
});
|
|
@@ -4481,7 +4484,7 @@ function generator$I(configOptions = {}) {
|
|
|
4481
4484
|
}
|
|
4482
4485
|
|
|
4483
4486
|
function generator$H(configOptions = {}) {
|
|
4484
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
4487
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
4485
4488
|
|
|
4486
4489
|
const { rotate = {} } = theme;
|
|
4487
4490
|
|
|
@@ -4500,6 +4503,7 @@ function generator$H(configOptions = {}) {
|
|
|
4500
4503
|
return `
|
|
4501
4504
|
${prefix}-${key} {
|
|
4502
4505
|
--transform-rotate: ${value};
|
|
4506
|
+
${vars.transform}
|
|
4503
4507
|
}
|
|
4504
4508
|
`;
|
|
4505
4509
|
});
|
|
@@ -4510,7 +4514,7 @@ function generator$H(configOptions = {}) {
|
|
|
4510
4514
|
}
|
|
4511
4515
|
|
|
4512
4516
|
function generator$G(configOptions = {}) {
|
|
4513
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
4517
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
4514
4518
|
|
|
4515
4519
|
const prefix = `${globalPrefix}scale`;
|
|
4516
4520
|
|
|
@@ -4523,12 +4527,15 @@ function generator$G(configOptions = {}) {
|
|
|
4523
4527
|
${prefix}-${key} {
|
|
4524
4528
|
--transform-scale-x: ${value};
|
|
4525
4529
|
--transform-scale-y: ${value};
|
|
4530
|
+
${vars.transform}
|
|
4526
4531
|
}
|
|
4527
4532
|
${prefix}-x-${key} {
|
|
4528
4533
|
--transform-scale-x: ${value};
|
|
4534
|
+
${vars.transform}
|
|
4529
4535
|
}
|
|
4530
4536
|
${prefix}-y-${key} {
|
|
4531
4537
|
--transform-scale-y: ${value};
|
|
4538
|
+
${vars.transform}
|
|
4532
4539
|
}
|
|
4533
4540
|
`
|
|
4534
4541
|
);
|
|
@@ -4754,7 +4761,7 @@ function generator$A(configOptions = {}) {
|
|
|
4754
4761
|
}
|
|
4755
4762
|
|
|
4756
4763
|
function generator$z(configOptions = {}) {
|
|
4757
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
4764
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
4758
4765
|
|
|
4759
4766
|
const prefix = `${globalPrefix}sepia`;
|
|
4760
4767
|
const basePrefix = prefix.replace(globalPrefix, "");
|
|
@@ -4766,10 +4773,12 @@ function generator$z(configOptions = {}) {
|
|
|
4766
4773
|
const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
|
|
4767
4774
|
return `
|
|
4768
4775
|
${prefix}${key} {
|
|
4769
|
-
--sepia:
|
|
4776
|
+
--sepia: ${value};
|
|
4777
|
+
${vars.filter}
|
|
4770
4778
|
}
|
|
4771
4779
|
${prefix.replace(basePrefix, `backdrop-${basePrefix}`)}${key} {
|
|
4772
|
-
--backdrop-sepia:
|
|
4780
|
+
--backdrop-sepia: ${value};
|
|
4781
|
+
${vars.backdropFilter}
|
|
4773
4782
|
}
|
|
4774
4783
|
`;
|
|
4775
4784
|
});
|
|
@@ -4803,7 +4812,7 @@ function generator$y(configOptions = {}) {
|
|
|
4803
4812
|
}
|
|
4804
4813
|
|
|
4805
4814
|
function generator$x(configOptions = {}) {
|
|
4806
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
4815
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
4807
4816
|
|
|
4808
4817
|
const { skew = {} } = theme;
|
|
4809
4818
|
|
|
@@ -4822,9 +4831,11 @@ function generator$x(configOptions = {}) {
|
|
|
4822
4831
|
return `
|
|
4823
4832
|
${prefix}-x-${key} {
|
|
4824
4833
|
--transform-skew-x: ${value};
|
|
4834
|
+
${vars.transform}
|
|
4825
4835
|
}
|
|
4826
4836
|
${prefix}-y-${key} {
|
|
4827
4837
|
--transform-skew-y: ${value};
|
|
4838
|
+
${vars.transform}
|
|
4828
4839
|
}
|
|
4829
4840
|
`;
|
|
4830
4841
|
});
|
|
@@ -5407,19 +5418,9 @@ function generator$b(configOptions = {}) {
|
|
|
5407
5418
|
}
|
|
5408
5419
|
|
|
5409
5420
|
function generator$a({ prefix }) {
|
|
5410
|
-
return `
|
|
5411
|
-
${prefix}transform {
|
|
5412
|
-
--transform-translate-x: 0;
|
|
5413
|
-
--transform-translate-y: 0;
|
|
5414
|
-
--transform-rotate: 0;
|
|
5415
|
-
--transform-skew-x: 0;
|
|
5416
|
-
--transform-skew-y: 0;
|
|
5417
|
-
--transform-scale-x: 1;
|
|
5418
|
-
--transform-scale-y: 1;
|
|
5419
|
-
transform: translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) rotate(var(--transform-rotate)) skewX(var(--transform-skew-x)) skewY(var(--transform-skew-y)) scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y));
|
|
5420
|
-
}
|
|
5421
|
+
return `
|
|
5421
5422
|
${prefix}transform-none {
|
|
5422
|
-
transform: none;
|
|
5423
|
+
transform: none !important;
|
|
5423
5424
|
}
|
|
5424
5425
|
`;
|
|
5425
5426
|
}
|
|
@@ -5446,7 +5447,7 @@ function generator$9(configOptions = {}) {
|
|
|
5446
5447
|
propertyOptions,
|
|
5447
5448
|
(key, value) => `
|
|
5448
5449
|
${prefix}-${key} {
|
|
5449
|
-
transform-origin: ${value.replace("-", " ")}
|
|
5450
|
+
transform-origin: ${value.replace("-", " ")};
|
|
5450
5451
|
}
|
|
5451
5452
|
`
|
|
5452
5453
|
);
|
|
@@ -5457,7 +5458,7 @@ function generator$9(configOptions = {}) {
|
|
|
5457
5458
|
}
|
|
5458
5459
|
|
|
5459
5460
|
function generator$8(configOptions = {}) {
|
|
5460
|
-
const { prefix: globalPrefix, theme = {} } = configOptions;
|
|
5461
|
+
const { prefix: globalPrefix, theme = {}, vars = {} } = configOptions;
|
|
5461
5462
|
|
|
5462
5463
|
const { translate = {} } = theme;
|
|
5463
5464
|
|
|
@@ -5476,9 +5477,11 @@ function generator$8(configOptions = {}) {
|
|
|
5476
5477
|
return `
|
|
5477
5478
|
${prefix}-x-${key} {
|
|
5478
5479
|
--transform-translate-x: ${value};
|
|
5480
|
+
${vars.transform}
|
|
5479
5481
|
}
|
|
5480
5482
|
${prefix}-y-${key} {
|
|
5481
5483
|
--transform-translate-y: ${value};
|
|
5484
|
+
${vars.transform}
|
|
5482
5485
|
}
|
|
5483
5486
|
`;
|
|
5484
5487
|
});
|
|
@@ -5697,909 +5700,948 @@ function generator(configOptions = {}) {
|
|
|
5697
5700
|
return responsiveCssString;
|
|
5698
5701
|
}
|
|
5699
5702
|
|
|
5700
|
-
const
|
|
5701
|
-
transitionNone: {
|
|
5702
|
-
regex: /^transition-none$/,
|
|
5703
|
-
cssProp: "transition-property",
|
|
5704
|
-
formatter: () => "none",
|
|
5705
|
-
},
|
|
5706
|
-
transitionAll: {
|
|
5707
|
-
regex: /^transition$/,
|
|
5708
|
-
cssProp: "transition-property",
|
|
5709
|
-
formatter: () => "all",
|
|
5710
|
-
},
|
|
5711
|
-
transitionProp: {
|
|
5712
|
-
regex:
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
if (value === "
|
|
5719
|
-
return
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5703
|
+
const transition = {
|
|
5704
|
+
transitionNone: {
|
|
5705
|
+
regex: /^transition-none$/,
|
|
5706
|
+
cssProp: "transition-property",
|
|
5707
|
+
formatter: () => "none",
|
|
5708
|
+
},
|
|
5709
|
+
transitionAll: {
|
|
5710
|
+
regex: /^transition$/,
|
|
5711
|
+
cssProp: "transition-property",
|
|
5712
|
+
formatter: () => "all",
|
|
5713
|
+
},
|
|
5714
|
+
transitionProp: {
|
|
5715
|
+
regex:
|
|
5716
|
+
/^transition-(opacity|colors|color|background|background-color|transform|shadow|opacity|all|none)$/,
|
|
5717
|
+
cssProp: "transition-property",
|
|
5718
|
+
formatter: (value) => {
|
|
5719
|
+
if (value === "colors")
|
|
5720
|
+
return "color, background-color, border-color, text-decoration-color, fill, stroke";
|
|
5721
|
+
if (value === "color") return "color";
|
|
5722
|
+
if (value === "background") return "background-color";
|
|
5723
|
+
return value;
|
|
5724
|
+
},
|
|
5725
|
+
},
|
|
5726
|
+
duration: {
|
|
5727
|
+
regex: /^duration-(\d+)$/,
|
|
5728
|
+
cssProp: "transition-duration",
|
|
5729
|
+
formatter: (value) => `${value}ms`,
|
|
5730
|
+
},
|
|
5731
|
+
delay: {
|
|
5732
|
+
regex: /^delay-(\d+)$/,
|
|
5733
|
+
cssProp: "transition-delay",
|
|
5734
|
+
formatter: (value) => `${value}ms`,
|
|
5735
|
+
},
|
|
5736
|
+
ease: {
|
|
5737
|
+
regex: /^ease-(linear|in|out|in-out)$/,
|
|
5738
|
+
cssProp: "transition-timing-function",
|
|
5739
|
+
formatter: (value) => {
|
|
5740
|
+
switch (value) {
|
|
5741
|
+
case "in":
|
|
5742
|
+
return "cubic-bezier(0.4, 0, 1, 1)";
|
|
5743
|
+
case "out":
|
|
5744
|
+
return "cubic-bezier(0, 0, 0.2, 1)";
|
|
5745
|
+
case "in-out":
|
|
5746
|
+
return "cubic-bezier(0.4, 0, 0.2, 1)";
|
|
5747
|
+
case "linear":
|
|
5748
|
+
default:
|
|
5749
|
+
return "linear";
|
|
5750
|
+
}
|
|
5751
|
+
},
|
|
5752
|
+
},
|
|
5753
|
+
};
|
|
5754
|
+
|
|
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}`,
|
|
5749
6038
|
};
|
|
5750
6039
|
|
|
5751
|
-
const
|
|
5752
|
-
|
|
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})`,
|
|
5753
6047
|
};
|
|
5754
6048
|
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
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
|
-
const
|
|
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
|
-
function
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
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
|
-
|
|
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
|
-
const
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
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
|
-
|
|
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
|
-
let isImportant = false;
|
|
6353
|
-
let pureClassName = className;
|
|
6354
|
-
|
|
6355
|
-
if (className.startsWith("!")) {
|
|
6356
|
-
isImportant = true;
|
|
6357
|
-
pureClassName = className.slice(1);
|
|
6358
|
-
}
|
|
6359
|
-
|
|
6360
|
-
const { media, finalSelector } = resolveVariants(selector, rawVariants);
|
|
6361
|
-
|
|
6362
|
-
let declarations =
|
|
6363
|
-
cssObject[pureClassName] ||
|
|
6364
|
-
cssObject[pureClassName.replace(/(\/)/g, "\\$1")] ||
|
|
6365
|
-
cssObject[pureClassName.replace(/\./g, "\\.")];
|
|
6366
|
-
|
|
6367
|
-
if (!declarations && pureClassName.includes("[")) {
|
|
6368
|
-
const match = pureClassName.match(/^(.+?)\[(.+)\]$/);
|
|
6369
|
-
if (match) {
|
|
6370
|
-
const [, prefix, dynamicValue] = match;
|
|
6371
|
-
const customKey = `${prefix}custom`;
|
|
6372
|
-
const template = cssObject[customKey];
|
|
6373
|
-
if (template) {
|
|
6374
|
-
declarations = template.replace(
|
|
6375
|
-
/custom_value/g,
|
|
6376
|
-
decodeBracketValues(dynamicValue)
|
|
6377
|
-
);
|
|
6378
|
-
}
|
|
6379
|
-
}
|
|
6380
|
-
}
|
|
6381
|
-
|
|
6382
|
-
if (!declarations) {
|
|
6383
|
-
declarations = parseCustomClassWithPatterns(pureClassName);
|
|
6384
|
-
}
|
|
6385
|
-
|
|
6386
|
-
if (!declarations) {
|
|
6387
|
-
continue;
|
|
6388
|
-
}
|
|
6389
|
-
|
|
6390
|
-
if (isImportant) {
|
|
6391
|
-
declarations = declarations.replace(
|
|
6392
|
-
/([^:;]+):([^;]+)(;?)/g,
|
|
6393
|
-
(_, prop, value) => {
|
|
6394
|
-
return prop.trim().startsWith("--")
|
|
6395
|
-
? `${prop}:${value};`
|
|
6396
|
-
: `${prop}:${value.trim()} !important;`;
|
|
6397
|
-
}
|
|
6398
|
-
);
|
|
6399
|
-
}
|
|
6400
|
-
|
|
6401
|
-
const isSpaceOrDivide = [
|
|
6402
|
-
"space-x-",
|
|
6403
|
-
"-space-x-",
|
|
6404
|
-
"space-y-",
|
|
6405
|
-
"-space-y-",
|
|
6406
|
-
"divide-",
|
|
6407
|
-
].some((prefix) => pureClassName.startsWith(prefix));
|
|
6408
|
-
|
|
6409
|
-
const expandedSelector = replaceSelector(finalSelector);
|
|
6410
|
-
const targetSelector = isSpaceOrDivide
|
|
6411
|
-
? `${expandedSelector} > :not([hidden]) ~ :not([hidden])`
|
|
6412
|
-
: expandedSelector;
|
|
6413
|
-
|
|
6414
|
-
if (media) {
|
|
6415
|
-
styles[media] = styles[media] || {};
|
|
6416
|
-
styles[media][targetSelector] = styles[media][targetSelector] || "";
|
|
6417
|
-
styles[media][targetSelector] += declarations + "\n";
|
|
6418
|
-
} else {
|
|
6419
|
-
styles[targetSelector] = styles[targetSelector] || "";
|
|
6420
|
-
styles[targetSelector] += declarations + "\n";
|
|
6421
|
-
}
|
|
6422
|
-
}
|
|
6423
|
-
|
|
6424
|
-
for (const nestedSel in nested) {
|
|
6425
|
-
const nestedVal = nested[nestedSel];
|
|
6426
|
-
if (nestedSel === "@css" && typeof nestedVal === "object") {
|
|
6427
|
-
const cssDeclarations = Object.entries(nestedVal)
|
|
6428
|
-
.map(([key, value]) => `${key}: ${value};`)
|
|
6429
|
-
.join(" ");
|
|
6430
|
-
|
|
6431
|
-
if (selector in styles) {
|
|
6432
|
-
styles[selector] += cssDeclarations + "\n";
|
|
6433
|
-
} else {
|
|
6434
|
-
styles[selector] = cssDeclarations + "\n";
|
|
6435
|
-
}
|
|
6436
|
-
continue;
|
|
6437
|
-
}
|
|
6438
|
-
|
|
6439
|
-
const combinedSel = nestedSel.includes("&")
|
|
6440
|
-
? nestedSel.replace(/&/g, selector)
|
|
6441
|
-
: `${selector} ${nestedSel}`;
|
|
6442
|
-
walk(combinedSel, nestedVal);
|
|
6443
|
-
}
|
|
6444
|
-
} else if (typeof val === "string") {
|
|
6445
|
-
if (val.trim() === "") return;
|
|
6446
|
-
|
|
6447
|
-
walk(selector, [expandGroupedClass(val)]);
|
|
6448
|
-
} else if (typeof val === "object" && val !== null) {
|
|
6449
|
-
const { baseSelector, cssProperty } = parseSelector(selector);
|
|
6450
|
-
if (cssProperty) {
|
|
6451
|
-
const cssValue = Object.values(val).join(" ");
|
|
6452
|
-
styles[baseSelector] = styles[baseSelector] || "";
|
|
6453
|
-
styles[baseSelector] += `${cssProperty}: ${cssValue};\n`;
|
|
6454
|
-
return;
|
|
6455
|
-
}
|
|
6456
|
-
|
|
6457
|
-
const cssDeclarations = Object.entries(val)
|
|
6458
|
-
.map(([key, value]) => `${key}: ${value};`)
|
|
6459
|
-
.join(" ");
|
|
6460
|
-
|
|
6461
|
-
if (selector in styles) {
|
|
6462
|
-
styles[selector] += cssDeclarations + "\n";
|
|
6463
|
-
} else {
|
|
6464
|
-
styles[selector] = cssDeclarations + "\n";
|
|
6465
|
-
}
|
|
6466
|
-
}
|
|
6467
|
-
}
|
|
6468
|
-
|
|
6469
|
-
// Menambahkan memoization untuk parseSelector
|
|
6470
|
-
const parseSelectorCache = new Map();
|
|
6471
|
-
function parseSelector(selector) {
|
|
6472
|
-
if (parseSelectorCache.has(selector)) {
|
|
6473
|
-
return parseSelectorCache.get(selector);
|
|
6474
|
-
}
|
|
6475
|
-
|
|
6476
|
-
let result;
|
|
6477
|
-
if (selector.includes('@css')) {
|
|
6478
|
-
const parts = selector.split('@css');
|
|
6479
|
-
const baseSelector = parts[0].trim();
|
|
6480
|
-
const cssProperty = parts[1]?.trim();
|
|
6481
|
-
result = { baseSelector, cssProperty };
|
|
6482
|
-
} else {
|
|
6483
|
-
result = { baseSelector: selector, cssProperty: null };
|
|
6484
|
-
}
|
|
6485
|
-
|
|
6486
|
-
parseSelectorCache.set(selector, result);
|
|
6487
|
-
limitCacheSize(parseSelectorCache);
|
|
6488
|
-
return result;
|
|
6489
|
-
}
|
|
6490
|
-
|
|
6491
|
-
function isSelectorObject(val) {
|
|
6492
|
-
return typeof val === "object" && val !== null && !Array.isArray(val);
|
|
6493
|
-
}
|
|
6494
|
-
|
|
6495
|
-
function flatten(obj, parentSelector = "") {
|
|
6496
|
-
const result = {};
|
|
6497
|
-
|
|
6498
|
-
for (const selector in obj) {
|
|
6499
|
-
const val = obj[selector];
|
|
6500
|
-
const currentSelector = parentSelector
|
|
6501
|
-
? selector.includes("&")
|
|
6502
|
-
? selector.replace(/&/g, parentSelector)
|
|
6503
|
-
: `${parentSelector} ${selector}`
|
|
6504
|
-
: selector;
|
|
6505
|
-
|
|
6506
|
-
if (typeof val === "string") {
|
|
6507
|
-
result[currentSelector] = val;
|
|
6508
|
-
} else if (Array.isArray(val)) {
|
|
6509
|
-
const flatArray = [];
|
|
6510
|
-
for (const item of val) {
|
|
6511
|
-
if (typeof item === "string") {
|
|
6512
|
-
flatArray.push(item);
|
|
6513
|
-
} else if (isSelectorObject(item)) {
|
|
6514
|
-
const nested = flatten(item, currentSelector);
|
|
6515
|
-
Object.assign(result, nested);
|
|
6516
|
-
}
|
|
6517
|
-
}
|
|
6518
|
-
if (flatArray.length > 0) {
|
|
6519
|
-
result[currentSelector] = result[currentSelector] || [];
|
|
6520
|
-
result[currentSelector].push(...flatArray);
|
|
6521
|
-
}
|
|
6522
|
-
} else if (isSelectorObject(val)) {
|
|
6523
|
-
const nested = flatten(val, currentSelector);
|
|
6524
|
-
Object.assign(result, nested);
|
|
6525
|
-
}
|
|
6526
|
-
}
|
|
6527
|
-
|
|
6528
|
-
return result;
|
|
6529
|
-
}
|
|
6530
|
-
|
|
6531
|
-
const flattened = flatten(obj);
|
|
6532
|
-
|
|
6533
|
-
for (const selector in flattened) {
|
|
6534
|
-
let val = flattened[selector];
|
|
6535
|
-
let baseClass = "";
|
|
6536
|
-
let nested = {};
|
|
6537
|
-
|
|
6538
|
-
if (typeof val === "string") {
|
|
6539
|
-
baseClass = expandGroupedClass(val);
|
|
6540
|
-
} else if (Array.isArray(val)) {
|
|
6541
|
-
for (const item of val) {
|
|
6542
|
-
if (typeof item === "string") {
|
|
6543
|
-
baseClass += (baseClass ? " " : "") + expandGroupedClass(item);
|
|
6544
|
-
} else if (typeof item === "object" && item !== null) {
|
|
6545
|
-
Object.assign(nested, item);
|
|
6546
|
-
}
|
|
6547
|
-
}
|
|
6548
|
-
}
|
|
6549
|
-
|
|
6550
|
-
walk(selector, [baseClass, nested]);
|
|
6551
|
-
}
|
|
6552
|
-
|
|
6553
|
-
let cssString = "";
|
|
6554
|
-
|
|
6555
|
-
const baseStyles = [];
|
|
6556
|
-
const mediaStyles = [];
|
|
6557
|
-
|
|
6558
|
-
for (const sel in styles) {
|
|
6559
|
-
if (!sel.startsWith("@media")) {
|
|
6560
|
-
baseStyles.push({ sel, css: styles[sel] });
|
|
6561
|
-
} else {
|
|
6562
|
-
mediaStyles.push({ sel, content: styles[sel] });
|
|
6563
|
-
}
|
|
6564
|
-
}
|
|
6565
|
-
|
|
6566
|
-
for (const { sel, css } of baseStyles) {
|
|
6567
|
-
cssString += `${sel}{${css.trim().replace(/\n/g, "")}}`;
|
|
6568
|
-
}
|
|
6569
|
-
|
|
6570
|
-
function mediaPriority(sel) {
|
|
6571
|
-
const match = sel.match(/@media \(min-width: (\d+)px\)/);
|
|
6572
|
-
return match ? parseInt(match[1], 10) : 99999;
|
|
6573
|
-
}
|
|
6574
|
-
|
|
6575
|
-
mediaStyles.sort((a, b) => mediaPriority(a.sel) - mediaPriority(b.sel));
|
|
6576
|
-
|
|
6577
|
-
for (const { sel, content } of mediaStyles) {
|
|
6578
|
-
cssString += `${sel}{`;
|
|
6579
|
-
for (const subSel in content) {
|
|
6580
|
-
cssString += `${subSel}{${content[subSel].trim().replace(/\n/g, "")}}`;
|
|
6581
|
-
}
|
|
6582
|
-
cssString += `}`;
|
|
6583
|
-
}
|
|
6584
|
-
return cssString.trim();
|
|
6585
|
-
}
|
|
6586
|
-
|
|
6587
|
-
// Daftarkan versi debounced dari fungsi-fungsi export
|
|
6588
|
-
/**
|
|
6589
|
-
* Versi debounced dari fungsi tws
|
|
6590
|
-
* Membantu mengoptimalkan performa ketika memanggil tws berulang kali
|
|
6591
|
-
* @param {string} classNames - String berisi kelas Tailwind yang akan dikonversi
|
|
6592
|
-
* @param {boolean} convertToJson - Jika true, hasil akan menjadi objek JSON, jika false menjadi string CSS
|
|
6593
|
-
* @returns {string|Object} String CSS inline atau objek style JSON
|
|
6594
|
-
*/
|
|
6595
|
-
const debouncedTws = debounce(tws);
|
|
6596
|
-
|
|
6597
|
-
/**
|
|
6598
|
-
* Versi debounced dari fungsi twsx
|
|
6599
|
-
* Membantu mengoptimalkan performa ketika memanggil twsx berulang kali
|
|
6600
|
-
* @param {Object} obj - Objek dengan format style mirip SCSS
|
|
6601
|
-
* @returns {string} String CSS yang dihasilkan
|
|
6602
|
-
*/
|
|
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
|
+
* @returns {string} String CSS yang dihasilkan
|
|
6297
|
+
*/
|
|
6298
|
+
function twsx(obj) {
|
|
6299
|
+
if (!obj || typeof obj !== "object") {
|
|
6300
|
+
console.warn("twsx: Expected an object but received:", obj);
|
|
6301
|
+
return "";
|
|
6302
|
+
}
|
|
6303
|
+
|
|
6304
|
+
const styles = {};
|
|
6305
|
+
|
|
6306
|
+
function expandGroupedClass(input) {
|
|
6307
|
+
function expandDirectiveGroups(str) {
|
|
6308
|
+
return str.replace(/(\w+)\(([^()]+)\)/g, (_, directive, content) => {
|
|
6309
|
+
return content
|
|
6310
|
+
.trim()
|
|
6311
|
+
.split(/\s+/)
|
|
6312
|
+
.map((val) => {
|
|
6313
|
+
if (val.includes(":")) {
|
|
6314
|
+
const [variant, v] = val.split(":");
|
|
6315
|
+
const prefix = v.startsWith("-") ? "-" : "";
|
|
6316
|
+
const value = v.startsWith("-") ? v.slice(1) : v;
|
|
6317
|
+
return `${variant}:${prefix}${directive}-${value}`;
|
|
6318
|
+
}
|
|
6319
|
+
const prefix = val.startsWith("-") ? "-" : "";
|
|
6320
|
+
const value = val.startsWith("-") ? val.slice(1) : val;
|
|
6321
|
+
return `${prefix}${directive}-${value}`;
|
|
6322
|
+
})
|
|
6323
|
+
.join(" ");
|
|
6324
|
+
});
|
|
6325
|
+
}
|
|
6326
|
+
|
|
6327
|
+
function expandVariants(str, parent = "") {
|
|
6328
|
+
return str.replace(
|
|
6329
|
+
/(\w+):\(([^()]+(?:\((?:[^()]+)\))?[^()]*)\)/g,
|
|
6330
|
+
(_, variant, content) => {
|
|
6331
|
+
return content
|
|
6332
|
+
.trim()
|
|
6333
|
+
.split(/\s+/)
|
|
6334
|
+
.map((c) => {
|
|
6335
|
+
if (/\w+:\(.*\)/.test(c)) {
|
|
6336
|
+
return expandVariants(
|
|
6337
|
+
c,
|
|
6338
|
+
parent ? `${parent}:${variant}` : variant
|
|
6339
|
+
);
|
|
6340
|
+
}
|
|
6341
|
+
return `${parent ? `${parent}:${variant}` : variant}:${c}`;
|
|
6342
|
+
})
|
|
6343
|
+
.join(" ");
|
|
6344
|
+
}
|
|
6345
|
+
);
|
|
6346
|
+
}
|
|
6347
|
+
|
|
6348
|
+
let result = encodeBracketValues(input);
|
|
6349
|
+
let prev;
|
|
6350
|
+
|
|
6351
|
+
do {
|
|
6352
|
+
prev = result;
|
|
6353
|
+
result = expandVariants(result);
|
|
6354
|
+
result = expandDirectiveGroups(result);
|
|
6355
|
+
} while (result !== prev);
|
|
6356
|
+
|
|
6357
|
+
return result;
|
|
6358
|
+
}
|
|
6359
|
+
function walk(selector, val) {
|
|
6360
|
+
if (!selector || typeof selector !== "string") {
|
|
6361
|
+
console.warn("Invalid selector in walk function:", selector);
|
|
6362
|
+
return;
|
|
6363
|
+
}
|
|
6364
|
+
|
|
6365
|
+
const { baseSelector, cssProperty } = parseSelector(selector);
|
|
6366
|
+
if (
|
|
6367
|
+
cssProperty &&
|
|
6368
|
+
typeof val === "object" &&
|
|
6369
|
+
Array.isArray(val) &&
|
|
6370
|
+
val.length > 0
|
|
6371
|
+
) {
|
|
6372
|
+
const cssValue = val[0];
|
|
6373
|
+
if (typeof cssValue === "string") {
|
|
6374
|
+
styles[baseSelector] = styles[baseSelector] || "";
|
|
6375
|
+
styles[baseSelector] += `${cssProperty}: ${cssValue};\n`;
|
|
6376
|
+
return;
|
|
6377
|
+
}
|
|
6378
|
+
}
|
|
6379
|
+
|
|
6380
|
+
if (Array.isArray(val)) {
|
|
6381
|
+
const [base, nested] = val;
|
|
6382
|
+
|
|
6383
|
+
if (typeof base !== "string") {
|
|
6384
|
+
return;
|
|
6385
|
+
}
|
|
6386
|
+
|
|
6387
|
+
for (const cls of base.split(" ")) {
|
|
6388
|
+
if (cls.trim() === "") continue;
|
|
6389
|
+
|
|
6390
|
+
const [rawVariants, className] = cls.includes(":")
|
|
6391
|
+
? [cls.split(":").slice(0, -1), cls.split(":").slice(-1)[0]]
|
|
6392
|
+
: [[], cls];
|
|
6393
|
+
|
|
6394
|
+
let isImportant = false;
|
|
6395
|
+
let pureClassName = className;
|
|
6396
|
+
|
|
6397
|
+
if (className.startsWith("!")) {
|
|
6398
|
+
isImportant = true;
|
|
6399
|
+
pureClassName = className.slice(1);
|
|
6400
|
+
}
|
|
6401
|
+
|
|
6402
|
+
const { media, finalSelector } = resolveVariants(selector, rawVariants);
|
|
6403
|
+
|
|
6404
|
+
let declarations =
|
|
6405
|
+
cssObject[pureClassName] ||
|
|
6406
|
+
cssObject[pureClassName.replace(/(\/)/g, "\\$1")] ||
|
|
6407
|
+
cssObject[pureClassName.replace(/\./g, "\\.")];
|
|
6408
|
+
|
|
6409
|
+
if (!declarations && pureClassName.includes("[")) {
|
|
6410
|
+
const match = pureClassName.match(/^(.+?)\[(.+)\]$/);
|
|
6411
|
+
if (match) {
|
|
6412
|
+
const [, prefix, dynamicValue] = match;
|
|
6413
|
+
const customKey = `${prefix}custom`;
|
|
6414
|
+
const template = cssObject[customKey];
|
|
6415
|
+
if (template) {
|
|
6416
|
+
declarations = template.replace(
|
|
6417
|
+
/custom_value/g,
|
|
6418
|
+
decodeBracketValues(dynamicValue)
|
|
6419
|
+
);
|
|
6420
|
+
}
|
|
6421
|
+
}
|
|
6422
|
+
}
|
|
6423
|
+
|
|
6424
|
+
if (!declarations) {
|
|
6425
|
+
declarations = parseCustomClassWithPatterns(pureClassName);
|
|
6426
|
+
}
|
|
6427
|
+
|
|
6428
|
+
if (!declarations) {
|
|
6429
|
+
continue;
|
|
6430
|
+
}
|
|
6431
|
+
|
|
6432
|
+
if (isImportant) {
|
|
6433
|
+
declarations = declarations.replace(
|
|
6434
|
+
/([^:;]+):([^;]+)(;?)/g,
|
|
6435
|
+
(_, prop, value) => {
|
|
6436
|
+
return prop.trim().startsWith("--")
|
|
6437
|
+
? `${prop}:${value};`
|
|
6438
|
+
: `${prop}:${value.trim()} !important;`;
|
|
6439
|
+
}
|
|
6440
|
+
);
|
|
6441
|
+
}
|
|
6442
|
+
|
|
6443
|
+
const isSpaceOrDivide = [
|
|
6444
|
+
"space-x-",
|
|
6445
|
+
"-space-x-",
|
|
6446
|
+
"space-y-",
|
|
6447
|
+
"-space-y-",
|
|
6448
|
+
"divide-",
|
|
6449
|
+
].some((prefix) => pureClassName.startsWith(prefix));
|
|
6450
|
+
|
|
6451
|
+
const expandedSelector = replaceSelector(finalSelector);
|
|
6452
|
+
const targetSelector = isSpaceOrDivide
|
|
6453
|
+
? `${expandedSelector} > :not([hidden]) ~ :not([hidden])`
|
|
6454
|
+
: expandedSelector;
|
|
6455
|
+
|
|
6456
|
+
if (media) {
|
|
6457
|
+
styles[media] = styles[media] || {};
|
|
6458
|
+
styles[media][targetSelector] = styles[media][targetSelector] || "";
|
|
6459
|
+
styles[media][targetSelector] += declarations + "\n";
|
|
6460
|
+
} else {
|
|
6461
|
+
styles[targetSelector] = styles[targetSelector] || "";
|
|
6462
|
+
styles[targetSelector] += declarations + "\n";
|
|
6463
|
+
}
|
|
6464
|
+
}
|
|
6465
|
+
|
|
6466
|
+
for (const nestedSel in nested) {
|
|
6467
|
+
const nestedVal = nested[nestedSel];
|
|
6468
|
+
if (nestedSel === "@css" && typeof nestedVal === "object") {
|
|
6469
|
+
const cssDeclarations = Object.entries(nestedVal)
|
|
6470
|
+
.map(([key, value]) => `${key}: ${value};`)
|
|
6471
|
+
.join(" ");
|
|
6472
|
+
|
|
6473
|
+
if (selector in styles) {
|
|
6474
|
+
styles[selector] += cssDeclarations + "\n";
|
|
6475
|
+
} else {
|
|
6476
|
+
styles[selector] = cssDeclarations + "\n";
|
|
6477
|
+
}
|
|
6478
|
+
continue;
|
|
6479
|
+
}
|
|
6480
|
+
|
|
6481
|
+
const combinedSel = nestedSel.includes("&")
|
|
6482
|
+
? nestedSel.replace(/&/g, selector)
|
|
6483
|
+
: `${selector} ${nestedSel}`;
|
|
6484
|
+
walk(combinedSel, nestedVal);
|
|
6485
|
+
}
|
|
6486
|
+
} else if (typeof val === "string") {
|
|
6487
|
+
if (val.trim() === "") return;
|
|
6488
|
+
|
|
6489
|
+
walk(selector, [expandGroupedClass(val)]);
|
|
6490
|
+
} else if (typeof val === "object" && val !== null) {
|
|
6491
|
+
const { baseSelector, cssProperty } = parseSelector(selector);
|
|
6492
|
+
if (cssProperty) {
|
|
6493
|
+
const cssValue = Object.values(val).join(" ");
|
|
6494
|
+
styles[baseSelector] = styles[baseSelector] || "";
|
|
6495
|
+
styles[baseSelector] += `${cssProperty}: ${cssValue};\n`;
|
|
6496
|
+
return;
|
|
6497
|
+
}
|
|
6498
|
+
|
|
6499
|
+
const cssDeclarations = Object.entries(val)
|
|
6500
|
+
.map(([key, value]) => `${key}: ${value};`)
|
|
6501
|
+
.join(" ");
|
|
6502
|
+
|
|
6503
|
+
if (selector in styles) {
|
|
6504
|
+
styles[selector] += cssDeclarations + "\n";
|
|
6505
|
+
} else {
|
|
6506
|
+
styles[selector] = cssDeclarations + "\n";
|
|
6507
|
+
}
|
|
6508
|
+
}
|
|
6509
|
+
}
|
|
6510
|
+
|
|
6511
|
+
// Menambahkan memoization untuk parseSelector
|
|
6512
|
+
const parseSelectorCache = new Map();
|
|
6513
|
+
function parseSelector(selector) {
|
|
6514
|
+
if (parseSelectorCache.has(selector)) {
|
|
6515
|
+
return parseSelectorCache.get(selector);
|
|
6516
|
+
}
|
|
6517
|
+
|
|
6518
|
+
let result;
|
|
6519
|
+
if (selector.includes("@css")) {
|
|
6520
|
+
const parts = selector.split("@css");
|
|
6521
|
+
const baseSelector = parts[0].trim();
|
|
6522
|
+
const cssProperty = parts[1]?.trim();
|
|
6523
|
+
result = { baseSelector, cssProperty };
|
|
6524
|
+
} else {
|
|
6525
|
+
result = { baseSelector: selector, cssProperty: null };
|
|
6526
|
+
}
|
|
6527
|
+
|
|
6528
|
+
parseSelectorCache.set(selector, result);
|
|
6529
|
+
limitCacheSize(parseSelectorCache);
|
|
6530
|
+
return result;
|
|
6531
|
+
}
|
|
6532
|
+
|
|
6533
|
+
function isSelectorObject(val) {
|
|
6534
|
+
return typeof val === "object" && val !== null && !Array.isArray(val);
|
|
6535
|
+
}
|
|
6536
|
+
|
|
6537
|
+
function flatten(obj, parentSelector = "") {
|
|
6538
|
+
const result = {};
|
|
6539
|
+
|
|
6540
|
+
for (const selector in obj) {
|
|
6541
|
+
const val = obj[selector];
|
|
6542
|
+
const currentSelector = parentSelector
|
|
6543
|
+
? selector.includes("&")
|
|
6544
|
+
? selector.replace(/&/g, parentSelector)
|
|
6545
|
+
: `${parentSelector} ${selector}`
|
|
6546
|
+
: selector;
|
|
6547
|
+
|
|
6548
|
+
if (typeof val === "string") {
|
|
6549
|
+
result[currentSelector] = val;
|
|
6550
|
+
} else if (Array.isArray(val)) {
|
|
6551
|
+
const flatArray = [];
|
|
6552
|
+
for (const item of val) {
|
|
6553
|
+
if (typeof item === "string") {
|
|
6554
|
+
flatArray.push(item);
|
|
6555
|
+
} else if (isSelectorObject(item)) {
|
|
6556
|
+
const nested = flatten(item, currentSelector);
|
|
6557
|
+
Object.assign(result, nested);
|
|
6558
|
+
}
|
|
6559
|
+
}
|
|
6560
|
+
if (flatArray.length > 0) {
|
|
6561
|
+
result[currentSelector] = result[currentSelector] || [];
|
|
6562
|
+
result[currentSelector].push(...flatArray);
|
|
6563
|
+
}
|
|
6564
|
+
} else if (isSelectorObject(val)) {
|
|
6565
|
+
const nested = flatten(val, currentSelector);
|
|
6566
|
+
Object.assign(result, nested);
|
|
6567
|
+
}
|
|
6568
|
+
}
|
|
6569
|
+
|
|
6570
|
+
return result;
|
|
6571
|
+
}
|
|
6572
|
+
|
|
6573
|
+
const flattened = flatten(obj);
|
|
6574
|
+
|
|
6575
|
+
for (const selector in flattened) {
|
|
6576
|
+
let val = flattened[selector];
|
|
6577
|
+
let baseClass = "";
|
|
6578
|
+
let nested = {};
|
|
6579
|
+
|
|
6580
|
+
if (typeof val === "string") {
|
|
6581
|
+
baseClass = expandGroupedClass(val);
|
|
6582
|
+
} else if (Array.isArray(val)) {
|
|
6583
|
+
for (const item of val) {
|
|
6584
|
+
if (typeof item === "string") {
|
|
6585
|
+
baseClass += (baseClass ? " " : "") + expandGroupedClass(item);
|
|
6586
|
+
} else if (typeof item === "object" && item !== null) {
|
|
6587
|
+
Object.assign(nested, item);
|
|
6588
|
+
}
|
|
6589
|
+
}
|
|
6590
|
+
}
|
|
6591
|
+
|
|
6592
|
+
walk(selector, [baseClass, nested]);
|
|
6593
|
+
}
|
|
6594
|
+
|
|
6595
|
+
let cssString = "";
|
|
6596
|
+
|
|
6597
|
+
const baseStyles = [];
|
|
6598
|
+
const mediaStyles = [];
|
|
6599
|
+
|
|
6600
|
+
for (const sel in styles) {
|
|
6601
|
+
if (!sel.startsWith("@media")) {
|
|
6602
|
+
baseStyles.push({ sel, css: styles[sel] });
|
|
6603
|
+
} else {
|
|
6604
|
+
mediaStyles.push({ sel, content: styles[sel] });
|
|
6605
|
+
}
|
|
6606
|
+
}
|
|
6607
|
+
|
|
6608
|
+
for (const { sel, css } of baseStyles) {
|
|
6609
|
+
cssString += `${sel}{${css.trim().replace(/\n/g, "")}}`;
|
|
6610
|
+
}
|
|
6611
|
+
|
|
6612
|
+
function mediaPriority(sel) {
|
|
6613
|
+
const match = sel.match(/@media \(min-width: (\d+)px\)/);
|
|
6614
|
+
return match ? parseInt(match[1], 10) : 99999;
|
|
6615
|
+
}
|
|
6616
|
+
|
|
6617
|
+
mediaStyles.sort((a, b) => mediaPriority(a.sel) - mediaPriority(b.sel));
|
|
6618
|
+
|
|
6619
|
+
for (const { sel, content } of mediaStyles) {
|
|
6620
|
+
cssString += `${sel}{`;
|
|
6621
|
+
for (const subSel in content) {
|
|
6622
|
+
cssString += `${subSel}{${content[subSel].trim().replace(/\n/g, "")}}`;
|
|
6623
|
+
}
|
|
6624
|
+
cssString += `}`;
|
|
6625
|
+
}
|
|
6626
|
+
return cssString.trim();
|
|
6627
|
+
}
|
|
6628
|
+
|
|
6629
|
+
// Daftarkan versi debounced dari fungsi-fungsi export
|
|
6630
|
+
/**
|
|
6631
|
+
* Versi debounced dari fungsi tws
|
|
6632
|
+
* Membantu mengoptimalkan performa ketika memanggil tws berulang kali
|
|
6633
|
+
* @param {string} classNames - String berisi kelas Tailwind yang akan dikonversi
|
|
6634
|
+
* @param {boolean} convertToJson - Jika true, hasil akan menjadi objek JSON, jika false menjadi string CSS
|
|
6635
|
+
* @returns {string|Object} String CSS inline atau objek style JSON
|
|
6636
|
+
*/
|
|
6637
|
+
const debouncedTws = debounce(tws);
|
|
6638
|
+
|
|
6639
|
+
/**
|
|
6640
|
+
* Versi debounced dari fungsi twsx
|
|
6641
|
+
* Membantu mengoptimalkan performa ketika memanggil twsx berulang kali
|
|
6642
|
+
* @param {Object} obj - Objek dengan format style mirip SCSS
|
|
6643
|
+
* @returns {string} String CSS yang dihasilkan
|
|
6644
|
+
*/
|
|
6603
6645
|
const debouncedTwsx = debounce(twsx);
|
|
6604
6646
|
|
|
6605
6647
|
export { debouncedTws, debouncedTwsx, tws, twsx };
|