@x1a0f3n9/dsh-client-ui-primitives 0.1.5-rc.3
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/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +164 -0
- package/README.zh.md +164 -0
- package/lib/Button.module.css +79 -0
- package/lib/ConnectionIndicator.module.css +107 -0
- package/lib/DiffBlock.module.css +101 -0
- package/lib/DisclosureRow.module.css +84 -0
- package/lib/FileTypeIcon.module.css +50 -0
- package/lib/HoverCard.module.css +54 -0
- package/lib/Input.module.css +38 -0
- package/lib/JsonTree.module.css +222 -0
- package/lib/Menu.module.css +248 -0
- package/lib/Modal.module.css +103 -0
- package/lib/OnboardingSurface.module.css +29 -0
- package/lib/Pill.module.css +27 -0
- package/lib/ReadBlock.module.css +111 -0
- package/lib/RiskConfirmation.module.css +73 -0
- package/lib/SearchBlock.module.css +112 -0
- package/lib/StateDot.module.css +73 -0
- package/lib/Switch.module.css +50 -0
- package/lib/Tag.module.css +57 -0
- package/lib/TerminalBlock.module.css +205 -0
- package/lib/Toast.module.css +72 -0
- package/lib/Tooltip.module.css +42 -0
- package/lib/WebBlock.module.css +141 -0
- package/lib/index.js +8030 -0
- package/lib/markdown/CodeBlock.module.css +130 -0
- package/lib/markdown/JsonBlock.module.css +32 -0
- package/lib/markdown/MarkdownText.module.css +321 -0
- package/lib/types/BrandWordmark.d.ts +15 -0
- package/lib/types/Button.d.ts +18 -0
- package/lib/types/CodeFileIcon.d.ts +12 -0
- package/lib/types/ConnectionIndicator.d.ts +25 -0
- package/lib/types/DiffBlock.d.ts +53 -0
- package/lib/types/DisclosureRow.d.ts +29 -0
- package/lib/types/FileTypeIcon.d.ts +43 -0
- package/lib/types/FishLogo.d.ts +16 -0
- package/lib/types/FoldToggle.d.ts +20 -0
- package/lib/types/HoverCard.d.ts +24 -0
- package/lib/types/Input.d.ts +11 -0
- package/lib/types/JsonTree.d.ts +48 -0
- package/lib/types/LinkIcon.d.ts +38 -0
- package/lib/types/Menu.d.ts +85 -0
- package/lib/types/Modal.d.ts +35 -0
- package/lib/types/OnboardingSurface.d.ts +11 -0
- package/lib/types/Pill.d.ts +13 -0
- package/lib/types/ReadBlock.d.ts +47 -0
- package/lib/types/ReferenceIcon.d.ts +16 -0
- package/lib/types/RiskConfirmation.d.ts +20 -0
- package/lib/types/SearchBlock.d.ts +72 -0
- package/lib/types/StateDot.d.ts +18 -0
- package/lib/types/Switch.d.ts +20 -0
- package/lib/types/Tag.d.ts +32 -0
- package/lib/types/TerminalBlock.d.ts +61 -0
- package/lib/types/Toast.d.ts +32 -0
- package/lib/types/Tooltip.d.ts +34 -0
- package/lib/types/WebBlock.d.ts +61 -0
- package/lib/types/ansi.d.ts +17 -0
- package/lib/types/clipboard.d.ts +9 -0
- package/lib/types/code-file-icon-artwork.d.ts +54 -0
- package/lib/types/code-file-types.d.ts +30 -0
- package/lib/types/file-size.d.ts +8 -0
- package/lib/types/head-tail-cap.d.ts +23 -0
- package/lib/types/icons/index.d.ts +194 -0
- package/lib/types/icons/props.d.ts +9 -0
- package/lib/types/index.d.ts +66 -0
- package/lib/types/markdown/CodeBlock.d.ts +28 -0
- package/lib/types/markdown/JsonBlock.d.ts +8 -0
- package/lib/types/markdown/MarkdownText.d.ts +42 -0
- package/lib/types/markdown/cjkFriendlyStrong.d.ts +9 -0
- package/lib/types/markdown/highlight.d.ts +142 -0
- package/lib/types/markdown/incremental.d.ts +80 -0
- package/lib/types/markdown/katex.d.ts +27 -0
- package/lib/types/markdown/mathCompatibility.d.ts +11 -0
- package/lib/types/markdown/parse.d.ts +25 -0
- package/lib/types/markdown/plain-text.d.ts +22 -0
- package/lib/types/markdown/render.d.ts +138 -0
- package/lib/types/markdown/useViewportHighlighting.d.ts +11 -0
- package/lib/types/pointer-grace.d.ts +22 -0
- package/lib/types/rank-by-name.d.ts +22 -0
- package/lib/types/relative-time.d.ts +23 -0
- package/lib/types/use-copy-feedback.d.ts +14 -0
- package/lib/types/useAnchoredMaxHeight.d.ts +11 -0
- package/lib/types/useAnchoredPosition.d.ts +34 -0
- package/lib/types/useDismissOnOutsidePointer.d.ts +11 -0
- package/lib/types/user-text.d.ts +39 -0
- package/lib/user-text.module.css +43 -0
- package/package.json +58 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared ranking for `/` menu candidates: the query must be a
|
|
3
|
+
* case-insensitive ordered subsequence of the candidate name or, when the
|
|
4
|
+
* candidate carries one, of its display label (a localized title). Prefix
|
|
5
|
+
* hits rank first, then the strongest alignment score over either key, then
|
|
6
|
+
* the source order of the input. Decision record:
|
|
7
|
+
* .agents/notes/archived/feature/2026-08-04-web-slash-command-fuzzy-discovery.md
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Rank named items by a menu query.
|
|
11
|
+
* @param items - candidates in source order (a host catalog, then client
|
|
12
|
+
* contributions); an item's optional `label` is a second search key beside
|
|
13
|
+
* its name.
|
|
14
|
+
* @param rawQuery - the text typed after the trigger, matched case-insensitively.
|
|
15
|
+
* @returns the matching items: prefix hits first, then by alignment score,
|
|
16
|
+
* then in source order. The input list itself for an empty query.
|
|
17
|
+
*/
|
|
18
|
+
export declare function rankByName<T extends {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly label?: string;
|
|
21
|
+
}>(items: readonly T[], rawQuery: string): readonly T[];
|
|
22
|
+
//# sourceMappingURL=rank-by-name.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compact relative-time bucketing shared by every surface that dates a
|
|
3
|
+
* session. Bucketing is here so two surfaces naming the same session agree;
|
|
4
|
+
* the words stay in each plugin's own dictionary, per locale-owned copy.
|
|
5
|
+
*
|
|
6
|
+
* @module @x1a0f3n9/dsh-client-ui-primitives/relative-time
|
|
7
|
+
*/
|
|
8
|
+
/** Relative-time bucket of a dated row's trailing label. */
|
|
9
|
+
export type RelativeTimeUnit = 'now' | 'minutes' | 'hours' | 'days' | 'months' | 'years';
|
|
10
|
+
/** Structured relative time: the bucket plus its magnitude (0 for 'now'). */
|
|
11
|
+
export interface RelativeTime {
|
|
12
|
+
unit: RelativeTimeUnit;
|
|
13
|
+
n: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Compact relative time, as a structured bucket the renderer localizes
|
|
17
|
+
* ("now"/"5min"/"3h"/"2d"/"4mo"/"1y" in en).
|
|
18
|
+
* @param at - epoch ms of the dated moment.
|
|
19
|
+
* @param now - current epoch ms (injected for pure rendering).
|
|
20
|
+
* @returns the row's trailing time bucket and magnitude.
|
|
21
|
+
*/
|
|
22
|
+
export declare function relativeTime(at: number, now: number): RelativeTime;
|
|
23
|
+
//# sourceMappingURL=relative-time.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The copy-feedback hook's return: the transient flag and the copy handler. */
|
|
2
|
+
export interface CopyFeedback {
|
|
3
|
+
/** True for {@link COPIED_FEEDBACK_MS} after a successful write; render the success label off it. */
|
|
4
|
+
copied: boolean;
|
|
5
|
+
/** Copy the hook's text; no-op while `copied` is still true, silent on a refused write. */
|
|
6
|
+
onCopy: () => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Copy `text` to the clipboard with one-second success feedback.
|
|
10
|
+
* @param text - the text to write on copy.
|
|
11
|
+
* @returns the `copied` flag and the `onCopy` handler.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useCopyFeedback(text: string): CopyFeedback;
|
|
14
|
+
//# sourceMappingURL=use-copy-feedback.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Clamp a bottom-anchored overlay's max-height to the viewport.
|
|
4
|
+
* @param ref - the overlay element; a null current (overlay closed) skips measuring.
|
|
5
|
+
* @param cap - design max-height in px (the clamp never exceeds it).
|
|
6
|
+
* @param signal - re-measure trigger: pass the overlay's render state so anchor
|
|
7
|
+
* moves (composer growth) re-fit; resize/scroll re-fit while mounted.
|
|
8
|
+
* @returns the max-height to apply inline, in px.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useAnchoredMaxHeight(ref: RefObject<HTMLElement>, cap: number, signal: unknown): number;
|
|
11
|
+
//# sourceMappingURL=useAnchoredMaxHeight.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keep a fixed-position floating element anchored to a trigger.
|
|
3
|
+
*
|
|
4
|
+
* A portaled panel is positioned from its anchor's viewport rect, which stops
|
|
5
|
+
* being true the moment anything scrolls or the window resizes. This owns that
|
|
6
|
+
* one concern: measure the anchor, offset the panel below or above it, clamp
|
|
7
|
+
* the result inside the viewport, and re-run on scroll (capture phase, so
|
|
8
|
+
* scrollers nested inside the page are caught too), on resize, and on the
|
|
9
|
+
* panel's own size changes while the element is open.
|
|
10
|
+
* @module @x1a0f3n9/dsh-client-ui-primitives/useAnchoredPosition
|
|
11
|
+
*/
|
|
12
|
+
import { type CSSProperties, type RefObject } from 'react';
|
|
13
|
+
/** Inputs for {@link useAnchoredPosition}. */
|
|
14
|
+
export interface AnchoredPositionOptions {
|
|
15
|
+
/** Whether the floating element is mounted and should track its anchor. */
|
|
16
|
+
open: boolean;
|
|
17
|
+
/** The element the panel is placed from. */
|
|
18
|
+
anchorRef: RefObject<HTMLElement | null>;
|
|
19
|
+
/** The floating element, measured so the clamp uses real dimensions. */
|
|
20
|
+
panelRef: RefObject<HTMLElement | null>;
|
|
21
|
+
/** Which anchor edge the panel hangs from: below it (`bottom`, the default) or above it (`top`). */
|
|
22
|
+
side?: 'top' | 'bottom';
|
|
23
|
+
/** Distance kept between the anchor edge named by `side` and the panel. */
|
|
24
|
+
gap: number;
|
|
25
|
+
/** Distance kept between the panel and each viewport edge. */
|
|
26
|
+
margin: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Track an anchor and return the panel's fixed coordinates.
|
|
30
|
+
* @param options - the open state, the two refs, the placement side, and the gap/margin distances.
|
|
31
|
+
* @returns `left`/`top` for the panel, or `null` before the first measurement.
|
|
32
|
+
*/
|
|
33
|
+
export declare function useAnchoredPosition(options: AnchoredPositionOptions): CSSProperties | null;
|
|
34
|
+
//# sourceMappingURL=useAnchoredPosition.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Close an open popover when a pointerdown lands outside its root element.
|
|
4
|
+
* @param root - element containing both the trigger and the open surface.
|
|
5
|
+
* @param open - whether the surface is showing; false detaches the listener.
|
|
6
|
+
* @param setOpen - state setter invoked with false on an outside pointerdown.
|
|
7
|
+
* @param portal - surface portaled outside the root (a `document.body` dialog)
|
|
8
|
+
* that also counts as inside; omit when the root contains the whole popover.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useDismissOnOutsidePointer(root: RefObject<HTMLElement | null>, open: boolean, setOpen: (open: boolean) => void, portal?: RefObject<HTMLElement | null>): void;
|
|
11
|
+
//# sourceMappingURL=useDismissOnOutsidePointer.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display projection of reference forms in sent user text (bubble and queue
|
|
3
|
+
* rows). The logged model text remains the single truth; this is presentation
|
|
4
|
+
* only, and every part renders inline so a single-line message never breaks
|
|
5
|
+
* across lines. Four decoration sources, by precedence: the wire session form
|
|
6
|
+
* `@[label](dsh-session:...)` folds to its label; exact session labels
|
|
7
|
+
* supplied by an adjacent recall decorate their bare `@label` mention; plain
|
|
8
|
+
* `@name` word-boundary tokens decorate by shape alone; and a plain `/name`
|
|
9
|
+
* token decorates only when the caller names it — a skill the host actually
|
|
10
|
+
* loaded for that message (ui-chat reads the step's `skill-invocation`
|
|
11
|
+
* injections) or the command a command-input bubble echoes — so `/123` or a
|
|
12
|
+
* stray `/word` stays plain text. A `/name` token is whitespace-bounded like
|
|
13
|
+
* the host skill gesture (`dsh-tool-skill`): it ends at whitespace or the
|
|
14
|
+
* text end, so slash paths (`/nfs-hg/xxx`, `/plan.md`) and punctuation-glued
|
|
15
|
+
* tokens (`/plan。`) stay plain even for a loaded name.
|
|
16
|
+
*/
|
|
17
|
+
import type { ReactNode } from 'react';
|
|
18
|
+
/** Optional navigation supplied by consumers that can preview references. */
|
|
19
|
+
export interface UserTextReferences {
|
|
20
|
+
/** Open a file or folder path decoded from an `@` mention. */
|
|
21
|
+
openFile: (path: string, options?: {
|
|
22
|
+
readonly directory?: boolean;
|
|
23
|
+
}) => void;
|
|
24
|
+
/** Open the source of a skill loaded for this message. */
|
|
25
|
+
openSkill: (name: string) => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Split one sent text into inline plain runs and reference chips.
|
|
29
|
+
* @param text - the logged model text of the message or queue row.
|
|
30
|
+
* @param sessionLabels - exact session mention labels associated by an adjacent recall.
|
|
31
|
+
* @param slashNames - names a `/name` token may decorate as: the skills the
|
|
32
|
+
* host loaded for this message, or the command a command bubble echoes
|
|
33
|
+
* (unsent queue rows pass none).
|
|
34
|
+
* @param slashKind - the chip kind those tokens render as.
|
|
35
|
+
* @param references - optional file and skill preview actions; session and command tokens stay labels.
|
|
36
|
+
* @returns inline nodes covering the whole text.
|
|
37
|
+
*/
|
|
38
|
+
export declare function projectUserText(text: string, sessionLabels: readonly string[], slashNames?: readonly string[], slashKind?: 'skill' | 'command', references?: UserTextReferences): ReactNode;
|
|
39
|
+
//# sourceMappingURL=user-text.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* Inline projection of sent user text: plain runs and reference chips flow in
|
|
2
|
+
the consumer's own line box (bubble or queue row); nothing here is block.
|
|
3
|
+
White-space policy stays with the consumer: the bubble wraps with pre-wrap,
|
|
4
|
+
the queue preview keeps its single nowrap/ellipsis line. */
|
|
5
|
+
|
|
6
|
+
.plainRun {
|
|
7
|
+
font-size: inherit;
|
|
8
|
+
line-height: inherit;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.refChip {
|
|
12
|
+
/* Plain inline, NOT inline-flex: a flex container takes its baseline from
|
|
13
|
+
its first flex item — the icon svg, which has no text baseline — so the
|
|
14
|
+
chip's label rode ~3px above the surrounding text in both surfaces. An
|
|
15
|
+
inline chip shares the consumer's baseline by construction. */
|
|
16
|
+
display: inline;
|
|
17
|
+
margin: 0 2px;
|
|
18
|
+
color: var(--dsw-alias-state-business-primary);
|
|
19
|
+
font-weight: 500;
|
|
20
|
+
white-space: nowrap;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* Skill and command tokens read as code: the theme's code family at the
|
|
24
|
+
consumer's own size and line height, so the chip sits on the bubble line
|
|
25
|
+
like the plain runs around it. `@` chips keep the body face — a file or
|
|
26
|
+
session name is a label, not code. */
|
|
27
|
+
.slashChip {
|
|
28
|
+
font-family: var(--dsw-font-markdown-code-font-family);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Inline reference glyphs (always ReferenceIcon svgs) ride the consumer's own
|
|
32
|
+
font: 1em keeps the glyph at the text's size in the bubble (14px + user
|
|
33
|
+
setting), the queue preview's fixed 13px line, and any future consumer — a
|
|
34
|
+
px+delta size followed only the bubble axis and left the glyph oversized in
|
|
35
|
+
the queue row. */
|
|
36
|
+
.refIcon {
|
|
37
|
+
width: 1em;
|
|
38
|
+
height: 1em;
|
|
39
|
+
margin-right: 4px;
|
|
40
|
+
/* Optical centering against the text: drops the glyph below the baseline by
|
|
41
|
+
a font-relative amount, so it holds across the font axis. */
|
|
42
|
+
vertical-align: -0.125em;
|
|
43
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x1a0f3n9/dsh-client-ui-primitives",
|
|
3
|
+
"description": "Pure React atoms for the dsh web UI: controls, icons, markdown, and JSON inspectors (zero cordis)",
|
|
4
|
+
"version": "0.1.5-rc.3",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
|
|
11
|
+
"directory": "packages/client/ui-primitives"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./src/*": "./src/*",
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/react": "~18.3.1",
|
|
27
|
+
"@types/react-dom": "~18.3.0",
|
|
28
|
+
"react": "^18.2.0",
|
|
29
|
+
"clsx": "^2.0.0",
|
|
30
|
+
"react-dom": "^18.2.0",
|
|
31
|
+
"anser": "^2.3.5",
|
|
32
|
+
"katex": "^0.16.47",
|
|
33
|
+
"micromark-core-commonmark": "^2.0.3",
|
|
34
|
+
"micromark-util-character": "^2.1.1",
|
|
35
|
+
"micromark-util-classify-character": "^2.0.1",
|
|
36
|
+
"micromark-util-symbol": "^2.0.1",
|
|
37
|
+
"micromark-util-types": "^2.0.2",
|
|
38
|
+
"shiki": "^4.3.1",
|
|
39
|
+
"@shikijs/langs": "^4.3.1",
|
|
40
|
+
"@types/mdast": "^4.0.4",
|
|
41
|
+
"micromark-factory-space": "^2.0.1",
|
|
42
|
+
"micromark-extension-math": "^3.1.0",
|
|
43
|
+
"mdast-util-from-markdown": "^2.0.3",
|
|
44
|
+
"mdast-util-gfm": "^3.1.0",
|
|
45
|
+
"mdast-util-math": "^3.0.0",
|
|
46
|
+
"micromark-extension-gfm": "^3.0.0",
|
|
47
|
+
"micromark-util-sanitize-uri": "^2.0.1",
|
|
48
|
+
"@deepseek-ai/cordis": "^4.0.2"
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"lib/index.js",
|
|
52
|
+
"lib/**/*.css",
|
|
53
|
+
"lib/types/**/*.d.ts"
|
|
54
|
+
],
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@deepseek-ai/cordis": "^4.0.2"
|
|
57
|
+
}
|
|
58
|
+
}
|