@iyulab/chat-components 0.4.0 → 0.5.0

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 (237) hide show
  1. package/CHANGELOG.md +124 -21
  2. package/README.md +133 -16
  3. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.js +9 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.122.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 +32 -2
  50. package/dist/components/prompt/UPrompt.js +118 -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 +7 -0
  79. package/dist/events/StopEvent.d.ts +7 -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 +32 -16
  146. package/dist/assets/action-prompt.md.js +0 -3
  147. package/dist/assets/widget-prompt.md.js +0 -3
  148. package/dist/components/actions/UQuestionAction.component.js +0 -58
  149. package/dist/components/actions/UQuestionAction.d.ts +0 -7
  150. package/dist/components/actions/UQuestionAction.js +0 -5
  151. package/dist/components/blocks/UCodeBlock.component.d.ts +0 -25
  152. package/dist/components/blocks/UCodeBlock.component.js +0 -88
  153. package/dist/components/blocks/UFilesBlock.component.d.ts +0 -22
  154. package/dist/components/blocks/UFilesBlock.component.js +0 -192
  155. package/dist/components/blocks/UFilesBlock.d.ts +0 -7
  156. package/dist/components/blocks/UFilesBlock.js +0 -5
  157. package/dist/components/blocks/UJsonBlock.component.d.ts +0 -45
  158. package/dist/components/blocks/UJsonBlock.component.js +0 -140
  159. package/dist/components/blocks/UMarkedBlock.component.d.ts +0 -40
  160. package/dist/components/blocks/UMarkedBlock.component.js +0 -159
  161. package/dist/components/blocks/URefBlock.component.d.ts +0 -17
  162. package/dist/components/blocks/URefBlock.component.js +0 -73
  163. package/dist/components/blocks/UTableBlock.component.d.ts +0 -49
  164. package/dist/components/blocks/UTableBlock.component.js +0 -228
  165. package/dist/components/blocks/UTextBlock.component.d.ts +0 -37
  166. package/dist/components/blocks/UTextBlock.component.js +0 -123
  167. package/dist/components/blocks/UThinkBlock.component.d.ts +0 -23
  168. package/dist/components/blocks/UThinkBlock.component.js +0 -90
  169. package/dist/components/blocks/UToolBlock.component.d.ts +0 -20
  170. package/dist/components/blocks/UToolBlock.component.js +0 -80
  171. package/dist/components/buttons/UAttachButton.component.d.ts +0 -22
  172. package/dist/components/buttons/UAttachButton.component.js +0 -89
  173. package/dist/components/buttons/UCopyButton.component.d.ts +0 -20
  174. package/dist/components/buttons/UCopyButton.component.js +0 -81
  175. package/dist/components/buttons/UReportButton.component.d.ts +0 -9
  176. package/dist/components/buttons/UReportButton.component.js +0 -36
  177. package/dist/components/buttons/UReportButton.d.ts +0 -7
  178. package/dist/components/buttons/UReportButton.js +0 -5
  179. package/dist/components/buttons/UReportButton.styles.js +0 -14
  180. package/dist/components/buttons/URetryButton.component.d.ts +0 -11
  181. package/dist/components/buttons/URetryButton.component.js +0 -53
  182. package/dist/components/buttons/URetryButton.d.ts +0 -7
  183. package/dist/components/buttons/URetryButton.js +0 -5
  184. package/dist/components/buttons/URetryButton.styles.js +0 -26
  185. package/dist/components/buttons/UShareButton.component.d.ts +0 -9
  186. package/dist/components/buttons/UShareButton.component.js +0 -36
  187. package/dist/components/buttons/UShareButton.d.ts +0 -7
  188. package/dist/components/buttons/UShareButton.js +0 -5
  189. package/dist/components/buttons/UShareButton.styles.js +0 -14
  190. package/dist/components/buttons/UVoteButton.component.d.ts +0 -15
  191. package/dist/components/buttons/UVoteButton.component.js +0 -73
  192. package/dist/components/message/UMessage.component.d.ts +0 -19
  193. package/dist/components/message/UMessage.component.js +0 -56
  194. package/dist/components/prompt/UPrompt.component.d.ts +0 -25
  195. package/dist/components/prompt/UPrompt.component.js +0 -113
  196. package/dist/components/references/URefCard.component.d.ts +0 -27
  197. package/dist/components/references/URefCard.component.js +0 -109
  198. package/dist/components/references/URefCardGroup.component.d.ts +0 -26
  199. package/dist/components/references/URefCardGroup.component.js +0 -88
  200. package/dist/components/references/URefTag.component.d.ts +0 -13
  201. package/dist/components/references/URefTag.component.js +0 -54
  202. package/dist/components/widgets/UChartWidget.component.js +0 -180
  203. package/dist/components/widgets/UChartWidget.d.ts +0 -7
  204. package/dist/components/widgets/UChartWidget.js +0 -5
  205. package/dist/components/widgets/UImagesWidget.component.js +0 -164
  206. package/dist/components/widgets/UImagesWidget.d.ts +0 -7
  207. package/dist/components/widgets/UImagesWidget.js +0 -5
  208. package/dist/components/widgets/UMapWidget.component.js +0 -65
  209. package/dist/components/widgets/UMapWidget.d.ts +0 -7
  210. package/dist/components/widgets/UMapWidget.js +0 -5
  211. package/dist/components/widgets/UMapWidget.styles.d.ts +0 -1
  212. package/dist/components/widgets/UVideoWidget.component.js +0 -106
  213. package/dist/components/widgets/UVideoWidget.d.ts +0 -7
  214. package/dist/components/widgets/UVideoWidget.js +0 -5
  215. package/dist/components/widgets/UVideoWidget.styles.d.ts +0 -1
  216. package/dist/components/widgets/UWidget.component.js +0 -140
  217. package/dist/components/widgets/UWidget.d.ts +0 -7
  218. package/dist/components/widgets/UWidget.js +0 -5
  219. package/dist/components/widgets/UWidget.styles.d.ts +0 -1
  220. package/dist/events/UCancelEvent.d.ts +0 -6
  221. package/dist/events/USubmitEvent.d.ts +0 -6
  222. package/dist/types/Actions.d.ts +0 -24
  223. package/dist/types/Actions.js +0 -34
  224. package/dist/types/Widgets.js +0 -115
  225. package/dist/utilities/ActionPromptBuilder.d.ts +0 -40
  226. package/dist/utilities/ActionPromptBuilder.js +0 -93
  227. package/dist/utilities/WidgetPromptBuilder.d.ts +0 -28
  228. package/dist/utilities/WidgetPromptBuilder.js +0 -87
  229. package/dist/utilities/converters.d.ts +0 -9
  230. package/dist/utilities/converters.js +0 -19
  231. /package/dist/components/{actions/UQuestionAction.styles.d.ts → blocks/UFileBlock.styles.d.ts} +0 -0
  232. /package/dist/components/{blocks/UFilesBlock.styles.d.ts → intents/UQuestionIntent.styles.d.ts} +0 -0
  233. /package/dist/components/{buttons/UReportButton.styles.d.ts → views/UChartView.styles.d.ts} +0 -0
  234. /package/dist/components/{buttons/URetryButton.styles.d.ts → views/UImagesView.styles.d.ts} +0 -0
  235. /package/dist/components/{buttons/UShareButton.styles.d.ts → views/UMapView.styles.d.ts} +0 -0
  236. /package/dist/components/{widgets/UChartWidget.styles.d.ts → views/UVideoView.styles.d.ts} +0 -0
  237. /package/dist/components/{widgets/UImagesWidget.styles.d.ts → views/UView.styles.d.ts} +0 -0
@@ -1,11 +1,10 @@
1
1
  import { nothing, PropertyValues } from 'lit';
2
2
  import { UElement } from '@iyulab/components/dist/components/UElement.js';
3
3
  /**
4
- * 비디오 플레이어 위젯 컴포넌트
4
+ * 비디오 플레이어 뷰 컴포넌트
5
5
  */
6
- export declare class UVideoWidget extends UElement {
6
+ export declare class UVideoView extends UElement {
7
7
  static styles: import('lit').CSSResultGroup[];
8
- static dependencies: Record<string, typeof UElement>;
9
8
  /** 비디오 URL (YouTube, Vimeo, 직접 파일) */
10
9
  src?: string;
11
10
  /** 포스터 이미지 URL */
@@ -19,3 +18,8 @@ export declare class UVideoWidget extends UElement {
19
18
  private extractYouTubeId;
20
19
  private extractVimeoId;
21
20
  }
21
+ declare global {
22
+ interface HTMLElementTagNameMap {
23
+ "u-video-view": UVideoView;
24
+ }
25
+ }
@@ -0,0 +1,81 @@
1
+ import { __decorateMetadata } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.js";
2
+ import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.js";
3
+ import { styles } from "./UVideoView.styles.js";
4
+ import { html, nothing } from "lit";
5
+ import { customElement, property } from "lit/decorators.js";
6
+ import { UElement } from "@iyulab/components/dist/components/UElement.js";
7
+ import { ifDefined } from "lit/directives/if-defined.js";
8
+ //#region src/components/views/UVideoView.ts
9
+ var UVideoView = class UVideoView extends UElement {
10
+ constructor(..._args) {
11
+ super(..._args);
12
+ this.ratio = "16:9";
13
+ }
14
+ static {
15
+ this.styles = [super.styles, styles];
16
+ }
17
+ updated(changedProperties) {
18
+ super.updated(changedProperties);
19
+ if (changedProperties.has("ratio")) this.style.setProperty("--video-ratio", this.ratio.replace(":", " / "));
20
+ }
21
+ render() {
22
+ if (!this.src) return nothing;
23
+ if (this.isYouTube(this.src)) {
24
+ const videoId = this.extractYouTubeId(this.src);
25
+ if (videoId) return html`
26
+ <div class="video-wrapper">
27
+ <iframe
28
+ src="https://www.youtube.com/embed/${videoId}"
29
+ loading="lazy"
30
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
31
+ allowfullscreen
32
+ ></iframe>
33
+ </div>
34
+ `;
35
+ }
36
+ if (this.isVimeo(this.src)) {
37
+ const videoId = this.extractVimeoId(this.src);
38
+ if (videoId) return html`
39
+ <div class="video-wrapper">
40
+ <iframe
41
+ src="https://player.vimeo.com/video/${videoId}"
42
+ loading="lazy"
43
+ allow="autoplay; fullscreen; picture-in-picture"
44
+ allowfullscreen
45
+ ></iframe>
46
+ </div>
47
+ `;
48
+ }
49
+ return html`
50
+ <video
51
+ src=${this.src}
52
+ poster=${ifDefined(this.poster)}
53
+ controls
54
+ playsinline
55
+ ></video>
56
+ `;
57
+ }
58
+ isYouTube(url) {
59
+ return /youtube\.com|youtu\.be/i.test(url);
60
+ }
61
+ isVimeo(url) {
62
+ return /vimeo\.com/i.test(url);
63
+ }
64
+ extractYouTubeId(url) {
65
+ for (const pattern of [/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&\s]+)/, /youtube\.com\/embed\/([^&\s]+)/]) {
66
+ const match = url.match(pattern);
67
+ if (match && match[1]) return match[1];
68
+ }
69
+ return null;
70
+ }
71
+ extractVimeoId(url) {
72
+ const match = url.match(/vimeo\.com\/(\d+)/);
73
+ return match ? match[1] : null;
74
+ }
75
+ };
76
+ __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UVideoView.prototype, "src", void 0);
77
+ __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UVideoView.prototype, "poster", void 0);
78
+ __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UVideoView.prototype, "ratio", void 0);
79
+ UVideoView = __decorate([customElement("u-video-view")], UVideoView);
80
+ //#endregion
81
+ export { UVideoView };
@@ -1,6 +1,6 @@
1
- import { css } from 'lit';
2
-
3
- const styles = css`
1
+ import { css } from "lit";
2
+ //#region src/components/views/UVideoView.styles.ts
3
+ var styles = css`
4
4
  :host {
5
5
  --video-ratio: 16 / 9;
6
6
  }
@@ -32,5 +32,5 @@ const styles = css`
32
32
  border-radius: 8px;
33
33
  }
34
34
  `;
35
-
35
+ //#endregion
36
36
  export { styles };
@@ -1,12 +1,10 @@
1
1
  import { nothing, PropertyValues } from 'lit';
2
- import { UElement } from '@iyulab/components/dist/components/UElement.js';
3
- import { UJsonElement } from '@iyulab/components/dist/components/UJsonElement.js';
2
+ import { UDataElement } from '@iyulab/components/dist/components/UDataElement.js';
4
3
  /**
5
- * 위젯 파싱/렌더링 오류를 표시하는 컴포넌트입니다.
4
+ * 뷰 컴포넌트를 렌더링 또는 오류를 표시하는 컴포넌트입니다.
6
5
  */
7
- export declare class UWidget extends UJsonElement {
6
+ export declare class UView extends UDataElement {
8
7
  static styles: (import('lit').CSSResult | import('lit').CSSResultGroup[])[];
9
- static dependencies: Record<string, typeof UElement>;
10
8
  /** 로딩 상태입니다. `true`인 경우, 위젯이 로딩 중임을 나타냅니다. */
11
9
  loading: boolean;
12
10
  /** `tag` 프로퍼티에 등록된 커스텀 엘리먼트를 렌더링하는 컴포넌트입니다. */
@@ -41,3 +39,8 @@ export declare class UWidget extends UJsonElement {
41
39
  */
42
40
  private validateProperties;
43
41
  }
42
+ declare global {
43
+ interface HTMLElementTagNameMap {
44
+ "u-view": UView;
45
+ }
46
+ }
@@ -0,0 +1,113 @@
1
+ import { __decorateMetadata } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.js";
2
+ import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.js";
3
+ import { styles } from "./UView.styles.js";
4
+ import { html, nothing } from "lit";
5
+ import { customElement, property, state } from "lit/decorators.js";
6
+ import { UDataElement } from "@iyulab/components/dist/components/UDataElement.js";
7
+ import "@iyulab/components/dist/components/skeleton/USkeleton.js";
8
+ //#region src/components/views/UView.ts
9
+ var _ref;
10
+ var DEFAULT_BLACKLIST = [
11
+ "innerHTML",
12
+ "outerHTML",
13
+ "textContent",
14
+ "innerText",
15
+ "outerText",
16
+ "srcdoc"
17
+ ];
18
+ var UView = class UView extends UDataElement {
19
+ constructor(..._args) {
20
+ super(..._args);
21
+ this.loading = false;
22
+ this.blacklist = DEFAULT_BLACKLIST;
23
+ this.element = null;
24
+ }
25
+ static {
26
+ this.styles = [super.styles, styles];
27
+ }
28
+ willUpdate(changedProperties) {
29
+ super.willUpdate(changedProperties);
30
+ if (changedProperties.has("tag")) this.updateElement(this.tag);
31
+ if (changedProperties.has("properties") && this.element) this.updateProperties(this.element, this.properties);
32
+ if (changedProperties.has("blacklist") && this.element && this.properties) this.updateProperties(this.element, this.properties);
33
+ }
34
+ render() {
35
+ if (this.loading === true) return html`
36
+ <div class="sk-container">
37
+ <div class="sk-card">
38
+ <u-skeleton effect="shimmer" width="100%" height="5em" shape="rectangle"></u-skeleton>
39
+ <u-skeleton effect="shimmer" width="80%" height="0.8em" shape="rounded"></u-skeleton>
40
+ <u-skeleton effect="shimmer" width="40%" height="0.75em" shape="rounded"></u-skeleton>
41
+ </div>
42
+ <div class="sk-doc">
43
+ <u-skeleton effect="shimmer" width="40%" height="0.75em" shape="rounded"></u-skeleton>
44
+ <u-skeleton effect="shimmer" width="80%" height="0.75em" shape="rounded"></u-skeleton>
45
+ <u-skeleton effect="shimmer" width="60%" height="0.8em" shape="rounded"></u-skeleton>
46
+ <u-skeleton effect="shimmer" width="100%" height="0.8em" shape="rounded"></u-skeleton>
47
+ <u-skeleton effect="shimmer" width="80%" height="0.8em" shape="rounded"></u-skeleton>
48
+ </div>
49
+ </div>`;
50
+ if (this.element != null) return this.element;
51
+ return nothing;
52
+ }
53
+ /**
54
+ * `loading`이 `true`인 경우, 에러 UI로 대체하지 않습니다.
55
+ */
56
+ async error(error) {
57
+ if (this.loading) return;
58
+ await super.error(error);
59
+ }
60
+ /**
61
+ * `tag` 프로퍼티에 등록된 커스텀 엘리먼트를 렌더링하는 컴포넌트입니다.
62
+ * `tag`가 변경될 때마다 등록된 커스텀 엘리먼트를 새로 생성하여 렌더링합니다.
63
+ * `tag`가 유효하지 않거나 등록된 커스텀 엘리먼트가 아닌 경우, 에러 처리합니다.
64
+ */
65
+ updateElement(tag) {
66
+ tag = tag?.trim();
67
+ if (!tag) {
68
+ this.element = null;
69
+ super.error(/* @__PURE__ */ new Error("Tag is required"));
70
+ return;
71
+ }
72
+ if (!customElements.get(tag)) {
73
+ this.element = null;
74
+ super.error(/* @__PURE__ */ new Error(`Unknown tag: ${tag}`));
75
+ return;
76
+ }
77
+ this.element = document.createElement(tag);
78
+ }
79
+ /**
80
+ * `properties` 객체의 키가 렌더링된 엘리먼트의 프로퍼티 이름과 일치하면 자동으로 할당됩니다.
81
+ * `properties` 객체에 위험한 프로퍼티가 포함되어 있는지 검증하여, 유효한 경우에만 할당합니다.
82
+ * 할당 중 오류가 발생한 경우, 에러 처리합니다.
83
+ */
84
+ updateProperties(element, props) {
85
+ if (this.validateProperties(props)) try {
86
+ Object.assign(element, props);
87
+ } catch (error) {
88
+ super.error(error);
89
+ }
90
+ else super.error(/* @__PURE__ */ new Error(`Not allowed properties: ${JSON.stringify(props)}`));
91
+ }
92
+ /**
93
+ * `properties` 객체에 위험한 프로퍼티가 포함되어 있는지 검증합니다.
94
+ * DOM 조작이나 이벤트 핸들러로 악용될 수 있는 프로퍼티를 최소한으로 차단합니다.
95
+ */
96
+ validateProperties(props) {
97
+ if (typeof props !== "object" || props === null || Array.isArray(props)) return false;
98
+ const obj = props;
99
+ for (const key of Object.keys(obj)) if (this.blacklist.includes(key)) return false;
100
+ return true;
101
+ }
102
+ };
103
+ __decorate([property({
104
+ type: Boolean,
105
+ reflect: true
106
+ }), __decorateMetadata("design:type", Object)], UView.prototype, "loading", void 0);
107
+ __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UView.prototype, "tag", void 0);
108
+ __decorate([property({ type: Object }), __decorateMetadata("design:type", typeof (_ref = typeof Record !== "undefined" && Record) === "function" ? _ref : Object)], UView.prototype, "properties", void 0);
109
+ __decorate([property({ type: Array }), __decorateMetadata("design:type", Array)], UView.prototype, "blacklist", void 0);
110
+ __decorate([state(), __decorateMetadata("design:type", Object)], UView.prototype, "element", void 0);
111
+ UView = __decorate([customElement("u-view")], UView);
112
+ //#endregion
113
+ export { UView };
@@ -1,6 +1,6 @@
1
- import { css } from 'lit';
2
-
3
- const styles = css`
1
+ import { css } from "lit";
2
+ //#region src/components/views/UView.styles.ts
3
+ var styles = css`
4
4
  :host {
5
5
  display: contents;
6
6
  }
@@ -29,5 +29,5 @@ const styles = css`
29
29
  justify-content: space-between;
30
30
  }
31
31
  `;
32
-
32
+ //#endregion
33
33
  export { styles };
@@ -0,0 +1,9 @@
1
+ export interface AttachEventDetail {
2
+ files: File[];
3
+ }
4
+ export type AttachEvent = CustomEvent<AttachEventDetail>;
5
+ declare global {
6
+ interface HTMLElementEventMap {
7
+ 'attach': AttachEvent;
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ export interface ChoiceEventDetail {
2
+ value: string;
3
+ }
4
+ export type ChoiceEvent = CustomEvent<ChoiceEventDetail>;
5
+ declare global {
6
+ interface HTMLElementEventMap {
7
+ 'choice': ChoiceEvent;
8
+ }
9
+ }
@@ -0,0 +1,7 @@
1
+ export type SendEventDetail = unknown;
2
+ export type SendEvent = CustomEvent<SendEventDetail>;
3
+ declare global {
4
+ interface HTMLElementEventMap {
5
+ 'send': SendEvent;
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ export type StopEventDetail = unknown;
2
+ export type StopEvent = CustomEvent<StopEventDetail>;
3
+ declare global {
4
+ interface HTMLElementEventMap {
5
+ 'stop': StopEvent;
6
+ }
7
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from './components/blocks/UCodeBlock.js';
2
- export * from './components/blocks/UFilesBlock.js';
2
+ export * from './components/blocks/UFileBlock.js';
3
3
  export * from './components/blocks/UJsonBlock.js';
4
4
  export * from './components/blocks/UMarkedBlock.js';
5
5
  export * from './components/blocks/UTextBlock.js';
@@ -10,27 +10,24 @@ export * from './components/blocks/UTableBlock.js';
10
10
  export * from './components/buttons/UAttachButton.js';
11
11
  export * from './components/buttons/UCopyButton.js';
12
12
  export * from './components/buttons/UVoteButton.js';
13
- export * from './components/buttons/UReportButton.js';
14
- export * from './components/buttons/URetryButton.js';
15
- export * from './components/buttons/UShareButton.js';
16
13
  export * from './components/message/UMessage.js';
17
14
  export * from './components/prompt/UPrompt.js';
18
15
  export * from './components/references/URefTag.js';
19
16
  export * from './components/references/URefCard.js';
20
17
  export * from './components/references/URefCardGroup.js';
21
- export * from './components/actions/UQuestionAction.js';
22
- export * from './components/widgets/UImagesWidget.js';
23
- export * from './components/widgets/UVideoWidget.js';
24
- export * from './components/widgets/UMapWidget.js';
25
- export * from './components/widgets/UChartWidget.js';
26
- export * from './components/widgets/UWidget.js';
18
+ export * from './components/intents/UQuestionIntent.js';
19
+ export * from './components/views/UImagesView.js';
20
+ export * from './components/views/UVideoView.js';
21
+ export * from './components/views/UMapView.js';
22
+ export * from './components/views/UChartView.js';
23
+ export * from './components/views/UView.js';
27
24
  export type * from './types/BlockItem';
28
25
  export type * from './types/JsonNode';
29
26
  export type * from './types/JsonSchema';
30
27
  export type * from './types/References';
31
- export * from './types/Actions';
32
- export * from './types/Widgets';
33
- export type * from './events/UCancelEvent';
34
- export type * from './events/USubmitEvent';
35
- export * from './utilities/ActionPromptBuilder.js';
36
- export * from './utilities/WidgetPromptBuilder.js';
28
+ export * from './types/Intents';
29
+ export * from './types/Views';
30
+ export type * from './events/SendEvent';
31
+ export type * from './events/StopEvent';
32
+ export * from './utilities/IntentPromptBuilder.js';
33
+ export * from './utilities/ViewPromptBuilder.js';
package/dist/index.js CHANGED
@@ -1,56 +1,28 @@
1
- import './components/blocks/UCodeBlock.js';
2
- import './components/blocks/UFilesBlock.js';
3
- import './components/blocks/UJsonBlock.js';
4
- import './components/blocks/UMarkedBlock.js';
5
- import './components/blocks/UTextBlock.js';
6
- import './components/blocks/UThinkBlock.js';
7
- import './components/blocks/UToolBlock.js';
8
- import './components/blocks/URefBlock.js';
9
- import './components/blocks/UTableBlock.js';
10
- import './components/buttons/UAttachButton.js';
11
- import './components/buttons/UCopyButton.js';
12
- import './components/buttons/UVoteButton.js';
13
- import './components/buttons/UReportButton.js';
14
- import './components/buttons/URetryButton.js';
15
- import './components/buttons/UShareButton.js';
16
- import './components/message/UMessage.js';
17
- import './components/prompt/UPrompt.js';
18
- import './components/references/URefTag.js';
19
- import './components/references/URefCard.js';
20
- import './components/references/URefCardGroup.js';
21
- import './components/actions/UQuestionAction.js';
22
- import './components/widgets/UImagesWidget.js';
23
- import './components/widgets/UVideoWidget.js';
24
- import './components/widgets/UMapWidget.js';
25
- import './components/widgets/UChartWidget.js';
26
- import './components/widgets/UWidget.js';
27
- export { PRESET_ACTION_DEFINITIONS, PRESET_ACTION_LIST, PresetAction } from './types/Actions.js';
28
- export { PRESET_WIDGET_DEFINITIONS, PRESET_WIDGET_LIST, PresetWidget } from './types/Widgets.js';
29
- export { ActionPromptBuilder } from './utilities/ActionPromptBuilder.js';
30
- export { WidgetPromptBuilder } from './utilities/WidgetPromptBuilder.js';
31
- export { UAttachButton } from './components/buttons/UAttachButton.component.js';
32
- export { UChartWidget } from './components/widgets/UChartWidget.component.js';
33
- export { UCodeBlock } from './components/blocks/UCodeBlock.component.js';
34
- export { UCopyButton } from './components/buttons/UCopyButton.component.js';
35
- export { UFilesBlock } from './components/blocks/UFilesBlock.component.js';
36
- export { UImagesWidget } from './components/widgets/UImagesWidget.component.js';
37
- export { UJsonBlock } from './components/blocks/UJsonBlock.component.js';
38
- export { UMapWidget } from './components/widgets/UMapWidget.component.js';
39
- export { UMarkedBlock } from './components/blocks/UMarkedBlock.component.js';
40
- export { UMessage } from './components/message/UMessage.component.js';
41
- export { UPrompt } from './components/prompt/UPrompt.component.js';
42
- export { UQuestionAction } from './components/actions/UQuestionAction.component.js';
43
- export { URefBlock } from './components/blocks/URefBlock.component.js';
44
- export { URefCard } from './components/references/URefCard.component.js';
45
- export { URefCardGroup } from './components/references/URefCardGroup.component.js';
46
- export { URefTag } from './components/references/URefTag.component.js';
47
- export { UReportButton } from './components/buttons/UReportButton.component.js';
48
- export { URetryButton } from './components/buttons/URetryButton.component.js';
49
- export { UShareButton } from './components/buttons/UShareButton.component.js';
50
- export { UTableBlock } from './components/blocks/UTableBlock.component.js';
51
- export { UTextBlock } from './components/blocks/UTextBlock.component.js';
52
- export { UThinkBlock } from './components/blocks/UThinkBlock.component.js';
53
- export { UToolBlock } from './components/blocks/UToolBlock.component.js';
54
- export { UVideoWidget } from './components/widgets/UVideoWidget.component.js';
55
- export { UVoteButton } from './components/buttons/UVoteButton.component.js';
56
- export { UWidget } from './components/widgets/UWidget.component.js';
1
+ import { UCopyButton } from "./components/buttons/UCopyButton.js";
2
+ import { UCodeBlock } from "./components/blocks/UCodeBlock.js";
3
+ import { UFileBlock } from "./components/blocks/UFileBlock.js";
4
+ import { UJsonBlock } from "./components/blocks/UJsonBlock.js";
5
+ import { URefTag } from "./components/references/URefTag.js";
6
+ import { URefCard } from "./components/references/URefCard.js";
7
+ import { URefCardGroup } from "./components/references/URefCardGroup.js";
8
+ import { UTableBlock } from "./components/blocks/UTableBlock.js";
9
+ import { UView } from "./components/views/UView.js";
10
+ import { UMarkedBlock } from "./components/blocks/UMarkedBlock.js";
11
+ import { UTextBlock } from "./components/blocks/UTextBlock.js";
12
+ import { UThinkBlock } from "./components/blocks/UThinkBlock.js";
13
+ import { UToolBlock } from "./components/blocks/UToolBlock.js";
14
+ import { URefBlock } from "./components/blocks/URefBlock.js";
15
+ import { UAttachButton } from "./components/buttons/UAttachButton.js";
16
+ import { UVoteButton } from "./components/buttons/UVoteButton.js";
17
+ import { UMessage } from "./components/message/UMessage.js";
18
+ import { UPrompt } from "./components/prompt/UPrompt.js";
19
+ import { UQuestionIntent } from "./components/intents/UQuestionIntent.js";
20
+ import { UImagesView } from "./components/views/UImagesView.js";
21
+ import { UVideoView } from "./components/views/UVideoView.js";
22
+ import { UMapView } from "./components/views/UMapView.js";
23
+ import { UChartView } from "./components/views/UChartView.js";
24
+ import { PRESET_INTENT_DEFINITIONS, PRESET_INTENT_LIST, PresetIntent } from "./types/Intents.js";
25
+ import { PRESET_VIEW_DEFINITIONS, PRESET_VIEW_LIST, PresetView } from "./types/Views.js";
26
+ import { IntentPromptBuilder } from "./utilities/IntentPromptBuilder.js";
27
+ import { ViewPromptBuilder } from "./utilities/ViewPromptBuilder.js";
28
+ export { IntentPromptBuilder, PRESET_INTENT_DEFINITIONS, PRESET_INTENT_LIST, PRESET_VIEW_DEFINITIONS, PRESET_VIEW_LIST, PresetIntent, PresetView, UAttachButton, UChartView, UCodeBlock, UCopyButton, UFileBlock, UImagesView, UJsonBlock, UMapView, UMarkedBlock, UMessage, UPrompt, UQuestionIntent, URefBlock, URefCard, URefCardGroup, URefTag, UTableBlock, UTextBlock, UThinkBlock, UToolBlock, UVideoView, UView, UVoteButton, ViewPromptBuilder };
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { UAttachButton as UAttachButtonElement } from '../components/buttons/UAttachButton';
3
+ import { type AttachEventDetail } from '../events/AttachEvent';
4
+
5
+ export declare const UAttachButton: React.ForwardRefExoticComponent<
6
+ Partial<UAttachButtonElement> & React.HTMLAttributes<UAttachButtonElement> & {
7
+ onAttach?: (event: CustomEvent<AttachEventDetail>) => void;
8
+ }
9
+ >;
10
+
11
+ export type UAttachButtonProps = React.ComponentProps<typeof UAttachButton>;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { createComponent } from '@lit/react';
3
+ import { UAttachButton } from '../components/buttons/UAttachButton.js';
4
+
5
+ export const UAttachButton = createComponent({
6
+ react: React,
7
+ tagName: 'u-attach-button',
8
+ elementClass: UAttachButton,
9
+ events: {
10
+ onAttach: 'attach',
11
+ },
12
+ });
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { UChartView as UChartViewElement } from '../components/views/UChartView';
3
+
4
+ export declare const UChartView: React.ForwardRefExoticComponent<
5
+ Partial<UChartViewElement> & React.HTMLAttributes<UChartViewElement> & {
6
+ }
7
+ >;
8
+
9
+ export type UChartViewProps = React.ComponentProps<typeof UChartView>;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { createComponent } from '@lit/react';
3
+ import { UChartView } from '../components/views/UChartView.js';
4
+
5
+ export const UChartView = createComponent({
6
+ react: React,
7
+ tagName: 'u-chart-view',
8
+ elementClass: UChartView,
9
+ events: {},
10
+ });
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { UCodeBlock as UCodeBlockElement } from '../components/blocks/UCodeBlock';
3
+
4
+ export declare const UCodeBlock: React.ForwardRefExoticComponent<
5
+ Partial<UCodeBlockElement> & React.HTMLAttributes<UCodeBlockElement> & {
6
+ }
7
+ >;
8
+
9
+ export type UCodeBlockProps = React.ComponentProps<typeof UCodeBlock>;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { createComponent } from '@lit/react';
3
+ import { UCodeBlock } from '../components/blocks/UCodeBlock.js';
4
+
5
+ export const UCodeBlock = createComponent({
6
+ react: React,
7
+ tagName: 'u-code-block',
8
+ elementClass: UCodeBlock,
9
+ events: {},
10
+ });
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { UCopyButton as UCopyButtonElement } from '../components/buttons/UCopyButton';
3
+
4
+ export declare const UCopyButton: React.ForwardRefExoticComponent<
5
+ Partial<UCopyButtonElement> & React.HTMLAttributes<UCopyButtonElement> & {
6
+ }
7
+ >;
8
+
9
+ export type UCopyButtonProps = React.ComponentProps<typeof UCopyButton>;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { createComponent } from '@lit/react';
3
+ import { UCopyButton } from '../components/buttons/UCopyButton.js';
4
+
5
+ export const UCopyButton = createComponent({
6
+ react: React,
7
+ tagName: 'u-copy-button',
8
+ elementClass: UCopyButton,
9
+ events: {},
10
+ });
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { UFileBlock as UFileBlockElement } from '../components/blocks/UFileBlock';
3
+ import { type RemoveEventDetail } from '../components/blocks/@iyulab/components/dist/events/RemoveEvent';
4
+
5
+ export declare const UFileBlock: React.ForwardRefExoticComponent<
6
+ Partial<UFileBlockElement> & React.HTMLAttributes<UFileBlockElement> & {
7
+ onRemove?: (event: CustomEvent<RemoveEventDetail>) => void;
8
+ }
9
+ >;
10
+
11
+ export type UFileBlockProps = React.ComponentProps<typeof UFileBlock>;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { createComponent } from '@lit/react';
3
+ import { UFileBlock } from '../components/blocks/UFileBlock.js';
4
+
5
+ export const UFileBlock = createComponent({
6
+ react: React,
7
+ tagName: 'u-file-block',
8
+ elementClass: UFileBlock,
9
+ events: {
10
+ onRemove: 'remove',
11
+ },
12
+ });
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { UImagesView as UImagesViewElement } from '../components/views/UImagesView';
3
+
4
+ export declare const UImagesView: React.ForwardRefExoticComponent<
5
+ Partial<UImagesViewElement> & React.HTMLAttributes<UImagesViewElement> & {
6
+ }
7
+ >;
8
+
9
+ export type UImagesViewProps = React.ComponentProps<typeof UImagesView>;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { createComponent } from '@lit/react';
3
+ import { UImagesView } from '../components/views/UImagesView.js';
4
+
5
+ export const UImagesView = createComponent({
6
+ react: React,
7
+ tagName: 'u-images-view',
8
+ elementClass: UImagesView,
9
+ events: {},
10
+ });
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { UJsonBlock as UJsonBlockElement } from '../components/blocks/UJsonBlock';
3
+
4
+ export declare const UJsonBlock: React.ForwardRefExoticComponent<
5
+ Partial<UJsonBlockElement> & React.HTMLAttributes<UJsonBlockElement> & {
6
+ }
7
+ >;
8
+
9
+ export type UJsonBlockProps = React.ComponentProps<typeof UJsonBlock>;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { createComponent } from '@lit/react';
3
+ import { UJsonBlock } from '../components/blocks/UJsonBlock.js';
4
+
5
+ export const UJsonBlock = createComponent({
6
+ react: React,
7
+ tagName: 'u-json-block',
8
+ elementClass: UJsonBlock,
9
+ events: {},
10
+ });
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { UMapView as UMapViewElement } from '../components/views/UMapView';
3
+
4
+ export declare const UMapView: React.ForwardRefExoticComponent<
5
+ Partial<UMapViewElement> & React.HTMLAttributes<UMapViewElement> & {
6
+ }
7
+ >;
8
+
9
+ export type UMapViewProps = React.ComponentProps<typeof UMapView>;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { createComponent } from '@lit/react';
3
+ import { UMapView } from '../components/views/UMapView.js';
4
+
5
+ export const UMapView = createComponent({
6
+ react: React,
7
+ tagName: 'u-map-view',
8
+ elementClass: UMapView,
9
+ events: {},
10
+ });