@mdbase-dev/ui 0.1.0-beta.157 → 0.1.0-beta.158

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 CHANGED
@@ -20,6 +20,8 @@ applyThemePreference(loadThemePreference());
20
20
  `--color-text-soft`, `--color-accent`, ...) for light, dark and system
21
21
  themes. Style components with roles, not palette values. Short aliases such
22
22
  as `--ink` belong to each app.
23
+ `--color-current` and `--color-on-current` mark the keyboard/pointer current
24
+ choice in palettes, completion lists and diagnostics; `--color-selected` stays subtle for persistent selections.
23
25
  - `theme` stores the System, Light or Dark choice as `mdbase:theme`.
24
26
  - `brand` draws the Frontmatter mark, each app's inverted mark, and the
25
27
  `mdbase <app>` wordmark. Add `motion.css` to animate the mark: loops
@@ -36,6 +38,21 @@ applyThemePreference(loadThemePreference());
36
38
  collection in another app. Lab and local builds pass their own URLs to
37
39
  `withAppUrls`.
38
40
 
41
+ ## Icon-button tooltips
42
+
43
+ Import `Tooltip` from `@mdbase-dev/ui/tooltip` and include `controls.css`.
44
+ Wrap one native icon button in `<Tooltip label="Search" shortcut="mod+k">…</Tooltip>`.
45
+ Localize the label in the caller. The optional shortcut uses the same notation and
46
+ platform labels as the command palette and sets `aria-keyshortcuts` on the button.
47
+ The button keeps its ref and handlers; a native manual popover adds no layout box
48
+ or focus stop. Escape dismisses a visible tooltip before the parent dialog;
49
+ the bubble remains visible while hovered, with 120 ms to cross the gap.
50
+ Only the supplemental shortcut is linked as a description, preserving existing
51
+ button names and descriptions. Hover waits 400 ms, keyboard
52
+ focus is immediate, and a recently closed tooltip keeps the next one immediate
53
+ for 800 ms. Touch presses do not show a tooltip. Scroll, resize, window blur,
54
+ press, or an unavailable trigger cancels pending and visible hints.
55
+
39
56
  ## Toasts
40
57
 
41
58
  Mount one `Toaster` from `@mdbase-dev/ui/toast` inside the app's locale provider
@@ -191,7 +208,6 @@ built-in value.
191
208
  | `border` | hairlines | `--color-border-strong` | light grey |
192
209
  | `danger` | errors and destructive actions | `--color-danger` | red |
193
210
  | `warning` | warning text | `--color-warning-text` | amber |
194
- | `warning-edge` | the warning notice's edge | `--color-warning` | amber |
195
211
  | `scrim` | behind dialogs and sheets | `--color-scrim` | `rgb(0 0 0 / 0.3)` |
196
212
  | `current-bg` | the open collection's row | (none) | accent 9% into surface, mixed in oklab |
197
213
  | `font` | font family | `--sans` | `system-ui, sans-serif` |
@@ -22,7 +22,6 @@
22
22
  --_border: var(--mdbase-collections-border, var(--color-border-strong, oklch(82% 0.008 255)));
23
23
  --_danger: var(--mdbase-collections-danger, var(--color-danger, oklch(50% 0.11 28)));
24
24
  --_warning: var(--mdbase-collections-warning, var(--color-warning-text, oklch(43% 0.055 69)));
25
- --_warning-edge: var(--mdbase-collections-warning-edge, var(--color-warning, oklch(60% 0.09 75)));
26
25
  --_scrim: var(--mdbase-collections-scrim, var(--color-scrim, rgb(0 0 0 / 0.3)));
27
26
  /*
28
27
  * Mixes are in oklab, which has no hue: in oklch an achromatic surface
@@ -258,21 +257,20 @@
258
257
  gap: 10px;
259
258
  padding: 12px 14px;
260
259
  border: 1px solid var(--_border);
261
- border-left-width: 3px;
262
260
  border-radius: var(--_radius);
263
261
  background: var(--_surface);
264
262
  }
265
263
 
266
264
  .mdbase-collections-notice[data-tone="warning"] {
267
- border-left-color: var(--_warning-edge);
265
+ background: color-mix(in oklab, var(--_warning) 8%, var(--_surface));
268
266
  }
269
267
 
270
268
  .mdbase-collections-notice[data-tone="error"] {
271
- border-left-color: var(--_danger);
269
+ background: color-mix(in oklab, var(--_danger) 8%, var(--_surface));
272
270
  }
273
271
 
274
272
  .mdbase-collections-notice[data-tone="info"] {
275
- border-left-color: var(--_accent);
273
+ background: color-mix(in oklab, var(--_accent) 8%, var(--_surface));
276
274
  }
277
275
 
278
276
  .mdbase-collections-notice.is-inline {
package/css/controls.css CHANGED
@@ -26,6 +26,33 @@
26
26
  white-space: nowrap;
27
27
  }
28
28
 
29
+ .mdbase-tooltip {
30
+ position: fixed;
31
+ inset: auto;
32
+ margin: 0;
33
+ display: flex;
34
+ align-items: center;
35
+ gap: 12px;
36
+ max-width: calc(100vw - 16px);
37
+ max-height: calc(100dvh - 16px);
38
+ box-sizing: border-box;
39
+ overflow: hidden;
40
+ overflow-wrap: anywhere;
41
+ padding: 6px 8px;
42
+ border: 1px solid var(--color-border-strong);
43
+ border-radius: var(--radius-sm);
44
+ background: var(--color-surface-overlay);
45
+ color: var(--color-text);
46
+ box-shadow: var(--elevation-low);
47
+ font: var(--font-size-caption)/1.4 var(--sans);
48
+ pointer-events: auto;
49
+ opacity: 1;
50
+ transition: opacity var(--motion-fast) var(--ease-out);
51
+ }
52
+ .mdbase-tooltip kbd { flex-shrink: 0; color: var(--color-text-muted); font: inherit; }
53
+ @starting-style { .mdbase-tooltip:popover-open { opacity: 0; } }
54
+ @media (prefers-reduced-motion: reduce) { .mdbase-tooltip { transition: none; } }
55
+
29
56
  .mdbase-message {
30
57
  margin: 1.2rem 0 0;
31
58
  padding: 0.7rem 0;
package/css/palette.css CHANGED
@@ -41,12 +41,16 @@
41
41
  }
42
42
 
43
43
  .mdbase-command-results {
44
- max-height: 380px;
44
+ min-height: 0;
45
+ height: 380px;
46
+ max-height: 100%;
45
47
  overflow: auto;
46
48
  padding: 4px 6px 8px;
47
49
  scroll-padding: 28px 0 8px;
48
50
  }
49
51
 
52
+ .mdbase-command-results:has(> .mdbase-command-empty) { height: auto; }
53
+
50
54
  .mdbase-command-group {
51
55
  position: sticky;
52
56
  top: -4px;
@@ -75,13 +79,18 @@
75
79
  cursor: pointer;
76
80
  }
77
81
 
78
- .mdbase-command-results > button[aria-selected="true"],
79
- .mdbase-command-results > button:hover {
82
+ .mdbase-command-results > button[aria-selected="true"] {
80
83
  color: var(--color-text);
81
- background: var(--color-selected);
84
+ background: light-dark(oklch(94% 0.001 286), oklch(29% 0.004 286));
85
+ box-shadow: inset 0 0 0 1px light-dark(oklch(60% 0.004 286), oklch(63% 0.004 286));
82
86
  }
83
87
 
84
- .mdbase-command-results > button:active { background: var(--color-border-strong); }
88
+ @media (forced-colors: active) {
89
+ .mdbase-command-results > button[aria-selected="true"] {
90
+ outline: 1px solid Highlight;
91
+ outline-offset: -1px;
92
+ }
93
+ }
85
94
 
86
95
  .mdbase-command-results .mdbase-command-copy {
87
96
  min-width: 0;
package/css/tokens.css CHANGED
@@ -17,6 +17,8 @@
17
17
  --color-border: oklch(94.5% 0.002 286);
18
18
  --color-border-strong: oklch(90% 0.004 286);
19
19
  --color-selected: oklch(95.8% 0.001 286);
20
+ --color-current: oklch(67% 0.001 286);
21
+ --color-on-current: var(--color-text);
20
22
  --color-accent: #005c88;
21
23
  --color-accent-strong: oklch(40% 0.1 239);
22
24
  --color-accent-soft: oklch(93.5% 0.035 238);
@@ -93,6 +95,7 @@
93
95
  --color-border: oklch(25.7% 0.004 286);
94
96
  --color-border-strong: oklch(32% 0.005 286);
95
97
  --color-selected: oklch(25.7% 0.004 286);
98
+ --color-current: oklch(50% 0.004 286);
96
99
  --color-accent: #63b1e2;
97
100
  --color-accent-strong: oklch(65% 0.105 238);
98
101
  --color-accent-soft: oklch(31% 0.045 238);
@@ -138,6 +141,7 @@
138
141
  --color-border: oklch(25.7% 0.004 286);
139
142
  --color-border-strong: oklch(32% 0.005 286);
140
143
  --color-selected: oklch(25.7% 0.004 286);
144
+ --color-current: oklch(50% 0.004 286);
141
145
  --color-accent: #63b1e2;
142
146
  --color-accent-strong: oklch(65% 0.105 238);
143
147
  --color-accent-soft: oklch(31% 0.045 238);
@@ -1,3 +1,4 @@
1
+ export { isApplePlatform, shortcutLabel } from "./shortcuts.js";
1
2
  import { type JSX, type RefObject, type ReactNode } from "react";
2
3
  export interface Command {
3
4
  readonly id: string;
@@ -10,6 +11,7 @@ export interface Command {
10
11
  readonly keywords?: string | undefined;
11
12
  /** For example "mod+shift+f"; see shortcutLabel. */
12
13
  readonly shortcut?: string | undefined;
14
+ readonly context?: string | undefined;
13
15
  readonly run: () => void;
14
16
  /** A variant run with Shift+Enter or Shift+click, such as opening beside the document. */
15
17
  readonly alternate?: {
@@ -17,9 +19,6 @@ export interface Command {
17
19
  readonly run: () => void;
18
20
  } | undefined;
19
21
  }
20
- export declare function isApplePlatform(): boolean;
21
- /** "mod+shift+f" as the platform writes it: ⌘⇧F on Apple systems, Ctrl+Shift+F elsewhere. */
22
- export declare function shortcutLabel(shortcut: string): string;
23
22
  /**
24
23
  * Without a query, show a few of each group (every command of the groups in `showAll`); with
25
24
  * one, show every command matching all its terms, grouped in their original order.
@@ -2,58 +2,30 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
2
2
  import { i18n as _i18n } from "@lingui/core";
3
3
  import { useLocaleRevision } from "./i18n.js";
4
4
  import { Dialog } from "./Dialog.js";
5
+ import { shortcutLabel } from "./shortcuts.js";
6
+ export { isApplePlatform, shortcutLabel } from "./shortcuts.js";
5
7
  import { Fragment, useEffect, useLayoutEffect, useId, useMemo, useRef, useState } from "react";
6
- export function isApplePlatform() {
7
- return typeof navigator !== "undefined" && /Mac|iPhone|iPad/u.test(navigator.platform || navigator.userAgent);
8
- }
9
- /** "mod+shift+f" as the platform writes it: ⌘⇧F on Apple systems, Ctrl+Shift+F elsewhere. */
10
- export function shortcutLabel(shortcut) {
11
- if (/^[a-z] [a-z]$/iu.test(shortcut)) return shortcut.toUpperCase();
12
- const apple = isApplePlatform();
13
- return shortcut.split("+").map(part => {
14
- switch (part.toLowerCase()) {
15
- case "mod":
16
- return apple ? "⌘" : "Ctrl";
17
- case "ctrl":
18
- return apple ? "⌃" : "Ctrl";
19
- case "shift":
20
- return apple ? "⇧" : "Shift";
21
- case "alt":
22
- return apple ? "⌥" : "Alt";
23
- case "arrowdown":
24
- return "↓";
25
- case "arrowup":
26
- return "↑";
27
- case "arrowleft":
28
- return "←";
29
- case "arrowright":
30
- return "→";
31
- case "contextmenu":
32
- return _i18n._(
33
- /** i18n */
34
- {
35
- id: "zucql-",
36
- message: "Menu"
37
- });
38
- default:
39
- return part.length === 1 ? part.toUpperCase() : part;
40
- }
41
- }).join(apple ? "" : "+");
42
- }
43
8
  const browseLimit = 6;
44
9
  const searchLimit = 40;
10
+ function contextualCommands(commands) {
11
+ return [...commands.filter(command => command.context).map(command => ({
12
+ ...command,
13
+ group: "context"
14
+ })), ...commands.filter(command => !command.context)];
15
+ }
45
16
  /**
46
17
  * Without a query, show a few of each group (every command of the groups in `showAll`); with
47
18
  * one, show every command matching all its terms, grouped in their original order.
48
19
  */
49
20
  export function matchingCommands(commands, query, showAll = []) {
21
+ commands = contextualCommands(commands);
50
22
  const terms = query.trim().toLocaleLowerCase().split(/\s+/u).filter(Boolean);
51
23
  if (terms.length === 0) {
52
24
  const counts = new Map();
53
25
  return commands.filter(command => {
54
26
  const count = counts.get(command.group) ?? 0;
55
27
  counts.set(command.group, count + 1);
56
- return showAll.includes(command.group) || count < browseLimit;
28
+ return command.context !== undefined || showAll.includes(command.group) || count < browseLimit;
57
29
  });
58
30
  }
59
31
  const matches = commands.filter(command => {
@@ -62,7 +34,7 @@ export function matchingCommands(commands, query, showAll = []) {
62
34
  });
63
35
  const names = matches.filter(command => terms.every(term => command.label.toLocaleLowerCase().includes(term)));
64
36
  const selected = [...names, ...matches.filter(command => !names.includes(command))].slice(0, searchLimit);
65
- const groups = [...new Set(selected.map(({
37
+ const groups = [...new Set([...selected.filter(command => command.context), ...selected.filter(command => !command.context)].map(({
66
38
  group
67
39
  }) => group))];
68
40
  return groups.flatMap(group => selected.filter(command => command.group === group));
@@ -137,7 +109,7 @@ function OpenCommandPalette({
137
109
  const [active, setActive] = useState(0);
138
110
  const inputRef = useRef(null);
139
111
  const resultsRef = useRef(null);
140
- const matches = useMemo(() => getResults ? getResults(query) : matchingCommands(commands, query, showAll), [commands, query, showAll, getResults]);
112
+ const matches = useMemo(() => getResults ? contextualCommands(getResults(query)) : matchingCommands(commands, query, showAll), [commands, query, showAll, getResults]);
141
113
  useLayoutEffect(() => {
142
114
  resultsRef.current.querySelector('[aria-selected="true"]')?.scrollIntoView({
143
115
  block: "nearest"
@@ -208,15 +180,16 @@ function OpenCommandPalette({
208
180
  }),
209
181
  "aria-describedby": hintId,
210
182
  children: matches.length > 0 ? matches.map((command, index) => _jsxs(Fragment, {
211
- children: [command.group !== matches[index - 1]?.group ? _jsx("div", {
183
+ children: [command.group !== matches[index - 1]?.group || command.context !== matches[index - 1]?.context ? _jsx("div", {
212
184
  className: "mdbase-command-group",
213
185
  role: "presentation",
214
- children: groupLabel ? groupLabel(command.group) : command.group
186
+ children: command.context ?? (groupLabel ? groupLabel(command.group) : command.group)
215
187
  }) : null, _jsx(CommandRow, {
216
188
  id: `${hintId}-${command.id}`,
217
189
  command: command,
218
190
  query: query,
219
191
  active: index === active,
192
+ onActivate: () => setActive(index),
220
193
  onRun: run
221
194
  })]
222
195
  }, command.id)) : _jsx("div", {
@@ -249,8 +222,8 @@ function OpenCommandPalette({
249
222
  }), " ", _i18n._(
250
223
  /** i18n */
251
224
  {
252
- id: "2cqK5k",
253
- message: "to open"
225
+ id: "yq3Myn",
226
+ message: "to run"
254
227
  })]
255
228
  }), matches[active]?.alternate ? _jsxs("span", {
256
229
  children: [_jsx("kbd", {
@@ -281,6 +254,7 @@ function CommandRow({
281
254
  command,
282
255
  query,
283
256
  active,
257
+ onActivate,
284
258
  onRun
285
259
  }) {
286
260
  useLocaleRevision();
@@ -294,6 +268,9 @@ function CommandRow({
294
268
  type: "button",
295
269
  role: "option",
296
270
  "aria-selected": active,
271
+ onPointerMove: event => {
272
+ if (event.movementX || event.movementY) onActivate();
273
+ },
297
274
  onMouseDown: event => event.preventDefault(),
298
275
  onClick: event => onRun(command, event.shiftKey),
299
276
  children: [command.icon && _jsx("span", {
package/dist/Dialog.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { i18n as _i18n } from "@lingui/core";
3
- import { useId, useLayoutEffect, useRef } from "react";
3
+ import { useEffect, useId, useLayoutEffect, useRef } from "react";
4
4
  import { createPortal } from "react-dom";
5
5
  import { useLocaleRevision } from "./i18n.js";
6
6
  import { useOverlay } from "./overlay.js";
7
+ import { Tooltip } from "./Tooltip.js";
7
8
  export function Dialog({
8
9
  open,
9
10
  onClose,
@@ -65,7 +66,7 @@ export function Dialog({
65
66
  preventScroll: true
66
67
  });
67
68
  }, [closeDisabled, open, ref]);
68
- useLayoutEffect(() => {
69
+ useEffect(() => {
69
70
  const dialog = ref.current;
70
71
  return () => {
71
72
  const wasOpen = dialog?.open;
@@ -115,26 +116,29 @@ export function Dialog({
115
116
  children: [_jsx("h2", {
116
117
  id: titleId,
117
118
  children: title
118
- }), _jsx("button", {
119
- type: "button",
120
- className: "mdbase-icon-button",
121
- disabled: closeDisabled,
122
- onClick: onClose,
123
- "aria-label": _i18n._(
119
+ }), _jsx(Tooltip, {
120
+ label: _i18n._(
124
121
  /** i18n */
125
122
  {
126
123
  id: "yz7wBu",
127
124
  message: "Close"
128
125
  }),
129
- children: _jsx("svg", {
130
- viewBox: "0 0 24 24",
131
- "aria-hidden": "true",
132
- fill: "none",
133
- stroke: "currentColor",
134
- strokeWidth: "1.6",
135
- strokeLinecap: "round",
136
- children: _jsx("path", {
137
- d: "m6 6 12 12M18 6 6 18"
126
+ shortcut: "Escape",
127
+ children: _jsx("button", {
128
+ type: "button",
129
+ className: "mdbase-icon-button",
130
+ disabled: closeDisabled,
131
+ onClick: onClose,
132
+ children: _jsx("svg", {
133
+ viewBox: "0 0 24 24",
134
+ "aria-hidden": "true",
135
+ fill: "none",
136
+ stroke: "currentColor",
137
+ strokeWidth: "1.6",
138
+ strokeLinecap: "round",
139
+ children: _jsx("path", {
140
+ d: "m6 6 12 12M18 6 6 18"
141
+ })
138
142
  })
139
143
  })
140
144
  })]
@@ -0,0 +1,6 @@
1
+ import { type ButtonHTMLAttributes, type ReactElement } from "react";
2
+ export declare function Tooltip({ label, shortcut, children }: {
3
+ readonly label: string;
4
+ readonly shortcut?: string;
5
+ readonly children: ReactElement<ButtonHTMLAttributes<HTMLButtonElement>>;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,143 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cloneElement, useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
3
+ import { useLocaleRevision } from "./i18n.js";
4
+ import { isApplePlatform, shortcutLabel } from "./shortcuts.js";
5
+ let activeTooltip;
6
+ let warmUntil = 0;
7
+ export function Tooltip({
8
+ label,
9
+ shortcut,
10
+ children
11
+ }) {
12
+ useLocaleRevision();
13
+ const id = useId();
14
+ const trigger = useRef(null);
15
+ const tooltip = useRef(null);
16
+ const timer = useRef(undefined);
17
+ const dispose = useRef(undefined);
18
+ const touch = useRef(false);
19
+ const [open, setOpen] = useState(false);
20
+ const close = useCallback(() => {
21
+ clearTimeout(timer.current);
22
+ dispose.current?.();
23
+ if (tooltip.current) warmUntil = performance.now() + 800;
24
+ if (activeTooltip === close) activeTooltip = undefined;
25
+ setOpen(false);
26
+ }, []);
27
+ useEffect(() => close, [close]);
28
+ useLayoutEffect(() => {
29
+ if (!open) return;
30
+ const bubble = tooltip.current;
31
+ bubble.showPopover();
32
+ const button = trigger.current.getBoundingClientRect();
33
+ const bounds = bubble.getBoundingClientRect();
34
+ bubble.style.left = `${Math.max(8, Math.min(button.left + (button.width - bounds.width) / 2, innerWidth - bounds.width - 8))}px`;
35
+ bubble.style.top = `${Math.max(8, Math.min(button.bottom + 6 + bounds.height <= innerHeight - 8 ? button.bottom + 6 : button.top - bounds.height - 6, innerHeight - bounds.height - 8))}px`;
36
+ }, [open, label, shortcut]);
37
+ const show = (button, delay) => {
38
+ const available = () => button.isConnected && !button.matches(":disabled, [aria-disabled=true]") && !button.closest("[hidden], [inert], [aria-hidden=true]") && button.checkVisibility({
39
+ checkVisibilityCSS: true,
40
+ checkOpacity: true
41
+ });
42
+ if (!available()) return;
43
+ activeTooltip?.();
44
+ activeTooltip = close;
45
+ trigger.current = button;
46
+ const controller = new AbortController();
47
+ const observer = new MutationObserver(() => {
48
+ if (!available()) close();
49
+ });
50
+ observer.observe(document.documentElement, {
51
+ subtree: true,
52
+ childList: true,
53
+ attributes: true,
54
+ attributeFilter: ["disabled", "aria-disabled", "hidden", "aria-hidden", "inert", "style", "class", "open"]
55
+ });
56
+ dispose.current = () => {
57
+ controller.abort();
58
+ observer.disconnect();
59
+ };
60
+ document.addEventListener("keydown", event => {
61
+ if (event.key !== "Escape") return;
62
+ if (tooltip.current) {
63
+ event.preventDefault();
64
+ event.stopImmediatePropagation();
65
+ }
66
+ close();
67
+ }, {
68
+ capture: true,
69
+ signal: controller.signal
70
+ });
71
+ document.addEventListener("pointerdown", close, {
72
+ capture: true,
73
+ signal: controller.signal
74
+ });
75
+ document.addEventListener("scroll", close, {
76
+ capture: true,
77
+ signal: controller.signal
78
+ });
79
+ window.addEventListener("resize", close, {
80
+ signal: controller.signal
81
+ });
82
+ window.addEventListener("blur", close, {
83
+ signal: controller.signal
84
+ });
85
+ if (delay && performance.now() >= warmUntil) timer.current = setTimeout(() => {
86
+ if (available()) setOpen(true);else close();
87
+ }, 400);else setOpen(true);
88
+ };
89
+ const leave = () => {
90
+ clearTimeout(timer.current);
91
+ if (tooltip.current) timer.current = setTimeout(close, 120);else close();
92
+ };
93
+ return _jsxs(_Fragment, {
94
+ children: [cloneElement(children, {
95
+ "aria-label": children.props["aria-label"] ?? label,
96
+ "aria-keyshortcuts": shortcut ? shortcut.replace(/\bmod\b/giu, isApplePlatform() ? "Meta" : "Control").replace(/\bctrl\b/giu, "Control") : children.props["aria-keyshortcuts"],
97
+ "aria-describedby": [children.props["aria-describedby"], open && shortcut ? id : ""].filter(Boolean).join(" ") || undefined,
98
+ title: undefined,
99
+ onPointerEnter: event => {
100
+ if (event.pointerType !== "touch" && matchMedia("(hover: hover)").matches) show(event.currentTarget, true);
101
+ children.props.onPointerEnter?.(event);
102
+ },
103
+ onPointerLeave: event => {
104
+ leave();
105
+ children.props.onPointerLeave?.(event);
106
+ },
107
+ onPointerDown: event => {
108
+ touch.current = event.pointerType === "touch";
109
+ close();
110
+ children.props.onPointerDown?.(event);
111
+ },
112
+ onFocus: event => {
113
+ if (!touch.current && event.currentTarget.matches(":focus-visible")) show(event.currentTarget, false);
114
+ children.props.onFocus?.(event);
115
+ },
116
+ onBlur: event => {
117
+ touch.current = false;
118
+ close();
119
+ children.props.onBlur?.(event);
120
+ },
121
+ onKeyDown: event => {
122
+ touch.current = false;
123
+ if (event.key === "Enter" || event.key === " ") close();
124
+ children.props.onKeyDown?.(event);
125
+ },
126
+ onClick: event => {
127
+ close();
128
+ children.props.onClick?.(event);
129
+ }
130
+ }), open && _jsxs("span", {
131
+ ref: tooltip,
132
+ role: "tooltip",
133
+ popover: "manual",
134
+ className: "mdbase-tooltip",
135
+ onPointerEnter: () => clearTimeout(timer.current),
136
+ onPointerLeave: leave,
137
+ children: [label, shortcut && _jsx("kbd", {
138
+ id: id,
139
+ children: shortcutLabel(shortcut)
140
+ })]
141
+ })]
142
+ });
143
+ }
@@ -37,8 +37,11 @@ export const mdbasePopupTheme = EditorView.theme({
37
37
  lineHeight: "1.35"
38
38
  },
39
39
  ".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]": {
40
- color: "var(--color-text)",
41
- background: "var(--color-selected)"
40
+ color: "var(--color-on-current)",
41
+ background: "var(--color-current)"
42
+ },
43
+ ".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected] :is(.cm-completionLabel, .cm-completionDetail, .cm-completionMatchedText, .cm-completionIcon), .cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected] .cm-completionIcon::after": {
44
+ color: "inherit"
42
45
  },
43
46
  ".cm-tooltip.cm-tooltip-autocomplete > ul > li > *": {
44
47
  minWidth: "0",
@@ -112,16 +115,28 @@ export const mdbasePopupTheme = EditorView.theme({
112
115
  },
113
116
  ".cm-diagnostic": {
114
117
  padding: "4px 8px",
118
+ border: "0",
115
119
  borderRadius: "var(--control-radius, 2px)",
116
120
  fontFamily: "var(--sans)"
117
121
  },
118
122
  ".cm-diagnostic-error": {
119
- borderLeft: "3px solid var(--color-danger)"
123
+ backgroundColor: "var(--color-danger-soft)"
120
124
  },
121
125
  ".cm-diagnostic-warning": {
122
- borderLeft: "3px solid var(--color-warning)"
126
+ backgroundColor: "var(--color-warning-surface)"
123
127
  },
124
128
  ".cm-diagnostic-info, .cm-diagnostic-hint": {
125
- borderLeft: "3px solid var(--color-accent)"
129
+ backgroundColor: "var(--color-accent-soft)"
130
+ },
131
+ ".cm-panel.cm-panel-lint": {
132
+ color: "var(--color-text)",
133
+ backgroundColor: "var(--color-surface)"
134
+ },
135
+ ".cm-panel.cm-panel-lint ul [aria-selected], .cm-panel.cm-panel-lint ul:focus [aria-selected]": {
136
+ color: "var(--color-on-current)",
137
+ backgroundColor: "var(--color-current)"
138
+ },
139
+ ".cm-panel.cm-panel-lint [aria-selected] .cm-diagnosticSource": {
140
+ opacity: "1"
126
141
  }
127
142
  });
@@ -177,7 +177,10 @@ export function useCollectionUi(options) {
177
177
  }));
178
178
  },
179
179
  start: () => {
180
- void run("start", signal => mdbase.start({
180
+ const collectionId = mdbase.getSnapshot().selectedCollectionId;
181
+ void run("start", signal => collectionId ? mdbase.select(collectionId, {
182
+ signal
183
+ }) : mdbase.start({
181
184
  signal
182
185
  }));
183
186
  },