@tangible/ui 0.2.24 → 0.2.26

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.
@@ -22,6 +22,13 @@
22
22
  --tui-nav-menu-indicator-color
23
23
  --tui-nav-menu-sub-indent
24
24
  --tui-nav-menu-sub-border
25
+ --tui-nav-menu-bar-gap
26
+ --tui-nav-menu-flyout-bg
27
+ --tui-nav-menu-flyout-fg
28
+ --tui-nav-menu-flyout-border
29
+ --tui-nav-menu-flyout-radius
30
+ --tui-nav-menu-flyout-shadow
31
+ --tui-nav-menu-flyout-min-width
25
32
  */
26
33
 
27
34
  @mixin styles() {
@@ -50,11 +57,20 @@
50
57
  // An ancestor of it (any other aria-current)
51
58
  // --tui-nav-menu-item-fg-disabled Inert items
52
59
  // --tui-nav-menu-icon-size Icon size (default: icon-size-sm, 16px)
53
- // --tui-nav-menu-indicator-width Leading bar on the current page.
54
- // Opt-in: 0 by default, try 3px.
60
+ // --tui-nav-menu-indicator-width Current-item indicator. Opt-in: 0 by
61
+ // default. Vertical: a leading bar on
62
+ // the page (try 3px). Horizontal: an
63
+ // underline on the page or its
64
+ // ancestor (try 2px).
55
65
  // --tui-nav-menu-indicator-color That bar's colour
56
66
  // --tui-nav-menu-sub-indent / -border Nested list indent and guide line
57
67
  //
68
+ // Horizontal (orientation="horizontal"):
69
+ // --tui-nav-menu-bar-gap Space between bar items and clusters
70
+ // --tui-nav-menu-flyout-{bg,fg,border,radius,shadow,min-width}
71
+ // The flyout panel (an elevated surface
72
+ // that owns its fg)
73
+ //
58
74
  // !important on the row's color, font-weight and text-decoration, the
59
75
  // Button precedent: rows are usually <a>, and hosts (WordPress themes, and
60
76
  // Storybook's own preview.css) style bare `a` unlayered, which beats every
@@ -191,12 +207,167 @@
191
207
  border-inline-start: var(--#{sys.$prefix}border-width) solid var(--#{sys.$prefix}nav-menu-sub-border, var(--#{sys.$prefix}color-border));
192
208
  }
193
209
 
210
+ // ==========================================================================
211
+ // Horizontal bar
212
+ // ==========================================================================
213
+ // Bar rows carry .is-bar (set by the component on top-level rows only), so
214
+ // nothing below reaches the rows inside a flyout, which keep the vertical
215
+ // treatment.
216
+
217
+ :where(.#{sys.$prefix}interface) .#{sys.$prefix}nav-menu.is-horizontal {
218
+ flex-direction: row;
219
+ flex-wrap: wrap;
220
+ align-items: center;
221
+ gap: var(--#{sys.$prefix}nav-menu-bar-gap, var(--#{sys.$prefix}spacing-xs));
222
+
223
+ // Wraps rather than overflowing (SC 1.4.10). The small-screen pattern is
224
+ // still to swap the bar for a Sidebar drawer; this keeps it from
225
+ // scrolling sideways meanwhile.
226
+ > .#{sys.$prefix}nav-menu__group > .#{sys.$prefix}nav-menu__list {
227
+ flex-direction: row;
228
+ flex-wrap: wrap;
229
+ align-items: center;
230
+ gap: var(--#{sys.$prefix}nav-menu-bar-gap, var(--#{sys.$prefix}spacing-xs));
231
+ }
232
+ }
233
+
234
+ :where(.#{sys.$prefix}interface) .#{sys.$prefix}nav-menu__entry.has-flyout {
235
+ position: relative;
236
+ }
237
+
238
+ :where(.#{sys.$prefix}interface) .#{sys.$prefix}nav-menu__entry.is-split {
239
+ display: flex;
240
+ align-items: center;
241
+ }
242
+
243
+ .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__item.is-bar {
244
+ inline-size: auto;
245
+ white-space: nowrap;
246
+
247
+ // States match the vertical rows (fill for the current page, emphasis
248
+ // for an ancestor). The indicator knob draws here as an underline rather
249
+ // than a leading bar, on the page or an ancestor, since an ancestor's
250
+ // page is inside the flyout. Opt-in: 0 wide unless the knob is set.
251
+ &[aria-current] {
252
+ &::before { content: none; }
253
+
254
+ &::after {
255
+ content: "";
256
+ position: absolute;
257
+ inset-inline: var(--_item-pad, var(--#{sys.$prefix}nav-menu-item-padding-inline, var(--#{sys.$prefix}spacing-sm)));
258
+ inset-block-end: 0;
259
+ block-size: var(--_indicator);
260
+ border-radius: var(--#{sys.$prefix}radius-full, 9999px);
261
+ background: var(--#{sys.$prefix}nav-menu-indicator-color, var(--#{sys.$prefix}theme-primary-base));
262
+ }
263
+ }
264
+ }
265
+
266
+ // The row-is-the-toggle chevron, and the separate toggle of a link parent.
267
+ :where(.#{sys.$prefix}interface) .#{sys.$prefix}nav-menu__chevron {
268
+ display: inline-flex;
269
+ flex: none;
270
+ font-size: var(--#{sys.$prefix}nav-menu-icon-size, var(--#{sys.$prefix}icon-size-sm, 1rem));
271
+ transition: transform var(--#{sys.$prefix}motion-duration) var(--#{sys.$prefix}motion-timing);
272
+ }
273
+
274
+ :where(.#{sys.$prefix}interface) [aria-expanded="true"] > .#{sys.$prefix}nav-menu__chevron {
275
+ transform: rotate(180deg);
276
+ }
277
+
278
+ .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__toggle {
279
+ display: inline-flex;
280
+ align-items: center;
281
+ justify-content: center;
282
+ box-sizing: border-box;
283
+ // At least the 24px target minimum (SC 2.5.8), as tall as the row.
284
+ min-inline-size: 1.5rem;
285
+ min-block-size: var(--#{sys.$prefix}nav-menu-item-height, var(--#{sys.$prefix}control-height-md, 2.5rem));
286
+ margin: 0;
287
+ padding-inline: var(--#{sys.$prefix}spacing-xxs);
288
+ border: 0;
289
+ border-radius: var(--#{sys.$prefix}nav-menu-item-radius, var(--#{sys.$prefix}radius-sm));
290
+ background: transparent;
291
+ color: var(--#{sys.$prefix}nav-menu-item-fg, var(--#{sys.$prefix}color-fg)) !important;
292
+ cursor: pointer;
293
+
294
+ &:hover {
295
+ background: var(--#{sys.$prefix}nav-menu-item-bg-hover, var(--#{sys.$prefix}color-fill-subtle));
296
+ }
297
+
298
+ &:focus-visible {
299
+ outline: var(--#{sys.$prefix}focus-ring-width) solid var(--#{sys.$prefix}focus-ring-color);
300
+ outline-offset: calc(-1 * var(--#{sys.$prefix}focus-ring-width));
301
+ }
302
+ }
303
+
304
+ // ==========================================================================
305
+ // Flyout panel
306
+ // ==========================================================================
307
+ // Positioned by Floating UI (inline styles), not portaled, so the DOM and
308
+ // tab order run toggle -> panel. An elevated surface, so it owns its fg.
309
+
310
+ :where(.#{sys.$prefix}interface) .#{sys.$prefix}nav-menu__flyout {
311
+ z-index: var(--#{sys.$prefix}layer-overlay, 100);
312
+ display: flex;
313
+ flex-direction: column;
314
+ gap: var(--#{sys.$prefix}nav-menu-group-gap, var(--#{sys.$prefix}spacing-sm));
315
+ box-sizing: border-box;
316
+ min-inline-size: var(--#{sys.$prefix}nav-menu-flyout-min-width, 14rem);
317
+ padding: var(--#{sys.$prefix}spacing-xxs);
318
+ border: var(--#{sys.$prefix}border-width) solid var(--#{sys.$prefix}nav-menu-flyout-border, var(--#{sys.$prefix}color-border));
319
+ border-radius: var(--#{sys.$prefix}nav-menu-flyout-radius, var(--#{sys.$prefix}radius-md));
320
+ background: var(--#{sys.$prefix}nav-menu-flyout-bg, var(--#{sys.$prefix}color-bg-elevated));
321
+ color: var(--#{sys.$prefix}nav-menu-flyout-fg, var(--#{sys.$prefix}color-fg));
322
+ box-shadow: var(--#{sys.$prefix}nav-menu-flyout-shadow, var(--#{sys.$prefix}shadow-dropdown));
323
+
324
+ // `display: flex` above would otherwise override the hidden attribute.
325
+ &[hidden] {
326
+ display: none;
327
+ }
328
+
329
+ // The Sub inside a flyout is the panel's content, not an indented branch.
330
+ > .#{sys.$prefix}nav-menu__sub {
331
+ margin: 0;
332
+ padding: 0;
333
+ border: 0;
334
+ }
335
+
336
+ .#{sys.$prefix}nav-menu__sub.has-groups {
337
+ display: flex;
338
+ flex-direction: column;
339
+ gap: var(--#{sys.$prefix}nav-menu-group-gap, var(--#{sys.$prefix}spacing-sm));
340
+ }
341
+ }
342
+
194
343
  @media (forced-colors: active) {
195
344
  .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__item[aria-current="page"] {
196
345
  outline: 2px solid Highlight;
197
346
  outline-offset: -2px;
198
347
  }
199
348
 
349
+ // The underline (when the indicator knob is set) is a background, which
350
+ // forced colours strip: keep it as Highlight.
351
+ .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__item.is-bar[aria-current]::after {
352
+ forced-color-adjust: none;
353
+ background: Highlight;
354
+ }
355
+
356
+ // An ancestor's only other cue is weight. Outline it, thinner than the
357
+ // page's 2px so the two stay distinct.
358
+ .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__item[aria-current]:not([aria-current="page"]) {
359
+ outline: 1px solid Highlight;
360
+ outline-offset: -2px;
361
+ }
362
+
363
+ // Expanded state had no cue but the chevron's rotation. Before the focus
364
+ // rule below, so focus still wins.
365
+ .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__item.is-toggle[aria-expanded="true"],
366
+ .#{sys.$prefix}interface .#{sys.$prefix}nav-menu__toggle[aria-expanded="true"] {
367
+ outline: 2px solid Highlight;
368
+ outline-offset: -2px;
369
+ }
370
+
200
371
  // Focus must stay distinct from the current row's outline: thicker and
201
372
  // outside the row. Without this, the two tie and the current-row rule
202
373
  // wins on order, so focus vanished on the row users land on most (SC 2.4.7).
package/tui-manifest.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.2.24",
3
- "generated": "2026-10-02T03:57:30.563Z",
2
+ "version": "0.2.26",
3
+ "generated": "2026-10-02T17:12:22.617Z",
4
4
  "components": {
5
5
  "Accordion": {
6
6
  "props": {
@@ -2079,6 +2079,23 @@
2079
2079
  "onClick": {
2080
2080
  "type": "MouseEventHandler<HTMLDivElement>",
2081
2081
  "required": false
2082
+ },
2083
+ "orientation": {
2084
+ "type": "\"vertical\" | \"horizontal\"",
2085
+ "required": false,
2086
+ "defaultValue": "vertical",
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
+ },
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
+ },
2095
+ "labels": {
2096
+ "type": "NavMenuLabels",
2097
+ "required": false,
2098
+ "description": "Visually hidden strings."
2082
2099
  }
2083
2100
  },
2084
2101
  "cssTokens": [
@@ -2102,7 +2119,14 @@
2102
2119
  "--tui-nav-menu-indicator-width",
2103
2120
  "--tui-nav-menu-indicator-color",
2104
2121
  "--tui-nav-menu-sub-indent",
2105
- "--tui-nav-menu-sub-border"
2122
+ "--tui-nav-menu-sub-border",
2123
+ "--tui-nav-menu-bar-gap",
2124
+ "--tui-nav-menu-flyout-bg",
2125
+ "--tui-nav-menu-flyout-fg",
2126
+ "--tui-nav-menu-flyout-border",
2127
+ "--tui-nav-menu-flyout-radius",
2128
+ "--tui-nav-menu-flyout-shadow",
2129
+ "--tui-nav-menu-flyout-min-width"
2106
2130
  ],
2107
2131
  "story": {
2108
2132
  "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
+ }