@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
@@ -1,22 +0,0 @@
1
- import { UElement } from '@iyulab/components/dist/components/UElement.js';
2
- import { FileItem } from '../../types/BlockItem.js';
3
- /**
4
- * 여러 파일을 그리드 형태로 표시하는 블록 컴포넌트입니다.
5
- */
6
- export declare class UFilesBlock extends UElement {
7
- static styles: import('lit').CSSResultGroup[];
8
- static dependencies: Record<string, typeof UElement>;
9
- /** 파일 목록 */
10
- files: FileItem[];
11
- /** 삭제 버튼 표시 여부 */
12
- removable: boolean;
13
- render(): unknown;
14
- private handleDownloadClick;
15
- private handleRemoveClick;
16
- /** MIME 타입 → Bootstrap Icon 이름 */
17
- private resolveIcon;
18
- /** 파일명 또는 MIME 타입에서 확장자를 추출합니다. */
19
- private resolveExt;
20
- /** bytes → 읽기 좋은 크기 문자열 */
21
- private formatSize;
22
- }
@@ -1,192 +0,0 @@
1
- import { nothing, html } from 'lit';
2
- import { property } from 'lit/decorators.js';
3
- import { repeat } from 'lit/directives/repeat.js';
4
- import { UElement } from '@iyulab/components/dist/components/UElement.js';
5
- import { UIcon } from '@iyulab/components/dist/components/icon/UIcon.component.js';
6
- import { UButton } from '@iyulab/components/dist/components/button/UButton.component.js';
7
- import { UProgressBar } from '@iyulab/components/dist/components/progress-bar/UProgressBar.component.js';
8
- import { styles } from './UFilesBlock.styles.js';
9
-
10
- var __defProp = Object.defineProperty;
11
- var __decorateClass = (decorators, target, key, kind) => {
12
- var result = void 0 ;
13
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
14
- if (decorator = decorators[i])
15
- result = (decorator(target, key, result) ) || result;
16
- if (result) __defProp(target, key, result);
17
- return result;
18
- };
19
- class UFilesBlock extends UElement {
20
- constructor() {
21
- super(...arguments);
22
- this.files = [];
23
- this.removable = false;
24
- this.handleDownloadClick = (e) => {
25
- e.stopPropagation();
26
- const index = e.currentTarget.dataset.index;
27
- if (index == null) return;
28
- const file = this.files.at(Number(index));
29
- if (!file?.downloadUrl) return;
30
- const a = document.createElement("a");
31
- a.href = file.downloadUrl;
32
- a.download = file.name;
33
- a.target = "_blank";
34
- a.rel = "noopener noreferrer";
35
- document.body.appendChild(a);
36
- a.click();
37
- a.remove();
38
- };
39
- this.handleRemoveClick = (e) => {
40
- e.stopPropagation();
41
- const index = e.currentTarget.dataset.index;
42
- if (index == null) return;
43
- const file = this.files.at(Number(index));
44
- if (!file) return;
45
- this.emit("u-remove", { index, file });
46
- };
47
- }
48
- static {
49
- this.styles = [super.styles, styles];
50
- }
51
- static {
52
- this.dependencies = {
53
- "u-icon": UIcon,
54
- "u-button": UButton,
55
- "u-progress-bar": UProgressBar
56
- };
57
- }
58
- render() {
59
- if (!this.files?.length) return nothing;
60
- return repeat(this.files, (_, i) => i, (f, i) => {
61
- const phase = f.upload?.phase ?? "done";
62
- const isUploading = phase === "uploading";
63
- const isError = phase === "error";
64
- return html`
65
- <div class="item" phase=${phase}>
66
- <div class="thumbnail">
67
- <u-icon lib="bootstrap" name=${this.resolveIcon(f.type)}></u-icon>
68
- <div class="thumbnail-overlay" ?hidden=${!isUploading}>
69
- <u-icon lib="bootstrap" name="cloud-arrow-up"></u-icon>
70
- </div>
71
- <div class="thumbnail-overlay" ?hidden=${!isError}>
72
- <u-icon lib="bootstrap" name="exclamation-circle-fill"></u-icon>
73
- </div>
74
- <u-button class="download-btn"
75
- ?hidden=${!f.downloadUrl || isUploading}
76
- data-index=${i}
77
- title="Download"
78
- variant="borderless"
79
- @click=${this.handleDownloadClick}>
80
- <u-icon lib="bootstrap" name="download"></u-icon>
81
- </u-button>
82
- </div>
83
- <div class="info">
84
- <div class="name" title=${f.name}>${f.name}</div>
85
- <div class="meta">
86
- <span class="type" ?hidden=${!f.type || isError}>
87
- ${this.resolveExt(f.name, f.type)}
88
- </span>
89
- <span class="size" ?hidden=${f.size == null || isError}>
90
- ${this.formatSize(f.size || 0)}
91
- </span>
92
- <span class="error-msg" ?hidden=${!isError}>
93
- <u-icon lib="bootstrap" name="exclamation-triangle"></u-icon>
94
- ${f.upload?.message ?? "File upload failed"}
95
- </span>
96
- </div>
97
- </div>
98
- <u-progress-bar class="upload-progress"
99
- ?hidden=${!isUploading}
100
- ?indeterminate=${f.upload?.progress == null}
101
- value=${f.upload?.progress ?? 0}
102
- ></u-progress-bar>
103
- <u-button class="remove-btn"
104
- ?hidden=${!this.removable}
105
- data-index=${i}
106
- title="Remove"
107
- variant="borderless"
108
- @click=${this.handleRemoveClick}>
109
- <u-icon lib="bootstrap" name="x-lg"></u-icon>
110
- </u-button>
111
- </div>
112
- `;
113
- });
114
- }
115
- /** MIME 타입 → Bootstrap Icon 이름 */
116
- resolveIcon(mimeType) {
117
- if (!mimeType) return "file-earmark";
118
- if (mimeType.startsWith("image/")) return "file-earmark-image";
119
- if (mimeType.startsWith("video/")) return "file-earmark-play";
120
- if (mimeType.startsWith("audio/")) return "file-earmark-music";
121
- if (mimeType === "application/pdf") return "file-earmark-pdf";
122
- const codeTypes = [
123
- "application/json",
124
- "application/javascript",
125
- "application/typescript",
126
- "application/xml",
127
- "text/html",
128
- "text/css",
129
- "text/javascript",
130
- "text/x-python",
131
- "text/x-java-source"
132
- ];
133
- if (codeTypes.includes(mimeType) || mimeType.startsWith("text/x-"))
134
- return "file-earmark-code";
135
- if ([
136
- "application/vnd.ms-excel",
137
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
138
- "text/csv"
139
- ].includes(mimeType))
140
- return "file-earmark-spreadsheet";
141
- if ([
142
- "application/zip",
143
- "application/x-zip-compressed",
144
- "application/x-tar",
145
- "application/x-rar-compressed",
146
- "application/gzip",
147
- "application/x-7z-compressed"
148
- ].includes(mimeType))
149
- return "file-earmark-zip";
150
- if (mimeType.startsWith("text/")) return "file-earmark-text";
151
- return "file-earmark";
152
- }
153
- /** 파일명 또는 MIME 타입에서 확장자를 추출합니다. */
154
- resolveExt(name, mimeType) {
155
- if (name) {
156
- const dot = name.lastIndexOf(".");
157
- if (dot !== -1 && dot < name.length - 1)
158
- return name.slice(dot + 1).toLowerCase();
159
- }
160
- const map = {
161
- "image/jpeg": "jpg",
162
- "image/png": "png",
163
- "image/gif": "gif",
164
- "image/webp": "webp",
165
- "image/svg+xml": "svg",
166
- "application/pdf": "pdf",
167
- "text/plain": "txt",
168
- "text/csv": "csv",
169
- "application/json": "json",
170
- "application/zip": "zip"
171
- };
172
- return mimeType ? map[mimeType] ?? mimeType.split("/").pop() ?? "" : "";
173
- }
174
- /** bytes → 읽기 좋은 크기 문자열 */
175
- formatSize(bytes) {
176
- if (bytes < 1024)
177
- return `${bytes} B`;
178
- if (bytes < 1024 ** 2)
179
- return `${(bytes / 1024).toFixed(1)} KB`;
180
- if (bytes < 1024 ** 3)
181
- return `${(bytes / 1024 ** 2).toFixed(1)} MB`;
182
- return `${(bytes / 1024 ** 3).toFixed(2)} GB`;
183
- }
184
- }
185
- __decorateClass([
186
- property({ type: Array })
187
- ], UFilesBlock.prototype, "files");
188
- __decorateClass([
189
- property({ type: Boolean, reflect: true })
190
- ], UFilesBlock.prototype, "removable");
191
-
192
- export { UFilesBlock };
@@ -1,7 +0,0 @@
1
- import { UFilesBlock } from './UFilesBlock.component.js';
2
- declare global {
3
- interface HTMLElementTagNameMap {
4
- "u-files-block": UFilesBlock;
5
- }
6
- }
7
- export { UFilesBlock };
@@ -1,5 +0,0 @@
1
- import { UFilesBlock } from './UFilesBlock.component.js';
2
-
3
- UFilesBlock.define("u-files-block");
4
-
5
- export { UFilesBlock };
@@ -1,45 +0,0 @@
1
- import { PropertyValues, TemplateResult } from 'lit';
2
- import { UElement } from '@iyulab/components/dist/components/UElement.js';
3
- import { JsonNode } from '../../types/JsonNode.js';
4
- /**
5
- * json 데이터를 트리 형태로 시각화하는 컴포넌트입니다.
6
- */
7
- export declare class UJsonBlock extends UElement {
8
- static styles: import('lit').CSSResultGroup[];
9
- static dependencies: Record<string, typeof UElement>;
10
- state: Record<string, boolean>;
11
- /** 초기 확장 상태를 관리하는 속성입니다. */
12
- expanded: boolean;
13
- /** JSON 데이터 (속성으로 전달 가능) */
14
- value: JsonNode;
15
- connectedCallback(): void;
16
- protected willUpdate(changedProperties: PropertyValues): void;
17
- render(): TemplateResult<1>;
18
- /**
19
- * JsonNode를 렌더링합니다.
20
- * @param value - JsonNode (JsonObject, JsonArray, 또는 JsonValue)
21
- * @param parent - 부모 노드의 경로
22
- */
23
- private renderNode;
24
- /**
25
- * JsonValue를 렌더링합니다.
26
- * @param node - JsonValue (string, number, boolean, null 등)
27
- */
28
- private renderValue;
29
- /**
30
- * JsonObject 또는 JsonArray를 렌더링합니다.
31
- * @param node - JsonObject 또는 JsonArray
32
- * @param depth - 현재 깊이
33
- */
34
- private renderObject;
35
- /**
36
- * 노드의 미리보기를 렌더링합니다.
37
- * @param node - JsonObject 또는 JsonArray
38
- */
39
- private renderPreview;
40
- /** JSON 데이터를 순회하며 각 경로의 확장 상태를 설정합니다. */
41
- private setState;
42
- private isValueType;
43
- /** 노드 확장/축소 클릭 핸들러 */
44
- private handlePropertyKeyClick;
45
- }
@@ -1,140 +0,0 @@
1
- import { html } from 'lit';
2
- import { state, property } from 'lit/decorators.js';
3
- import { map } from 'lit/directives/map.js';
4
- import { when } from 'lit/directives/when.js';
5
- import { UElement } from '@iyulab/components/dist/components/UElement.js';
6
- import { jsonAttrConverter } from '../../utilities/converters.js';
7
- import { styles } from './UJsonBlock.styles.js';
8
-
9
- var __defProp = Object.defineProperty;
10
- var __decorateClass = (decorators, target, key, kind) => {
11
- var result = void 0 ;
12
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
13
- if (decorator = decorators[i])
14
- result = (decorator(target, key, result) ) || result;
15
- if (result) __defProp(target, key, result);
16
- return result;
17
- };
18
- class UJsonBlock extends UElement {
19
- constructor() {
20
- super(...arguments);
21
- this.state = {};
22
- this.expanded = true;
23
- this.value = {};
24
- this.isValueType = (value) => {
25
- return value !== Object(value);
26
- };
27
- }
28
- static {
29
- this.styles = [super.styles, styles];
30
- }
31
- static {
32
- this.dependencies = {};
33
- }
34
- connectedCallback() {
35
- super.connectedCallback();
36
- this.setAttribute("tabindex", "0");
37
- }
38
- willUpdate(changedProperties) {
39
- super.willUpdate(changedProperties);
40
- if (changedProperties.has("value") || changedProperties.has("expanded")) {
41
- this.state = this.setState(this.value);
42
- }
43
- }
44
- render() {
45
- return html`
46
- <div part="base">
47
- ${this.renderNode(this.value)}
48
- </div>
49
- `;
50
- }
51
- /**
52
- * JsonNode를 렌더링합니다.
53
- * @param value - JsonNode (JsonObject, JsonArray, 또는 JsonValue)
54
- * @param parent - 부모 노드의 경로
55
- */
56
- renderNode(value, parent = "") {
57
- return this.isValueType(value) ? this.renderValue(value) : this.renderObject(value, parent);
58
- }
59
- /**
60
- * JsonValue를 렌더링합니다.
61
- * @param node - JsonValue (string, number, boolean, null 등)
62
- */
63
- renderValue(node) {
64
- const type = node === null ? "null" : Array.isArray(node) ? "array" : typeof node === "object" ? "object" : typeof node;
65
- return html`
66
- <span part="${type}" class="${type}" role="treeitem">
67
- ${JSON.stringify(node)}
68
- </span>
69
- `;
70
- }
71
- /**
72
- * JsonObject 또는 JsonArray를 렌더링합니다.
73
- * @param node - JsonObject 또는 JsonArray
74
- * @param depth - 현재 깊이
75
- */
76
- renderObject(node, parent) {
77
- return html`
78
- <ul part="object" role="group">
79
- ${map(Object.entries(node), ([key, value]) => {
80
- const path = parent ? `${parent}.${key}` : key;
81
- const isValue = this.isValueType(value);
82
- const isExpanded = this.state[path] ?? this.expanded;
83
- return html`
84
- <li part="property" role="treeitem"
85
- data-path="${path}"
86
- aria-expanded="${isExpanded ? "true" : "false"}">
87
- <span part="key"
88
- class="key"
89
- ?collapsable="${!isValue}"
90
- ?collapsed="${!isValue && !isExpanded}"
91
- @click=${!isValue ? () => this.handlePropertyKeyClick(path) : null}>
92
- ${key}:
93
- ${when(!isValue && !isExpanded, () => this.renderPreview(value))}
94
- </span>
95
-
96
- ${when(isValue || isExpanded, () => this.renderNode(value, path))}
97
- </li>`;
98
- })}
99
- </ul>
100
- `;
101
- }
102
- /**
103
- * 노드의 미리보기를 렌더링합니다.
104
- * @param node - JsonObject 또는 JsonArray
105
- */
106
- renderPreview(node) {
107
- return html`
108
- <span part="preview" class="preview">
109
- ${Array.isArray(node) ? node.length === 0 ? "[ ]" : `[ ${node.length} items ]` : Object.keys(node).length === 0 ? "{ }" : `{ ${Object.keys(node).length} properties }`}
110
- </span>
111
- `;
112
- }
113
- /** JSON 데이터를 순회하며 각 경로의 확장 상태를 설정합니다. */
114
- setState(value, parent = "") {
115
- if (typeof value !== "object" || value === null) return {};
116
- const state2 = {};
117
- Object.entries(value).forEach(([key, item]) => {
118
- const path = parent ? `${parent}.${key}` : key;
119
- state2[path] = this.expanded;
120
- Object.assign(state2, this.setState(item, path));
121
- });
122
- return state2;
123
- }
124
- /** 노드 확장/축소 클릭 핸들러 */
125
- handlePropertyKeyClick(path) {
126
- const isExpanded = this.state[path] ?? false;
127
- this.state = { ...this.state, [path]: !isExpanded };
128
- }
129
- }
130
- __decorateClass([
131
- state()
132
- ], UJsonBlock.prototype, "state");
133
- __decorateClass([
134
- property({ type: Boolean })
135
- ], UJsonBlock.prototype, "expanded");
136
- __decorateClass([
137
- property({ type: Object, converter: jsonAttrConverter })
138
- ], UJsonBlock.prototype, "value");
139
-
140
- export { UJsonBlock };
@@ -1,40 +0,0 @@
1
- import { UElement } from '@iyulab/components/dist/components/UElement.js';
2
- import { ReferenceCitation } from '../../types/References.js';
3
- /**
4
- * 마크다운 컨텐츠를 렌더링하는 컴포넌트입니다.
5
- *
6
- * 주의:
7
- * - refs로 삽입되는 커스텀 태그(u-ref-*)는 속성/내용을 모두 escape하여 XSS를 방지합니다.
8
- * - 코드블록 내부는 HTML을 전부 텍스트로 취급(escape)하며, refs 태그는 통째 제거합니다.
9
- * - 인덱스 기반 삽입(ref.endIndex)이 깨지지 않도록 "normalize(제로폭 제거)"를 insertRefs 전에 1회 수행합니다.
10
- */
11
- export declare class UMarkedBlock extends UElement {
12
- static styles: import('lit').CSSResultGroup[];
13
- static dependencies: Record<string, typeof UElement>;
14
- /** 마크다운 컨텐츠를 렌더링할 때 사용할 값입니다. */
15
- value?: string;
16
- /** 컨텐츠의 인용 출처들입니다. */
17
- refs?: ReferenceCitation[];
18
- /** Marked 인스턴스: 커스텀 렌더러와 KaTeX 확장 포함 */
19
- private parser;
20
- /** Marked 파싱 중 ref HTML을 임시 보관하는 플레이스홀더 */
21
- private placeholder;
22
- render(): import('lit-html/directive.js').DirectiveResult<typeof import('lit-html/directives/unsafe-html.js').UnsafeHTMLDirective>;
23
- /**
24
- * 코드블록은 별도의 컴포넌트로 렌더링 합니다.
25
- */
26
- private renderCode;
27
- /**
28
- * 테이블은 JSON 데이터로 변환하여 별도의 컴포넌트로 렌더링합니다.
29
- */
30
- private renderTable;
31
- /**
32
- * 인용/출처 참조객체가 있을때 ref 태그 HTML을 this.placeholder에 보관하고
33
- * 마크다운 문자열의 해당 위치에 주석 플레이스홀더를 삽입합니다.
34
- */
35
- private insertRefs;
36
- /**
37
- * 코드블록 내부의 <!--ref:idx--> 플레이스홀더와 그 외 refs 태그를 모두 제거하여 HTML이 코드로 렌더링되도록 합니다.
38
- */
39
- private removeRefs;
40
- }
@@ -1,159 +0,0 @@
1
- import { nothing } from 'lit';
2
- import { property } from 'lit/decorators.js';
3
- import { unsafeHTML } from 'lit/directives/unsafe-html.js';
4
- import { Marked } from 'marked';
5
- import markedKatex from 'marked-katex-extension';
6
- import { UElement } from '@iyulab/components/dist/components/UElement.js';
7
- import { UJsonElement } from '@iyulab/components/dist/components/UJsonElement.js';
8
- import { stripZeroWidth, escapeHtmlText } from '@iyulab/components/dist/utilities/sanitizers.js';
9
- import { buildElementHTML } from '@iyulab/components/dist/utilities/elements.js';
10
- import { UTooltip } from '@iyulab/components/dist/components/tooltip/UTooltip.component.js';
11
- import { UCodeBlock } from './UCodeBlock.component.js';
12
- import { UTableBlock } from './UTableBlock.component.js';
13
- import { URefTag } from '../references/URefTag.component.js';
14
- import { URefCard } from '../references/URefCard.component.js';
15
- import { URefCardGroup } from '../references/URefCardGroup.component.js';
16
- import { UWidget } from '../widgets/UWidget.component.js';
17
- import { styles } from './UMarkedBlock.styles.js';
18
-
19
- var __defProp = Object.defineProperty;
20
- var __decorateClass = (decorators, target, key, kind) => {
21
- var result = void 0 ;
22
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
23
- if (decorator = decorators[i])
24
- result = (decorator(target, key, result) ) || result;
25
- if (result) __defProp(target, key, result);
26
- return result;
27
- };
28
- class UMarkedBlock extends UElement {
29
- constructor() {
30
- super(...arguments);
31
- /** Marked 인스턴스: 커스텀 렌더러와 KaTeX 확장 포함 */
32
- this.parser = new Marked({
33
- pedantic: false,
34
- gfm: true,
35
- breaks: true,
36
- silent: true,
37
- renderer: {
38
- code: (token) => this.renderCode(token),
39
- table: (token) => this.renderTable(token)
40
- }
41
- }).use(markedKatex({ output: "mathml" }));
42
- /** Marked 파싱 중 ref HTML을 임시 보관하는 플레이스홀더 */
43
- this.placeholder = new HtmlPlaceholder();
44
- }
45
- static {
46
- this.styles = [super.styles, styles];
47
- }
48
- static {
49
- this.dependencies = {
50
- "u-tooltip": UTooltip,
51
- "u-code-block": UCodeBlock,
52
- "u-table-block": UTableBlock,
53
- "u-ref-tag": URefTag,
54
- "u-ref-card": URefCard,
55
- "u-ref-card-group": URefCardGroup,
56
- "u-widget": UWidget
57
- };
58
- }
59
- render() {
60
- if (!this.value) return nothing;
61
- this.placeholder.reset();
62
- let value = stripZeroWidth(this.value);
63
- if (this.refs?.length) {
64
- value = this.insertRefs(value, this.refs);
65
- }
66
- let html = this.parser.parse(value, { async: false });
67
- return unsafeHTML(this.placeholder.restore(html));
68
- }
69
- /**
70
- * 코드블록은 별도의 컴포넌트로 렌더링 합니다.
71
- */
72
- renderCode(token) {
73
- const lang = token.lang ?? "plaintext";
74
- const trimmed = token.raw.trimEnd();
75
- const isClosed = trimmed.endsWith("```") || trimmed.endsWith("~~~");
76
- if (lang === "widget-json") {
77
- return UJsonElement.buildHTML("u-widget", token.text, { loading: !isClosed });
78
- }
79
- if (lang === "action-json") {
80
- return "";
81
- }
82
- const safeText = this.removeRefs(token.text);
83
- return buildElementHTML("u-code-block", { lang, loading: !isClosed }, safeText);
84
- }
85
- /**
86
- * 테이블은 JSON 데이터로 변환하여 별도의 컴포넌트로 렌더링합니다.
87
- */
88
- renderTable(token) {
89
- const headers = token.header.map((h) => ({
90
- text: h.text,
91
- align: h.align
92
- }));
93
- const rows = token.rows.map(
94
- (row) => row.map((cell) => ({
95
- text: cell.text,
96
- align: cell.align
97
- }))
98
- );
99
- return UJsonElement.buildHTML("u-table-block", { headers, rows });
100
- }
101
- /**
102
- * 인용/출처 참조객체가 있을때 ref 태그 HTML을 this.placeholder에 보관하고
103
- * 마크다운 문자열의 해당 위치에 주석 플레이스홀더를 삽입합니다.
104
- */
105
- insertRefs(value, refs) {
106
- const sorted = [...refs].sort((a, b) => b.endIndex - a.endIndex);
107
- for (const ref of sorted) {
108
- const sources = ref.sources ?? [];
109
- const label = escapeHtmlText(ref.label ?? `[${refs.indexOf(ref) + 1}]`);
110
- const link = sources.at(0)?.url;
111
- let tooltip = "";
112
- if (sources.length > 0) {
113
- const cards = sources.map((s) => UJsonElement.buildHTML("u-ref-card", s)).join("");
114
- tooltip = buildElementHTML("u-ref-card-group", { slot: "tooltip" }, cards);
115
- }
116
- const html = buildElementHTML("u-ref-tag", { href: link }, label + tooltip);
117
- const key = this.placeholder.store(html);
118
- value = value.slice(0, ref.endIndex) + key + value.slice(ref.endIndex);
119
- }
120
- return value;
121
- }
122
- /**
123
- * 코드블록 내부의 <!--ref:idx--> 플레이스홀더와 그 외 refs 태그를 모두 제거하여 HTML이 코드로 렌더링되도록 합니다.
124
- */
125
- removeRefs(value) {
126
- value = value.replace(/<u-ref-tag\b[^>]*>[\s\S]*?<\/u-ref-tag>/gi, "");
127
- value = value.replace(/<!--ref:\d+-->/g, "");
128
- return value;
129
- }
130
- }
131
- __decorateClass([
132
- property({ type: String })
133
- ], UMarkedBlock.prototype, "value");
134
- __decorateClass([
135
- property({ type: Array })
136
- ], UMarkedBlock.prototype, "refs");
137
- class HtmlPlaceholder {
138
- constructor() {
139
- this.map = {};
140
- this.idx = 0;
141
- }
142
- reset() {
143
- this.map = {};
144
- this.idx = 0;
145
- }
146
- /** html을 저장하고 대응하는 플레이스홀더 키를 반환합니다. */
147
- store(html) {
148
- const key = `<!--ref:${this.idx++}-->`;
149
- this.map[key] = html;
150
- return key;
151
- }
152
- /** html 안의 등록된 모든 플레이스홀더를 원래 HTML로 복원합니다. */
153
- restore(html) {
154
- if (this.idx === 0) return html;
155
- return html.replace(/<!--ref:\d+-->/g, (key) => this.map[key] ?? "");
156
- }
157
- }
158
-
159
- export { UMarkedBlock };
@@ -1,17 +0,0 @@
1
- import { UElement } from '@iyulab/components/dist/components/UElement.js';
2
- import { ReferenceSource } from '../../types/References.js';
3
- /**
4
- * 레퍼런스 정보를 블록 형태로 표시하는 컴포넌트입니다.
5
- * 단일 또는 다중 레퍼런스 카드를 그리드 레이아웃으로 표시합니다.
6
- */
7
- export declare class URefBlock extends UElement {
8
- static styles: import('lit').CSSResultGroup[];
9
- static dependencies: Record<string, typeof UElement>;
10
- /** 접힘 상태 @default: true */
11
- collapsed: boolean;
12
- /** 블록 제목 */
13
- heading?: string;
14
- /** 출처 목록 */
15
- sources?: ReferenceSource[];
16
- render(): import('lit-html').TemplateResult<1>;
17
- }