@iyulab/chat-components 0.4.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 (265) hide show
  1. package/CHANGELOG.md +83 -52
  2. package/README.md +133 -16
  3. package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/decorate.js +9 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/decorateMetadata.js +6 -0
  5. package/dist/_virtual/_glob-assets_raw/intent-prompt.md.1907474e.js +4 -0
  6. package/dist/_virtual/_glob-assets_raw/view-prompt.md.e0dbcffe.js +4 -0
  7. package/dist/components/blocks/UCodeBlock.d.ts +24 -2
  8. package/dist/components/blocks/UCodeBlock.js +65 -2
  9. package/dist/components/blocks/UCodeBlock.styles.js +4 -4
  10. package/dist/components/blocks/UFileBlock.d.ts +33 -0
  11. package/dist/components/blocks/UFileBlock.js +154 -0
  12. package/dist/components/blocks/{UFilesBlock.styles.js → UFileBlock.styles.js} +12 -90
  13. package/dist/components/blocks/UJsonBlock.d.ts +44 -2
  14. package/dist/components/blocks/UJsonBlock.js +128 -3
  15. package/dist/components/blocks/UJsonBlock.styles.js +4 -4
  16. package/dist/components/blocks/UMarkedBlock.d.ts +44 -2
  17. package/dist/components/blocks/UMarkedBlock.js +154 -4
  18. package/dist/components/blocks/UMarkedBlock.styles.js +4 -4
  19. package/dist/components/blocks/URefBlock.d.ts +16 -2
  20. package/dist/components/blocks/URefBlock.js +58 -3
  21. package/dist/components/blocks/URefBlock.styles.js +4 -4
  22. package/dist/components/blocks/UTableBlock.d.ts +47 -2
  23. package/dist/components/blocks/UTableBlock.js +197 -4
  24. package/dist/components/blocks/UTableBlock.styles.js +4 -5
  25. package/dist/components/blocks/UTextBlock.d.ts +36 -2
  26. package/dist/components/blocks/UTextBlock.js +94 -4
  27. package/dist/components/blocks/UTextBlock.styles.js +4 -4
  28. package/dist/components/blocks/UThinkBlock.d.ts +30 -2
  29. package/dist/components/blocks/UThinkBlock.js +86 -4
  30. package/dist/components/blocks/UThinkBlock.styles.js +4 -4
  31. package/dist/components/blocks/UToolBlock.d.ts +19 -2
  32. package/dist/components/blocks/UToolBlock.js +68 -3
  33. package/dist/components/blocks/UToolBlock.styles.js +4 -4
  34. package/dist/components/buttons/UAttachButton.d.ts +21 -2
  35. package/dist/components/buttons/UAttachButton.js +61 -3
  36. package/dist/components/buttons/UAttachButton.styles.js +4 -4
  37. package/dist/components/buttons/UCopyButton.d.ts +19 -2
  38. package/dist/components/buttons/UCopyButton.js +57 -3
  39. package/dist/components/buttons/UCopyButton.styles.js +4 -4
  40. package/dist/components/buttons/UVoteButton.d.ts +14 -3
  41. package/dist/components/buttons/UVoteButton.js +62 -3
  42. package/dist/components/buttons/UVoteButton.styles.js +4 -4
  43. package/dist/components/{actions/UQuestionAction.component.d.ts → intents/UQuestionIntent.d.ts} +6 -2
  44. package/dist/components/intents/UQuestionIntent.js +41 -0
  45. package/dist/components/{actions/UQuestionAction.styles.js → intents/UQuestionIntent.styles.js} +4 -6
  46. package/dist/components/message/UMessage.d.ts +18 -2
  47. package/dist/components/message/UMessage.js +47 -2
  48. package/dist/components/message/UMessage.styles.js +4 -4
  49. package/dist/components/prompt/UPrompt.d.ts +37 -2
  50. package/dist/components/prompt/UPrompt.js +139 -2
  51. package/dist/components/prompt/UPrompt.styles.js +15 -5
  52. package/dist/components/references/URefCard.d.ts +30 -2
  53. package/dist/components/references/URefCard.js +97 -2
  54. package/dist/components/references/URefCard.styles.js +4 -4
  55. package/dist/components/references/URefCardGroup.d.ts +25 -2
  56. package/dist/components/references/URefCardGroup.js +69 -4
  57. package/dist/components/references/URefCardGroup.styles.js +4 -4
  58. package/dist/components/references/URefTag.d.ts +12 -2
  59. package/dist/components/references/URefTag.js +37 -2
  60. package/dist/components/references/URefTag.styles.js +4 -4
  61. package/dist/components/{widgets/UChartWidget.component.d.ts → views/UChartView.d.ts} +7 -4
  62. package/dist/components/views/UChartView.js +167 -0
  63. package/dist/components/{widgets/UChartWidget.styles.js → views/UChartView.styles.js} +4 -4
  64. package/dist/components/{widgets/UImagesWidget.component.d.ts → views/UImagesView.d.ts} +7 -4
  65. package/dist/components/views/UImagesView.js +144 -0
  66. package/dist/components/{widgets/UImagesWidget.styles.js → views/UImagesView.styles.js} +6 -5
  67. package/dist/components/{widgets/UMapWidget.component.d.ts → views/UMapView.d.ts} +7 -3
  68. package/dist/components/views/UMapView.js +45 -0
  69. package/dist/components/{widgets/UMapWidget.styles.js → views/UMapView.styles.js} +4 -4
  70. package/dist/components/{widgets/UVideoWidget.component.d.ts → views/UVideoView.d.ts} +7 -3
  71. package/dist/components/views/UVideoView.js +81 -0
  72. package/dist/components/{widgets/UVideoWidget.styles.js → views/UVideoView.styles.js} +4 -4
  73. package/dist/components/{widgets/UWidget.component.d.ts → views/UView.d.ts} +8 -5
  74. package/dist/components/views/UView.js +113 -0
  75. package/dist/components/{widgets/UWidget.styles.js → views/UView.styles.js} +4 -4
  76. package/dist/events/AttachEvent.d.ts +9 -0
  77. package/dist/events/ChoiceEvent.d.ts +9 -0
  78. package/dist/events/SendEvent.d.ts +21 -0
  79. package/dist/events/StopEvent.d.ts +17 -0
  80. package/dist/index.d.ts +13 -16
  81. package/dist/index.js +28 -56
  82. package/dist/react/UAttachButton.d.ts +11 -0
  83. package/dist/react/UAttachButton.js +12 -0
  84. package/dist/react/UChartView.d.ts +9 -0
  85. package/dist/react/UChartView.js +10 -0
  86. package/dist/react/UCodeBlock.d.ts +9 -0
  87. package/dist/react/UCodeBlock.js +10 -0
  88. package/dist/react/UCopyButton.d.ts +9 -0
  89. package/dist/react/UCopyButton.js +10 -0
  90. package/dist/react/UFileBlock.d.ts +11 -0
  91. package/dist/react/UFileBlock.js +12 -0
  92. package/dist/react/UImagesView.d.ts +9 -0
  93. package/dist/react/UImagesView.js +10 -0
  94. package/dist/react/UJsonBlock.d.ts +9 -0
  95. package/dist/react/UJsonBlock.js +10 -0
  96. package/dist/react/UMapView.d.ts +9 -0
  97. package/dist/react/UMapView.js +10 -0
  98. package/dist/react/UMarkedBlock.d.ts +9 -0
  99. package/dist/react/UMarkedBlock.js +10 -0
  100. package/dist/react/UMessage.d.ts +9 -0
  101. package/dist/react/UMessage.js +10 -0
  102. package/dist/react/UPrompt.d.ts +13 -0
  103. package/dist/react/UPrompt.js +13 -0
  104. package/dist/react/UQuestionIntent.d.ts +11 -0
  105. package/dist/react/UQuestionIntent.js +12 -0
  106. package/dist/react/URefBlock.d.ts +9 -0
  107. package/dist/react/URefBlock.js +10 -0
  108. package/dist/react/URefCard.d.ts +9 -0
  109. package/dist/react/URefCard.js +10 -0
  110. package/dist/react/URefCardGroup.d.ts +9 -0
  111. package/dist/react/URefCardGroup.js +10 -0
  112. package/dist/react/URefTag.d.ts +9 -0
  113. package/dist/react/URefTag.js +10 -0
  114. package/dist/react/UTableBlock.d.ts +9 -0
  115. package/dist/react/UTableBlock.js +10 -0
  116. package/dist/react/UTextBlock.d.ts +9 -0
  117. package/dist/react/UTextBlock.js +10 -0
  118. package/dist/react/UThinkBlock.d.ts +9 -0
  119. package/dist/react/UThinkBlock.js +10 -0
  120. package/dist/react/UToolBlock.d.ts +9 -0
  121. package/dist/react/UToolBlock.js +10 -0
  122. package/dist/react/UVideoView.d.ts +9 -0
  123. package/dist/react/UVideoView.js +10 -0
  124. package/dist/react/UView.d.ts +9 -0
  125. package/dist/react/UView.js +10 -0
  126. package/dist/react/UVoteButton.d.ts +9 -0
  127. package/dist/react/UVoteButton.js +10 -0
  128. package/dist/react/index.d.ts +23 -0
  129. package/dist/react/index.js +23 -0
  130. package/dist/types/BlockItem.d.ts +21 -32
  131. package/dist/types/Intents.d.ts +26 -0
  132. package/dist/types/Intents.js +30 -0
  133. package/dist/types/{Widgets.d.ts → Views.d.ts} +8 -8
  134. package/dist/types/Views.js +150 -0
  135. package/dist/utilities/IntentPromptBuilder.d.ts +40 -0
  136. package/dist/utilities/IntentPromptBuilder.js +95 -0
  137. package/dist/utilities/ViewPromptBuilder.d.ts +28 -0
  138. package/dist/utilities/ViewPromptBuilder.js +76 -0
  139. package/dist/utilities/dom-agent/DOMAgent.d.ts +74 -0
  140. package/dist/utilities/dom-agent/DOMController.d.ts +78 -0
  141. package/dist/utilities/dom-agent/DOMPromptBuilder.d.ts +54 -0
  142. package/dist/utilities/dom-agent/DOMScanner.d.ts +83 -0
  143. package/dist/utilities/dom-agent/index.d.ts +9 -0
  144. package/dist/utilities/dom-agent/types.d.ts +209 -0
  145. package/package.json +33 -16
  146. package/skills/iyulab-chat-components/SKILL.md +107 -0
  147. package/skills/iyulab-chat-components/references/components/attach-button.md +69 -0
  148. package/skills/iyulab-chat-components/references/components/chart-view.md +65 -0
  149. package/skills/iyulab-chat-components/references/components/code-block.md +42 -0
  150. package/skills/iyulab-chat-components/references/components/copy-button.md +46 -0
  151. package/skills/iyulab-chat-components/references/components/file-block.md +64 -0
  152. package/skills/iyulab-chat-components/references/components/images-view.md +63 -0
  153. package/skills/iyulab-chat-components/references/components/json-block.md +41 -0
  154. package/skills/iyulab-chat-components/references/components/map-view.md +54 -0
  155. package/skills/iyulab-chat-components/references/components/marked-block.md +53 -0
  156. package/skills/iyulab-chat-components/references/components/message.md +60 -0
  157. package/skills/iyulab-chat-components/references/components/prompt.md +102 -0
  158. package/skills/iyulab-chat-components/references/components/question-intent.md +75 -0
  159. package/skills/iyulab-chat-components/references/components/ref-block.md +45 -0
  160. package/skills/iyulab-chat-components/references/components/ref-card-group.md +41 -0
  161. package/skills/iyulab-chat-components/references/components/ref-card.md +48 -0
  162. package/skills/iyulab-chat-components/references/components/ref-tag.md +40 -0
  163. package/skills/iyulab-chat-components/references/components/table-block.md +63 -0
  164. package/skills/iyulab-chat-components/references/components/text-block.md +59 -0
  165. package/skills/iyulab-chat-components/references/components/think-block.md +48 -0
  166. package/skills/iyulab-chat-components/references/components/tool-block.md +57 -0
  167. package/skills/iyulab-chat-components/references/components/video-view.md +55 -0
  168. package/skills/iyulab-chat-components/references/components/view.md +51 -0
  169. package/skills/iyulab-chat-components/references/components/vote-button.md +60 -0
  170. package/skills/iyulab-chat-components/references/types.md +115 -0
  171. package/skills/iyulab-chat-components/references/usage.md +254 -0
  172. package/skills/iyulab-chat-components/references/utilities/intent-prompt-builder.md +123 -0
  173. package/skills/iyulab-chat-components/references/utilities/view-prompt-builder.md +112 -0
  174. package/dist/assets/action-prompt.md.js +0 -3
  175. package/dist/assets/widget-prompt.md.js +0 -3
  176. package/dist/components/actions/UQuestionAction.component.js +0 -58
  177. package/dist/components/actions/UQuestionAction.d.ts +0 -7
  178. package/dist/components/actions/UQuestionAction.js +0 -5
  179. package/dist/components/blocks/UCodeBlock.component.d.ts +0 -25
  180. package/dist/components/blocks/UCodeBlock.component.js +0 -88
  181. package/dist/components/blocks/UFilesBlock.component.d.ts +0 -22
  182. package/dist/components/blocks/UFilesBlock.component.js +0 -192
  183. package/dist/components/blocks/UFilesBlock.d.ts +0 -7
  184. package/dist/components/blocks/UFilesBlock.js +0 -5
  185. package/dist/components/blocks/UJsonBlock.component.d.ts +0 -45
  186. package/dist/components/blocks/UJsonBlock.component.js +0 -140
  187. package/dist/components/blocks/UMarkedBlock.component.d.ts +0 -40
  188. package/dist/components/blocks/UMarkedBlock.component.js +0 -159
  189. package/dist/components/blocks/URefBlock.component.d.ts +0 -17
  190. package/dist/components/blocks/URefBlock.component.js +0 -73
  191. package/dist/components/blocks/UTableBlock.component.d.ts +0 -49
  192. package/dist/components/blocks/UTableBlock.component.js +0 -228
  193. package/dist/components/blocks/UTextBlock.component.d.ts +0 -37
  194. package/dist/components/blocks/UTextBlock.component.js +0 -123
  195. package/dist/components/blocks/UThinkBlock.component.d.ts +0 -23
  196. package/dist/components/blocks/UThinkBlock.component.js +0 -90
  197. package/dist/components/blocks/UToolBlock.component.d.ts +0 -20
  198. package/dist/components/blocks/UToolBlock.component.js +0 -80
  199. package/dist/components/buttons/UAttachButton.component.d.ts +0 -22
  200. package/dist/components/buttons/UAttachButton.component.js +0 -89
  201. package/dist/components/buttons/UCopyButton.component.d.ts +0 -20
  202. package/dist/components/buttons/UCopyButton.component.js +0 -81
  203. package/dist/components/buttons/UReportButton.component.d.ts +0 -9
  204. package/dist/components/buttons/UReportButton.component.js +0 -36
  205. package/dist/components/buttons/UReportButton.d.ts +0 -7
  206. package/dist/components/buttons/UReportButton.js +0 -5
  207. package/dist/components/buttons/UReportButton.styles.js +0 -14
  208. package/dist/components/buttons/URetryButton.component.d.ts +0 -11
  209. package/dist/components/buttons/URetryButton.component.js +0 -53
  210. package/dist/components/buttons/URetryButton.d.ts +0 -7
  211. package/dist/components/buttons/URetryButton.js +0 -5
  212. package/dist/components/buttons/URetryButton.styles.js +0 -26
  213. package/dist/components/buttons/UShareButton.component.d.ts +0 -9
  214. package/dist/components/buttons/UShareButton.component.js +0 -36
  215. package/dist/components/buttons/UShareButton.d.ts +0 -7
  216. package/dist/components/buttons/UShareButton.js +0 -5
  217. package/dist/components/buttons/UShareButton.styles.js +0 -14
  218. package/dist/components/buttons/UVoteButton.component.d.ts +0 -15
  219. package/dist/components/buttons/UVoteButton.component.js +0 -73
  220. package/dist/components/message/UMessage.component.d.ts +0 -19
  221. package/dist/components/message/UMessage.component.js +0 -56
  222. package/dist/components/prompt/UPrompt.component.d.ts +0 -25
  223. package/dist/components/prompt/UPrompt.component.js +0 -113
  224. package/dist/components/references/URefCard.component.d.ts +0 -27
  225. package/dist/components/references/URefCard.component.js +0 -109
  226. package/dist/components/references/URefCardGroup.component.d.ts +0 -26
  227. package/dist/components/references/URefCardGroup.component.js +0 -88
  228. package/dist/components/references/URefTag.component.d.ts +0 -13
  229. package/dist/components/references/URefTag.component.js +0 -54
  230. package/dist/components/widgets/UChartWidget.component.js +0 -180
  231. package/dist/components/widgets/UChartWidget.d.ts +0 -7
  232. package/dist/components/widgets/UChartWidget.js +0 -5
  233. package/dist/components/widgets/UImagesWidget.component.js +0 -164
  234. package/dist/components/widgets/UImagesWidget.d.ts +0 -7
  235. package/dist/components/widgets/UImagesWidget.js +0 -5
  236. package/dist/components/widgets/UMapWidget.component.js +0 -65
  237. package/dist/components/widgets/UMapWidget.d.ts +0 -7
  238. package/dist/components/widgets/UMapWidget.js +0 -5
  239. package/dist/components/widgets/UMapWidget.styles.d.ts +0 -1
  240. package/dist/components/widgets/UVideoWidget.component.js +0 -106
  241. package/dist/components/widgets/UVideoWidget.d.ts +0 -7
  242. package/dist/components/widgets/UVideoWidget.js +0 -5
  243. package/dist/components/widgets/UVideoWidget.styles.d.ts +0 -1
  244. package/dist/components/widgets/UWidget.component.js +0 -140
  245. package/dist/components/widgets/UWidget.d.ts +0 -7
  246. package/dist/components/widgets/UWidget.js +0 -5
  247. package/dist/components/widgets/UWidget.styles.d.ts +0 -1
  248. package/dist/events/UCancelEvent.d.ts +0 -6
  249. package/dist/events/USubmitEvent.d.ts +0 -6
  250. package/dist/types/Actions.d.ts +0 -24
  251. package/dist/types/Actions.js +0 -34
  252. package/dist/types/Widgets.js +0 -115
  253. package/dist/utilities/ActionPromptBuilder.d.ts +0 -40
  254. package/dist/utilities/ActionPromptBuilder.js +0 -93
  255. package/dist/utilities/WidgetPromptBuilder.d.ts +0 -28
  256. package/dist/utilities/WidgetPromptBuilder.js +0 -87
  257. package/dist/utilities/converters.d.ts +0 -9
  258. package/dist/utilities/converters.js +0 -19
  259. /package/dist/components/{actions/UQuestionAction.styles.d.ts → blocks/UFileBlock.styles.d.ts} +0 -0
  260. /package/dist/components/{blocks/UFilesBlock.styles.d.ts → intents/UQuestionIntent.styles.d.ts} +0 -0
  261. /package/dist/components/{buttons/UReportButton.styles.d.ts → views/UChartView.styles.d.ts} +0 -0
  262. /package/dist/components/{buttons/URetryButton.styles.d.ts → views/UImagesView.styles.d.ts} +0 -0
  263. /package/dist/components/{buttons/UShareButton.styles.d.ts → views/UMapView.styles.d.ts} +0 -0
  264. /package/dist/components/{widgets/UChartWidget.styles.d.ts → views/UVideoView.styles.d.ts} +0 -0
  265. /package/dist/components/{widgets/UImagesWidget.styles.d.ts → views/UView.styles.d.ts} +0 -0
@@ -0,0 +1,48 @@
1
+ # u-ref-card
2
+
3
+ ```ts
4
+ import '@iyulab/chat-components/dist/components/references/URefCard.js';
5
+ ```
6
+
7
+ **Tag:** `u-ref-card`
8
+
9
+ Displays a single reference source as a card. Supports `web` and `document` types. For web sources, automatically fetches a favicon via the Google Favicon API.
10
+
11
+ Extends `UDataElement`, so data can also be injected via a `<script type="application/json">` slot.
12
+
13
+ ```html
14
+ <!-- Web source -->
15
+ <u-ref-card
16
+ type="web"
17
+ url="https://example.com/article"
18
+ title="Article Title"
19
+ snippet="Short content summary..."
20
+ .tags=${["tech", "AI"]}
21
+ ></u-ref-card>
22
+
23
+ <!-- Document source -->
24
+ <u-ref-card
25
+ type="document"
26
+ title="Internal Document"
27
+ snippet="Document excerpt..."
28
+ ></u-ref-card>
29
+
30
+ <!-- JSON slot injection -->
31
+ <u-ref-card>
32
+ <script type="application/json">
33
+ { "type": "web", "url": "https://example.com", "title": "Example", "snippet": "Description" }
34
+ </script>
35
+ </u-ref-card>
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Properties
41
+
42
+ | Property | Type | Default | Reflect | Description |
43
+ |----------|------|---------|---------|-------------|
44
+ | `type` | `'web'\|'document'` | `'web'` | ✓ | Card type. Determines badge icon |
45
+ | `url` | `string` | `undefined` | — | External link URL. Click is suppressed if not set |
46
+ | `title` | `string` | `''` | — | Card title (falls back to domain name for web type) |
47
+ | `snippet` | `string` | `undefined` | — | Excerpt text |
48
+ | `tags` | `string[]` | `undefined` | — | Tag list. Pass as JSON array string via HTML attribute |
@@ -0,0 +1,40 @@
1
+ # u-ref-tag
2
+
3
+ ```ts
4
+ import '@iyulab/chat-components/dist/components/references/URefTag.js';
5
+ ```
6
+
7
+ **Tag:** `u-ref-tag`
8
+
9
+ Inline citation tag inserted within markdown body text. Opens an external link on click and shows source details in a tooltip.
10
+
11
+ Typically inserted automatically by `u-marked-block` when `refs` data is provided.
12
+
13
+ ```html
14
+ <!-- Inline citation -->
15
+ <u-ref-tag href="https://example.com">
16
+ [1]
17
+ <div slot="tooltip">Example Domain — source description...</div>
18
+ </u-ref-tag>
19
+
20
+ <!-- No href (local document) -->
21
+ <u-ref-tag>
22
+ [2]
23
+ <div slot="tooltip">Internal document title</div>
24
+ </u-ref-tag>
25
+ ```
26
+
27
+ ---
28
+
29
+ ## Slots
30
+
31
+ | Name | Description |
32
+ |------|-------------|
33
+ | *(default)* | Citation label text (e.g. `[1]`, `(Smith, 2023)`) |
34
+ | `tooltip` | Tooltip content (source details) |
35
+
36
+ ## Properties
37
+
38
+ | Property | Type | Default | Description |
39
+ |----------|------|---------|-------------|
40
+ | `href` | `string` | `undefined` | External link URL. Click is suppressed if not set |
@@ -0,0 +1,63 @@
1
+ # u-table-block
2
+
3
+ ```ts
4
+ import '@iyulab/chat-components/dist/components/blocks/UTableBlock.js';
5
+ ```
6
+
7
+ **Tag:** `u-table-block`
8
+
9
+ Renders tabular data with column sorting, search filtering, and CSV/XLS download. Automatically rendered inside `u-marked-block` for markdown tables.
10
+
11
+ Extends `UDataElement`, so data can also be injected via a `<script type="application/json">` slot.
12
+
13
+ ```html
14
+ <!-- Direct data binding -->
15
+ <u-table-block
16
+ .headers=${[
17
+ { text: 'Name', align: 'left' },
18
+ { text: 'Age', align: 'center' },
19
+ { text: 'Score', align: 'right' }
20
+ ]}
21
+ .rows=${[
22
+ [{ text: 'Alice', align: 'left' }, { text: '30', align: 'center' }, { text: '95', align: 'right' }],
23
+ [{ text: 'Bob', align: 'left' }, { text: '25', align: 'center' }, { text: '88', align: 'right' }]
24
+ ]}
25
+ ></u-table-block>
26
+
27
+ <!-- JSON slot injection -->
28
+ <u-table-block>
29
+ <script type="application/json">
30
+ {
31
+ "headers": [{ "text": "Name", "align": "left" }],
32
+ "rows": [[{ "text": "Alice", "align": "left" }]]
33
+ }
34
+ </script>
35
+ </u-table-block>
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Properties
41
+
42
+ | Property | Type | Default | Description |
43
+ |----------|------|---------|-------------|
44
+ | `headers` | `TableCell[]` | `[]` | Header cells, each with `text` and `align` |
45
+ | `rows` | `TableCell[][]` | `[]` | Row data; each row is an array of `TableCell` |
46
+
47
+ ## TableCell Type
48
+
49
+ ```ts
50
+ interface TableCell {
51
+ text: string;
52
+ align: 'left' | 'center' | 'right' | null;
53
+ }
54
+ ```
55
+
56
+ ## Features
57
+
58
+ | Feature | Description |
59
+ |---------|-------------|
60
+ | Column sort | Click a header to sort asc/desc |
61
+ | Search filter | Search bar filters rows (debounced) |
62
+ | CSV download | Downloads current filtered/sorted data as CSV |
63
+ | XLS download | Downloads as Excel file |
@@ -0,0 +1,59 @@
1
+ # u-text-block
2
+
3
+ ```ts
4
+ import '@iyulab/chat-components/dist/components/blocks/UTextBlock.js';
5
+ ```
6
+
7
+ **Tag:** `u-text-block`
8
+
9
+ Displays plain text or acts as an editable textarea. Used inside `u-prompt` as the input area.
10
+
11
+ ```html
12
+ <!-- Read-only text display -->
13
+ <u-text-block .value=${"Hello!"}></u-text-block>
14
+
15
+ <!-- Editable textarea -->
16
+ <u-text-block
17
+ editable
18
+ placeholder="Type a message..."
19
+ .minRows=${3}
20
+ .maxRows=${10}
21
+ .value=${inputValue}
22
+ @input=${handleInput}
23
+ ></u-text-block>
24
+ ```
25
+
26
+ ```ts
27
+ const block = document.querySelector('u-text-block');
28
+
29
+ block.addEventListener('input', () => {
30
+ console.log(block.value);
31
+ });
32
+
33
+ block.focus();
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Properties
39
+
40
+ | Property | Type | Default | Reflect | Description |
41
+ |----------|------|---------|---------|-------------|
42
+ | `value` | `string` | `undefined` | — | Text content |
43
+ | `editable` | `boolean` | `false` | ✓ | Enables the textarea and focuses it on activation |
44
+ | `placeholder` | `string` | `undefined` | — | Placeholder shown in edit mode |
45
+ | `minRows` | `number` | `1` | — | Minimum visible rows |
46
+ | `maxRows` | `number` | `undefined` | — | Maximum rows before scrolling |
47
+ | `spellcheck` | `boolean` | `false` | — | Enables browser spell-check |
48
+
49
+ ## Methods
50
+
51
+ | Method | Description |
52
+ |--------|-------------|
53
+ | `focus(options?)` | Focuses the inner textarea |
54
+
55
+ ## Events
56
+
57
+ | Event | Description |
58
+ |-------|-------------|
59
+ | `input` | Fired on text change (re-dispatches the original `InputEvent`) |
@@ -0,0 +1,48 @@
1
+ # u-think-block
2
+
3
+ ```ts
4
+ import '@iyulab/chat-components/dist/components/blocks/UThinkBlock.js';
5
+ ```
6
+
7
+ **Tag:** `u-think-block`
8
+
9
+ Displays LLM reasoning (thinking) content. Shows "Thinking..." while loading and switches to "Thought" on completion. Content can be collapsed or expanded via a header click.
10
+
11
+ ```html
12
+ <!-- Reasoning in progress -->
13
+ <u-think-block loading .value=${"Analyzing..."}></u-think-block>
14
+
15
+ <!-- Completed (default: collapsed) -->
16
+ <u-think-block .value=${"Full reasoning content here."}></u-think-block>
17
+
18
+ <!-- Expanded with auto-scroll during streaming -->
19
+ <u-think-block
20
+ auto-scroll
21
+ .collapsed=${false}
22
+ .value=${streamingThought}
23
+ ></u-think-block>
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Properties
29
+
30
+ | Property | Type | Default | Reflect | Description |
31
+ |----------|------|---------|---------|-------------|
32
+ | `value` | `string` | `undefined` | — | Reasoning text (rendered as markdown) |
33
+ | `loading` | `boolean` | `false` | ✓ | Loading state. Shows spinner, displays "Thinking..." label |
34
+ | `collapsed` | `boolean` | `true` | ✓ | Collapsed state. Toggle by clicking the header |
35
+ | `autoScroll` | `boolean` | `false` | — | (`auto-scroll`) Scrolls to bottom on each `value` update. Disables on user scroll interaction |
36
+
37
+ ## Methods
38
+
39
+ | Method | Returns | Description |
40
+ |--------|---------|-------------|
41
+ | `scrollToBottom()` | `boolean` | Smoothly scrolls the body to the bottom. Returns `true` if body element exists |
42
+
43
+ ## CSS Parts
44
+
45
+ | Part | Description |
46
+ |------|-------------|
47
+ | `header` | Header row (icon + title + collapse toggle) |
48
+ | `body` | Scrollable content area |
@@ -0,0 +1,57 @@
1
+ # u-tool-block
2
+
3
+ ```ts
4
+ import '@iyulab/chat-components/dist/components/blocks/UToolBlock.js';
5
+ ```
6
+
7
+ **Tag:** `u-tool-block`
8
+
9
+ Displays a tool call's input and output as collapsible JSON trees. Used to show LLM tool usage inline in a message.
10
+
11
+ ```html
12
+ <!-- Tool call in progress -->
13
+ <u-tool-block loading title="search_web"></u-tool-block>
14
+
15
+ <!-- Completed tool call -->
16
+ <u-tool-block
17
+ title="search_web"
18
+ .input=${{ query: "weather today" }}
19
+ .output=${{ results: ["Sunny, 25°C"] }}
20
+ ></u-tool-block>
21
+
22
+ <!-- Expanded by default -->
23
+ <u-tool-block
24
+ title="code_execution"
25
+ .collapsed=${false}
26
+ .input=${{ code: "print('hello')" }}
27
+ .output=${{ stdout: "hello\n" }}
28
+ ></u-tool-block>
29
+ ```
30
+
31
+ Pass JSON via HTML attribute (uses `jsonAttrConverter`):
32
+
33
+ ```html
34
+ <u-tool-block
35
+ title="calculator"
36
+ input='{"expression": "2 + 2"}'
37
+ output='{"result": 4}'
38
+ ></u-tool-block>
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Properties
44
+
45
+ | Property | Type | Default | Reflect | Description |
46
+ |----------|------|---------|---------|-------------|
47
+ | `title` | `string` | `''` | — | Tool name shown in the header (falls back to 'Tool Usage') |
48
+ | `loading` | `boolean` | `false` | ✓ | Loading state. Shows spinner in header |
49
+ | `collapsed` | `boolean` | `true` | ✓ | Collapsed state. Toggle by clicking the header |
50
+ | `input` | `JsonNode` | `undefined` | — | Tool input JSON |
51
+ | `output` | `JsonNode` | `undefined` | — | Tool output JSON |
52
+
53
+ ## CSS Parts
54
+
55
+ | Part | Description |
56
+ |------|-------------|
57
+ | `body` | Input / output display area |
@@ -0,0 +1,55 @@
1
+ # u-video-view
2
+
3
+ ```ts
4
+ import '@iyulab/chat-components/dist/components/views/UVideoView.js';
5
+ ```
6
+
7
+ **Tag:** `u-video-view`
8
+
9
+ Embeds a video from YouTube, Vimeo, or a direct file URL. Automatically detects the platform from the URL and selects the appropriate player.
10
+
11
+ ```html
12
+ <!-- YouTube -->
13
+ <u-video-view src="https://www.youtube.com/watch?v=dQw4w9WgXcQ"></u-video-view>
14
+
15
+ <!-- Vimeo -->
16
+ <u-video-view src="https://vimeo.com/123456789"></u-video-view>
17
+
18
+ <!-- Direct video file -->
19
+ <u-video-view
20
+ src="https://example.com/video.mp4"
21
+ poster="https://example.com/thumbnail.jpg"
22
+ ratio="4:3"
23
+ ></u-video-view>
24
+ ```
25
+
26
+ LLM output example (`view-json` code block):
27
+
28
+ ````
29
+ ```view-json
30
+ {
31
+ "tag": "u-video-view",
32
+ "properties": {
33
+ "src": "https://www.youtube.com/watch?v=VIDEO_ID"
34
+ }
35
+ }
36
+ ```
37
+ ````
38
+
39
+ ---
40
+
41
+ ## Properties
42
+
43
+ | Property | Type | Default | Description |
44
+ |----------|------|---------|-------------|
45
+ | `src` | `string` | `undefined` | Video URL: YouTube, Vimeo, or direct file |
46
+ | `poster` | `string` | `undefined` | Poster image URL for direct video files |
47
+ | `ratio` | `'16:9'\|'4:3'\|'1:1'` | `'16:9'` | Aspect ratio |
48
+
49
+ ## Supported Platforms
50
+
51
+ | Platform | URL Pattern | Embed Method |
52
+ |----------|-------------|--------------|
53
+ | YouTube | `youtube.com`, `youtu.be` | `youtube.com/embed/{id}` iframe |
54
+ | Vimeo | `vimeo.com` | `player.vimeo.com/video/{id}` iframe |
55
+ | Other | any URL | Native `<video>` element |
@@ -0,0 +1,51 @@
1
+ # u-view
2
+
3
+ ```ts
4
+ import '@iyulab/chat-components/dist/components/views/UView.js';
5
+ ```
6
+
7
+ **Tag:** `u-view`
8
+
9
+ Dynamic custom element renderer. Creates the element specified by `tag`, binds `properties` to it, and handles loading and error states. Used internally by `u-marked-block` to render `view-json` code blocks.
10
+
11
+ ```html
12
+ <!-- Render u-chart-view dynamically -->
13
+ <u-view
14
+ tag="u-chart-view"
15
+ .properties=${{
16
+ type: 'bar',
17
+ data: { labels: ['A', 'B'], datasets: [{ data: [10, 20] }] }
18
+ }}
19
+ ></u-view>
20
+
21
+ <!-- Loading state (skeleton placeholder) -->
22
+ <u-view tag="u-chart-view" loading></u-view>
23
+ ```
24
+
25
+ How `u-marked-block` processes a `view-json` block:
26
+
27
+ ````
28
+ ```view-json
29
+ {
30
+ "tag": "u-images-view",
31
+ "properties": { "items": [{ "src": "https://..." }] }
32
+ }
33
+ ```
34
+ ````
35
+
36
+ This is converted to `<u-view tag="u-images-view" ...>` via `UView.buildHTML()`.
37
+
38
+ ---
39
+
40
+ ## Properties
41
+
42
+ | Property | Type | Default | Reflect | Description |
43
+ |----------|------|---------|---------|-------------|
44
+ | `tag` | `string` | `undefined` | — | Custom element tag to render. Must already be registered |
45
+ | `properties` | `Record<string, unknown>` | `undefined` | — | Properties to bind to the rendered element |
46
+ | `loading` | `boolean` | `false` | ✓ | Shows a skeleton placeholder instead of the element |
47
+ | `blacklist` | `string[]` | `['innerHTML', 'outerHTML', ...]` | — | Property names blocked from binding for XSS prevention |
48
+
49
+ ## Security
50
+
51
+ The following property names are blocked by default to prevent XSS: `innerHTML`, `outerHTML`, `textContent`, `innerText`, `outerText`, `srcdoc`. Extend `blacklist` to add more restrictions.
@@ -0,0 +1,60 @@
1
+ # u-vote-button
2
+
3
+ ```ts
4
+ import '@iyulab/chat-components/dist/components/buttons/UVoteButton.js';
5
+ ```
6
+
7
+ **Tag:** `u-vote-button`
8
+
9
+ Thumbs-up / thumbs-down vote button pair. Clicking a button toggles its active state; clicking the same button again resets back to `none`.
10
+
11
+ ```html
12
+ <!-- Basic usage -->
13
+ <u-vote-button></u-vote-button>
14
+
15
+ <!-- Pre-set state -->
16
+ <u-vote-button value="up"></u-vote-button>
17
+
18
+ <!-- With tooltips -->
19
+ <u-vote-button>
20
+ <span slot="up">Helpful</span>
21
+ <span slot="down">Not helpful</span>
22
+ </u-vote-button>
23
+ ```
24
+
25
+ ```ts
26
+ const voteBtn = document.querySelector('u-vote-button');
27
+
28
+ voteBtn.addEventListener('change', () => {
29
+ console.log('vote:', voteBtn.value); // 'up' | 'down' | 'none'
30
+ });
31
+ ```
32
+
33
+ ---
34
+
35
+ ## Slots
36
+
37
+ | Name | Description |
38
+ |------|-------------|
39
+ | `up` | Tooltip text for the thumbs-up button |
40
+ | `down` | Tooltip text for the thumbs-down button |
41
+
42
+ ## Properties
43
+
44
+ | Property | Type | Default | Description |
45
+ |----------|------|---------|-------------|
46
+ | `value` | `'none'\|'up'\|'down'` | `'none'` | Current vote state |
47
+
48
+ ## Events
49
+
50
+ | Event | Description |
51
+ |-------|-------------|
52
+ | `change` | Fired when vote state changes (`bubbles: true, composed: true`) |
53
+
54
+ ## CSS Parts
55
+
56
+ | Part | Description |
57
+ |------|-------------|
58
+ | `up-btn` | Thumbs-up button |
59
+ | `down-btn` | Thumbs-down button |
60
+ | `icon` | Button icon |
@@ -0,0 +1,115 @@
1
+ # Types
2
+
3
+ ## BlockItem
4
+
5
+ ```ts
6
+ import type { BlockItem } from '@iyulab/chat-components';
7
+ ```
8
+
9
+ Union type for all message content blocks. Used to exchange structured message data with a server API.
10
+
11
+ ```ts
12
+ type BlockItem =
13
+ | ThinkingBlockItem
14
+ | TextBlockItem
15
+ | MarkdownBlockItem
16
+ | FileBlockItem
17
+ | ToolBlockItem
18
+ | ReferenceBlockItem;
19
+ ```
20
+
21
+ ### ThinkingBlockItem → `u-think-block`
22
+
23
+ ```ts
24
+ interface ThinkingBlockItem {
25
+ type: 'thinking';
26
+ loading?: boolean; // Streaming in progress
27
+ value?: string; // Reasoning text content
28
+ }
29
+ ```
30
+
31
+ ### TextBlockItem → `u-text-block`
32
+
33
+ ```ts
34
+ interface TextBlockItem {
35
+ type: 'text';
36
+ value?: string;
37
+ }
38
+ ```
39
+
40
+ ### MarkdownBlockItem → `u-marked-block`
41
+
42
+ ```ts
43
+ interface MarkdownBlockItem {
44
+ type: 'markdown';
45
+ value?: string;
46
+ refs?: ReferenceCitation[];
47
+ }
48
+ ```
49
+
50
+ ### FileBlockItem → `u-file-block` / `u-prompt.files`
51
+
52
+ ```ts
53
+ interface FileBlockItem {
54
+ type: 'file';
55
+ status?: 'idle' | 'uploading' | 'error';
56
+ name?: string; // File name
57
+ size?: number; // File size in bytes
58
+ mimeType?: string; // MIME type, e.g. "image/png"
59
+ url?: string; // Download URL
60
+ data?: any;
61
+ }
62
+ ```
63
+
64
+ ### ToolBlockItem → `u-tool-block`
65
+
66
+ ```ts
67
+ interface ToolBlockItem {
68
+ type: 'tool';
69
+ loading?: boolean;
70
+ title?: string;
71
+ input?: JsonNode;
72
+ output?: JsonNode;
73
+ }
74
+ ```
75
+
76
+ ### ReferenceBlockItem → `u-ref-block`
77
+
78
+ ```ts
79
+ interface ReferenceBlockItem {
80
+ type: 'reference';
81
+ sources: ReferenceSource[];
82
+ }
83
+ ```
84
+
85
+ ---
86
+
87
+ ## ReferenceSource & ReferenceCitation
88
+
89
+ ```ts
90
+ interface ReferenceSource {
91
+ type: 'web' | 'document';
92
+ url?: string;
93
+ title?: string;
94
+ snippet?: string;
95
+ tags?: string[];
96
+ }
97
+
98
+ interface ReferenceCitation {
99
+ startIndex: number; // Start char index in markdown text
100
+ endIndex: number; // End char index
101
+ label?: string; // Display label, e.g. "[1]"
102
+ sources: ReferenceSource[];
103
+ }
104
+ ```
105
+
106
+ ---
107
+
108
+ ## JsonNode
109
+
110
+ ```ts
111
+ type JsonValue = string | number | boolean | null;
112
+ type JsonArray = JsonNode[];
113
+ type JsonObject = { [key: string]: JsonNode };
114
+ type JsonNode = JsonValue | JsonArray | JsonObject;
115
+ ```