@tangible/ui 0.2.25 → 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.
- package/components/NavMenu/NavMenu.d.ts +2 -1
- package/components/NavMenu/NavMenu.js +190 -22
- package/components/NavMenu/index.d.ts +1 -1
- package/components/NavMenu/types.d.ts +13 -0
- package/components/Toolbar/Toolbar.js +2 -1
- package/components/Tooltip/Tooltip.d.ts +1 -1
- package/components/Tooltip/Tooltip.js +53 -7
- package/components/Tooltip/TooltipContext.d.ts +12 -0
- package/components/Tooltip/TooltipContext.js +3 -0
- package/components/Tooltip/TooltipWarmthScope.d.ts +13 -0
- package/components/Tooltip/TooltipWarmthScope.js +28 -0
- package/components/Tooltip/types.d.ts +12 -0
- package/components/index.d.ts +1 -1
- package/figma-tokens.json +1 -1
- package/package.json +1 -1
- package/skills/building-with-tui/SKILL.md +3 -1
- package/styles/all.css +1 -1
- package/styles/all.expanded.css +6 -10
- package/styles/all.expanded.unlayered.css +6 -10
- package/styles/all.unlayered.css +1 -1
- package/styles/components/nav-menu.scss +20 -22
- package/tui-manifest.json +8 -5
- package/utils/hover-intent.d.ts +38 -0
- package/utils/hover-intent.js +67 -0
|
@@ -23,9 +23,6 @@
|
|
|
23
23
|
--tui-nav-menu-sub-indent
|
|
24
24
|
--tui-nav-menu-sub-border
|
|
25
25
|
--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
26
|
--tui-nav-menu-flyout-bg
|
|
30
27
|
--tui-nav-menu-flyout-fg
|
|
31
28
|
--tui-nav-menu-flyout-border
|
|
@@ -60,19 +57,16 @@
|
|
|
60
57
|
// An ancestor of it (any other aria-current)
|
|
61
58
|
// --tui-nav-menu-item-fg-disabled Inert items
|
|
62
59
|
// --tui-nav-menu-icon-size Icon size (default: icon-size-sm, 16px)
|
|
63
|
-
// --tui-nav-menu-indicator-width
|
|
64
|
-
//
|
|
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).
|
|
65
65
|
// --tui-nav-menu-indicator-color That bar's colour
|
|
66
66
|
// --tui-nav-menu-sub-indent / -border Nested list indent and guide line
|
|
67
67
|
//
|
|
68
68
|
// Horizontal (orientation="horizontal"):
|
|
69
69
|
// --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
70
|
// --tui-nav-menu-flyout-{bg,fg,border,radius,shadow,min-width}
|
|
77
71
|
// The flyout panel (an elevated surface
|
|
78
72
|
// that owns its fg)
|
|
@@ -250,14 +244,11 @@
|
|
|
250
244
|
inline-size: auto;
|
|
251
245
|
white-space: nowrap;
|
|
252
246
|
|
|
253
|
-
//
|
|
254
|
-
//
|
|
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.
|
|
255
251
|
&[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
252
|
&::before { content: none; }
|
|
262
253
|
|
|
263
254
|
&::after {
|
|
@@ -265,9 +256,9 @@
|
|
|
265
256
|
position: absolute;
|
|
266
257
|
inset-inline: var(--_item-pad, var(--#{sys.$prefix}nav-menu-item-padding-inline, var(--#{sys.$prefix}spacing-sm)));
|
|
267
258
|
inset-block-end: 0;
|
|
268
|
-
block-size: var(
|
|
259
|
+
block-size: var(--_indicator);
|
|
269
260
|
border-radius: var(--#{sys.$prefix}radius-full, 9999px);
|
|
270
|
-
background: var(--#{sys.$prefix}nav-menu-
|
|
261
|
+
background: var(--#{sys.$prefix}nav-menu-indicator-color, var(--#{sys.$prefix}theme-primary-base));
|
|
271
262
|
}
|
|
272
263
|
}
|
|
273
264
|
}
|
|
@@ -355,13 +346,20 @@
|
|
|
355
346
|
outline-offset: -2px;
|
|
356
347
|
}
|
|
357
348
|
|
|
358
|
-
// The
|
|
359
|
-
//
|
|
349
|
+
// The underline (when the indicator knob is set) is a background, which
|
|
350
|
+
// forced colours strip: keep it as Highlight.
|
|
360
351
|
.#{sys.$prefix}interface .#{sys.$prefix}nav-menu__item.is-bar[aria-current]::after {
|
|
361
352
|
forced-color-adjust: none;
|
|
362
353
|
background: Highlight;
|
|
363
354
|
}
|
|
364
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
|
+
|
|
365
363
|
// Expanded state had no cue but the chevron's rotation. Before the focus
|
|
366
364
|
// rule below, so focus still wins.
|
|
367
365
|
.#{sys.$prefix}interface .#{sys.$prefix}nav-menu__item.is-toggle[aria-expanded="true"],
|
package/tui-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.2.
|
|
3
|
-
"generated": "2026-10-
|
|
2
|
+
"version": "0.2.26",
|
|
3
|
+
"generated": "2026-10-02T17:12:22.617Z",
|
|
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,
|
|
@@ -2115,9 +2121,6 @@
|
|
|
2115
2121
|
"--tui-nav-menu-sub-indent",
|
|
2116
2122
|
"--tui-nav-menu-sub-border",
|
|
2117
2123
|
"--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
2124
|
"--tui-nav-menu-flyout-bg",
|
|
2122
2125
|
"--tui-nav-menu-flyout-fg",
|
|
2123
2126
|
"--tui-nav-menu-flyout-border",
|
|
@@ -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
|
+
}
|