@qilin-agent/client-ui-attachment 0.0.0-stage → 3.1.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 +46 -0
- package/README.md +105 -2
- package/README.zh.md +106 -0
- package/lib/client.js +878 -0
- package/lib/index.js +6 -0
- package/lib/types/AttachmentRail.d.ts +39 -0
- package/lib/types/DropOverlay.d.ts +24 -0
- package/lib/types/FileCard.d.ts +26 -0
- package/lib/types/MessageImage.d.ts +64 -0
- package/lib/types/client/ComposerAttachments.d.ts +4 -0
- package/lib/types/client/MessageImages.d.ts +4 -0
- package/lib/types/client/drop-events.d.ts +14 -0
- package/lib/types/client/index.d.ts +7 -0
- package/lib/types/client/labels.d.ts +43 -0
- package/lib/types/index.d.ts +4 -0
- package/package.json +69 -3
package/lib/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Draft-attachment rail: scrollbar-less horizontal overflow paged by edge arrows. */
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
/** One ordered draft attachment rendered by the rail owner. */
|
|
4
|
+
export interface AttachmentRailItem {
|
|
5
|
+
/** Stable identity for the React key. */
|
|
6
|
+
id: string;
|
|
7
|
+
}
|
|
8
|
+
/** Rail-level strings the owner resolves from its own locale namespace. */
|
|
9
|
+
export interface AttachmentRailLabels {
|
|
10
|
+
/** Accessible name of the rail group. */
|
|
11
|
+
group: string;
|
|
12
|
+
/** Accessible label of the left paging arrow. */
|
|
13
|
+
scrollLeft: string;
|
|
14
|
+
/** Accessible label of the right paging arrow. */
|
|
15
|
+
scrollRight: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Horizontal rail over the caller's ordered draft attachments.
|
|
19
|
+
*
|
|
20
|
+
* The rail scrolls with its scrollbar hidden; overflow is announced by edge
|
|
21
|
+
* arrows recomputed from scroll geometry on scroll, item-count changes, and
|
|
22
|
+
* rail size changes (a ResizeObserver on the rail element, so sidebar or
|
|
23
|
+
* panel resizes count, not only window resizes). A vertical wheel pans the
|
|
24
|
+
* rail horizontally and is consumed exclusively (non-passive listener), a
|
|
25
|
+
* newly added item is revealed at the rail's end while a rail that mounts
|
|
26
|
+
* over an existing draft keeps its start position. The owner renders each
|
|
27
|
+
* item and decides mounting; it renders the rail only while items exist.
|
|
28
|
+
*
|
|
29
|
+
* @param props.items - attachments in draft order.
|
|
30
|
+
* @param props.labels - rail-level strings (group name and paging arrows).
|
|
31
|
+
* @param props.renderItem - render one attachment card in draft order.
|
|
32
|
+
* @returns the rail group with its paging arrows.
|
|
33
|
+
*/
|
|
34
|
+
export declare function AttachmentRail<T extends AttachmentRailItem>({ items, labels, renderItem }: {
|
|
35
|
+
items: readonly T[];
|
|
36
|
+
labels: AttachmentRailLabels;
|
|
37
|
+
renderItem: (item: T) => ReactNode;
|
|
38
|
+
}): import("react").JSX.Element;
|
|
39
|
+
//# sourceMappingURL=AttachmentRail.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Drop-overlay strings the owner resolves from its own locale namespace. */
|
|
2
|
+
export interface DropOverlayLabels {
|
|
3
|
+
/** Headline inviting the drop, or naming why it is unavailable. */
|
|
4
|
+
title: string;
|
|
5
|
+
/** Limits line under the title; shown only while drops are accepted. */
|
|
6
|
+
desc?: string | undefined;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Full-viewport invitation shown while a file drag is over the page
|
|
10
|
+
* (DeepSeek Chat's DragMask). Decoration only: `pointer-events: none` keeps
|
|
11
|
+
* drag targeting on the page below, so the owner's document-level listeners
|
|
12
|
+
* keep an accurate enter/leave count and own accept/reject. Rendered through
|
|
13
|
+
* a body portal for the same transformed-ancestor reason as the lightbox.
|
|
14
|
+
*
|
|
15
|
+
* @param props.disabled - drops are currently refused; renders the blocked
|
|
16
|
+
* illustration and drops the desc line.
|
|
17
|
+
* @param props.labels - resolved title and limits strings.
|
|
18
|
+
* @returns the overlay layer.
|
|
19
|
+
*/
|
|
20
|
+
export declare function DropOverlay({ disabled, labels }: {
|
|
21
|
+
disabled: boolean;
|
|
22
|
+
labels: DropOverlayLabels;
|
|
23
|
+
}): import("react").ReactPortal;
|
|
24
|
+
//# sourceMappingURL=DropOverlay.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Localized strings consumed by one pending-file card. */
|
|
2
|
+
export interface FileCardLabels {
|
|
3
|
+
/** Card body announcement, e.g. "Pending file {name}". */
|
|
4
|
+
readonly label: string;
|
|
5
|
+
/** Remove-button label. */
|
|
6
|
+
readonly remove: string;
|
|
7
|
+
/** Status line while the upload is in flight. */
|
|
8
|
+
readonly uploading: string;
|
|
9
|
+
/** Status line and retry affordance after a failed upload. */
|
|
10
|
+
readonly failed: string;
|
|
11
|
+
/** Retry-button label. */
|
|
12
|
+
readonly retry: string;
|
|
13
|
+
}
|
|
14
|
+
/** Upload display state resolved by the owner. */
|
|
15
|
+
export type FileCardState = 'uploading' | 'ready' | 'error';
|
|
16
|
+
/** One pending file card: type glyph, name, size or upload status, remove, retry. */
|
|
17
|
+
export declare function FileCard({ name, bytes, state, progress, labels, onRemove, onRetry, }: {
|
|
18
|
+
name: string;
|
|
19
|
+
bytes: number;
|
|
20
|
+
state: FileCardState;
|
|
21
|
+
progress?: number;
|
|
22
|
+
labels: FileCardLabels;
|
|
23
|
+
onRemove: () => void;
|
|
24
|
+
onRetry: () => void;
|
|
25
|
+
}): import("react").JSX.Element;
|
|
26
|
+
//# sourceMappingURL=FileCard.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ImageAttachmentRef } from '@qilin-agent/attachment';
|
|
2
|
+
import type { ImageLightboxLabels } from '@qilin-agent/client-ui-primitives';
|
|
3
|
+
/** Loads a session-authorized durable image URL and may expose a cached URL synchronously. */
|
|
4
|
+
export type ImageLoader = ((attachment: ImageAttachmentRef) => Promise<string>) & {
|
|
5
|
+
peek?: (attachment: ImageAttachmentRef) => string | undefined;
|
|
6
|
+
};
|
|
7
|
+
/** One gallery entry: a durable admitted reference, or a submission echo's local preview. */
|
|
8
|
+
export type MessageImageSpec = {
|
|
9
|
+
readonly attachment: ImageAttachmentRef;
|
|
10
|
+
/** Presentation-only name for the thumbnail and lightbox; loading uses the original reference. */
|
|
11
|
+
readonly label?: string;
|
|
12
|
+
} | {
|
|
13
|
+
readonly preview: {
|
|
14
|
+
readonly url: string;
|
|
15
|
+
readonly name?: string;
|
|
16
|
+
readonly width?: number;
|
|
17
|
+
readonly height?: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
/** Message-image strings the owner resolves from its own locale namespace. */
|
|
21
|
+
export interface MessageImageLabels {
|
|
22
|
+
/** Fallback display name for an unnamed image. */
|
|
23
|
+
image: string;
|
|
24
|
+
/** Thumbnail tooltip inviting the original-image preview. */
|
|
25
|
+
open: string;
|
|
26
|
+
/** Accessible thumbnail label; receives the image's display name. */
|
|
27
|
+
openNamed: (label: string) => string;
|
|
28
|
+
/** Loading placeholder shown until bytes resolve. */
|
|
29
|
+
loading: string;
|
|
30
|
+
/** Retry-control label shown when the load fails. */
|
|
31
|
+
loadFailed: string;
|
|
32
|
+
/** Lightbox strings forwarded to the opened preview. */
|
|
33
|
+
lightbox: ImageLightboxLabels;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Compact history renderer with retryable loading and click-to-open original
|
|
37
|
+
* preview. A lone image renders at its `singleFit` size; an image among
|
|
38
|
+
* several renders as a fixed 64px square tile. The preview arm displays its
|
|
39
|
+
* local URL directly — no loader round-trip, no failure/retry surface.
|
|
40
|
+
* List thumbnails use status icons with localized tooltips and accessible names.
|
|
41
|
+
*
|
|
42
|
+
* @param props.image - the durable reference to load, or the local preview to display.
|
|
43
|
+
* @param props.load - session-authorized URL loader for the durable arm.
|
|
44
|
+
* @param props.variant - lone image, cropped gallery tile, or uncropped list thumbnail.
|
|
45
|
+
* @param props.labels - resolved strings (tooltip, loading, retry, lightbox).
|
|
46
|
+
* @returns the bounded thumbnail button, or the retry control on failure.
|
|
47
|
+
*/
|
|
48
|
+
export declare function MessageImage({ image, load, variant, labels }: {
|
|
49
|
+
image: MessageImageSpec;
|
|
50
|
+
load: ImageLoader;
|
|
51
|
+
variant: 'single' | 'tile' | 'thumbnail';
|
|
52
|
+
labels: MessageImageLabels;
|
|
53
|
+
}): import("react").JSX.Element;
|
|
54
|
+
/** Wrapping image group shared by user and assistant history: a lone image
|
|
55
|
+
* renders large unless its owner requests compact tiles or contained list thumbnails. */
|
|
56
|
+
export declare function ImageGallery({ images, load, align, compact, thumbnail, labels }: {
|
|
57
|
+
images: readonly MessageImageSpec[];
|
|
58
|
+
load: ImageLoader;
|
|
59
|
+
align: 'start' | 'end';
|
|
60
|
+
compact?: boolean;
|
|
61
|
+
thumbnail?: boolean;
|
|
62
|
+
labels: MessageImageLabels;
|
|
63
|
+
}): import("react").JSX.Element | null;
|
|
64
|
+
//# sourceMappingURL=MessageImage.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ComposerAttachmentsProps } from '@qilin-agent/client-ui-conversation/client';
|
|
2
|
+
/** Draft image previews, pending-file cards, drop target, and original-image preview. */
|
|
3
|
+
export declare function ComposerAttachments({ attachments, canAcceptDrop, onAddFiles, onRemoveAttachment, uploads, onRetryFile, dropLimits, t, }: ComposerAttachmentsProps): import("react").JSX.Element;
|
|
4
|
+
//# sourceMappingURL=ComposerAttachments.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { MessageImagesProps } from '@qilin-agent/client-ui-chat/client';
|
|
2
|
+
/** Historical message-image slot entry. */
|
|
3
|
+
export declare function MessageImages({ images, loadImage, align, compact, thumbnail, t }: MessageImagesProps): import("react").JSX.Element;
|
|
4
|
+
//# sourceMappingURL=MessageImages.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Document drag-and-drop listeners owned by one mounted attachment view. */
|
|
2
|
+
import type { ComposerAttachmentsProps } from '@qilin-agent/client-ui-conversation/client';
|
|
3
|
+
/**
|
|
4
|
+
* Install one attachment view's file-drop listeners.
|
|
5
|
+
* @param canAcceptDrop - whether this view accepts the dropped files.
|
|
6
|
+
* @param onAddFiles - attachment intake callback.
|
|
7
|
+
* @param dragDepth - the view's retained nested-drag counter.
|
|
8
|
+
* @param setDragActive - publish whether a file drag is active.
|
|
9
|
+
* @returns cleanup for exactly these listeners.
|
|
10
|
+
*/
|
|
11
|
+
export declare function installDocumentDropEvents(canAcceptDrop: ComposerAttachmentsProps['canAcceptDrop'], onAddFiles: ComposerAttachmentsProps['onAddFiles'], dragDepth: {
|
|
12
|
+
current: number;
|
|
13
|
+
}, setDragActive: (active: boolean) => void): () => void;
|
|
14
|
+
//# sourceMappingURL=drop-events.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Browser attachment plugin: fills conversation's composer and image slots. */
|
|
2
|
+
import type { Context as ClientContext } from '@qilin-agent/kylin';
|
|
3
|
+
/** Slot registry required by this presentation plugin. */
|
|
4
|
+
export declare const inject: string[];
|
|
5
|
+
/** Register attachment presentation without exporting React components as package values. */
|
|
6
|
+
export declare function apply(ctx: ClientContext): void;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TranslateNS } from '@qilin-agent/client-ui-slots';
|
|
2
|
+
import type { AttachmentRailLabels } from '../AttachmentRail.tsx';
|
|
3
|
+
import type { DropOverlayLabels } from '../DropOverlay.tsx';
|
|
4
|
+
import type { FileCardLabels } from '../FileCard.tsx';
|
|
5
|
+
import type { ImageLightboxLabels } from '@qilin-agent/client-ui-primitives';
|
|
6
|
+
import type { MessageImageLabels } from '../MessageImage.tsx';
|
|
7
|
+
/**
|
|
8
|
+
* Resolve original-image lightbox strings from the conversation namespace.
|
|
9
|
+
* @param t - conversation namespace translator.
|
|
10
|
+
* @returns translated lightbox labels.
|
|
11
|
+
*/
|
|
12
|
+
export declare function lightboxLabels(t: TranslateNS<'conversation'>): ImageLightboxLabels;
|
|
13
|
+
/**
|
|
14
|
+
* Resolve historical message-image strings from the conversation namespace.
|
|
15
|
+
* @param t - conversation namespace translator.
|
|
16
|
+
* @returns translated message-image labels.
|
|
17
|
+
*/
|
|
18
|
+
export declare function messageImageLabels(t: TranslateNS<'conversation'>): MessageImageLabels;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the document-level drop invitation and its optional limits line.
|
|
21
|
+
* @param t - conversation namespace translator.
|
|
22
|
+
* @param accepting - whether the composer can accept dropped files.
|
|
23
|
+
* @param limits - optional translated count and size values.
|
|
24
|
+
* @returns translated drop-overlay labels.
|
|
25
|
+
*/
|
|
26
|
+
export declare function dropOverlayLabels(t: TranslateNS<'conversation'>, accepting: boolean, limits?: {
|
|
27
|
+
readonly count: number;
|
|
28
|
+
readonly size: string;
|
|
29
|
+
}): DropOverlayLabels;
|
|
30
|
+
/**
|
|
31
|
+
* Resolve pending-file card strings from the conversation namespace.
|
|
32
|
+
* @param t - conversation namespace translator.
|
|
33
|
+
* @param name - browser file name interpolated into remove/retry labels.
|
|
34
|
+
* @returns translated file-card labels.
|
|
35
|
+
*/
|
|
36
|
+
export declare function fileCardLabels(t: TranslateNS<'conversation'>, name: string): FileCardLabels;
|
|
37
|
+
/**
|
|
38
|
+
* Resolve the mixed draft-attachment rail strings from the conversation namespace.
|
|
39
|
+
* @param t - conversation namespace translator.
|
|
40
|
+
* @returns translated attachment-rail labels.
|
|
41
|
+
*/
|
|
42
|
+
export declare function attachmentRailLabels(t: TranslateNS<'conversation'>): AttachmentRailLabels;
|
|
43
|
+
//# sourceMappingURL=labels.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qilin-agent/client-ui-attachment",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "Dynamic attachment presentation plugin for conversation input, message-image, and trajectory image slots",
|
|
4
|
+
"version": "3.1.3",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/kkutysllb/QiLin.git",
|
|
11
|
+
"directory": "packages/client/ui-attachment"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": "^22.19.0 || >=24.0.0"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "lib/index.js",
|
|
18
|
+
"types": "lib/types/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./lib/types/index.d.ts",
|
|
22
|
+
"default": "./lib/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./client": {
|
|
25
|
+
"types": "./lib/types/client/index.d.ts",
|
|
26
|
+
"default": "./lib/client.js"
|
|
27
|
+
},
|
|
28
|
+
"./src/*": "./src/*",
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
},
|
|
31
|
+
"qilin": {
|
|
32
|
+
"client": {
|
|
33
|
+
"inject": [
|
|
34
|
+
"@qilin-agent/client-ui-chat",
|
|
35
|
+
"@qilin-agent/client-ui-conversation",
|
|
36
|
+
"@qilin-agent/client-ui-renderer",
|
|
37
|
+
"@qilin-agent/client-ui-trajectory",
|
|
38
|
+
"@qilin-agent/client-ui-tool"
|
|
39
|
+
],
|
|
40
|
+
"platform": "web"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/react": "~18.3.1",
|
|
46
|
+
"@types/react-dom": "~18.3.0",
|
|
47
|
+
"react": "^18.2.0",
|
|
48
|
+
"react-dom": "^18.2.0",
|
|
49
|
+
"clsx": "^2.0.0",
|
|
50
|
+
"@qilin-agent/kylin": "~4.0.3",
|
|
51
|
+
"@qilin-agent/client-ui-trajectory": "3.1.3",
|
|
52
|
+
"@qilin-agent/client-ui-chat": "3.1.3",
|
|
53
|
+
"@qilin-agent/client-ui-conversation": "3.1.3",
|
|
54
|
+
"@qilin-agent/client-ui-renderer": "3.1.3",
|
|
55
|
+
"@qilin-agent/client-ui-primitives": "3.1.3",
|
|
56
|
+
"@qilin-agent/client-ui-slots": "3.1.3",
|
|
57
|
+
"@qilin-agent/attachment": "3.1.3",
|
|
58
|
+
"@qilin-agent/client-ui-tool": "3.1.3"
|
|
59
|
+
},
|
|
60
|
+
"files": [
|
|
61
|
+
"lib/index.js",
|
|
62
|
+
"lib/client.js",
|
|
63
|
+
"lib/types/**/*.d.ts"
|
|
64
|
+
],
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"@qilin-agent/kylin": "~4.0.3"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"bundle": "tsdown",
|
|
70
|
+
"watch": "tsdown --watch"
|
|
71
|
+
}
|
|
6
72
|
}
|