@tangible/ui 0.2.25 → 0.2.27

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.
@@ -1,3 +1,4 @@
1
+ @use "sass:map";
1
2
  @use "../system" as sys;
2
3
 
3
4
  /* @tui-tokens
@@ -7,13 +8,17 @@
7
8
  --tui-nav-menu-item-padding-inline
8
9
  --tui-nav-menu-item-radius
9
10
  --tui-nav-menu-item-font-size
11
+ --tui-nav-menu-item-bg
10
12
  --tui-nav-menu-item-fg
11
13
  --tui-nav-menu-item-weight
12
14
  --tui-nav-menu-item-bg-hover
13
15
  --tui-nav-menu-item-fg-hover
16
+ --tui-nav-menu-item-bg-active
17
+ --tui-nav-menu-item-fg-active
14
18
  --tui-nav-menu-item-bg-current
15
19
  --tui-nav-menu-item-fg-current
16
20
  --tui-nav-menu-item-weight-current
21
+ --tui-nav-menu-item-bg-ancestor
17
22
  --tui-nav-menu-item-fg-ancestor
18
23
  --tui-nav-menu-item-weight-ancestor
19
24
  --tui-nav-menu-item-fg-disabled
@@ -23,17 +28,93 @@
23
28
  --tui-nav-menu-sub-indent
24
29
  --tui-nav-menu-sub-border
25
30
  --tui-nav-menu-bar-gap
26
- --tui-nav-menu-bar-bg-current
27
- --tui-nav-menu-underline-width
28
- --tui-nav-menu-underline-color
29
31
  --tui-nav-menu-flyout-bg
30
32
  --tui-nav-menu-flyout-fg
31
33
  --tui-nav-menu-flyout-border
32
34
  --tui-nav-menu-flyout-radius
33
35
  --tui-nav-menu-flyout-shadow
34
36
  --tui-nav-menu-flyout-min-width
37
+ --tui-nav-menu-sub-item-bg
38
+ --tui-nav-menu-sub-item-fg
39
+ --tui-nav-menu-sub-item-weight
40
+ --tui-nav-menu-sub-item-bg-hover
41
+ --tui-nav-menu-sub-item-fg-hover
42
+ --tui-nav-menu-sub-item-bg-active
43
+ --tui-nav-menu-sub-item-fg-active
44
+ --tui-nav-menu-sub-item-bg-current
45
+ --tui-nav-menu-sub-item-fg-current
46
+ --tui-nav-menu-sub-item-weight-current
47
+ --tui-nav-menu-sub-item-bg-ancestor
48
+ --tui-nav-menu-sub-item-fg-ancestor
49
+ --tui-nav-menu-sub-item-weight-ancestor
50
+ --tui-nav-menu-sub-item-fg-disabled
51
+ --tui-nav-menu-bar-item-bg
52
+ --tui-nav-menu-bar-item-fg
53
+ --tui-nav-menu-bar-item-weight
54
+ --tui-nav-menu-bar-item-bg-hover
55
+ --tui-nav-menu-bar-item-fg-hover
56
+ --tui-nav-menu-bar-item-bg-active
57
+ --tui-nav-menu-bar-item-fg-active
58
+ --tui-nav-menu-bar-item-bg-current
59
+ --tui-nav-menu-bar-item-fg-current
60
+ --tui-nav-menu-bar-item-weight-current
61
+ --tui-nav-menu-bar-item-bg-ancestor
62
+ --tui-nav-menu-bar-item-fg-ancestor
63
+ --tui-nav-menu-bar-item-weight-ancestor
64
+ --tui-nav-menu-bar-item-fg-disabled
65
+ --tui-nav-menu-flyout-item-bg
66
+ --tui-nav-menu-flyout-item-fg
67
+ --tui-nav-menu-flyout-item-weight
68
+ --tui-nav-menu-flyout-item-bg-hover
69
+ --tui-nav-menu-flyout-item-fg-hover
70
+ --tui-nav-menu-flyout-item-bg-active
71
+ --tui-nav-menu-flyout-item-fg-active
72
+ --tui-nav-menu-flyout-item-bg-current
73
+ --tui-nav-menu-flyout-item-fg-current
74
+ --tui-nav-menu-flyout-item-weight-current
75
+ --tui-nav-menu-flyout-item-bg-ancestor
76
+ --tui-nav-menu-flyout-item-fg-ancestor
77
+ --tui-nav-menu-flyout-item-weight-ancestor
78
+ --tui-nav-menu-flyout-item-fg-disabled
35
79
  */
36
80
 
81
+ // Row state knobs, resolved per level. Each level (sub, bar, flyout) reads
82
+ // its own --tui-nav-menu-{level}-item-{knob}, then the general
83
+ // --tui-nav-menu-item-{knob}, then the default here. Setting the general knob
84
+ // restyles every level; a level knob overrides one. They resolve into --_k-*
85
+ // internals, so the state rules stay level-agnostic. Defaults that read
86
+ // another --_k-* (hover falls back to rest, pressed to hover) resolve on the
87
+ // same element, so a level's rest override carries into its hover.
88
+ // --_rest-fg is the row's resting text for its state (an ancestor's own fg),
89
+ // so hovering an ancestor keeps a consumer's fg-ancestor.
90
+ $_p: sys.$prefix;
91
+ $_knob-defaults: (
92
+ bg: "transparent",
93
+ fg: "var(--#{$_p}color-fg)",
94
+ weight: "var(--#{$_p}typography-weight-normal, 400)",
95
+ bg-hover: "var(--#{$_p}color-fill-subtle)",
96
+ fg-hover: "var(--_rest-fg)",
97
+ bg-active: "var(--_k-bg-hover)",
98
+ fg-active: "var(--_k-fg-hover)",
99
+ bg-current: "var(--#{$_p}theme-primary-subtlest)",
100
+ fg-current: "var(--#{$_p}theme-primary-strong)",
101
+ weight-current: "var(--#{$_p}typography-weight-semibold, 600)",
102
+ bg-ancestor: "var(--_k-bg)",
103
+ fg-ancestor: "var(--_k-fg)",
104
+ weight-ancestor: "var(--#{$_p}typography-weight-semibold, 600)",
105
+ fg-disabled: "var(--#{$_p}color-fg-muted)",
106
+ );
107
+
108
+ @mixin _item-knobs($level: null, $overrides: ()) {
109
+ @each $knob, $default in map.merge($_knob-defaults, $overrides) {
110
+ @if $level {
111
+ --_k-#{$knob}: var(--#{$_p}nav-menu-#{$level}-item-#{$knob}, var(--#{$_p}nav-menu-item-#{$knob}, #{$default}));
112
+ } @else {
113
+ --_k-#{$knob}: var(--#{$_p}nav-menu-item-#{$knob}, #{$default});
114
+ }
115
+ }
116
+ }
117
+
37
118
  @mixin styles() {
38
119
  // ==========================================================================
39
120
  // NavMenu
@@ -51,28 +132,34 @@
51
132
  // aligns its text to it
52
133
  // --tui-nav-menu-item-radius Row radius
53
134
  // --tui-nav-menu-item-font-size Row font size
54
- // --tui-nav-menu-item-fg Row text
55
- // --tui-nav-menu-item-weight Row weight (default: normal)
135
+ // --tui-nav-menu-item-bg / -fg / -weight
136
+ // Row at rest (weight default: normal)
56
137
  // --tui-nav-menu-item-bg-hover / -fg-hover
138
+ // --tui-nav-menu-item-bg-active / -fg-active
139
+ // Pressed (default: the hover values)
57
140
  // --tui-nav-menu-item-bg-current / -fg-current / -weight-current
58
141
  // The current page (aria-current="page")
59
- // --tui-nav-menu-item-fg-ancestor / -weight-ancestor
60
- // An ancestor of it (any other aria-current)
142
+ // --tui-nav-menu-item-bg-ancestor / -fg-ancestor / -weight-ancestor
143
+ // An ancestor of it (any other
144
+ // aria-current). Hover still applies.
61
145
  // --tui-nav-menu-item-fg-disabled Inert items
146
+ //
147
+ // Per-level overrides of every row knob above, each falling back to the
148
+ // general one: --tui-nav-menu-sub-item-* (rows in a nested Sub)
149
+ // --tui-nav-menu-bar-item-* (top-level bar rows)
150
+ // --tui-nav-menu-flyout-item-* (rows in a flyout panel; fg
151
+ // defaults to the panel's fg)
62
152
  // --tui-nav-menu-icon-size Icon size (default: icon-size-sm, 16px)
63
- // --tui-nav-menu-indicator-width Leading bar on the current page.
64
- // Opt-in: 0 by default, try 3px.
153
+ // --tui-nav-menu-indicator-width Current-item indicator. Opt-in: 0 by
154
+ // default. Vertical: a leading bar on
155
+ // the page (try 3px). Horizontal: an
156
+ // underline on the page or its
157
+ // ancestor (try 2px).
65
158
  // --tui-nav-menu-indicator-color That bar's colour
66
159
  // --tui-nav-menu-sub-indent / -border Nested list indent and guide line
67
160
  //
68
161
  // Horizontal (orientation="horizontal"):
69
162
  // --tui-nav-menu-bar-gap Space between bar items and clusters
70
- // --tui-nav-menu-bar-bg-current Current bar item fill (default: none)
71
- // --tui-nav-menu-underline-width / -color
72
- // The current bar item's underline
73
- // (default 2px, primary-base). Also marks
74
- // an ancestor, since its page is in the
75
- // flyout.
76
163
  // --tui-nav-menu-flyout-{bg,fg,border,radius,shadow,min-width}
77
164
  // The flyout panel (an elevated surface
78
165
  // that owns its fg)
@@ -121,9 +208,11 @@
121
208
  // Row. Full specificity on .tui-interface: it's a themed element (a, button),
122
209
  // and host button/link styles must not win.
123
210
  .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__item {
124
- --_fg: var(--#{sys.$prefix}nav-menu-item-fg, var(--#{sys.$prefix}color-fg));
125
- --_weight: var(--#{sys.$prefix}nav-menu-item-weight, var(--#{sys.$prefix}typography-weight-normal, 400));
126
- --_bg: transparent;
211
+ @include _item-knobs;
212
+ --_rest-fg: var(--_k-fg);
213
+ --_fg: var(--_rest-fg);
214
+ --_weight: var(--_k-weight);
215
+ --_bg: var(--_k-bg);
127
216
  --_indicator: var(--#{sys.$prefix}nav-menu-indicator-width, 0px);
128
217
 
129
218
  position: relative;
@@ -149,9 +238,26 @@
149
238
  cursor: pointer;
150
239
  transition: background-color var(--#{sys.$prefix}motion-duration) var(--#{sys.$prefix}motion-timing);
151
240
 
241
+ // An ancestor of the current page (aria-current="true", or any value
242
+ // other than "page"): emphasis without the fill. Zero-specificity
243
+ // attribute part and written before :hover, so hovering an ancestor
244
+ // still shows the hover state; it keeps its weight.
245
+ &:where([aria-current]:not([aria-current="page"])) {
246
+ --_rest-fg: var(--_k-fg-ancestor);
247
+ --_bg: var(--_k-bg-ancestor);
248
+ --_fg: var(--_rest-fg);
249
+ --_weight: var(--_k-weight-ancestor);
250
+ }
251
+
152
252
  &:hover {
153
- --_bg: var(--#{sys.$prefix}nav-menu-item-bg-hover, var(--#{sys.$prefix}color-fill-subtle));
154
- --_fg: var(--#{sys.$prefix}nav-menu-item-fg-hover, var(--#{sys.$prefix}nav-menu-item-fg, var(--#{sys.$prefix}color-fg)));
253
+ --_bg: var(--_k-bg-hover);
254
+ --_fg: var(--_k-fg-hover);
255
+ }
256
+
257
+ // Pressed. Defaults to the hover values (no change), the Button precedent.
258
+ &:active {
259
+ --_bg: var(--_k-bg-active);
260
+ --_fg: var(--_k-fg-active);
155
261
  }
156
262
 
157
263
  // Inset, so adjacent rows and the sidebar edge don't clip it.
@@ -160,19 +266,12 @@
160
266
  outline-offset: calc(-1 * var(--#{sys.$prefix}focus-ring-width));
161
267
  }
162
268
 
163
- // An ancestor of the current page (aria-current="true", or any value
164
- // other than "page"): emphasis without the fill.
165
- &[aria-current]:not([aria-current="page"]) {
166
- --_fg: var(--#{sys.$prefix}nav-menu-item-fg-ancestor, var(--#{sys.$prefix}color-fg));
167
- --_weight: var(--#{sys.$prefix}nav-menu-item-weight-ancestor, var(--#{sys.$prefix}typography-weight-semibold, 600));
168
- }
169
-
170
269
  // The current page. Fill + strong text + weight, so it never relies on
171
270
  // colour alone. primary-strong measures 4.81:1 on primary-subtlest in dark.
172
271
  &[aria-current="page"] {
173
- --_bg: var(--#{sys.$prefix}nav-menu-item-bg-current, var(--#{sys.$prefix}theme-primary-subtlest));
174
- --_fg: var(--#{sys.$prefix}nav-menu-item-fg-current, var(--#{sys.$prefix}theme-primary-strong));
175
- --_weight: var(--#{sys.$prefix}nav-menu-item-weight-current, var(--#{sys.$prefix}typography-weight-semibold, 600));
272
+ --_bg: var(--_k-bg-current);
273
+ --_fg: var(--_k-fg-current);
274
+ --_weight: var(--_k-weight-current);
176
275
 
177
276
  // Opt-in leading bar. Zero-width (invisible) unless the token is set.
178
277
  &::before {
@@ -188,8 +287,8 @@
188
287
  }
189
288
 
190
289
  &[aria-disabled="true"] {
191
- --_fg: var(--#{sys.$prefix}nav-menu-item-fg-disabled, var(--#{sys.$prefix}color-fg-muted));
192
- --_bg: transparent;
290
+ --_fg: var(--_k-fg-disabled);
291
+ --_bg: var(--_k-bg);
193
292
  cursor: default;
194
293
  }
195
294
  }
@@ -205,6 +304,34 @@
205
304
  min-inline-size: 0;
206
305
  }
207
306
 
307
+ // Leading slot (replaces the icon) and trailing slot (badges, counts).
308
+ // Both sit inside the row, so their text joins its accessible name.
309
+ :where(.#{sys.$prefix}interface) .#{sys.$prefix}nav-menu__prefix,
310
+ :where(.#{sys.$prefix}interface) .#{sys.$prefix}nav-menu__suffix {
311
+ display: inline-flex;
312
+ flex: none;
313
+ align-items: center;
314
+ }
315
+
316
+ // Level overrides. (0,3,0): out-weighs the row's own knob resolution
317
+ // (0,2,0). Flyout comes last, so a Sub nested inside a flyout reads the
318
+ // flyout knobs: it's on the panel's surface, not the page's.
319
+ .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__sub .#{sys.$prefix}nav-menu__item {
320
+ @include _item-knobs(sub);
321
+ }
322
+
323
+ // Top-level bar rows sit on the host's header surface, so a dark header
324
+ // sets these without touching the flyout rows on the panel.
325
+ .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__item.is-bar {
326
+ @include _item-knobs(bar);
327
+ }
328
+
329
+ // The panel owns its fg (--tui-nav-menu-flyout-fg); its rows inherit that
330
+ // as their default rather than the page's.
331
+ .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__flyout .#{sys.$prefix}nav-menu__item {
332
+ @include _item-knobs(flyout, (fg: "var(--#{$_p}nav-menu-flyout-fg, var(--#{$_p}color-fg))"));
333
+ }
334
+
208
335
  // Nested items: indented under a guide line.
209
336
  :where(.#{sys.$prefix}interface) .#{sys.$prefix}nav-menu__sub {
210
337
  margin-block-start: var(--#{sys.$prefix}nav-menu-item-gap, 2px);
@@ -250,14 +377,11 @@
250
377
  inline-size: auto;
251
378
  white-space: nowrap;
252
379
 
253
- // Current page, or an ancestor of it (whose page is inside the flyout):
254
- // strong text, weight and an underline. No fill by default.
380
+ // States match the vertical rows (fill for the current page, emphasis
381
+ // for an ancestor). The indicator knob draws here as an underline rather
382
+ // than a leading bar, on the page or an ancestor, since an ancestor's
383
+ // page is inside the flyout. Opt-in: 0 wide unless the knob is set.
255
384
  &[aria-current] {
256
- --_bg: var(--#{sys.$prefix}nav-menu-bar-bg-current, transparent);
257
- --_fg: var(--#{sys.$prefix}nav-menu-item-fg-current, var(--#{sys.$prefix}theme-primary-strong));
258
- --_weight: var(--#{sys.$prefix}nav-menu-item-weight-current, var(--#{sys.$prefix}typography-weight-semibold, 600));
259
-
260
- // The vertical leading bar doesn't apply in a bar.
261
385
  &::before { content: none; }
262
386
 
263
387
  &::after {
@@ -265,9 +389,9 @@
265
389
  position: absolute;
266
390
  inset-inline: var(--_item-pad, var(--#{sys.$prefix}nav-menu-item-padding-inline, var(--#{sys.$prefix}spacing-sm)));
267
391
  inset-block-end: 0;
268
- block-size: var(--#{sys.$prefix}nav-menu-underline-width, 2px);
392
+ block-size: var(--_indicator);
269
393
  border-radius: var(--#{sys.$prefix}radius-full, 9999px);
270
- background: var(--#{sys.$prefix}nav-menu-underline-color, var(--#{sys.$prefix}theme-primary-base));
394
+ background: var(--#{sys.$prefix}nav-menu-indicator-color, var(--#{sys.$prefix}theme-primary-base));
271
395
  }
272
396
  }
273
397
  }
@@ -296,12 +420,21 @@
296
420
  padding-inline: var(--#{sys.$prefix}spacing-xxs);
297
421
  border: 0;
298
422
  border-radius: var(--#{sys.$prefix}nav-menu-item-radius, var(--#{sys.$prefix}radius-sm));
299
- background: transparent;
300
- color: var(--#{sys.$prefix}nav-menu-item-fg, var(--#{sys.$prefix}color-fg)) !important;
423
+ // Only ever in the bar, so it reads the bar knobs like its row.
424
+ @include _item-knobs(bar);
425
+ --_rest-fg: var(--_k-fg);
426
+ background: var(--_k-bg);
427
+ color: var(--_k-fg) !important;
301
428
  cursor: pointer;
302
429
 
303
430
  &:hover {
304
- background: var(--#{sys.$prefix}nav-menu-item-bg-hover, var(--#{sys.$prefix}color-fill-subtle));
431
+ background: var(--_k-bg-hover);
432
+ color: var(--_k-fg-hover) !important;
433
+ }
434
+
435
+ &:active {
436
+ background: var(--_k-bg-active);
437
+ color: var(--_k-fg-active) !important;
305
438
  }
306
439
 
307
440
  &:focus-visible {
@@ -355,13 +488,20 @@
355
488
  outline-offset: -2px;
356
489
  }
357
490
 
358
- // The bar's underline is a background, which forced colours strip; it's
359
- // the only current cue for an ancestor, so keep it as Highlight.
491
+ // The underline (when the indicator knob is set) is a background, which
492
+ // forced colours strip: keep it as Highlight.
360
493
  .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__item.is-bar[aria-current]::after {
361
494
  forced-color-adjust: none;
362
495
  background: Highlight;
363
496
  }
364
497
 
498
+ // An ancestor's only other cue is weight. Outline it, thinner than the
499
+ // page's 2px so the two stay distinct.
500
+ .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__item[aria-current]:not([aria-current="page"]) {
501
+ outline: 1px solid Highlight;
502
+ outline-offset: -2px;
503
+ }
504
+
365
505
  // Expanded state had no cue but the chevron's rotation. Before the focus
366
506
  // rule below, so focus still wins.
367
507
  .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__item.is-toggle[aria-expanded="true"],
@@ -381,5 +521,12 @@
381
521
  .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__item[aria-disabled="true"] {
382
522
  color: GrayText !important;
383
523
  }
524
+
525
+ // Slot content (a Chip badge) sets its own colour, which would read as
526
+ // enabled beside a GrayText label.
527
+ .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__item[aria-disabled="true"] :is(.#{sys.$prefix}nav-menu__prefix, .#{sys.$prefix}nav-menu__suffix),
528
+ .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__item[aria-disabled="true"] :is(.#{sys.$prefix}nav-menu__prefix, .#{sys.$prefix}nav-menu__suffix) * {
529
+ color: GrayText !important;
530
+ }
384
531
  }
385
532
  }
package/tui-manifest.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.2.25",
3
- "generated": "2026-10-02T15:07:08.166Z",
2
+ "version": "0.2.27",
3
+ "generated": "2026-10-02T18:39:54.058Z",
4
4
  "components": {
5
5
  "Accordion": {
6
6
  "props": {
@@ -2086,6 +2086,12 @@
2086
2086
  "defaultValue": "vertical",
2087
2087
  "description": "`vertical` (sidebars) stacks groups and nests a `NavMenu.Sub` inline.\n`horizontal` makes a bar: groups become inline clusters (headings visually\nhidden, lists still labelled), and an item with a `NavMenu.Sub` opens it\nas a flyout. A flyout follows the APG disclosure pattern: a button with\n`aria-expanded`, opened by click or Enter/Space (never hover), closed by\nEscape (focus returns to the button), Tab-ing out or clicking elsewhere.\nOne flyout is open at a time. Groups inside a flyout show their headings."
2088
2088
  },
2089
+ "flyoutTrigger": {
2090
+ "type": "\"click\" | \"hover\"",
2091
+ "required": false,
2092
+ "defaultValue": "click",
2093
+ "description": "How a horizontal bar's flyouts open. `click` (default): click or\nEnter/Space. `hover`: also opens for a mouse once the pointer settles on\nan item (hover intent, as in WordPress's Toolbar: under 6px of movement in\n100ms), so sweeping across the bar opens nothing. Once primed (a panel is\nopen, or one just closed), the next opens at once. There's a grace period\nfor crossing into the panel. Escape dismisses it until the pointer leaves\n(WCAG 1.4.13); clicking pins it open. Touch and keyboard behave as `click`\neither way."
2094
+ },
2089
2095
  "labels": {
2090
2096
  "type": "NavMenuLabels",
2091
2097
  "required": false,
@@ -2099,13 +2105,17 @@
2099
2105
  "--tui-nav-menu-item-padding-inline",
2100
2106
  "--tui-nav-menu-item-radius",
2101
2107
  "--tui-nav-menu-item-font-size",
2108
+ "--tui-nav-menu-item-bg",
2102
2109
  "--tui-nav-menu-item-fg",
2103
2110
  "--tui-nav-menu-item-weight",
2104
2111
  "--tui-nav-menu-item-bg-hover",
2105
2112
  "--tui-nav-menu-item-fg-hover",
2113
+ "--tui-nav-menu-item-bg-active",
2114
+ "--tui-nav-menu-item-fg-active",
2106
2115
  "--tui-nav-menu-item-bg-current",
2107
2116
  "--tui-nav-menu-item-fg-current",
2108
2117
  "--tui-nav-menu-item-weight-current",
2118
+ "--tui-nav-menu-item-bg-ancestor",
2109
2119
  "--tui-nav-menu-item-fg-ancestor",
2110
2120
  "--tui-nav-menu-item-weight-ancestor",
2111
2121
  "--tui-nav-menu-item-fg-disabled",
@@ -2115,15 +2125,54 @@
2115
2125
  "--tui-nav-menu-sub-indent",
2116
2126
  "--tui-nav-menu-sub-border",
2117
2127
  "--tui-nav-menu-bar-gap",
2118
- "--tui-nav-menu-bar-bg-current",
2119
- "--tui-nav-menu-underline-width",
2120
- "--tui-nav-menu-underline-color",
2121
2128
  "--tui-nav-menu-flyout-bg",
2122
2129
  "--tui-nav-menu-flyout-fg",
2123
2130
  "--tui-nav-menu-flyout-border",
2124
2131
  "--tui-nav-menu-flyout-radius",
2125
2132
  "--tui-nav-menu-flyout-shadow",
2126
- "--tui-nav-menu-flyout-min-width"
2133
+ "--tui-nav-menu-flyout-min-width",
2134
+ "--tui-nav-menu-sub-item-bg",
2135
+ "--tui-nav-menu-sub-item-fg",
2136
+ "--tui-nav-menu-sub-item-weight",
2137
+ "--tui-nav-menu-sub-item-bg-hover",
2138
+ "--tui-nav-menu-sub-item-fg-hover",
2139
+ "--tui-nav-menu-sub-item-bg-active",
2140
+ "--tui-nav-menu-sub-item-fg-active",
2141
+ "--tui-nav-menu-sub-item-bg-current",
2142
+ "--tui-nav-menu-sub-item-fg-current",
2143
+ "--tui-nav-menu-sub-item-weight-current",
2144
+ "--tui-nav-menu-sub-item-bg-ancestor",
2145
+ "--tui-nav-menu-sub-item-fg-ancestor",
2146
+ "--tui-nav-menu-sub-item-weight-ancestor",
2147
+ "--tui-nav-menu-sub-item-fg-disabled",
2148
+ "--tui-nav-menu-bar-item-bg",
2149
+ "--tui-nav-menu-bar-item-fg",
2150
+ "--tui-nav-menu-bar-item-weight",
2151
+ "--tui-nav-menu-bar-item-bg-hover",
2152
+ "--tui-nav-menu-bar-item-fg-hover",
2153
+ "--tui-nav-menu-bar-item-bg-active",
2154
+ "--tui-nav-menu-bar-item-fg-active",
2155
+ "--tui-nav-menu-bar-item-bg-current",
2156
+ "--tui-nav-menu-bar-item-fg-current",
2157
+ "--tui-nav-menu-bar-item-weight-current",
2158
+ "--tui-nav-menu-bar-item-bg-ancestor",
2159
+ "--tui-nav-menu-bar-item-fg-ancestor",
2160
+ "--tui-nav-menu-bar-item-weight-ancestor",
2161
+ "--tui-nav-menu-bar-item-fg-disabled",
2162
+ "--tui-nav-menu-flyout-item-bg",
2163
+ "--tui-nav-menu-flyout-item-fg",
2164
+ "--tui-nav-menu-flyout-item-weight",
2165
+ "--tui-nav-menu-flyout-item-bg-hover",
2166
+ "--tui-nav-menu-flyout-item-fg-hover",
2167
+ "--tui-nav-menu-flyout-item-bg-active",
2168
+ "--tui-nav-menu-flyout-item-fg-active",
2169
+ "--tui-nav-menu-flyout-item-bg-current",
2170
+ "--tui-nav-menu-flyout-item-fg-current",
2171
+ "--tui-nav-menu-flyout-item-weight-current",
2172
+ "--tui-nav-menu-flyout-item-bg-ancestor",
2173
+ "--tui-nav-menu-flyout-item-fg-ancestor",
2174
+ "--tui-nav-menu-flyout-item-weight-ancestor",
2175
+ "--tui-nav-menu-flyout-item-fg-disabled"
2127
2176
  ],
2128
2177
  "story": {
2129
2178
  "title": "Components/NavMenu",
@@ -0,0 +1,38 @@
1
+ export type HoverWarmth = {
2
+ /** How many members are open right now. */
3
+ open: number;
4
+ /** performance.now() until which the group stays warm after a close. */
5
+ warmUntil: number;
6
+ };
7
+ export declare function createHoverWarmth(): HoverWarmth;
8
+ /** Warm: a member is open, or one closed within its keep-warm window. */
9
+ export declare function isWarm(warmth: HoverWarmth): boolean;
10
+ /** A member opened. */
11
+ export declare function markOpen(warmth: HoverWarmth): void;
12
+ /**
13
+ * A member closed. The group stays warm for `keepWarmMs`, so moving straight
14
+ * on to a neighbour isn't a cold start. Pass 0 for a dismissal (Escape): the
15
+ * user asked for it gone, not for the next one.
16
+ */
17
+ export declare function markClosed(warmth: HoverWarmth, keepWarmMs: number): void;
18
+ export type HoverIntentOptions = {
19
+ /** Current pointer position, kept up to date by the caller's pointermove. */
20
+ readPointer: () => {
21
+ x: number;
22
+ y: number;
23
+ };
24
+ /** Called once the pointer has settled. */
25
+ onIntent: () => void;
26
+ /** Sample period in ms. @default 100 */
27
+ interval?: number;
28
+ /** Max movement in px over one sample that still counts as settled. @default 6 */
29
+ sensitivity?: number;
30
+ };
31
+ export declare const HOVER_INTENT_INTERVAL = 100;
32
+ export declare const HOVER_INTENT_SENSITIVITY = 6;
33
+ /**
34
+ * Starts sampling the pointer for intent; returns a cancel function. Each
35
+ * `interval` it compares the pointer with the last sample and calls
36
+ * `onIntent` once movement drops under `sensitivity`.
37
+ */
38
+ export declare function sampleHoverIntent({ readPointer, onIntent, interval, sensitivity, }: HoverIntentOptions): () => void;
@@ -0,0 +1,67 @@
1
+ // =============================================================================
2
+ // Hover intent and warmth
3
+ // =============================================================================
4
+ //
5
+ // Two separable ideas for hover-revealed UI, shared by NavMenu flyouts and
6
+ // tooltips.
7
+ //
8
+ // WARMTH: once something in a group is showing, or showed moments ago, the
9
+ // next one opens at once instead of waiting out its delay. Glide along a
10
+ // toolbar and each tooltip appears immediately; move between a bar's
11
+ // flyouts and they switch without a cold start. A group is a plain mutable
12
+ // object (no React state: it's read at event time, never rendered from),
13
+ // scoped by whoever owns it: TooltipProvider, Toolbar, a NavMenu root.
14
+ //
15
+ // INTENT: open when the pointer settles, not after a fixed delay. It's
16
+ // measured as moving under `sensitivity` px over one `interval` sample, after
17
+ // WordPress's Toolbar (hoverIntent). A sweep across a bar on the way
18
+ // elsewhere never opens anything, however slow. NavMenu uses it; tooltips
19
+ // keep their `delayDuration` API, so consumer settings mean what they did.
20
+ // =============================================================================
21
+ export function createHoverWarmth() {
22
+ return { open: 0, warmUntil: 0 };
23
+ }
24
+ /** Warm: a member is open, or one closed within its keep-warm window. */
25
+ export function isWarm(warmth) {
26
+ return warmth.open > 0 || performance.now() < warmth.warmUntil;
27
+ }
28
+ /** A member opened. */
29
+ export function markOpen(warmth) {
30
+ warmth.open += 1;
31
+ }
32
+ /**
33
+ * A member closed. The group stays warm for `keepWarmMs`, so moving straight
34
+ * on to a neighbour isn't a cold start. Pass 0 for a dismissal (Escape): the
35
+ * user asked for it gone, not for the next one.
36
+ */
37
+ export function markClosed(warmth, keepWarmMs) {
38
+ warmth.open = Math.max(0, warmth.open - 1);
39
+ warmth.warmUntil = keepWarmMs > 0 ? Math.max(warmth.warmUntil, performance.now() + keepWarmMs) : 0;
40
+ }
41
+ export const HOVER_INTENT_INTERVAL = 100;
42
+ export const HOVER_INTENT_SENSITIVITY = 6;
43
+ /**
44
+ * Starts sampling the pointer for intent; returns a cancel function. Each
45
+ * `interval` it compares the pointer with the last sample and calls
46
+ * `onIntent` once movement drops under `sensitivity`.
47
+ */
48
+ export function sampleHoverIntent({ readPointer, onIntent, interval = HOVER_INTENT_INTERVAL, sensitivity = HOVER_INTENT_SENSITIVITY, }) {
49
+ let last = readPointer();
50
+ let timer = null;
51
+ const tick = () => {
52
+ const now = readPointer();
53
+ if (Math.hypot(now.x - last.x, now.y - last.y) < sensitivity) {
54
+ timer = null;
55
+ onIntent();
56
+ return;
57
+ }
58
+ last = now;
59
+ timer = setTimeout(tick, interval);
60
+ };
61
+ timer = setTimeout(tick, interval);
62
+ return () => {
63
+ if (timer)
64
+ clearTimeout(timer);
65
+ timer = null;
66
+ };
67
+ }