@iyulab/chat-components 0.5.0 → 0.5.2
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/CHANGELOG.md +78 -144
- package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.128.0}/helpers/decorate.js +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.128.0}/helpers/decorateMetadata.js +1 -1
- package/dist/components/blocks/UCodeBlock.js +4 -3
- package/dist/components/blocks/UFileBlock.js +2 -2
- package/dist/components/blocks/UJsonBlock.js +2 -2
- package/dist/components/blocks/UMarkedBlock.js +3 -27
- package/dist/components/blocks/URefBlock.js +2 -2
- package/dist/components/blocks/UTableBlock.js +4 -3
- package/dist/components/blocks/UTextBlock.js +2 -2
- package/dist/components/blocks/UThinkBlock.js +2 -2
- package/dist/components/blocks/UToolBlock.js +2 -2
- package/dist/components/buttons/UAttachButton.js +2 -2
- package/dist/components/buttons/UCopyButton.js +2 -2
- package/dist/components/buttons/UVoteButton.js +2 -2
- package/dist/components/intents/UQuestionIntent.js +2 -2
- package/dist/components/message/UMessage.js +2 -2
- package/dist/components/prompt/UPrompt.d.ts +5 -0
- package/dist/components/prompt/UPrompt.js +27 -5
- package/dist/components/references/URefCard.js +2 -2
- package/dist/components/references/URefCardGroup.js +4 -3
- package/dist/components/references/URefTag.js +2 -2
- package/dist/components/views/UChartView.js +2 -2
- package/dist/components/views/UImagesView.js +2 -2
- package/dist/components/views/UMapView.js +2 -2
- package/dist/components/views/UVideoView.js +2 -2
- package/dist/components/views/UView.js +2 -2
- package/dist/events/SendEvent.d.ts +15 -1
- package/dist/events/StopEvent.d.ts +11 -1
- package/dist/types/Intents.js +1 -1
- package/dist/types/Views.js +1 -1
- package/dist/utilities/HtmlPlaceholder.d.ts +11 -0
- package/dist/utilities/HtmlPlaceholder.js +26 -0
- package/package.json +11 -10
- package/skills/iyulab-chat-components/SKILL.md +107 -0
- package/skills/iyulab-chat-components/references/components/attach-button.md +69 -0
- package/skills/iyulab-chat-components/references/components/chart-view.md +65 -0
- package/skills/iyulab-chat-components/references/components/code-block.md +42 -0
- package/skills/iyulab-chat-components/references/components/copy-button.md +46 -0
- package/skills/iyulab-chat-components/references/components/file-block.md +64 -0
- package/skills/iyulab-chat-components/references/components/images-view.md +63 -0
- package/skills/iyulab-chat-components/references/components/json-block.md +41 -0
- package/skills/iyulab-chat-components/references/components/map-view.md +54 -0
- package/skills/iyulab-chat-components/references/components/marked-block.md +53 -0
- package/skills/iyulab-chat-components/references/components/message.md +60 -0
- package/skills/iyulab-chat-components/references/components/prompt.md +102 -0
- package/skills/iyulab-chat-components/references/components/question-intent.md +75 -0
- package/skills/iyulab-chat-components/references/components/ref-block.md +45 -0
- package/skills/iyulab-chat-components/references/components/ref-card-group.md +41 -0
- package/skills/iyulab-chat-components/references/components/ref-card.md +48 -0
- package/skills/iyulab-chat-components/references/components/ref-tag.md +40 -0
- package/skills/iyulab-chat-components/references/components/table-block.md +63 -0
- package/skills/iyulab-chat-components/references/components/text-block.md +59 -0
- package/skills/iyulab-chat-components/references/components/think-block.md +48 -0
- package/skills/iyulab-chat-components/references/components/tool-block.md +57 -0
- package/skills/iyulab-chat-components/references/components/video-view.md +55 -0
- package/skills/iyulab-chat-components/references/components/view.md +51 -0
- package/skills/iyulab-chat-components/references/components/vote-button.md +60 -0
- package/skills/iyulab-chat-components/references/types.md +115 -0
- package/skills/iyulab-chat-components/references/usage.md +254 -0
- package/skills/iyulab-chat-components/references/utilities/intent-prompt-builder.md +123 -0
- package/skills/iyulab-chat-components/references/utilities/view-prompt-builder.md +112 -0
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import { FileBlockItem } from '../types/BlockItem.js';
|
|
2
|
+
/**
|
|
3
|
+
* `send` 이벤트의 detail 페이로드.
|
|
4
|
+
* - `value`: 사용자가 입력한 텍스트 (trim된 원본, 빈 문자열일 수 있음)
|
|
5
|
+
* - `files`: 첨부된 파일 목록 (있는 경우)
|
|
6
|
+
*/
|
|
7
|
+
export interface SendEventDetail {
|
|
8
|
+
value: string;
|
|
9
|
+
files?: FileBlockItem[];
|
|
10
|
+
}
|
|
2
11
|
export type SendEvent = CustomEvent<SendEventDetail>;
|
|
3
12
|
declare global {
|
|
4
13
|
interface HTMLElementEventMap {
|
|
5
14
|
'send': SendEvent;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated 0.5.1부터 `send`와 동시에 발생합니다. 0.6.0에서 제거 예정.
|
|
17
|
+
* 새 코드는 `send`를 사용하세요.
|
|
18
|
+
*/
|
|
19
|
+
'u-submit': SendEvent;
|
|
6
20
|
}
|
|
7
21
|
}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* `stop` 이벤트의 detail 페이로드.
|
|
3
|
+
* 현재는 추가 컨텍스트가 없으므로 빈 객체이며, 향후 확장 대비 interface로 유지.
|
|
4
|
+
*/
|
|
5
|
+
export interface StopEventDetail {
|
|
6
|
+
}
|
|
2
7
|
export type StopEvent = CustomEvent<StopEventDetail>;
|
|
3
8
|
declare global {
|
|
4
9
|
interface HTMLElementEventMap {
|
|
5
10
|
'stop': StopEvent;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated 0.5.1부터 `stop`과 동시에 발생합니다. 0.6.0에서 제거 예정.
|
|
13
|
+
* 새 코드는 `stop`를 사용하세요.
|
|
14
|
+
*/
|
|
15
|
+
'u-cancel': StopEvent;
|
|
6
16
|
}
|
|
7
17
|
}
|
package/dist/types/Intents.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/** 프리셋 Intent 비트 플래그 */
|
|
3
3
|
var PresetIntent = /* @__PURE__ */ function(PresetIntent) {
|
|
4
4
|
PresetIntent[PresetIntent["Questions"] = 1] = "Questions";
|
|
5
|
-
PresetIntent[PresetIntent["All"] =
|
|
5
|
+
PresetIntent[PresetIntent["All"] = PresetIntent.Questions] = "All";
|
|
6
6
|
return PresetIntent;
|
|
7
7
|
}({});
|
|
8
8
|
/** 프리셋 Intent 목록 (비트 플래그 순서대로) */
|
package/dist/types/Views.js
CHANGED
|
@@ -11,7 +11,7 @@ var PresetView = /* @__PURE__ */ function(PresetView) {
|
|
|
11
11
|
PresetView[PresetView["Video"] = 2] = "Video";
|
|
12
12
|
PresetView[PresetView["Map"] = 8] = "Map";
|
|
13
13
|
PresetView[PresetView["Chart"] = 16] = "Chart";
|
|
14
|
-
PresetView[PresetView["All"] =
|
|
14
|
+
PresetView[PresetView["All"] = PresetView.Images | PresetView.Video | PresetView.Map | PresetView.Chart] = "All";
|
|
15
15
|
return PresetView;
|
|
16
16
|
}({});
|
|
17
17
|
/**
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marked 파싱 중 HTML이 GFM에 의해 오염되는 것을 방지하기 위해
|
|
3
|
+
* HTML을 주석 플레이스홀더로 치환하고, 나중에 원래 HTML로 복원하는 유틸입니다.
|
|
4
|
+
*/
|
|
5
|
+
export declare class HtmlPlaceholder {
|
|
6
|
+
private map;
|
|
7
|
+
private idx;
|
|
8
|
+
reset(): void;
|
|
9
|
+
store(html: string): string;
|
|
10
|
+
restore(html: string): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/utilities/HtmlPlaceholder.ts
|
|
2
|
+
/**
|
|
3
|
+
* Marked 파싱 중 HTML이 GFM에 의해 오염되는 것을 방지하기 위해
|
|
4
|
+
* HTML을 주석 플레이스홀더로 치환하고, 나중에 원래 HTML로 복원하는 유틸입니다.
|
|
5
|
+
*/
|
|
6
|
+
var HtmlPlaceholder = class {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.map = {};
|
|
9
|
+
this.idx = 0;
|
|
10
|
+
}
|
|
11
|
+
reset() {
|
|
12
|
+
this.map = {};
|
|
13
|
+
this.idx = 0;
|
|
14
|
+
}
|
|
15
|
+
store(html) {
|
|
16
|
+
const key = `<!--ref:${this.idx++}-->`;
|
|
17
|
+
this.map[key] = html;
|
|
18
|
+
return key;
|
|
19
|
+
}
|
|
20
|
+
restore(html) {
|
|
21
|
+
if (this.idx === 0) return html;
|
|
22
|
+
return html.replace(/<!--ref:\d+-->/g, (key) => this.map[key] ?? "");
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { HtmlPlaceholder };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iyulab/chat-components",
|
|
3
3
|
"description": "llm chat components for building chat interfaces",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.2",
|
|
5
5
|
"author": "iyulab",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"dist",
|
|
21
|
+
"skills",
|
|
21
22
|
"package.json",
|
|
22
23
|
"README.md",
|
|
23
24
|
"CHANGELOG.md",
|
|
@@ -40,12 +41,12 @@
|
|
|
40
41
|
"build": "eslint && vite build"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"@iyulab/components": "^1.0.
|
|
44
|
+
"@iyulab/components": "^1.0.5",
|
|
44
45
|
"highlight.js": "^11.11.1",
|
|
45
46
|
"html2canvas": "^1.4.1",
|
|
46
47
|
"lit": "^3.3.2",
|
|
47
|
-
"marked": "^
|
|
48
|
-
"marked-katex-extension": "^5.1.
|
|
48
|
+
"marked": "^18.0.3",
|
|
49
|
+
"marked-katex-extension": "^5.1.8"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
52
|
"@lit/react": ">=1.0.8",
|
|
@@ -65,16 +66,16 @@
|
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
67
68
|
"@eslint/js": "^9.39.4",
|
|
68
|
-
"@types/node": "^25.
|
|
69
|
+
"@types/node": "^25.6.2",
|
|
69
70
|
"chart.js": "^4.5.1",
|
|
70
71
|
"eslint": "^9.39.4",
|
|
71
72
|
"eslint-plugin-lit": "^2.2.1",
|
|
72
73
|
"glob": "^13.0.6",
|
|
73
|
-
"globals": "^17.
|
|
74
|
-
"openai": "^6.
|
|
74
|
+
"globals": "^17.6.0",
|
|
75
|
+
"openai": "^6.37.0",
|
|
75
76
|
"typescript": "^5.9.3",
|
|
76
|
-
"typescript-eslint": "^8.
|
|
77
|
-
"vite": "^8.0.
|
|
78
|
-
"vite-plugin-dts": "^
|
|
77
|
+
"typescript-eslint": "^8.59.2",
|
|
78
|
+
"vite": "^8.0.11",
|
|
79
|
+
"vite-plugin-dts": "^5.0.0"
|
|
79
80
|
}
|
|
80
81
|
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: iyulab-chat-components
|
|
3
|
+
description: LLM chat UI component library. Covers all u-* custom elements for building chat interfaces — message rendering, chat input, markdown/code blocks, file attachments, reference citations, and the Intent/View system. Use when working with @iyulab/chat-components package.
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
author: iyulab
|
|
7
|
+
version: "0.5.2"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# @iyulab/chat-components
|
|
11
|
+
|
|
12
|
+
Web component library for building LLM chat interfaces, built on [Lit](https://lit.dev/). All components are custom elements (`u-*` tags) that work in any framework or vanilla HTML.
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @iyulab/chat-components
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Import all components at once:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import '@iyulab/chat-components';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Import individual components (tree-shakable):
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import '@iyulab/chat-components/dist/components/message/UMessage.js';
|
|
30
|
+
import '@iyulab/chat-components/dist/components/prompt/UPrompt.js';
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
> For detailed setup and usage patterns, see [./references/usage.md](./references/usage.md).
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Components
|
|
38
|
+
|
|
39
|
+
### Message & Input
|
|
40
|
+
|
|
41
|
+
- [`u-message`](./references/components/message.md) — Chat message wrapper. Slot-based block layout, loading animation, bubble/default style variants
|
|
42
|
+
- [`u-prompt`](./references/components/prompt.md) — Chat input component. File attachment preview, auto-resize textarea, integrated send/stop button
|
|
43
|
+
|
|
44
|
+
### Content Blocks
|
|
45
|
+
|
|
46
|
+
- [`u-marked-block`](./references/components/marked-block.md) — Renders markdown to HTML. KaTeX math, code highlighting, citation insertion, view-json/intent-json handling
|
|
47
|
+
- [`u-code-block`](./references/components/code-block.md) — Highlight.js code block with language label and clipboard copy
|
|
48
|
+
- [`u-text-block`](./references/components/text-block.md) — Plain text display or editable textarea
|
|
49
|
+
- [`u-think-block`](./references/components/think-block.md) — LLM reasoning (thinking) block. Collapse/expand, auto-scroll
|
|
50
|
+
- [`u-tool-block`](./references/components/tool-block.md) — Tool call input/output display. Collapse/expand
|
|
51
|
+
- [`u-file-block`](./references/components/file-block.md) — File attachment card. Type icon, upload status, download, remove
|
|
52
|
+
- [`u-ref-block`](./references/components/ref-block.md) — Reference source group block. Collapse/expand, grid of ref cards
|
|
53
|
+
- [`u-json-block`](./references/components/json-block.md) — Visualizes JSON data as a collapsible tree
|
|
54
|
+
- [`u-table-block`](./references/components/table-block.md) — Markdown table renderer. Column sort, search filter, CSV/XLS download
|
|
55
|
+
|
|
56
|
+
### Action Buttons
|
|
57
|
+
|
|
58
|
+
- [`u-copy-button`](./references/components/copy-button.md) — Clipboard copy button; icon changes after copy
|
|
59
|
+
- [`u-vote-button`](./references/components/vote-button.md) — Thumbs-up / thumbs-down vote button pair
|
|
60
|
+
- [`u-attach-button`](./references/components/attach-button.md) — File picker button; fires `attach` event with selected files
|
|
61
|
+
|
|
62
|
+
### Reference Components
|
|
63
|
+
|
|
64
|
+
- [`u-ref-tag`](./references/components/ref-tag.md) — Inline citation tag. Tooltip and external-link icon
|
|
65
|
+
- [`u-ref-card`](./references/components/ref-card.md) — Reference source card. web/document type, favicon, tags
|
|
66
|
+
- [`u-ref-card-group`](./references/components/ref-card-group.md) — Paginated group of reference cards
|
|
67
|
+
|
|
68
|
+
### Intent Components
|
|
69
|
+
|
|
70
|
+
- [`u-question-intent`](./references/components/question-intent.md) — LLM-generated question with clickable choice buttons
|
|
71
|
+
|
|
72
|
+
### View Components
|
|
73
|
+
|
|
74
|
+
- [`u-images-view`](./references/components/images-view.md) — Image gallery (carousel + lightbox)
|
|
75
|
+
- [`u-video-view`](./references/components/video-view.md) — YouTube / Vimeo / direct video file player
|
|
76
|
+
- [`u-chart-view`](./references/components/chart-view.md) — Chart.js charts (bar, line, pie, etc.)
|
|
77
|
+
- [`u-map-view`](./references/components/map-view.md) — OpenStreetMap embed
|
|
78
|
+
- [`u-view`](./references/components/view.md) — Dynamic custom element renderer (runtime for view-json blocks)
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Utilities
|
|
83
|
+
|
|
84
|
+
- [`IntentPromptBuilder`](./references/utilities/intent-prompt-builder.md) — Build LLM system prompt instructions for intents and parse intent-json responses
|
|
85
|
+
- [`ViewPromptBuilder`](./references/utilities/view-prompt-builder.md) — Build LLM system prompt instructions for views
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Types
|
|
90
|
+
|
|
91
|
+
- [`BlockItem`](./references/types.md) — Union type for message content blocks (text, markdown, file, tool, reference, thinking)
|
|
92
|
+
- `ReferenceSource` / `ReferenceCitation` — Citation source and inline citation position types
|
|
93
|
+
- `IntentDefinition` / `PresetIntent` — Intent definition and preset bit flags
|
|
94
|
+
- `ViewDefinition` / `PresetView` — View definition and preset bit flags
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Events
|
|
99
|
+
|
|
100
|
+
| Event | Source | Detail Type | Description |
|
|
101
|
+
|-------|--------|-------------|-------------|
|
|
102
|
+
| `send` | `u-prompt` | `unknown` | Send button clicked or Enter pressed |
|
|
103
|
+
| `stop` | `u-prompt` | `unknown` | Stop button clicked while loading |
|
|
104
|
+
| `attach` | `u-attach-button` | `{ files: File[] }` | File selection completed |
|
|
105
|
+
| `choice` | `u-question-intent` | `{ value: string }` | Choice button clicked |
|
|
106
|
+
| `change` | `u-vote-button` | `Event` | Vote state changed |
|
|
107
|
+
| `remove` | `u-file-block` | `RemoveEventDetail` | Remove button clicked |
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# u-attach-button
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import '@iyulab/chat-components/dist/components/buttons/UAttachButton.js';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**Tag:** `u-attach-button`
|
|
8
|
+
|
|
9
|
+
Opens a file picker dialog. Fires an `attach` event with the selected files. Place in `u-prompt`'s `left-actions` slot.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<!-- Basic usage -->
|
|
13
|
+
<u-attach-button></u-attach-button>
|
|
14
|
+
|
|
15
|
+
<!-- Images only -->
|
|
16
|
+
<u-attach-button accept="image/*">Add image</u-attach-button>
|
|
17
|
+
|
|
18
|
+
<!-- Multiple files allowed -->
|
|
19
|
+
<u-attach-button multiple accept="image/*,application/pdf">Attach files</u-attach-button>
|
|
20
|
+
|
|
21
|
+
<!-- Inside u-prompt -->
|
|
22
|
+
<u-prompt>
|
|
23
|
+
<u-attach-button
|
|
24
|
+
slot="left-actions"
|
|
25
|
+
multiple
|
|
26
|
+
accept="image/*,application/pdf,text/*"
|
|
27
|
+
@attach=${handleAttach}
|
|
28
|
+
>
|
|
29
|
+
Files
|
|
30
|
+
</u-attach-button>
|
|
31
|
+
</u-prompt>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
const attachBtn = document.querySelector('u-attach-button');
|
|
36
|
+
|
|
37
|
+
attachBtn.addEventListener('attach', (e) => {
|
|
38
|
+
const { files } = e.detail; // File[]
|
|
39
|
+
console.log('Selected files:', files.map(f => f.name));
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Slots
|
|
46
|
+
|
|
47
|
+
| Name | Description |
|
|
48
|
+
|------|-------------|
|
|
49
|
+
| *(default)* | Tooltip label text |
|
|
50
|
+
|
|
51
|
+
## Properties
|
|
52
|
+
|
|
53
|
+
| Property | Type | Default | Description |
|
|
54
|
+
|----------|------|---------|-------------|
|
|
55
|
+
| `accept` | `string` | `undefined` | Accepted MIME types (comma-separated). E.g. `"image/*"`, `"image/*,application/pdf"` |
|
|
56
|
+
| `multiple` | `boolean` | `false` | Allow selecting multiple files |
|
|
57
|
+
|
|
58
|
+
## Events
|
|
59
|
+
|
|
60
|
+
| Event | Detail | Description |
|
|
61
|
+
|-------|--------|-------------|
|
|
62
|
+
| `attach` | `{ files: File[] }` | Fired after file selection. The file input is reset automatically |
|
|
63
|
+
|
|
64
|
+
## CSS Parts
|
|
65
|
+
|
|
66
|
+
| Part | Description |
|
|
67
|
+
|------|-------------|
|
|
68
|
+
| `base` | The button element (`u-button`) |
|
|
69
|
+
| `icon` | Paperclip icon |
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# u-chart-view
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import '@iyulab/chat-components/dist/components/views/UChartView.js';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**Tag:** `u-chart-view`
|
|
8
|
+
|
|
9
|
+
Renders charts using Chart.js (lazy-loaded). Supports PNG and JSON download. Automatically re-renders when the page theme changes.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<!-- Bar chart -->
|
|
13
|
+
<u-chart-view
|
|
14
|
+
type="bar"
|
|
15
|
+
.data=${{
|
|
16
|
+
labels: ['Jan', 'Feb', 'Mar'],
|
|
17
|
+
datasets: [{ label: 'Revenue', data: [100, 200, 150] }]
|
|
18
|
+
}}
|
|
19
|
+
></u-chart-view>
|
|
20
|
+
|
|
21
|
+
<!-- Line chart with options -->
|
|
22
|
+
<u-chart-view
|
|
23
|
+
type="line"
|
|
24
|
+
.data=${{
|
|
25
|
+
labels: ['A', 'B', 'C', 'D'],
|
|
26
|
+
datasets: [{ label: 'Trend', data: [10, 40, 30, 60], fill: true }]
|
|
27
|
+
}}
|
|
28
|
+
.options=${{ plugins: { legend: { position: 'bottom' } } }}
|
|
29
|
+
></u-chart-view>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
LLM output example (`view-json` code block):
|
|
33
|
+
|
|
34
|
+
````
|
|
35
|
+
```view-json
|
|
36
|
+
{
|
|
37
|
+
"tag": "u-chart-view",
|
|
38
|
+
"properties": {
|
|
39
|
+
"type": "bar",
|
|
40
|
+
"data": {
|
|
41
|
+
"labels": ["Jan", "Feb", "Mar"],
|
|
42
|
+
"datasets": [{ "label": "Revenue", "data": [100, 200, 150] }]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
````
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Properties
|
|
52
|
+
|
|
53
|
+
| Property | Type | Default | Description |
|
|
54
|
+
|----------|------|---------|-------------|
|
|
55
|
+
| `type` | `ChartType` | `undefined` | Chart type: `'bar'`, `'line'`, `'pie'`, `'doughnut'`, `'radar'`, `'polarArea'`, `'bubble'`, `'scatter'` |
|
|
56
|
+
| `data` | `ChartData` | `undefined` | Chart.js data object with `labels` and `datasets` |
|
|
57
|
+
| `options` | `ChartOptions` | `undefined` | Chart.js options object |
|
|
58
|
+
|
|
59
|
+
## Features
|
|
60
|
+
|
|
61
|
+
| Feature | Description |
|
|
62
|
+
|---------|-------------|
|
|
63
|
+
| Lazy load | Chart.js is dynamically imported on first render |
|
|
64
|
+
| Download | Export chart as PNG or raw JSON data |
|
|
65
|
+
| Theme sync | Watches `document.documentElement[theme]` and re-renders on change |
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# u-code-block
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import '@iyulab/chat-components/dist/components/blocks/UCodeBlock.js';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**Tag:** `u-code-block`
|
|
8
|
+
|
|
9
|
+
Syntax-highlighted code block powered by Highlight.js. Shows a language label, clipboard copy button, and loading spinner. Automatically rendered inside `u-marked-block` for fenced code blocks.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<!-- Direct usage -->
|
|
13
|
+
<u-code-block lang="typescript" .value=${"const x: number = 42;"}></u-code-block>
|
|
14
|
+
|
|
15
|
+
<!-- Without header -->
|
|
16
|
+
<u-code-block lang="json" headless .value=${JSON.stringify({key: 'value'}, null, 2)}></u-code-block>
|
|
17
|
+
|
|
18
|
+
<!-- Loading state (streaming) -->
|
|
19
|
+
<u-code-block lang="python" loading .value=${"def hello():"}></u-code-block>
|
|
20
|
+
|
|
21
|
+
<!-- Inject code via slot -->
|
|
22
|
+
<u-code-block lang="javascript">
|
|
23
|
+
console.log("Hello from slot");
|
|
24
|
+
</u-code-block>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Properties
|
|
30
|
+
|
|
31
|
+
| Property | Type | Default | Reflect | Description |
|
|
32
|
+
|----------|------|---------|---------|-------------|
|
|
33
|
+
| `lang` | `string` | `'plaintext'` | ✓ | Code language. Falls back to `plaintext` if not supported by Highlight.js |
|
|
34
|
+
| `value` | `string` | `undefined` | — | Code content. Can also be set via slot `textContent` |
|
|
35
|
+
| `loading` | `boolean` | `false` | ✓ | Loading state. Replaces the code icon with a spinner in the header |
|
|
36
|
+
| `headless` | `boolean` | `false` | ✓ | Hides the header (language label + copy button) |
|
|
37
|
+
|
|
38
|
+
## Slots
|
|
39
|
+
|
|
40
|
+
| Name | Description |
|
|
41
|
+
|------|-------------|
|
|
42
|
+
| *(default, hidden)* | Code text injected directly as content; updates `value` on `slotchange` |
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# u-copy-button
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import '@iyulab/chat-components/dist/components/buttons/UCopyButton.js';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**Tag:** `u-copy-button`
|
|
8
|
+
|
|
9
|
+
Copies text to the clipboard on click. The icon switches to a checkmark temporarily to confirm the action. Used inside `u-code-block` for code copying.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<!-- Basic usage -->
|
|
13
|
+
<u-copy-button .value=${"Text to copy"}></u-copy-button>
|
|
14
|
+
|
|
15
|
+
<!-- With tooltip text -->
|
|
16
|
+
<u-copy-button .value=${"code content"}>Copy</u-copy-button>
|
|
17
|
+
|
|
18
|
+
<!-- Custom reset delay (default: 1000ms) -->
|
|
19
|
+
<u-copy-button .value=${"text"} .delay=${2000}></u-copy-button>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Typical placement in a message footer:
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<u-message>
|
|
26
|
+
<u-marked-block slot="default" .value=${content}></u-marked-block>
|
|
27
|
+
<div slot="footer">
|
|
28
|
+
<u-copy-button .value=${content}>Copy</u-copy-button>
|
|
29
|
+
</div>
|
|
30
|
+
</u-message>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Slots
|
|
36
|
+
|
|
37
|
+
| Name | Description |
|
|
38
|
+
|------|-------------|
|
|
39
|
+
| *(default)* | Tooltip label text |
|
|
40
|
+
|
|
41
|
+
## Properties
|
|
42
|
+
|
|
43
|
+
| Property | Type | Default | Description |
|
|
44
|
+
|----------|------|---------|-------------|
|
|
45
|
+
| `value` | `string` | `undefined` | Text to copy to clipboard |
|
|
46
|
+
| `delay` | `number` | `1000` | Time in ms before the icon resets after copying. `0` resets immediately |
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# u-file-block
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import '@iyulab/chat-components/dist/components/blocks/UFileBlock.js';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**Tag:** `u-file-block`
|
|
8
|
+
|
|
9
|
+
Displays a single file as a card. Shows a type-appropriate icon, upload status, download link, and an optional remove button.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<!-- Image file -->
|
|
13
|
+
<u-file-block name="photo.png" type="image/png" size=${102400}></u-file-block>
|
|
14
|
+
|
|
15
|
+
<!-- Uploading state -->
|
|
16
|
+
<u-file-block name="document.pdf" type="application/pdf" status="uploading"></u-file-block>
|
|
17
|
+
|
|
18
|
+
<!-- With download link -->
|
|
19
|
+
<u-file-block
|
|
20
|
+
name="report.xlsx"
|
|
21
|
+
type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
22
|
+
size=${512000}
|
|
23
|
+
url="https://example.com/report.xlsx"
|
|
24
|
+
></u-file-block>
|
|
25
|
+
|
|
26
|
+
<!-- Removable (e.g. prompt attachment) -->
|
|
27
|
+
<u-file-block
|
|
28
|
+
removable
|
|
29
|
+
name="image.jpg"
|
|
30
|
+
type="image/jpeg"
|
|
31
|
+
@remove=${handleRemove}
|
|
32
|
+
></u-file-block>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Properties
|
|
38
|
+
|
|
39
|
+
| Property | Type | Default | Reflect | Description |
|
|
40
|
+
|----------|------|---------|---------|-------------|
|
|
41
|
+
| `removable` | `boolean` | `false` | ✓ | Shows the remove button |
|
|
42
|
+
| `status` | `'idle'\|'uploading'\|'error'` | `undefined` | ✓ | File state. `uploading` shows spinner; `error` shows error icon |
|
|
43
|
+
| `name` | `string` | `undefined` | — | File name |
|
|
44
|
+
| `type` | `string` | `undefined` | — | MIME type (determines icon) |
|
|
45
|
+
| `size` | `number` | `undefined` | — | File size in bytes; auto-formatted to KB/MB |
|
|
46
|
+
| `url` | `string` | `undefined` | — | Download URL. Shows download button when set |
|
|
47
|
+
|
|
48
|
+
## Events
|
|
49
|
+
|
|
50
|
+
| Event | Detail | Description |
|
|
51
|
+
|-------|--------|-------------|
|
|
52
|
+
| `remove` | `RemoveEventDetail` | Fired when the remove button is clicked. If not cancelled, the element removes itself from the DOM |
|
|
53
|
+
|
|
54
|
+
## Icon Resolution by MIME Type
|
|
55
|
+
|
|
56
|
+
| MIME | Icon |
|
|
57
|
+
|------|------|
|
|
58
|
+
| `image/*` | `file-earmark-image` |
|
|
59
|
+
| `video/*` | `file-earmark-play` |
|
|
60
|
+
| `audio/*` | `file-earmark-music` |
|
|
61
|
+
| `application/pdf` | `file-earmark-pdf` |
|
|
62
|
+
| `application/zip` | `file-earmark-zip` |
|
|
63
|
+
| `text/*` | `file-earmark-text` |
|
|
64
|
+
| other | `file-earmark` |
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# u-images-view
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import '@iyulab/chat-components/dist/components/views/UImagesView.js';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**Tag:** `u-images-view`
|
|
8
|
+
|
|
9
|
+
Image gallery view. Uses `u-carousel` for a horizontal slide layout, with a click-to-open lightbox. Shows up to 3 slides at once. Keyboard arrow keys navigate the lightbox.
|
|
10
|
+
|
|
11
|
+
Automatically rendered by `u-marked-block` from a `view-json` code block.
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<!-- Direct usage -->
|
|
15
|
+
<u-images-view
|
|
16
|
+
.items=${[
|
|
17
|
+
{ src: 'https://example.com/photo1.jpg', alt: 'First photo', caption: 'Seoul at night' },
|
|
18
|
+
{ src: 'https://example.com/photo2.jpg', caption: 'Busan beach' },
|
|
19
|
+
{ src: 'https://example.com/photo3.jpg' }
|
|
20
|
+
]}
|
|
21
|
+
></u-images-view>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
LLM output example (`view-json` code block):
|
|
25
|
+
|
|
26
|
+
````
|
|
27
|
+
```view-json
|
|
28
|
+
{
|
|
29
|
+
"tag": "u-images-view",
|
|
30
|
+
"properties": {
|
|
31
|
+
"items": [
|
|
32
|
+
{ "src": "https://example.com/photo.jpg", "alt": "Description", "caption": "Caption" }
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
````
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Properties
|
|
42
|
+
|
|
43
|
+
| Property | Type | Default | Description |
|
|
44
|
+
|----------|------|---------|-------------|
|
|
45
|
+
| `items` | `ImageSlide[]` | `[]` | Array of image slide objects |
|
|
46
|
+
|
|
47
|
+
## ImageSlide Type
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
interface ImageSlide {
|
|
51
|
+
src: string; // Image URL (required)
|
|
52
|
+
alt?: string; // Accessibility alt text
|
|
53
|
+
caption?: string; // Caption shown below the image
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Features
|
|
58
|
+
|
|
59
|
+
| Feature | Description |
|
|
60
|
+
|---------|-------------|
|
|
61
|
+
| Carousel | Up to 3 slides visible; draggable |
|
|
62
|
+
| Lightbox | Full-screen modal on image click |
|
|
63
|
+
| Keyboard | `←` `→` to navigate, `Esc` to close |
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# u-json-block
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import '@iyulab/chat-components/dist/components/blocks/UJsonBlock.js';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**Tag:** `u-json-block`
|
|
8
|
+
|
|
9
|
+
Renders JSON data as a collapsible, interactive tree. Used inside `u-tool-block` to display tool call input and output.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<!-- Basic usage -->
|
|
13
|
+
<u-json-block .value=${{ name: "Alice", age: 30, hobbies: ["reading", "coding"] }}></u-json-block>
|
|
14
|
+
|
|
15
|
+
<!-- Collapsed by default -->
|
|
16
|
+
<u-json-block .expanded=${false} .value=${complexData}></u-json-block>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Pass JSON via HTML attribute:
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<u-json-block value='{"key": "value", "count": 42}'></u-json-block>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Properties
|
|
28
|
+
|
|
29
|
+
| Property | Type | Default | Description |
|
|
30
|
+
|----------|------|---------|-------------|
|
|
31
|
+
| `value` | `JsonNode` | `{}` | JSON data to render (object, array, or primitive) |
|
|
32
|
+
| `expanded` | `boolean` | `true` | Initial expand state for all object/array nodes |
|
|
33
|
+
|
|
34
|
+
## JsonNode Type
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
type JsonValue = string | number | boolean | null;
|
|
38
|
+
type JsonArray = JsonNode[];
|
|
39
|
+
type JsonObject = { [key: string]: JsonNode };
|
|
40
|
+
type JsonNode = JsonValue | JsonArray | JsonObject;
|
|
41
|
+
```
|