@weasel-js/theme 1.9.2 → 1.9.4
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 +7 -0
- package/dist/{chunk-NUILKH2Z.js → chunk-7LCRXZDY.js} +43 -20
- package/dist/chunk-7LCRXZDY.js.map +1 -0
- package/dist/{chunk-CAMHNPQN.js → chunk-EFGZ56CE.js} +311 -51
- package/dist/chunk-EFGZ56CE.js.map +1 -0
- package/dist/{definition-DLgEuUUG.d.ts → definition-GS7_Kz9D.d.ts} +45 -8
- package/dist/engine.d.ts +4 -4
- package/dist/engine.js +76 -36
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +19 -9
- package/dist/index.js +21 -7
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +6 -4
- package/dist/react.js.map +1 -1
- package/dist/tokens.css +32 -4
- package/package.json +3 -2
- package/dist/chunk-CAMHNPQN.js.map +0 -1
- package/dist/chunk-NUILKH2Z.js.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { themeAxes, fullSelection,
|
|
1
|
+
import { themeAxes, fullSelection, resolveTheme, themeChain, isByAxis, generate, DEFAULT_CONSTRAINTS } from './chunk-7LCRXZDY.js';
|
|
2
|
+
import { isPlainObject } from '@weasel-js/registry';
|
|
2
3
|
|
|
3
4
|
// src/generated/themes.ts
|
|
4
5
|
var THEMES = {
|
|
@@ -62,6 +63,12 @@ var THEMES = {
|
|
|
62
63
|
"--wzl-secondary-fg": "#dc9d15",
|
|
63
64
|
"--wzl-fg-inverse": "#0e0f12",
|
|
64
65
|
"--wzl-shadow": "rgba(0, 0, 0, 0.6)",
|
|
66
|
+
"--wzl-code-keyword": "#955cf9",
|
|
67
|
+
"--wzl-code-string": "#48e628",
|
|
68
|
+
"--wzl-code-number": "#e69628",
|
|
69
|
+
"--wzl-code-constant": "#3ee1cb",
|
|
70
|
+
"--wzl-code-property": "#36bff2",
|
|
71
|
+
"--wzl-code-name": "#fa4590",
|
|
65
72
|
"--wzl-panel-surface": "#25272c",
|
|
66
73
|
"--wzl-panel-border-color": "#25272c",
|
|
67
74
|
"--wzl-panel-border-style": "solid",
|
|
@@ -139,8 +146,8 @@ var THEMES = {
|
|
|
139
146
|
"--wzl-slider-thumb-size": "8px",
|
|
140
147
|
"--wzl-slider-track-slop": "6px",
|
|
141
148
|
"--wzl-slider-thumb-slop": "6px",
|
|
142
|
-
"--wzl-slider-track-mix": "
|
|
143
|
-
"--wzl-slider-thumb-mix": "
|
|
149
|
+
"--wzl-slider-track-mix": "40%",
|
|
150
|
+
"--wzl-slider-thumb-mix": "100%",
|
|
144
151
|
"--wzl-handle-size": "9px",
|
|
145
152
|
"--wzl-handle-size-sm": "7px",
|
|
146
153
|
"--wzl-handle-size-lg": "10px",
|
|
@@ -234,6 +241,12 @@ var THEMES = {
|
|
|
234
241
|
"--wzl-secondary-fg": "#dc9d15",
|
|
235
242
|
"--wzl-fg-inverse": "#0e0f12",
|
|
236
243
|
"--wzl-shadow": "rgba(0, 0, 0, 0.6)",
|
|
244
|
+
"--wzl-code-keyword": "#955cf9",
|
|
245
|
+
"--wzl-code-string": "#48e628",
|
|
246
|
+
"--wzl-code-number": "#e69628",
|
|
247
|
+
"--wzl-code-constant": "#3ee1cb",
|
|
248
|
+
"--wzl-code-property": "#36bff2",
|
|
249
|
+
"--wzl-code-name": "#fa4590",
|
|
237
250
|
"--wzl-panel-surface": "#25272c",
|
|
238
251
|
"--wzl-panel-border-color": "#25272c",
|
|
239
252
|
"--wzl-panel-border-style": "solid",
|
|
@@ -311,8 +324,8 @@ var THEMES = {
|
|
|
311
324
|
"--wzl-slider-thumb-size": "8px",
|
|
312
325
|
"--wzl-slider-track-slop": "6px",
|
|
313
326
|
"--wzl-slider-thumb-slop": "6px",
|
|
314
|
-
"--wzl-slider-track-mix": "
|
|
315
|
-
"--wzl-slider-thumb-mix": "
|
|
327
|
+
"--wzl-slider-track-mix": "40%",
|
|
328
|
+
"--wzl-slider-thumb-mix": "100%",
|
|
316
329
|
"--wzl-handle-size": "9px",
|
|
317
330
|
"--wzl-handle-size-sm": "7px",
|
|
318
331
|
"--wzl-handle-size-lg": "10px",
|
|
@@ -406,6 +419,12 @@ var THEMES = {
|
|
|
406
419
|
"--wzl-secondary-fg": "#dc9d15",
|
|
407
420
|
"--wzl-fg-inverse": "#0e0f12",
|
|
408
421
|
"--wzl-shadow": "rgba(0, 0, 0, 0.6)",
|
|
422
|
+
"--wzl-code-keyword": "#955cf9",
|
|
423
|
+
"--wzl-code-string": "#48e628",
|
|
424
|
+
"--wzl-code-number": "#e69628",
|
|
425
|
+
"--wzl-code-constant": "#3ee1cb",
|
|
426
|
+
"--wzl-code-property": "#36bff2",
|
|
427
|
+
"--wzl-code-name": "#fa4590",
|
|
409
428
|
"--wzl-panel-surface": "#25272c",
|
|
410
429
|
"--wzl-panel-border-color": "#25272c",
|
|
411
430
|
"--wzl-panel-border-style": "solid",
|
|
@@ -483,8 +502,8 @@ var THEMES = {
|
|
|
483
502
|
"--wzl-slider-thumb-size": "8px",
|
|
484
503
|
"--wzl-slider-track-slop": "6px",
|
|
485
504
|
"--wzl-slider-thumb-slop": "6px",
|
|
486
|
-
"--wzl-slider-track-mix": "
|
|
487
|
-
"--wzl-slider-thumb-mix": "
|
|
505
|
+
"--wzl-slider-track-mix": "40%",
|
|
506
|
+
"--wzl-slider-thumb-mix": "100%",
|
|
488
507
|
"--wzl-handle-size": "9px",
|
|
489
508
|
"--wzl-handle-size-sm": "7px",
|
|
490
509
|
"--wzl-handle-size-lg": "10px",
|
|
@@ -578,6 +597,12 @@ var THEMES = {
|
|
|
578
597
|
"--wzl-secondary-fg": "#016458",
|
|
579
598
|
"--wzl-fg-inverse": "#f5f5f6",
|
|
580
599
|
"--wzl-shadow": "rgba(0, 0, 0, 0.18)",
|
|
600
|
+
"--wzl-code-keyword": "#6d28d9",
|
|
601
|
+
"--wzl-code-string": "#15803d",
|
|
602
|
+
"--wzl-code-number": "#b45309",
|
|
603
|
+
"--wzl-code-constant": "#0f766e",
|
|
604
|
+
"--wzl-code-property": "#0369a1",
|
|
605
|
+
"--wzl-code-name": "#be123c",
|
|
581
606
|
"--wzl-panel-surface": "#e6e7e9",
|
|
582
607
|
"--wzl-panel-border-color": "#c9cbcf",
|
|
583
608
|
"--wzl-panel-border-style": "solid",
|
|
@@ -750,6 +775,12 @@ var THEMES = {
|
|
|
750
775
|
"--wzl-secondary-fg": "#016458",
|
|
751
776
|
"--wzl-fg-inverse": "#f5f5f6",
|
|
752
777
|
"--wzl-shadow": "rgba(0, 0, 0, 0.18)",
|
|
778
|
+
"--wzl-code-keyword": "#6d28d9",
|
|
779
|
+
"--wzl-code-string": "#15803d",
|
|
780
|
+
"--wzl-code-number": "#b45309",
|
|
781
|
+
"--wzl-code-constant": "#0f766e",
|
|
782
|
+
"--wzl-code-property": "#0369a1",
|
|
783
|
+
"--wzl-code-name": "#be123c",
|
|
753
784
|
"--wzl-panel-surface": "#e6e7e9",
|
|
754
785
|
"--wzl-panel-border-color": "#c9cbcf",
|
|
755
786
|
"--wzl-panel-border-style": "solid",
|
|
@@ -922,6 +953,12 @@ var THEMES = {
|
|
|
922
953
|
"--wzl-secondary-fg": "#016458",
|
|
923
954
|
"--wzl-fg-inverse": "#f5f5f6",
|
|
924
955
|
"--wzl-shadow": "rgba(0, 0, 0, 0.18)",
|
|
956
|
+
"--wzl-code-keyword": "#6d28d9",
|
|
957
|
+
"--wzl-code-string": "#15803d",
|
|
958
|
+
"--wzl-code-number": "#b45309",
|
|
959
|
+
"--wzl-code-constant": "#0f766e",
|
|
960
|
+
"--wzl-code-property": "#0369a1",
|
|
961
|
+
"--wzl-code-name": "#be123c",
|
|
925
962
|
"--wzl-panel-surface": "#e6e7e9",
|
|
926
963
|
"--wzl-panel-border-color": "#c9cbcf",
|
|
927
964
|
"--wzl-panel-border-style": "solid",
|
|
@@ -1396,6 +1433,78 @@ var THEME_SOURCES = {
|
|
|
1396
1433
|
"value": "rgba(0, 0, 0, 0.18)",
|
|
1397
1434
|
"type": "color"
|
|
1398
1435
|
}
|
|
1436
|
+
},
|
|
1437
|
+
"code-keyword": {
|
|
1438
|
+
"by": "mode",
|
|
1439
|
+
"dark": {
|
|
1440
|
+
"ref": "swatch-violet",
|
|
1441
|
+
"type": "color",
|
|
1442
|
+
"description": "Keywords in highlighted code."
|
|
1443
|
+
},
|
|
1444
|
+
"light": {
|
|
1445
|
+
"value": "#6d28d9",
|
|
1446
|
+
"type": "color"
|
|
1447
|
+
}
|
|
1448
|
+
},
|
|
1449
|
+
"code-string": {
|
|
1450
|
+
"by": "mode",
|
|
1451
|
+
"dark": {
|
|
1452
|
+
"ref": "swatch-green",
|
|
1453
|
+
"type": "color",
|
|
1454
|
+
"description": "String literals in highlighted code."
|
|
1455
|
+
},
|
|
1456
|
+
"light": {
|
|
1457
|
+
"value": "#15803d",
|
|
1458
|
+
"type": "color"
|
|
1459
|
+
}
|
|
1460
|
+
},
|
|
1461
|
+
"code-number": {
|
|
1462
|
+
"by": "mode",
|
|
1463
|
+
"dark": {
|
|
1464
|
+
"ref": "swatch-amber",
|
|
1465
|
+
"type": "color",
|
|
1466
|
+
"description": "Numbers in highlighted code."
|
|
1467
|
+
},
|
|
1468
|
+
"light": {
|
|
1469
|
+
"value": "#b45309",
|
|
1470
|
+
"type": "color"
|
|
1471
|
+
}
|
|
1472
|
+
},
|
|
1473
|
+
"code-constant": {
|
|
1474
|
+
"by": "mode",
|
|
1475
|
+
"dark": {
|
|
1476
|
+
"ref": "swatch-teal",
|
|
1477
|
+
"type": "color",
|
|
1478
|
+
"description": "true, false, null and undefined in highlighted code."
|
|
1479
|
+
},
|
|
1480
|
+
"light": {
|
|
1481
|
+
"value": "#0f766e",
|
|
1482
|
+
"type": "color"
|
|
1483
|
+
}
|
|
1484
|
+
},
|
|
1485
|
+
"code-property": {
|
|
1486
|
+
"by": "mode",
|
|
1487
|
+
"dark": {
|
|
1488
|
+
"ref": "swatch-sky",
|
|
1489
|
+
"type": "color",
|
|
1490
|
+
"description": "Property keys and attribute names in highlighted code."
|
|
1491
|
+
},
|
|
1492
|
+
"light": {
|
|
1493
|
+
"value": "#0369a1",
|
|
1494
|
+
"type": "color"
|
|
1495
|
+
}
|
|
1496
|
+
},
|
|
1497
|
+
"code-name": {
|
|
1498
|
+
"by": "mode",
|
|
1499
|
+
"dark": {
|
|
1500
|
+
"ref": "swatch-rose",
|
|
1501
|
+
"type": "color",
|
|
1502
|
+
"description": "Functions, classes and other names in highlighted code."
|
|
1503
|
+
},
|
|
1504
|
+
"light": {
|
|
1505
|
+
"value": "#be123c",
|
|
1506
|
+
"type": "color"
|
|
1507
|
+
}
|
|
1399
1508
|
}
|
|
1400
1509
|
},
|
|
1401
1510
|
"components": {
|
|
@@ -1904,14 +2013,30 @@ var THEME_SOURCES = {
|
|
|
1904
2013
|
"description": "How far past a range thumb's edge a press still grabs the thumb rather than landing on the track. Sits over the track's own slop."
|
|
1905
2014
|
},
|
|
1906
2015
|
"slider-track-mix": {
|
|
1907
|
-
"
|
|
1908
|
-
"
|
|
1909
|
-
|
|
2016
|
+
"by": "mode",
|
|
2017
|
+
"dark": {
|
|
2018
|
+
"value": "40%",
|
|
2019
|
+
"type": "dimension",
|
|
2020
|
+
"description": "Proportion of accent-fg in a range track, as a color-mix percentage \u2014 not a color. Mixed into a real property, never into another custom property. Higher in dark mode, where a light tint of the accent sinks into the surface."
|
|
2021
|
+
},
|
|
2022
|
+
"light": {
|
|
2023
|
+
"value": "18%",
|
|
2024
|
+
"type": "dimension",
|
|
2025
|
+
"description": "Proportion of accent-fg in a range track, as a color-mix percentage \u2014 not a color."
|
|
2026
|
+
}
|
|
1910
2027
|
},
|
|
1911
2028
|
"slider-thumb-mix": {
|
|
1912
|
-
"
|
|
1913
|
-
"
|
|
1914
|
-
|
|
2029
|
+
"by": "mode",
|
|
2030
|
+
"dark": {
|
|
2031
|
+
"value": "100%",
|
|
2032
|
+
"type": "dimension",
|
|
2033
|
+
"description": "Proportion of accent-fg in a range thumb, as a color-mix percentage \u2014 not a color. Solid in dark mode."
|
|
2034
|
+
},
|
|
2035
|
+
"light": {
|
|
2036
|
+
"value": "70%",
|
|
2037
|
+
"type": "dimension",
|
|
2038
|
+
"description": "Proportion of accent-fg in a range thumb, as a color-mix percentage \u2014 not a color."
|
|
2039
|
+
}
|
|
1915
2040
|
},
|
|
1916
2041
|
"handle-size": {
|
|
1917
2042
|
"value": "9px",
|
|
@@ -2645,6 +2770,78 @@ var BAKED_THEMES = {
|
|
|
2645
2770
|
"value": "rgba(0, 0, 0, 0.18)"
|
|
2646
2771
|
}
|
|
2647
2772
|
},
|
|
2773
|
+
"code-keyword": {
|
|
2774
|
+
"by": "mode",
|
|
2775
|
+
"dark": {
|
|
2776
|
+
"type": "color",
|
|
2777
|
+
"value": "{swatch-violet}",
|
|
2778
|
+
"description": "Keywords in highlighted code."
|
|
2779
|
+
},
|
|
2780
|
+
"light": {
|
|
2781
|
+
"type": "color",
|
|
2782
|
+
"value": "#6d28d9"
|
|
2783
|
+
}
|
|
2784
|
+
},
|
|
2785
|
+
"code-string": {
|
|
2786
|
+
"by": "mode",
|
|
2787
|
+
"dark": {
|
|
2788
|
+
"type": "color",
|
|
2789
|
+
"value": "{swatch-green}",
|
|
2790
|
+
"description": "String literals in highlighted code."
|
|
2791
|
+
},
|
|
2792
|
+
"light": {
|
|
2793
|
+
"type": "color",
|
|
2794
|
+
"value": "#15803d"
|
|
2795
|
+
}
|
|
2796
|
+
},
|
|
2797
|
+
"code-number": {
|
|
2798
|
+
"by": "mode",
|
|
2799
|
+
"dark": {
|
|
2800
|
+
"type": "color",
|
|
2801
|
+
"value": "{swatch-amber}",
|
|
2802
|
+
"description": "Numbers in highlighted code."
|
|
2803
|
+
},
|
|
2804
|
+
"light": {
|
|
2805
|
+
"type": "color",
|
|
2806
|
+
"value": "#b45309"
|
|
2807
|
+
}
|
|
2808
|
+
},
|
|
2809
|
+
"code-constant": {
|
|
2810
|
+
"by": "mode",
|
|
2811
|
+
"dark": {
|
|
2812
|
+
"type": "color",
|
|
2813
|
+
"value": "{swatch-teal}",
|
|
2814
|
+
"description": "true, false, null and undefined in highlighted code."
|
|
2815
|
+
},
|
|
2816
|
+
"light": {
|
|
2817
|
+
"type": "color",
|
|
2818
|
+
"value": "#0f766e"
|
|
2819
|
+
}
|
|
2820
|
+
},
|
|
2821
|
+
"code-property": {
|
|
2822
|
+
"by": "mode",
|
|
2823
|
+
"dark": {
|
|
2824
|
+
"type": "color",
|
|
2825
|
+
"value": "{swatch-sky}",
|
|
2826
|
+
"description": "Property keys and attribute names in highlighted code."
|
|
2827
|
+
},
|
|
2828
|
+
"light": {
|
|
2829
|
+
"type": "color",
|
|
2830
|
+
"value": "#0369a1"
|
|
2831
|
+
}
|
|
2832
|
+
},
|
|
2833
|
+
"code-name": {
|
|
2834
|
+
"by": "mode",
|
|
2835
|
+
"dark": {
|
|
2836
|
+
"type": "color",
|
|
2837
|
+
"value": "{swatch-rose}",
|
|
2838
|
+
"description": "Functions, classes and other names in highlighted code."
|
|
2839
|
+
},
|
|
2840
|
+
"light": {
|
|
2841
|
+
"type": "color",
|
|
2842
|
+
"value": "#be123c"
|
|
2843
|
+
}
|
|
2844
|
+
},
|
|
2648
2845
|
"panel-surface": {
|
|
2649
2846
|
"type": "color",
|
|
2650
2847
|
"value": "{surface-raised}",
|
|
@@ -3032,14 +3229,30 @@ var BAKED_THEMES = {
|
|
|
3032
3229
|
"description": "How far past a range thumb's edge a press still grabs the thumb rather than landing on the track. Sits over the track's own slop."
|
|
3033
3230
|
},
|
|
3034
3231
|
"slider-track-mix": {
|
|
3035
|
-
"
|
|
3036
|
-
"
|
|
3037
|
-
|
|
3232
|
+
"by": "mode",
|
|
3233
|
+
"dark": {
|
|
3234
|
+
"type": "dimension",
|
|
3235
|
+
"value": "40%",
|
|
3236
|
+
"description": "Proportion of accent-fg in a range track, as a color-mix percentage \u2014 not a color. Mixed into a real property, never into another custom property. Higher in dark mode, where a light tint of the accent sinks into the surface."
|
|
3237
|
+
},
|
|
3238
|
+
"light": {
|
|
3239
|
+
"type": "dimension",
|
|
3240
|
+
"value": "18%",
|
|
3241
|
+
"description": "Proportion of accent-fg in a range track, as a color-mix percentage \u2014 not a color."
|
|
3242
|
+
}
|
|
3038
3243
|
},
|
|
3039
3244
|
"slider-thumb-mix": {
|
|
3040
|
-
"
|
|
3041
|
-
"
|
|
3042
|
-
|
|
3245
|
+
"by": "mode",
|
|
3246
|
+
"dark": {
|
|
3247
|
+
"type": "dimension",
|
|
3248
|
+
"value": "100%",
|
|
3249
|
+
"description": "Proportion of accent-fg in a range thumb, as a color-mix percentage \u2014 not a color. Solid in dark mode."
|
|
3250
|
+
},
|
|
3251
|
+
"light": {
|
|
3252
|
+
"type": "dimension",
|
|
3253
|
+
"value": "70%",
|
|
3254
|
+
"description": "Proportion of accent-fg in a range thumb, as a color-mix percentage \u2014 not a color."
|
|
3255
|
+
}
|
|
3043
3256
|
},
|
|
3044
3257
|
"handle-size": {
|
|
3045
3258
|
"type": "dimension",
|
|
@@ -3312,9 +3525,7 @@ var BAKED_THEMES = {
|
|
|
3312
3525
|
}
|
|
3313
3526
|
}
|
|
3314
3527
|
};
|
|
3315
|
-
|
|
3316
|
-
// src/theme.ts
|
|
3317
|
-
var isPinObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v) && "value" in v;
|
|
3528
|
+
var isPinObject = (v) => isPlainObject(v) && "value" in v;
|
|
3318
3529
|
function toRaw(v) {
|
|
3319
3530
|
if (isByAxis(v)) {
|
|
3320
3531
|
const out = { by: v.by };
|
|
@@ -3355,45 +3566,94 @@ function defineTheme(input) {
|
|
|
3355
3566
|
};
|
|
3356
3567
|
}
|
|
3357
3568
|
|
|
3358
|
-
// src/
|
|
3569
|
+
// src/themeSheet.ts
|
|
3359
3570
|
var STYLE_ID = "wzl-themes";
|
|
3360
|
-
var
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
return typeof CSSStyleSheet !== "undefined" && "replaceSync" in CSSStyleSheet.prototype && Array.isArray(document.adoptedStyleSheets);
|
|
3571
|
+
var sheets = /* @__PURE__ */ new WeakMap();
|
|
3572
|
+
function styleRootOf(el) {
|
|
3573
|
+
const root = el.getRootNode();
|
|
3574
|
+
return root instanceof (el.ownerDocument.defaultView?.ShadowRoot ?? ShadowRoot) ? root : el.ownerDocument;
|
|
3365
3575
|
}
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3576
|
+
var documentOf = (root) => "host" in root ? root.ownerDocument : root;
|
|
3577
|
+
var only = (id) => id === 0 ? "" : `:where([data-wzl-variant='${id}'])`;
|
|
3578
|
+
function write(root, held) {
|
|
3579
|
+
const css = [...held.rules].flatMap(([selector, variants]) => (
|
|
3580
|
+
// The bare rule first: it matches a variant's elements too, and the variant's has to win the tie.
|
|
3581
|
+
[...variants].sort((a, b) => a.id - b.id).map((v) => `${selector}${only(v.id)} { ${v.body} }`)
|
|
3582
|
+
)).join("\n");
|
|
3583
|
+
const win = documentOf(root).defaultView;
|
|
3584
|
+
const Sheet = win?.CSSStyleSheet;
|
|
3585
|
+
if (Sheet && "replaceSync" in Sheet.prototype && Array.isArray(root.adoptedStyleSheets)) {
|
|
3586
|
+
if (!held.sheet) {
|
|
3587
|
+
held.sheet = new Sheet();
|
|
3588
|
+
root.adoptedStyleSheets = [...root.adoptedStyleSheets, held.sheet];
|
|
3372
3589
|
}
|
|
3373
|
-
sheet.replaceSync(css);
|
|
3590
|
+
held.sheet.replaceSync(css);
|
|
3374
3591
|
return;
|
|
3375
3592
|
}
|
|
3376
|
-
if (!styleEl) {
|
|
3377
|
-
styleEl =
|
|
3378
|
-
styleEl.id = STYLE_ID;
|
|
3379
|
-
|
|
3593
|
+
if (!held.styleEl) {
|
|
3594
|
+
held.styleEl = documentOf(root).createElement("style");
|
|
3595
|
+
held.styleEl.id = STYLE_ID;
|
|
3596
|
+
("host" in root ? root : root.head).appendChild(held.styleEl);
|
|
3597
|
+
}
|
|
3598
|
+
held.styleEl.textContent = css;
|
|
3599
|
+
}
|
|
3600
|
+
function holdRule(root, selector, body) {
|
|
3601
|
+
let held = sheets.get(root);
|
|
3602
|
+
if (!held) sheets.set(root, held = { rules: /* @__PURE__ */ new Map(), sheet: null, styleEl: null });
|
|
3603
|
+
const variants = held.rules.get(selector) ?? [];
|
|
3604
|
+
let variant = variants.find((v) => v.body === body);
|
|
3605
|
+
if (variant) {
|
|
3606
|
+
variant.holds++;
|
|
3607
|
+
} else {
|
|
3608
|
+
let id = 0;
|
|
3609
|
+
while (variants.some((v) => v.id === id)) id++;
|
|
3610
|
+
variant = { id, body, holds: 1 };
|
|
3611
|
+
held.rules.set(selector, [...variants, variant]);
|
|
3612
|
+
write(root, held);
|
|
3380
3613
|
}
|
|
3381
|
-
|
|
3614
|
+
const mine = variant;
|
|
3615
|
+
const sheet = held;
|
|
3616
|
+
let released = false;
|
|
3617
|
+
return {
|
|
3618
|
+
variant: mine.id,
|
|
3619
|
+
release: () => {
|
|
3620
|
+
if (released) return;
|
|
3621
|
+
released = true;
|
|
3622
|
+
if (--mine.holds > 0) return;
|
|
3623
|
+
const left = (sheet.rules.get(selector) ?? []).filter((v) => v !== mine);
|
|
3624
|
+
if (left.length > 0) sheet.rules.set(selector, left);
|
|
3625
|
+
else sheet.rules.delete(selector);
|
|
3626
|
+
write(root, sheet);
|
|
3627
|
+
}
|
|
3628
|
+
};
|
|
3382
3629
|
}
|
|
3630
|
+
|
|
3631
|
+
// src/applyTheme.ts
|
|
3632
|
+
var holds = /* @__PURE__ */ new WeakMap();
|
|
3383
3633
|
function applyTheme(el, theme, selection = {}) {
|
|
3384
|
-
if (typeof document === "undefined") return
|
|
3634
|
+
if (typeof document === "undefined") return () => {
|
|
3635
|
+
};
|
|
3385
3636
|
const axes = themeAxes(theme);
|
|
3386
3637
|
const sel = fullSelection(axes, selection);
|
|
3387
|
-
const key = `${theme.name}::${selectionKey(axes, sel)}`;
|
|
3388
3638
|
const body = Object.entries(resolveTheme(theme, sel)).map(([name, value]) => `${name}: ${value};`).join(" ");
|
|
3389
|
-
const
|
|
3390
|
-
const
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
flushRules();
|
|
3394
|
-
}
|
|
3639
|
+
const names = Object.keys(axes);
|
|
3640
|
+
const selector = `[data-wzl-theme='${theme.name}']${names.map((a) => `[data-wzl-${a}='${sel[a]}']`).join("")}`;
|
|
3641
|
+
const { variant, release: releaseRule } = holdRule(styleRootOf(el), selector, body);
|
|
3642
|
+
holds.get(el)?.();
|
|
3395
3643
|
el.setAttribute("data-wzl-theme", theme.name);
|
|
3396
|
-
for (const a of
|
|
3644
|
+
for (const a of names) el.setAttribute(`data-wzl-${a}`, sel[a]);
|
|
3645
|
+
if (variant === 0) el.removeAttribute("data-wzl-variant");
|
|
3646
|
+
else el.setAttribute("data-wzl-variant", String(variant));
|
|
3647
|
+
const letGo = () => {
|
|
3648
|
+
holds.delete(el);
|
|
3649
|
+
releaseRule();
|
|
3650
|
+
};
|
|
3651
|
+
holds.set(el, letGo);
|
|
3652
|
+
return () => {
|
|
3653
|
+
if (holds.get(el) !== letGo) return;
|
|
3654
|
+
letGo();
|
|
3655
|
+
for (const a of ["theme", "variant", ...names]) el.removeAttribute(`data-wzl-${a}`);
|
|
3656
|
+
};
|
|
3397
3657
|
}
|
|
3398
3658
|
|
|
3399
3659
|
// src/colorMode.ts
|
|
@@ -3449,5 +3709,5 @@ function colorCount(list, ctx = defaultContext()) {
|
|
|
3449
3709
|
}
|
|
3450
3710
|
|
|
3451
3711
|
export { BAKED_THEMES, THEMES, THEME_SOURCES, applyTheme, colorAt, colorCount, colorCssAt, defineTheme, isColorModePreference, rampSteps, themeTones, weaselTheme };
|
|
3452
|
-
//# sourceMappingURL=chunk-
|
|
3453
|
-
//# sourceMappingURL=chunk-
|
|
3712
|
+
//# sourceMappingURL=chunk-EFGZ56CE.js.map
|
|
3713
|
+
//# sourceMappingURL=chunk-EFGZ56CE.js.map
|