@qilin-agent/client-ui-primitives 3.1.6 → 3.1.8

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.
Files changed (63) hide show
  1. package/README.i18n.yaml +8 -8
  2. package/README.md +11 -4
  3. package/README.zh.md +12 -4
  4. package/lib/AnimatedRows.module.css +7 -0
  5. package/lib/Button.module.css +6 -3
  6. package/lib/DetailDocument.module.css +67 -0
  7. package/lib/HoverCard.module.css +3 -3
  8. package/lib/ImageLightbox.module.css +1 -1
  9. package/lib/InlineEditor.module.css +1 -1
  10. package/lib/Input.module.css +2 -2
  11. package/lib/Menu.module.css +127 -78
  12. package/lib/MenuSurface.module.css +23 -7
  13. package/lib/QuotePreview.module.css +89 -0
  14. package/lib/RowDragPreview.module.css +12 -0
  15. package/lib/SegmentedTabs.module.css +4 -1
  16. package/lib/Tag.module.css +1 -1
  17. package/lib/TerminalBlock.module.css +1 -1
  18. package/lib/Toast.module.css +28 -0
  19. package/lib/Tooltip.module.css +18 -3
  20. package/lib/UserMessageBubble.module.css +11 -0
  21. package/lib/index.js +4919 -2423
  22. package/lib/markdown/CodeBlock.module.css +23 -0
  23. package/lib/markdown/JsonBlock.module.css +1 -1
  24. package/lib/markdown/MarkdownText.module.css +11 -7
  25. package/lib/settings-form/fields.module.css +2 -2
  26. package/lib/types/AnimatedRows.d.ts +46 -0
  27. package/lib/types/Button.d.ts +13 -4
  28. package/lib/types/DetailDocument.d.ts +79 -0
  29. package/lib/types/ImageLightbox.d.ts +3 -1
  30. package/lib/types/LinkIcon.d.ts +15 -30
  31. package/lib/types/Menu.d.ts +30 -9
  32. package/lib/types/MenuSurface.d.ts +9 -0
  33. package/lib/types/PermissionIcon.d.ts +51 -0
  34. package/lib/types/QuotePreview.d.ts +26 -0
  35. package/lib/types/ReferenceIcon.d.ts +12 -7
  36. package/lib/types/SegmentedTabs.d.ts +3 -1
  37. package/lib/types/SiteGlyph.d.ts +1 -1
  38. package/lib/types/Toast.d.ts +19 -1
  39. package/lib/types/Tooltip.d.ts +36 -21
  40. package/lib/types/UserMessageBubble.d.ts +11 -0
  41. package/lib/types/code-file-types.d.ts +1 -1
  42. package/lib/types/code-highlighting.d.ts +12 -0
  43. package/lib/types/focus.d.ts +8 -0
  44. package/lib/types/icons/index.d.ts +405 -216
  45. package/lib/types/icons/props.d.ts +1 -1
  46. package/lib/types/icons/shared-artwork.d.ts +44 -0
  47. package/lib/types/index.d.ts +23 -6
  48. package/lib/types/markdown/MarkdownDelegate.d.ts +19 -2
  49. package/lib/types/markdown/MarkdownText.d.ts +3 -1
  50. package/lib/types/markdown/file-link.d.ts +13 -3
  51. package/lib/types/markdown/mathCompatibility.d.ts +12 -5
  52. package/lib/types/markdown/render.d.ts +2 -1
  53. package/lib/types/markdown/windows-path-destinations.d.ts +12 -0
  54. package/lib/types/motion.d.ts +13 -0
  55. package/lib/types/overlay-top-margin.d.ts +10 -2
  56. package/lib/types/quote-text.d.ts +69 -0
  57. package/lib/types/tooltip-placement.d.ts +35 -0
  58. package/lib/types/use-clipboard-copy.d.ts +14 -0
  59. package/lib/types/useAnchoredPosition.d.ts +31 -18
  60. package/lib/types/useRowDragPreview.d.ts +20 -0
  61. package/lib/types/user-text.d.ts +24 -2
  62. package/package.json +8 -6
  63. package/lib/types/use-copy-feedback.d.ts +0 -14
@@ -1,17 +1,19 @@
1
- import type { FocusEventHandler, MouseEventHandler, ReactElement, Ref } from 'react';
2
- /** Bubble placement relative to the anchor. */
3
- export type TooltipSide = 'right' | 'bottom' | 'top';
1
+ /** Anchor-preserving tooltips; an optional body portal escapes clipping containers and stacking contexts that cap the bubble's z-index. */
2
+ import type { FocusEventHandler, MouseEventHandler, PointerEventHandler, ReactElement, Ref } from 'react';
3
+ import { type TooltipSide } from './tooltip-placement.ts';
4
+ export type { TooltipSide } from './tooltip-placement.ts';
4
5
  /**
5
- * Suppression channel for enclosing tooltip and hover-card anchors: a visible
6
- * tooltip within an anchor withdraws the enclosing preview while its bubble is shown.
6
+ * Suppression channel for nested tooltips: a visible descendant tooltip
7
+ * withdraws the enclosing tooltip while its bubble is shown.
7
8
  */
8
9
  export declare const TooltipSuppression: import("react").Context<((suppressed: boolean) => void) | null>;
9
10
  /** Props Tooltip injects into its anchor child; the child's own handlers are chained ahead of the tooltip's. */
10
11
  interface AnchorProps {
11
12
  'aria-describedby'?: string | undefined;
12
13
  ref?: Ref<HTMLElement> | undefined;
13
- onMouseEnter?: MouseEventHandler | undefined;
14
- onMouseLeave?: MouseEventHandler | undefined;
14
+ onPointerEnter?: PointerEventHandler | undefined;
15
+ onPointerLeave?: PointerEventHandler | undefined;
16
+ onPointerDown?: PointerEventHandler | undefined;
15
17
  onClick?: MouseEventHandler | undefined;
16
18
  onFocus?: FocusEventHandler | undefined;
17
19
  onBlur?: FocusEventHandler | undefined;
@@ -19,36 +21,49 @@ interface AnchorProps {
19
21
  type TooltipLabel = string | (() => string);
20
22
  /**
21
23
  * Attach a hover/focus tooltip to an anchor element.
22
- * @param props.label - bubble text, or a resolver evaluated only while the bubble is visible.
24
+ * @param props.label - bubble text, or a resolver evaluated only while visible; an empty string shows only shortcut keys.
23
25
  * @param props.shortcutKeys - effective key labels rendered as platform-formatted keycaps after optional text.
24
- * @param props.side - placement relative to the anchor (default 'right').
26
+ * @param props.side - preferred placement (default 'right'); fitting tries the opposite then perpendicular sides.
27
+ * @param props.align - horizontal anchor-edge alignment for 'bottom'/'top' bubbles: 'end' pins
28
+ * the bubble's right edge to the anchor's (for anchors beside other hover surfaces the centered
29
+ * bubble would overlap); default 'center'. Horizontal placements ignore it.
30
+ * @param props.portal - render the bubble under document.body, so an ancestor's clipping or its
31
+ * stacking context (which confines the bubble's z-index to that context) cannot hide it.
25
32
  * @param props.delayMs - hover delay in milliseconds (default 0).
26
- * @param props.focusDelayMs - keyboard focus delay in milliseconds (default 0); blur, mouse
27
- * leave, disabling, and unmount cancel a pending show.
33
+ * @param props.focusDelayMs - keyboard focus delay in milliseconds (default 0); blur, click,
34
+ * mouse leave, disabling, and unmount cancel a pending show.
35
+ * @param props.gap - anchor-to-bubble distance in pixels for 'bottom'/'top' bubbles (default 8);
36
+ * horizontal placements use 10px, including after a flip.
28
37
  * @param props.disabled - suppress the bubble while true; the anchor renders identically so
29
38
  * toggling never remounts it (which would cut its CSS transitions).
30
- * @param props.portal - render the bubble under document.body, so an ancestor's clipping or its
31
- * stacking context can neither clip the bubble nor paint over it.
32
39
  * @param props.maxWidth - bubble width cap in pixels, for labels long enough that the default
33
- * half-viewport cap would render a slab wider than the surface the anchor sits on.
34
- * @param props.openOnClick - clicking also pins the bubble for reading; another click, Escape,
35
- * Tab, or an outside pointerdown dismisses it. Defaults to false, leaving an ordinary action
36
- * tooltip to hover and focus alone.
40
+ * half-viewport cap would render a slab wider than the surface the anchor sits on; always bounded by viewport margins.
41
+ * @param props.openOnClick - clicking or tapping also pins the bubble for reading; another click, Escape,
42
+ * Tab, or an outside pointerdown dismisses it. Defaults to false for ordinary action tooltips.
43
+ * @param props.onlyWhenClipped - show the bubble only when the anchor or an HTML element inside it
44
+ * overflows horizontally, measured when the bubble is about to show; for labels that repeat
45
+ * text an ellipsis may cut off. Defaults to false.
37
46
  * @param props.children - a single anchor element; its own ref (callback or object) is forwarded alongside the tooltip's.
38
- * An anchor that accepts no ref still positions the bubble: a raise records the element the event ran on.
39
- * @returns the cloned anchor plus a fixed-position bubble while hovered/focused.
47
+ * @returns the cloned anchor plus a fixed-position bubble, optionally portaled to the body.
48
+ * The bubble stays hidden until ResizeObserver supplies its size for viewport fitting; clicking the
49
+ * anchor dismisses the bubble unless openOnClick is enabled, and focus arriving after a pointer
50
+ * interaction (a closing menu refocusing its trigger) never raises it. Touch cannot trigger hover
51
+ * tooltips; tapping still invokes the child's action and can open an openOnClick explanation.
52
+ * When no side fits, the viewport-bounded fallback may overlap the anchor; oversized content is scrollable when pinned.
40
53
  */
41
- export declare function Tooltip({ label, shortcutKeys, side, delayMs, focusDelayMs, disabled, portal, maxWidth, openOnClick, children }: {
54
+ export declare function Tooltip({ label, shortcutKeys, side, align, delayMs, focusDelayMs, gap, disabled, portal, maxWidth, openOnClick, onlyWhenClipped, children }: {
42
55
  label: TooltipLabel;
43
56
  shortcutKeys?: readonly string[] | undefined;
44
57
  side?: TooltipSide;
58
+ align?: 'center' | 'end';
45
59
  delayMs?: number;
46
60
  focusDelayMs?: number;
61
+ gap?: number;
47
62
  disabled?: boolean;
48
63
  portal?: boolean;
49
64
  maxWidth?: number;
50
65
  openOnClick?: boolean;
66
+ onlyWhenClipped?: boolean;
51
67
  children: ReactElement<AnchorProps>;
52
68
  }): import("react").JSX.Element;
53
- export {};
54
69
  //# sourceMappingURL=Tooltip.d.ts.map
@@ -0,0 +1,11 @@
1
+ /** Shared user-message background, typography, and content inset. */
2
+ import type { ComponentPropsWithoutRef } from 'react';
3
+ /** Native div attributes for user-authored message content. */
4
+ export type UserMessageBubbleProps = ComponentPropsWithoutRef<'div'>;
5
+ /**
6
+ * Render user-style message content without row placement or actions.
7
+ * @param props - Native div attributes and the caller-owned content.
8
+ * @returns A theme-aware message surface that wraps its content.
9
+ */
10
+ export declare function UserMessageBubble({ className, ...props }: UserMessageBubbleProps): import("react").JSX.Element;
11
+ //# sourceMappingURL=UserMessageBubble.d.ts.map
@@ -14,7 +14,7 @@ export interface FileTypeProjectContext {
14
14
  */
15
15
  export declare function isCodeFileType(type: string): type is CodeFileType;
16
16
  /**
17
- * Test whether an extension belonged to the established coarse LinkIcon code category.
17
+ * Test whether an extension belongs to the established coarse link-icon code category.
18
18
  * @param extension - Extension without a leading dot.
19
19
  * @returns Whether clickable links keep the code glyph for this extension.
20
20
  */
@@ -0,0 +1,12 @@
1
+ import { type HighlightSpan } from './markdown/highlight.ts';
2
+ export { CODE_HIGHLIGHT_EXTENSIONS, languageForPath } from '@qilin-agent/util-code-language';
3
+ /** Highlight one source fragment into one token list per line. */
4
+ export type CodeHighlighter = (code: string) => HighlightSpan[][] | undefined;
5
+ /**
6
+ * Bind the shared lazy highlighter to one language and refresh after its grammar loads.
7
+ * @param language - grammar hint selected from the source filename.
8
+ * @returns a stable fragment highlighter; unknown and loading grammars return `undefined` for plain-text fallback.
9
+ */
10
+ export declare function useCodeHighlighter(language: string | undefined): CodeHighlighter;
11
+ export type { HighlightSpan };
12
+ //# sourceMappingURL=code-highlighting.d.ts.map
@@ -6,4 +6,12 @@
6
6
  * @param options - browser focus options, including scroll preservation.
7
7
  */
8
8
  export declare function focusWithoutRing(element: HTMLElement, options?: FocusOptions): void;
9
+ /**
10
+ * Whether this browser runs on a touch-first mobile device.
11
+ *
12
+ * The answer is cached, so a caller must not expect it to follow a viewport
13
+ * resize. It drives input-shape choices only; layout reacts to container width.
14
+ * @returns `true` on a mobile browser, `false` on a desktop one.
15
+ */
16
+ export declare function isMobileDevice(): boolean;
9
17
  //# sourceMappingURL=focus.d.ts.map