@iyulab/chat-components 0.5.0 → 0.5.1

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 (58) hide show
  1. package/CHANGELOG.md +73 -145
  2. package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.124.0}/helpers/decorate.js +1 -1
  3. package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.124.0}/helpers/decorateMetadata.js +1 -1
  4. package/dist/components/blocks/UCodeBlock.js +2 -2
  5. package/dist/components/blocks/UFileBlock.js +2 -2
  6. package/dist/components/blocks/UJsonBlock.js +2 -2
  7. package/dist/components/blocks/UMarkedBlock.js +2 -2
  8. package/dist/components/blocks/URefBlock.js +2 -2
  9. package/dist/components/blocks/UTableBlock.js +2 -2
  10. package/dist/components/blocks/UTextBlock.js +2 -2
  11. package/dist/components/blocks/UThinkBlock.js +2 -2
  12. package/dist/components/blocks/UToolBlock.js +2 -2
  13. package/dist/components/buttons/UAttachButton.js +2 -2
  14. package/dist/components/buttons/UCopyButton.js +2 -2
  15. package/dist/components/buttons/UVoteButton.js +2 -2
  16. package/dist/components/intents/UQuestionIntent.js +2 -2
  17. package/dist/components/message/UMessage.js +2 -2
  18. package/dist/components/prompt/UPrompt.d.ts +5 -0
  19. package/dist/components/prompt/UPrompt.js +25 -4
  20. package/dist/components/references/URefCard.js +2 -2
  21. package/dist/components/references/URefCardGroup.js +2 -2
  22. package/dist/components/references/URefTag.js +2 -2
  23. package/dist/components/views/UChartView.js +2 -2
  24. package/dist/components/views/UImagesView.js +2 -2
  25. package/dist/components/views/UMapView.js +2 -2
  26. package/dist/components/views/UVideoView.js +2 -2
  27. package/dist/components/views/UView.js +2 -2
  28. package/dist/events/SendEvent.d.ts +15 -1
  29. package/dist/events/StopEvent.d.ts +11 -1
  30. package/package.json +4 -3
  31. package/skills/iyulab-chat-components/SKILL.md +107 -0
  32. package/skills/iyulab-chat-components/references/components/attach-button.md +69 -0
  33. package/skills/iyulab-chat-components/references/components/chart-view.md +65 -0
  34. package/skills/iyulab-chat-components/references/components/code-block.md +42 -0
  35. package/skills/iyulab-chat-components/references/components/copy-button.md +46 -0
  36. package/skills/iyulab-chat-components/references/components/file-block.md +64 -0
  37. package/skills/iyulab-chat-components/references/components/images-view.md +63 -0
  38. package/skills/iyulab-chat-components/references/components/json-block.md +41 -0
  39. package/skills/iyulab-chat-components/references/components/map-view.md +54 -0
  40. package/skills/iyulab-chat-components/references/components/marked-block.md +53 -0
  41. package/skills/iyulab-chat-components/references/components/message.md +60 -0
  42. package/skills/iyulab-chat-components/references/components/prompt.md +102 -0
  43. package/skills/iyulab-chat-components/references/components/question-intent.md +75 -0
  44. package/skills/iyulab-chat-components/references/components/ref-block.md +45 -0
  45. package/skills/iyulab-chat-components/references/components/ref-card-group.md +41 -0
  46. package/skills/iyulab-chat-components/references/components/ref-card.md +48 -0
  47. package/skills/iyulab-chat-components/references/components/ref-tag.md +40 -0
  48. package/skills/iyulab-chat-components/references/components/table-block.md +63 -0
  49. package/skills/iyulab-chat-components/references/components/text-block.md +59 -0
  50. package/skills/iyulab-chat-components/references/components/think-block.md +48 -0
  51. package/skills/iyulab-chat-components/references/components/tool-block.md +57 -0
  52. package/skills/iyulab-chat-components/references/components/video-view.md +55 -0
  53. package/skills/iyulab-chat-components/references/components/view.md +51 -0
  54. package/skills/iyulab-chat-components/references/components/vote-button.md +60 -0
  55. package/skills/iyulab-chat-components/references/types.md +115 -0
  56. package/skills/iyulab-chat-components/references/usage.md +254 -0
  57. package/skills/iyulab-chat-components/references/utilities/intent-prompt-builder.md +123 -0
  58. package/skills/iyulab-chat-components/references/utilities/view-prompt-builder.md +112 -0
@@ -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.0"
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
+ ```
@@ -0,0 +1,54 @@
1
+ # u-map-view
2
+
3
+ ```ts
4
+ import '@iyulab/chat-components/dist/components/views/UMapView.js';
5
+ ```
6
+
7
+ **Tag:** `u-map-view`
8
+
9
+ Embeds an OpenStreetMap iframe centered on a given coordinate. A marker is placed at the specified `lat`/`lng` position.
10
+
11
+ ```html
12
+ <!-- Basic map -->
13
+ <u-map-view lat="37.5665" lng="126.9780"></u-map-view>
14
+
15
+ <!-- With label, description, and zoom -->
16
+ <u-map-view
17
+ lat="37.5665"
18
+ lng="126.9780"
19
+ zoom="13"
20
+ label="Seoul City Hall"
21
+ description="110 Sejong-daero, Jung-gu, Seoul"
22
+ ></u-map-view>
23
+ ```
24
+
25
+ LLM output example (`view-json` code block):
26
+
27
+ ````
28
+ ```view-json
29
+ {
30
+ "tag": "u-map-view",
31
+ "properties": {
32
+ "lat": 37.5665,
33
+ "lng": 126.9780,
34
+ "zoom": 15,
35
+ "label": "Seoul City Hall",
36
+ "description": "Jung-gu, Seoul"
37
+ }
38
+ }
39
+ ```
40
+ ````
41
+
42
+ ---
43
+
44
+ ## Properties
45
+
46
+ | Property | Type | Default | Description |
47
+ |----------|------|---------|-------------|
48
+ | `lat` | `number` | `undefined` | Latitude (required) |
49
+ | `lng` | `number` | `undefined` | Longitude (required) |
50
+ | `zoom` | `number` | `15` | Zoom level (1–19) |
51
+ | `label` | `string` | `undefined` | Bold label shown below the map |
52
+ | `description` | `string` | `undefined` | Description shown below the label |
53
+
54
+ Renders nothing if either `lat` or `lng` is missing.
@@ -0,0 +1,53 @@
1
+ # u-marked-block
2
+
3
+ ```ts
4
+ import '@iyulab/chat-components/dist/components/blocks/UMarkedBlock.js';
5
+ ```
6
+
7
+ **Tag:** `u-marked-block`
8
+
9
+ Renders markdown text to HTML. Supports KaTeX math equations, code syntax highlighting, inline citation tag injection, and special handling for `view-json` and `intent-json` code blocks. Applying an 80ms debounce makes it suitable for LLM streaming.
10
+
11
+ **Special code fences:**
12
+ - `` ```view-json `` → automatically rendered as a `u-view` component
13
+ - `` ```intent-json `` → stripped from output (must be parsed separately via `IntentPromptBuilder`)
14
+ - All other HTML inside markdown is escaped to prevent XSS
15
+
16
+ ```html
17
+ <!-- Basic markdown -->
18
+ <u-marked-block value="# Hello\n\nThis is **bold** and `code`."></u-marked-block>
19
+
20
+ <!-- Math equations -->
21
+ <u-marked-block value="Euler's identity: $e^{i\pi} + 1 = 0$"></u-marked-block>
22
+
23
+ <!-- With citation references -->
24
+ <u-marked-block
25
+ .value=${"The Earth orbits the Sun."}
26
+ .refs=${[{
27
+ startIndex: 4,
28
+ endIndex: 9,
29
+ label: '[1]',
30
+ sources: [{ type: 'web', url: 'https://...', title: 'Source' }]
31
+ }]}
32
+ ></u-marked-block>
33
+ ```
34
+
35
+ ---
36
+
37
+ ## Properties
38
+
39
+ | Property | Type | Default | Description |
40
+ |----------|------|---------|-------------|
41
+ | `value` | `string` | `undefined` | Markdown text to render |
42
+ | `refs` | `ReferenceCitation[]` | `undefined` | Citation list. `u-ref-tag` elements are automatically inserted at `startIndex`/`endIndex` positions |
43
+
44
+ ## ReferenceCitation Type
45
+
46
+ ```ts
47
+ interface ReferenceCitation {
48
+ startIndex: number; // Start character index in the markdown text
49
+ endIndex: number; // End character index
50
+ label?: string; // Display label, e.g. "[1]" or "(Smith, 2023)"
51
+ sources: ReferenceSource[];
52
+ }
53
+ ```
@@ -0,0 +1,60 @@
1
+ # u-message
2
+
3
+ ```ts
4
+ import '@iyulab/chat-components/dist/components/message/UMessage.js';
5
+ ```
6
+
7
+ **Tag:** `u-message`
8
+
9
+ Chat message wrapper component. Arranges content blocks via slots, shows a loading animation while the response streams in, and supports bubble or default visual styles.
10
+
11
+ ```html
12
+ <!-- Default AI message -->
13
+ <u-message>
14
+ <u-marked-block .value=${"## Hello\nMarkdown here."}></u-marked-block>
15
+ </u-message>
16
+
17
+ <!-- User message (right-aligned, bubble style) -->
18
+ <u-message position="right" variant="bubble">
19
+ <u-text-block .value=${"Hello!"}></u-text-block>
20
+ </u-message>
21
+
22
+ <!-- Loading state (streaming) -->
23
+ <u-message loading>
24
+ <u-marked-block .value=${"Streaming..."}></u-marked-block>
25
+ </u-message>
26
+
27
+ <!-- With header and footer slots -->
28
+ <u-message>
29
+ <div slot="header">AI Assistant</div>
30
+ <u-marked-block .value=${content}></u-marked-block>
31
+ <div slot="footer">
32
+ <u-copy-button .value=${content}></u-copy-button>
33
+ <u-vote-button></u-vote-button>
34
+ </div>
35
+ </u-message>
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Slots
41
+
42
+ | Name | Description |
43
+ |------|-------------|
44
+ | `header` | Area above the message body (avatar, name, etc.) |
45
+ | *(default)* | Message content blocks |
46
+ | `footer` | Area below the message body (buttons, etc.); hidden while `loading` |
47
+
48
+ ## Properties
49
+
50
+ | Property | Type | Default | Reflect | Description |
51
+ |----------|------|---------|---------|-------------|
52
+ | `loading` | `boolean` | `false` | ✓ | Loading state. Shows three-dot animation; hides `footer` slot |
53
+ | `variant` | `'default'\|'bubble'` | `'default'` | ✓ | Visual style |
54
+ | `position` | `'left'\|'right'` | `'left'` | ✓ | Message alignment |
55
+
56
+ ## CSS Parts
57
+
58
+ | Part | Description |
59
+ |------|-------------|
60
+ | `body` | Message body wrapper |