@cscfi/csc-ui 4.0.0-alpha.17 → 4.0.0-alpha.19
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/csc-ui.js +2844 -2813
- package/dist/custom-elements.json +11 -4
- package/dist/docs/c-main/usage.md +2 -2
- package/dist/docs/c-side-navigation/usage.md +21 -0
- package/dist/styles/css/tailwind-theme.css +1 -0
- package/dist/styles/css/tokens.css +18 -5
- package/dist/vscode.css-custom-data.json +9 -1
- package/dist/vscode.html-custom-data.json +2 -2
- package/dist/web-types.json +19 -6
- package/dist-types/index.d.ts +1 -1
- package/dist-types/tag-name-map.d.ts +1 -0
- package/dist-types/theme/chart-data.d.ts +2 -1
- package/dist-types/theme/themeMode.d.ts +31 -8
- package/package.json +1 -1
|
@@ -6057,7 +6057,12 @@
|
|
|
6057
6057
|
"description": "The main element carrying the page canvas and the dashboard grid layout"
|
|
6058
6058
|
}
|
|
6059
6059
|
],
|
|
6060
|
-
"cssProperties": [
|
|
6060
|
+
"cssProperties": [
|
|
6061
|
+
{
|
|
6062
|
+
"name": "--c-main-viewport-height",
|
|
6063
|
+
"description": "Height of the scroll viewport the layout pins against (default `100dvh`); a bounded shell with its own scrollbar sets it to its box height"
|
|
6064
|
+
}
|
|
6065
|
+
],
|
|
6061
6066
|
"cssStates": [],
|
|
6062
6067
|
"events": [],
|
|
6063
6068
|
"members": [
|
|
@@ -9107,7 +9112,9 @@
|
|
|
9107
9112
|
"kind": "class",
|
|
9108
9113
|
"name": "CSideNavigation",
|
|
9109
9114
|
"tagName": "c-side-navigation",
|
|
9115
|
+
"description": "The dashboard layout's left-hand menu: section titles, navigation items and their sub-items in a drawer that is pinned beside the page on desktop and slides in over it on mobile.",
|
|
9110
9116
|
"csc": {
|
|
9117
|
+
"usage": "docs/c-side-navigation/usage.md",
|
|
9111
9118
|
"subcomponents": [
|
|
9112
9119
|
"c-side-navigation-item",
|
|
9113
9120
|
"c-side-navigation-title",
|
|
@@ -9137,7 +9144,7 @@
|
|
|
9137
9144
|
"cssParts": [
|
|
9138
9145
|
{
|
|
9139
9146
|
"name": "root",
|
|
9140
|
-
"description": "The outer drawer container"
|
|
9147
|
+
"description": "The outer drawer container: the item list above the bottom slot's region"
|
|
9141
9148
|
},
|
|
9142
9149
|
{
|
|
9143
9150
|
"name": "nav",
|
|
@@ -9190,11 +9197,11 @@
|
|
|
9190
9197
|
"slots": [
|
|
9191
9198
|
{
|
|
9192
9199
|
"name": "default",
|
|
9193
|
-
"description": "
|
|
9200
|
+
"description": "The navigation items: titles, items and their sub-items"
|
|
9194
9201
|
},
|
|
9195
9202
|
{
|
|
9196
9203
|
"name": "bottom",
|
|
9197
|
-
"description": "
|
|
9204
|
+
"description": "Trailing content below the items, such as a sign-out button; it stays at the drawer's bottom edge while the items scroll"
|
|
9198
9205
|
}
|
|
9199
9206
|
]
|
|
9200
9207
|
}
|
|
@@ -2,7 +2,7 @@ The page shell of an application: it paints the page canvas and lays out the too
|
|
|
2
2
|
|
|
3
3
|
## Dashboard layout
|
|
4
4
|
|
|
5
|
-
Slot the layout components as direct children and `c-main` places them: `c-toolbar` spans the top, `c-side-navigation` takes the left column and `c-page` fills the rest. The toolbar pins itself to the top of the viewport; `c-main` pins the desktop side navigation beneath it
|
|
5
|
+
Slot the layout components as direct children and `c-main` places them: `c-toolbar` spans the top, `c-side-navigation` takes the left column and `c-page` fills the rest. The toolbar pins itself to the top of the viewport; `c-main` pins the desktop side navigation beneath it and moves its pin to the top edge when the toolbar is `static`. The drawer is sized to the pinned height: a short menu fills the column, a long one scrolls inside the drawer, and the side navigation's bottom slot stays at the bottom edge of the viewport — also while a banner or a static toolbar is still above the drawer. The 3.x `autoheight` host class is ignored here, and the mobile drawer is not touched.
|
|
6
6
|
|
|
7
7
|
## Banner
|
|
8
8
|
|
|
@@ -18,4 +18,4 @@ The document scrolls, so browser scroll restoration, anchors, find-in-page and m
|
|
|
18
18
|
|
|
19
19
|
## Customization
|
|
20
20
|
|
|
21
|
-
Structural styling via `::part(root)`. To show the layout inside a bounded box — a demo, a preview — give the part a height together with `min-height: 0` and `overflow-y: auto
|
|
21
|
+
Structural styling via `::part(root)`. To show the layout inside a bounded box — a demo, a preview — give the part a height together with `min-height: 0` and `overflow-y: auto`, and set `--c-main-viewport-height` to the same height so the pinned side navigation is sized to the box instead of the viewport; the toolbar and side navigation then pin inside that box.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The dashboard layout's left-hand menu: section titles, navigation items and their sub-items in a drawer that is pinned beside the page on desktop and slides in over it on mobile.
|
|
2
|
+
|
|
3
|
+
## Inside c-main
|
|
4
|
+
|
|
5
|
+
Slot it as a direct child of `c-main` and the dashboard layout places and pins it: the drawer sits beneath the toolbar — or at the top edge once a `static` toolbar has scrolled away — is sized to the pinned height, and scrolls a long menu on its own. No host class is needed; the 3.x `autoheight` class is ignored there.
|
|
6
|
+
|
|
7
|
+
## Bottom slot
|
|
8
|
+
|
|
9
|
+
Trailing content — a sign-out button, a help link — goes in the `bottom` slot. It stays at the drawer's bottom edge while the items scroll above it: the viewport's bottom edge on desktop, the panel's in the mobile drawer. It is reached without scrolling the menu and is not a menu item.
|
|
10
|
+
|
|
11
|
+
## Mobile
|
|
12
|
+
|
|
13
|
+
Set `mobile` to render the drawer as a panel that slides in from the right over a backdrop. `menu-visible` opens and closes it, and a `c-navigation-button` anywhere on the page toggles it. Closing from within — the close button or the backdrop — emits `change:menu-visible`.
|
|
14
|
+
|
|
15
|
+
## Standalone
|
|
16
|
+
|
|
17
|
+
Outside `c-main` the drawer is an ordinary block that grows with its items. The `autoheight` host class sizes it to the viewport minus the toolbar height and lets its item list scroll, for a shell that pins the drawer itself.
|
|
18
|
+
|
|
19
|
+
## Customization
|
|
20
|
+
|
|
21
|
+
Structural styling via `::part(root)` (the drawer) and `::part(nav)` (the scrolling item list). The surface is the `nav-surface` token role; override the tokens to re-theme.
|
|
@@ -113,6 +113,7 @@
|
|
|
113
113
|
--color-on-nav: var(--c-on-nav);
|
|
114
114
|
--color-nav-active: var(--c-nav-active);
|
|
115
115
|
--color-on-nav-active: var(--c-on-nav-active);
|
|
116
|
+
--color-nav-sub-active: var(--c-nav-sub-active);
|
|
116
117
|
|
|
117
118
|
--color-logo-wordmark: var(--c-logo-wordmark);
|
|
118
119
|
--color-logo-teal: var(--c-logo-teal);
|
|
@@ -134,6 +134,12 @@
|
|
|
134
134
|
* Semantic tokens. Role-named properties that resolve to a
|
|
135
135
|
* different palette step per theme mode; components author against the
|
|
136
136
|
* per-role color utilities the @theme inline map in tailwind.css exposes.
|
|
137
|
+
*
|
|
138
|
+
* The mode selectors are not anchored to :root — any element carrying
|
|
139
|
+
* data-theme="light" or "dark" opens a mode scope for its subtree, and the
|
|
140
|
+
* nearest enclosing scope wins (ADR-0053). Block order is load-bearing:
|
|
141
|
+
* :root and [data-theme='dark'] have equal specificity, so dark must stay
|
|
142
|
+
* last. See utils/createSemanticTheme.cjs for the full cascade rationale.
|
|
137
143
|
*/
|
|
138
144
|
|
|
139
145
|
/* Mode-invariant roles (identical in light and dark). */
|
|
@@ -145,8 +151,10 @@
|
|
|
145
151
|
--c-scrim: var(--c-black);
|
|
146
152
|
}
|
|
147
153
|
|
|
154
|
+
/* Light is the default; any element may open a light mode scope. */
|
|
148
155
|
:root,
|
|
149
|
-
|
|
156
|
+
[data-theme='light'] {
|
|
157
|
+
color-scheme: light;
|
|
150
158
|
--c-surface: var(--c-white);
|
|
151
159
|
--c-surface-raised: var(--c-white);
|
|
152
160
|
--c-surface-overlay: var(--c-white);
|
|
@@ -220,6 +228,7 @@
|
|
|
220
228
|
--c-on-nav: var(--c-white);
|
|
221
229
|
--c-nav-active: var(--c-primary-100);
|
|
222
230
|
--c-on-nav-active: var(--c-primary-700);
|
|
231
|
+
--c-nav-sub-active: var(--c-white);
|
|
223
232
|
--c-chart-1: oklch(0.6534 0.1710 247.9336);
|
|
224
233
|
--c-chart-2: oklch(0.5906 0.1462 343.7182);
|
|
225
234
|
--c-chart-3: oklch(0.6697 0.1291 89.0072);
|
|
@@ -240,8 +249,9 @@
|
|
|
240
249
|
--c-logo-magenta: oklch(0.4006 0.1660 351.9773);
|
|
241
250
|
}
|
|
242
251
|
|
|
243
|
-
/* Explicit dark mode (wins over the OS preference). */
|
|
244
|
-
|
|
252
|
+
/* Explicit dark, at the root or in any mode scope (wins over the OS preference). */
|
|
253
|
+
[data-theme='dark'] {
|
|
254
|
+
color-scheme: dark;
|
|
245
255
|
--c-surface: var(--c-slate-800);
|
|
246
256
|
--c-surface-raised: var(--c-slate-800);
|
|
247
257
|
--c-surface-overlay: var(--c-slate-700);
|
|
@@ -315,6 +325,7 @@
|
|
|
315
325
|
--c-on-nav: var(--c-primary-100);
|
|
316
326
|
--c-nav-active: var(--c-primary-500);
|
|
317
327
|
--c-on-nav-active: var(--c-white);
|
|
328
|
+
--c-nav-sub-active: color-mix(in srgb, var(--c-white) 18%, transparent);
|
|
318
329
|
--c-chart-1: oklch(0.6504 0.1710 247.9858);
|
|
319
330
|
--c-chart-2: oklch(0.5920 0.1445 343.8493);
|
|
320
331
|
--c-chart-3: oklch(0.6696 0.1303 89.2281);
|
|
@@ -335,9 +346,10 @@
|
|
|
335
346
|
--c-logo-magenta: var(--c-white);
|
|
336
347
|
}
|
|
337
348
|
|
|
338
|
-
/* OS dark preference, only when
|
|
349
|
+
/* OS dark preference, only when the root pins no mode. */
|
|
339
350
|
@media (prefers-color-scheme: dark) {
|
|
340
|
-
:root:not([data-theme]) {
|
|
351
|
+
:root:not([data-theme='light']):not([data-theme='dark']) {
|
|
352
|
+
color-scheme: dark;
|
|
341
353
|
--c-surface: var(--c-slate-800);
|
|
342
354
|
--c-surface-raised: var(--c-slate-800);
|
|
343
355
|
--c-surface-overlay: var(--c-slate-700);
|
|
@@ -411,6 +423,7 @@
|
|
|
411
423
|
--c-on-nav: var(--c-primary-100);
|
|
412
424
|
--c-nav-active: var(--c-primary-500);
|
|
413
425
|
--c-on-nav-active: var(--c-white);
|
|
426
|
+
--c-nav-sub-active: color-mix(in srgb, var(--c-white) 18%, transparent);
|
|
414
427
|
--c-chart-1: oklch(0.6504 0.1710 247.9858);
|
|
415
428
|
--c-chart-2: oklch(0.5920 0.1445 343.8493);
|
|
416
429
|
--c-chart-3: oklch(0.6696 0.1303 89.2281);
|
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
"name": "--c-font-family",
|
|
7
7
|
"description": "Font stack applied to the label (native buttons do not inherit it).",
|
|
8
8
|
"values": []
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "--c-main-viewport-height",
|
|
12
|
+
"description": "Height of the scroll viewport the layout pins against (default `100dvh`); a bounded shell with its own scrollbar sets it to its box height",
|
|
13
|
+
"values": []
|
|
9
14
|
}
|
|
10
15
|
],
|
|
11
16
|
"pseudoElements": [
|
|
@@ -577,7 +582,10 @@
|
|
|
577
582
|
"name": "::part(tag-root)",
|
|
578
583
|
"description": "The pill box inside each tag (the `c-tag` `root` part), for colours and borders"
|
|
579
584
|
},
|
|
580
|
-
{
|
|
585
|
+
{
|
|
586
|
+
"name": "::part(root)",
|
|
587
|
+
"description": "The outer drawer container: the item list above the bottom slot's region"
|
|
588
|
+
},
|
|
581
589
|
{
|
|
582
590
|
"name": "::part(nav)",
|
|
583
591
|
"description": "The scrollable `<nav>` element holding the navigation items"
|
|
@@ -937,7 +937,7 @@
|
|
|
937
937
|
},
|
|
938
938
|
{
|
|
939
939
|
"name": "c-main",
|
|
940
|
-
"description": "The page shell of an application: it paints the page canvas and lays out the toolbar, the side navigation and the page in the dashboard layout. It is at least a viewport tall and grows with its content, so the document — not a component — is what scrolls.\n---\n\n\n### **Slots:**\n - **default** - Contents of the page: the toolbar, side navigation and page\n- **banner** - A full-width message strip above the toolbar; it scrolls away with the page\n\n### **CSS Parts:**\n - **root** - The main element carrying the page canvas and the dashboard grid layout",
|
|
940
|
+
"description": "The page shell of an application: it paints the page canvas and lays out the toolbar, the side navigation and the page in the dashboard layout. It is at least a viewport tall and grows with its content, so the document — not a component — is what scrolls.\n---\n\n\n### **Slots:**\n - **default** - Contents of the page: the toolbar, side navigation and page\n- **banner** - A full-width message strip above the toolbar; it scrolls away with the page\n\n### **CSS Properties:**\n - **--c-main-viewport-height** - Height of the scroll viewport the layout pins against (default `100dvh`); a bounded shell with its own scrollbar sets it to its box height _(default: undefined)_\n\n### **CSS Parts:**\n - **root** - The main element carrying the page canvas and the dashboard grid layout",
|
|
941
941
|
"attributes": [
|
|
942
942
|
{
|
|
943
943
|
"name": "disable-layout",
|
|
@@ -1461,7 +1461,7 @@
|
|
|
1461
1461
|
},
|
|
1462
1462
|
{
|
|
1463
1463
|
"name": "c-side-navigation",
|
|
1464
|
-
"description": "
|
|
1464
|
+
"description": "The dashboard layout's left-hand menu: section titles, navigation items and their sub-items in a drawer that is pinned beside the page on desktop and slides in over it on mobile.\n---\n\n\n### **Events:**\n - **change:menu-visible** - Fired when the drawer is closed from within (the mobile close button or\nthe backdrop overlay), carrying the new visibility (`false`).\nNamed `change:menu-visible`, not `update:menuVisible`: Vue's runtime\nsilently drops `onUpdate:*` listeners on custom elements\n(`isModelListener`), so a template `@update:menu-visible` would never be\nattached.\n\n### **Slots:**\n - **default** - The navigation items: titles, items and their sub-items\n- **bottom** - Trailing content below the items, such as a sign-out button; it stays at the drawer's bottom edge while the items scroll\n\n### **CSS Parts:**\n - **root** - The outer drawer container: the item list above the bottom slot's region\n- **nav** - The scrollable `<nav>` element holding the navigation items",
|
|
1465
1465
|
"attributes": [
|
|
1466
1466
|
{
|
|
1467
1467
|
"name": "menu-visible",
|
package/dist/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
|
|
3
3
|
"name": "@cscfi/csc-ui",
|
|
4
|
-
"version": "4.0.0-alpha.
|
|
4
|
+
"version": "4.0.0-alpha.19",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -2456,7 +2456,7 @@
|
|
|
2456
2456
|
},
|
|
2457
2457
|
{
|
|
2458
2458
|
"name": "c-main",
|
|
2459
|
-
"description": "The page shell of an application: it paints the page canvas and lays out the toolbar, the side navigation and the page in the dashboard layout. It is at least a viewport tall and grows with its content, so the document — not a component — is what scrolls.\n---\n\n\n### **Slots:**\n - **default** - Contents of the page: the toolbar, side navigation and page\n- **banner** - A full-width message strip above the toolbar; it scrolls away with the page\n\n### **CSS Parts:**\n - **root** - The main element carrying the page canvas and the dashboard grid layout",
|
|
2459
|
+
"description": "The page shell of an application: it paints the page canvas and lays out the toolbar, the side navigation and the page in the dashboard layout. It is at least a viewport tall and grows with its content, so the document — not a component — is what scrolls.\n---\n\n\n### **Slots:**\n - **default** - Contents of the page: the toolbar, side navigation and page\n- **banner** - A full-width message strip above the toolbar; it scrolls away with the page\n\n### **CSS Properties:**\n - **--c-main-viewport-height** - Height of the scroll viewport the layout pins against (default `100dvh`); a bounded shell with its own scrollbar sets it to its box height _(default: undefined)_\n\n### **CSS Parts:**\n - **root** - The main element carrying the page canvas and the dashboard grid layout",
|
|
2460
2460
|
"doc-url": "",
|
|
2461
2461
|
"attributes": [
|
|
2462
2462
|
{
|
|
@@ -3858,7 +3858,7 @@
|
|
|
3858
3858
|
},
|
|
3859
3859
|
{
|
|
3860
3860
|
"name": "c-side-navigation",
|
|
3861
|
-
"description": "
|
|
3861
|
+
"description": "The dashboard layout's left-hand menu: section titles, navigation items and their sub-items in a drawer that is pinned beside the page on desktop and slides in over it on mobile.\n---\n\n\n### **Events:**\n - **change:menu-visible** - Fired when the drawer is closed from within (the mobile close button or\nthe backdrop overlay), carrying the new visibility (`false`).\nNamed `change:menu-visible`, not `update:menuVisible`: Vue's runtime\nsilently drops `onUpdate:*` listeners on custom elements\n(`isModelListener`), so a template `@update:menu-visible` would never be\nattached.\n\n### **Slots:**\n - **default** - The navigation items: titles, items and their sub-items\n- **bottom** - Trailing content below the items, such as a sign-out button; it stays at the drawer's bottom edge while the items scroll\n\n### **CSS Parts:**\n - **root** - The outer drawer container: the item list above the bottom slot's region\n- **nav** - The scrollable `<nav>` element holding the navigation items",
|
|
3862
3862
|
"doc-url": "",
|
|
3863
3863
|
"attributes": [
|
|
3864
3864
|
{
|
|
@@ -3873,8 +3873,14 @@
|
|
|
3873
3873
|
}
|
|
3874
3874
|
],
|
|
3875
3875
|
"slots": [
|
|
3876
|
-
{
|
|
3877
|
-
|
|
3876
|
+
{
|
|
3877
|
+
"name": "default",
|
|
3878
|
+
"description": "The navigation items: titles, items and their sub-items"
|
|
3879
|
+
},
|
|
3880
|
+
{
|
|
3881
|
+
"name": "bottom",
|
|
3882
|
+
"description": "Trailing content below the items, such as a sign-out button; it stays at the drawer's bottom edge while the items scroll"
|
|
3883
|
+
}
|
|
3878
3884
|
],
|
|
3879
3885
|
"events": [
|
|
3880
3886
|
{
|
|
@@ -5848,6 +5854,10 @@
|
|
|
5848
5854
|
{
|
|
5849
5855
|
"name": "--c-font-family",
|
|
5850
5856
|
"description": "Font stack applied to the label (native buttons do not inherit it)."
|
|
5857
|
+
},
|
|
5858
|
+
{
|
|
5859
|
+
"name": "--c-main-viewport-height",
|
|
5860
|
+
"description": "Height of the scroll viewport the layout pins against (default `100dvh`); a bounded shell with its own scrollbar sets it to its box height"
|
|
5851
5861
|
}
|
|
5852
5862
|
],
|
|
5853
5863
|
"pseudo-elements": [
|
|
@@ -6431,7 +6441,10 @@
|
|
|
6431
6441
|
"name": "part(tag-root)",
|
|
6432
6442
|
"description": "The pill box inside each tag (the `c-tag` `root` part), for colours and borders"
|
|
6433
6443
|
},
|
|
6434
|
-
{
|
|
6444
|
+
{
|
|
6445
|
+
"name": "part(root)",
|
|
6446
|
+
"description": "The outer drawer container: the item list above the bottom slot's region"
|
|
6447
|
+
},
|
|
6435
6448
|
{
|
|
6436
6449
|
"name": "part(nav)",
|
|
6437
6450
|
"description": "The scrollable `<nav>` element holding the navigation items"
|
package/dist-types/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export type { AppDefaults, DefaultableTag } from './shared/appDefaults';
|
|
|
29
29
|
export { chartAnatomy, chartAnatomyHex, chartSlots, chartSlotsHex, } from './theme/chart-data';
|
|
30
30
|
export type { ChartAnatomy, ChartSlots } from './theme/chart-data';
|
|
31
31
|
export { DEFAULT_SEEDS, FAMILIES } from './theme/ramp.js';
|
|
32
|
-
export { themeMode } from './theme/themeMode';
|
|
32
|
+
export { observeThemeMode, themeMode } from './theme/themeMode';
|
|
33
33
|
export type { ThemeMode } from './theme/themeMode';
|
|
34
34
|
export type { CFieldSize, CPlacement, CSelectItem, CToastMessage, CToastType, } from './types';
|
|
35
35
|
export { h } from 'vue';
|
|
@@ -1212,6 +1212,7 @@ export interface CSideNavigationElementEventMap {
|
|
|
1212
1212
|
*/
|
|
1213
1213
|
'change:menu-visible': CustomEvent<boolean>;
|
|
1214
1214
|
}
|
|
1215
|
+
/** The dashboard layout's left-hand menu: section titles, navigation items and their sub-items in a drawer that is pinned beside the page on desktop and slides in over it on mobile. */
|
|
1215
1216
|
export interface CSideNavigationElement extends Omit<HTMLElement, 'menuVisible' | 'mobile' | 'styles'> {
|
|
1216
1217
|
/** Mobile version menu visibility */
|
|
1217
1218
|
menuVisible?: boolean;
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* The chart tokens (ADR-0030) as importable data (ADR-0040): the twelve
|
|
8
8
|
* series slots and the chart anatomy roles per theme mode. Values are the
|
|
9
9
|
* frozen, validated set — they never follow a consumer's `--c-chart-*`
|
|
10
|
-
* overrides. Pair with `themeMode()` to pick the mode
|
|
10
|
+
* overrides. Pair with `themeMode(el)` to pick the mode in effect where the
|
|
11
|
+
* chart sits, or `observeThemeMode()` to follow it.
|
|
11
12
|
*/
|
|
12
13
|
import type { ThemeMode } from './themeMode';
|
|
13
14
|
/** The twelve series slots in slot order (`chart-1` … `chart-12`). */
|
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
/** The light-or-dark state that selects which palette the semantic tokens resolve to. */
|
|
2
2
|
export type ThemeMode = 'dark' | 'light';
|
|
3
3
|
/**
|
|
4
|
-
* Resolve the theme mode
|
|
5
|
-
* `tokens.css`:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
4
|
+
* Resolve the theme mode in effect for an element, mirroring the cascade in
|
|
5
|
+
* `tokens.css`: the nearest enclosing **mode scope** wins (an ancestor-or-self
|
|
6
|
+
* carrying `data-theme="light"` or `"dark"`, ADR-0053); otherwise the OS
|
|
7
|
+
* preference; light where neither is available (server rendering, no
|
|
8
|
+
* `matchMedia`). Any other `data-theme` value is inert, exactly as it is in CSS.
|
|
9
|
+
*
|
|
10
|
+
* Pass the element whose mode you need — a chart inside a dark panel on an
|
|
11
|
+
* otherwise light page resolves `dark` only if you ask about the chart.
|
|
12
|
+
* `observeThemeMode()` keeps that answer current.
|
|
13
|
+
*
|
|
14
|
+
* @param root the element to resolve for — defaults to `<html>`
|
|
12
15
|
*/
|
|
13
16
|
export declare function themeMode(root?: Element | null): ThemeMode;
|
|
17
|
+
/**
|
|
18
|
+
* Watch the theme mode in effect for an element and report every change.
|
|
19
|
+
*
|
|
20
|
+
* Calls `onChange` once synchronously with the current mode, then again
|
|
21
|
+
* whenever it actually changes — so wiring a chart up is the one call, with no
|
|
22
|
+
* separate initial render. Covers both paths that can change the answer: a
|
|
23
|
+
* `data-theme` attribute mutating anywhere in the document (the element's own
|
|
24
|
+
* **mode scope** or any ancestor's, which is why a `documentElement`-only
|
|
25
|
+
* observer is not enough), and the OS preference flipping while no scope pins
|
|
26
|
+
* a mode. Re-parenting `target` is not observed; re-subscribe if you move it.
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* const stop = observeThemeMode(chartEl, (mode) => {
|
|
30
|
+
* chart.setOption({ color: chartSlotsHex[mode] });
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @returns a disposer that detaches both listeners
|
|
35
|
+
*/
|
|
36
|
+
export declare function observeThemeMode(target: Element, onChange: (mode: ThemeMode) => void): () => void;
|
package/package.json
CHANGED