@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,113 +0,0 @@
1
- import { html } from 'lit';
2
- import { property } from 'lit/decorators.js';
3
- import { UElement } from '@iyulab/components/dist/components/UElement.js';
4
- import { UIcon } from '@iyulab/components/dist/components/icon/UIcon.component.js';
5
- import { UButton } from '@iyulab/components/dist/components/button/UButton.component.js';
6
- import { UTextBlock } from '../blocks/UTextBlock.component.js';
7
- import { styles } from './UPrompt.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 UPrompt extends UElement {
19
- constructor() {
20
- super(...arguments);
21
- this.loading = false;
22
- this.minRows = 1;
23
- this.maxRows = 10;
24
- this.handleSendButtonClick = (e) => {
25
- e.preventDefault();
26
- e.stopPropagation();
27
- this.send();
28
- };
29
- }
30
- static {
31
- this.styles = [super.styles, styles];
32
- }
33
- static {
34
- this.dependencies = {
35
- "u-icon": UIcon,
36
- "u-button": UButton,
37
- "u-text-block": UTextBlock
38
- };
39
- }
40
- connectedCallback() {
41
- super.connectedCallback();
42
- this.setAttribute("tabindex", "0");
43
- }
44
- render() {
45
- return html`
46
- <slot name="header"></slot>
47
-
48
- <u-text-block part="input"
49
- editable
50
- .minRows=${this.minRows}
51
- .maxRows=${this.maxRows}
52
- .value=${this.value}
53
- .placeholder=${this.placeholder}
54
- @input=${this.handleTextBlockInput}
55
- @keydown=${this.handleTextBlockKeydown}
56
- ></u-text-block>
57
-
58
- <div class="control" part="control">
59
- <slot name="left-actions"></slot>
60
- <div style="flex: 1;"></div>
61
- <slot name="right-actions"></slot>
62
-
63
- <u-button class="send-btn" part="send-btn"
64
- ?disabled=${!this.loading && !this.value}
65
- @click=${this.handleSendButtonClick}>
66
- <u-icon
67
- lib="internal"
68
- name=${this.loading ? "stop-circle" : "arrow-up"}
69
- ></u-icon>
70
- </u-button>
71
- </div>
72
-
73
- <slot name="footer"></slot>
74
- `;
75
- }
76
- send() {
77
- const value = this.value?.trim();
78
- if (this.loading) {
79
- this.emit("u-cancel");
80
- } else if (value) {
81
- this.emit("u-submit", { value: this.value });
82
- this.value = "";
83
- } else ;
84
- }
85
- handleTextBlockInput(e) {
86
- e.preventDefault();
87
- const target = e.target;
88
- this.value = target.value;
89
- }
90
- handleTextBlockKeydown(e) {
91
- if (e.key === "Enter" && !e.shiftKey) {
92
- e.preventDefault();
93
- this.send();
94
- }
95
- }
96
- }
97
- __decorateClass([
98
- property({ type: Boolean, reflect: true })
99
- ], UPrompt.prototype, "loading");
100
- __decorateClass([
101
- property({ type: Number })
102
- ], UPrompt.prototype, "minRows");
103
- __decorateClass([
104
- property({ type: Number })
105
- ], UPrompt.prototype, "maxRows");
106
- __decorateClass([
107
- property({ type: String })
108
- ], UPrompt.prototype, "placeholder");
109
- __decorateClass([
110
- property({ type: String })
111
- ], UPrompt.prototype, "value");
112
-
113
- export { UPrompt };
@@ -1,27 +0,0 @@
1
- import { UElement } from '@iyulab/components/dist/components/UElement.js';
2
- import { UJsonElement } from '@iyulab/components/dist/components/UJsonElement.js';
3
- /**
4
- * 참조 소스를 카드 형태로 표시하는 공통 컴포넌트입니다.
5
- * Web과 Document 타입 모두 지원합니다.
6
- */
7
- export declare class URefCard extends UJsonElement {
8
- static styles: (import('lit').CSSResult | import('lit').CSSResultGroup[])[];
9
- static dependencies: Record<string, typeof UElement>;
10
- /** 카드 타입 (web 또는 document) */
11
- type: 'web' | 'document';
12
- /** 외부 링크 URL */
13
- url?: string;
14
- /** 카드 타이틀 */
15
- title: string;
16
- /** 카드 본문 스니펫 */
17
- snippet?: string;
18
- /** 태그 목록 */
19
- tags?: string[];
20
- render(): import('lit-html').TemplateResult<1>;
21
- /** 링크 클릭 핸들러 */
22
- private handleAnchorClick;
23
- /** URL에서 Google의 파비콘 URL을 반환합니다. */
24
- private getFaviconUrl;
25
- /** URL에서 도메인 사이트 주소를 반환합니다. */
26
- private getDomainName;
27
- }
@@ -1,109 +0,0 @@
1
- import { html } from 'lit';
2
- import { property } from 'lit/decorators.js';
3
- import { ifDefined } from 'lit/directives/if-defined.js';
4
- import { arrayAttrConverter } from '@iyulab/components/dist/utilities/converters.js';
5
- import { UJsonElement } from '@iyulab/components/dist/components/UJsonElement.js';
6
- import { UIcon } from '@iyulab/components/dist/components/icon/UIcon.component.js';
7
- import { styles } from './URefCard.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 URefCard extends UJsonElement {
19
- constructor() {
20
- super(...arguments);
21
- this.type = "web";
22
- this.title = "";
23
- }
24
- static {
25
- this.styles = [super.styles, styles];
26
- }
27
- static {
28
- this.dependencies = {
29
- "u-icon": UIcon
30
- };
31
- }
32
- render() {
33
- return html`
34
- <a href="${ifDefined(this.url)}" target="_blank" rel="noopener noreferrer"
35
- @click=${this.handleAnchorClick}>
36
- <div class="header">
37
- <img class="favicon"
38
- src="${this.getFaviconUrl(this.url)}"
39
- alt="favicon"
40
- />
41
- <div class="title">
42
- ${this.title || this.getDomainName(this.url)}
43
- </div>
44
-
45
- <div style="flex: 1;"></div>
46
-
47
- <div class="badge" type=${this.type}>
48
- <u-icon
49
- lib="internal"
50
- name=${this.type === "web" ? "globe" : "file-earmark"}
51
- ></u-icon>
52
- ${this.type.toUpperCase()}
53
- </div>
54
- </div>
55
-
56
- <div class="body">
57
- ${this.snippet}
58
- </div>
59
-
60
- <div class="footer" ?hidden=${!this.tags || this.tags.length === 0}>
61
- ${this.tags?.map((tag) => html`<span class="tag">${tag}</span>`)}
62
- </div>
63
- </a>
64
- `;
65
- }
66
- /** 링크 클릭 핸들러 */
67
- handleAnchorClick(e) {
68
- if (!this.url) {
69
- e.preventDefault();
70
- e.stopPropagation();
71
- }
72
- }
73
- /** URL에서 Google의 파비콘 URL을 반환합니다. */
74
- getFaviconUrl(url) {
75
- if (!url) return `/favicon.ico`;
76
- try {
77
- const hostname = new URL(url).hostname;
78
- return `https://www.google.com/s2/favicons?sz=64&domain=${hostname}`;
79
- } catch {
80
- return `/favicon.ico`;
81
- }
82
- }
83
- /** URL에서 도메인 사이트 주소를 반환합니다. */
84
- getDomainName(url) {
85
- if (!url) return "";
86
- try {
87
- return new URL(url).hostname;
88
- } catch {
89
- return "";
90
- }
91
- }
92
- }
93
- __decorateClass([
94
- property({ type: String, reflect: true })
95
- ], URefCard.prototype, "type");
96
- __decorateClass([
97
- property({ type: String })
98
- ], URefCard.prototype, "url");
99
- __decorateClass([
100
- property({ type: String })
101
- ], URefCard.prototype, "title");
102
- __decorateClass([
103
- property({ type: String })
104
- ], URefCard.prototype, "snippet");
105
- __decorateClass([
106
- property({ type: Array, converter: arrayAttrConverter((v) => v) })
107
- ], URefCard.prototype, "tags");
108
-
109
- export { URefCard };
@@ -1,26 +0,0 @@
1
- import { UElement } from '@iyulab/components/dist/components/UElement.js';
2
- import { URefCard } from './URefCard.component.js';
3
- /**
4
- * 여러 참조 카드를 그룹으로 표시하는 컴포넌트입니다.
5
- * 페이지네이션 기능을 제공하여 각 카드를 하나씩 탐색할 수 있습니다.
6
- * 카드가 1개 이하인 경우 페이지네이션 UI는 자동으로 숨겨집니다.
7
- */
8
- export declare class URefCardGroup extends UElement {
9
- static styles: import('lit').CSSResultGroup[];
10
- static dependencies: Record<string, typeof UElement>;
11
- /** slot으로 받은 카드 엘리먼트들 */
12
- cards: URefCard[];
13
- /** 현재 표시 중인 카드의 인덱스 */
14
- currentIndex: number;
15
- render(): import('lit-html').TemplateResult<1>;
16
- /**
17
- * 해당하는 인덱스에 해당하는 카드로 변경합니다.
18
- */
19
- switch(index: number): void;
20
- /** 이전 카드로 이동합니다. */
21
- private handlePreviousButtonClick;
22
- /** 다음 카드로 이동합니다. */
23
- private handleNextButtonClick;
24
- /** slot 내용이 변경될 때 호출됩니다. */
25
- private handleSlotChange;
26
- }
@@ -1,88 +0,0 @@
1
- import { html } from 'lit';
2
- import { state } from 'lit/decorators.js';
3
- import { UElement } from '@iyulab/components/dist/components/UElement.js';
4
- import { UIcon } from '@iyulab/components/dist/components/icon/UIcon.component.js';
5
- import { URefCard } from './URefCard.component.js';
6
- import { styles } from './URefCardGroup.styles.js';
7
-
8
- var __defProp = Object.defineProperty;
9
- var __decorateClass = (decorators, target, key, kind) => {
10
- var result = void 0 ;
11
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
12
- if (decorator = decorators[i])
13
- result = (decorator(target, key, result) ) || result;
14
- if (result) __defProp(target, key, result);
15
- return result;
16
- };
17
- class URefCardGroup extends UElement {
18
- constructor() {
19
- super(...arguments);
20
- this.cards = [];
21
- this.currentIndex = 0;
22
- }
23
- static {
24
- this.styles = [super.styles, styles];
25
- }
26
- static {
27
- this.dependencies = {
28
- "u-icon": UIcon,
29
- "u-ref-card": URefCard
30
- };
31
- }
32
- render() {
33
- return html`
34
- <div class="header" ?hidden=${this.cards.length <= 1}>
35
- <button class="nav-button"
36
- @click=${this.handlePreviousButtonClick}>
37
- <u-icon lib="internal" name="chevron-left"></u-icon>
38
- </button>
39
-
40
- <span class="page-indicator">
41
- ${this.currentIndex + 1} / ${this.cards.length}
42
- </span>
43
-
44
- <button class="nav-button"
45
- @click=${this.handleNextButtonClick}>
46
- <u-icon lib="internal" name="chevron-right"></u-icon>
47
- </button>
48
- </div>
49
-
50
- <div class="viewport">
51
- <div class="track" style=${`transform: translateX(-${this.currentIndex * 100}%);`}>
52
- <slot @slotchange=${this.handleSlotChange}></slot>
53
- </div>
54
- </div>
55
- `;
56
- }
57
- /**
58
- * 해당하는 인덱스에 해당하는 카드로 변경합니다.
59
- */
60
- switch(index) {
61
- const len = this.cards.length;
62
- if (len === 0) return;
63
- this.currentIndex = index < 0 ? len - 1 : index >= len ? 0 : index;
64
- }
65
- /** 이전 카드로 이동합니다. */
66
- handlePreviousButtonClick() {
67
- this.switch(this.currentIndex - 1);
68
- }
69
- /** 다음 카드로 이동합니다. */
70
- handleNextButtonClick() {
71
- this.switch(this.currentIndex + 1);
72
- }
73
- /** slot 내용이 변경될 때 호출됩니다. */
74
- handleSlotChange(e) {
75
- const slot = e.target;
76
- const elements = slot.assignedElements({ flatten: true });
77
- this.cards = elements.filter((el) => el instanceof URefCard);
78
- this.switch(0);
79
- }
80
- }
81
- __decorateClass([
82
- state()
83
- ], URefCardGroup.prototype, "cards");
84
- __decorateClass([
85
- state()
86
- ], URefCardGroup.prototype, "currentIndex");
87
-
88
- export { URefCardGroup };
@@ -1,13 +0,0 @@
1
- import { UElement } from '@iyulab/components/dist/components/UElement.js';
2
- /**
3
- * 인용 태그 컴포넌트입니다.
4
- */
5
- export declare class URefTag extends UElement {
6
- static styles: import('lit').CSSResultGroup[];
7
- static dependencies: Record<string, typeof UElement>;
8
- /** 인용 출처 소스 데이터 */
9
- href?: string;
10
- render(): import('lit-html').TemplateResult<1>;
11
- /** 링크 클릭 핸들러 */
12
- private handleAnchorClick;
13
- }
@@ -1,54 +0,0 @@
1
- import { html } from 'lit';
2
- import { property } from 'lit/decorators.js';
3
- import { ifDefined } from 'lit/directives/if-defined.js';
4
- import { UElement } from '@iyulab/components/dist/components/UElement.js';
5
- import { UTooltip } from '@iyulab/components/dist/components/tooltip/UTooltip.component.js';
6
- import { UIcon } from '@iyulab/components/dist/components/icon/UIcon.component.js';
7
- import { styles } from './URefTag.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 URefTag extends UElement {
19
- static {
20
- this.styles = [super.styles, styles];
21
- }
22
- static {
23
- this.dependencies = {
24
- "u-icon": UIcon,
25
- "u-tooltip": UTooltip
26
- };
27
- }
28
- render() {
29
- return html`
30
- <a href="${ifDefined(this.href)}" target="_blank" rel="noopener noreferrer"
31
- @click=${this.handleAnchorClick}>
32
- <slot></slot>
33
- </a>
34
-
35
- <u-icon lib="internal" name="box-arrow-up-right"></u-icon>
36
-
37
- <u-tooltip interactive placement="bottom" distance="4">
38
- <slot name="tooltip"></slot>
39
- </u-tooltip>
40
- `;
41
- }
42
- /** 링크 클릭 핸들러 */
43
- handleAnchorClick(e) {
44
- if (!this.href) {
45
- e.preventDefault();
46
- e.stopPropagation();
47
- }
48
- }
49
- }
50
- __decorateClass([
51
- property({ type: String })
52
- ], URefTag.prototype, "href");
53
-
54
- export { URefTag };
@@ -1,180 +0,0 @@
1
- import { nothing, html } from 'lit';
2
- import { property, query, state } from 'lit/decorators.js';
3
- import { Chart } from 'chart.js/auto';
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 { styles } from './UChartWidget.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 UChartWidget extends UElement {
19
- constructor() {
20
- super(...arguments);
21
- this.error = null;
22
- this.chartjs = null;
23
- }
24
- static {
25
- this.styles = [super.styles, styles];
26
- }
27
- static {
28
- this.dependencies = {
29
- "u-icon": UIcon,
30
- "u-button": UButton
31
- };
32
- }
33
- connectedCallback() {
34
- super.connectedCallback();
35
- this.observer = new MutationObserver(() => {
36
- this.applyTheme();
37
- this.createChart();
38
- });
39
- this.observer.observe(document.documentElement, {
40
- attributes: true,
41
- attributeFilter: ["theme"]
42
- });
43
- }
44
- disconnectedCallback() {
45
- super.disconnectedCallback();
46
- this.observer?.disconnect();
47
- this.destroyChart();
48
- }
49
- updated(changedProperties) {
50
- super.updated(changedProperties);
51
- if (changedProperties.has("data") || changedProperties.has("type") || changedProperties.has("options")) {
52
- this.createChart();
53
- }
54
- }
55
- render() {
56
- if (!this.data) return nothing;
57
- return html`
58
- <div class="toolbar">
59
- <div class="toolbar-left"></div>
60
- <div class="toolbar-right">
61
- <u-button title="PNG Download" @click=${this.handleDownloadPNG}>
62
- PNG
63
- <u-icon slot="suffix" lib="internal" name="download"></u-icon>
64
- </u-button>
65
- <u-button title="JSON Download" @click=${this.handleDownloadJSON}>
66
- JSON
67
- <u-icon slot="suffix" lib="internal" name="download"></u-icon>
68
- </u-button>
69
- <u-button title="Full Screen" @click=${this.handleFullscreen}>
70
- <u-icon lib="internal" name="box-arrow-up-right"></u-icon>
71
- </u-button>
72
- </div>
73
- </div>
74
- <div class="viewport">
75
- <canvas></canvas>
76
- <div class="error-overlay" ?hidden=${!this.error}>
77
- <u-icon lib="internal" name="exclamation-triangle-fill"></u-icon>
78
- <span>${this.error}</span>
79
- </div>
80
- </div>
81
- `;
82
- }
83
- /** Chart.js로 차트 생성 */
84
- createChart() {
85
- if (!this.canvas) return;
86
- if (!this.type || !this.data) return;
87
- this.destroyChart();
88
- this.error = null;
89
- const ctx = this.canvas.getContext("2d");
90
- if (!ctx) {
91
- this.error = "Canvas 2D context를 가져올 수 없습니다.";
92
- return;
93
- }
94
- try {
95
- this.applyTheme();
96
- this.chartjs = new Chart(ctx, {
97
- type: this.type,
98
- data: this.data,
99
- options: {
100
- responsive: true,
101
- maintainAspectRatio: true,
102
- ...this.options
103
- }
104
- });
105
- } catch (e) {
106
- this.error = e instanceof Error ? e.message : String(e);
107
- }
108
- }
109
- /** 기존 차트 인스턴스 제거 */
110
- destroyChart() {
111
- if (this.chartjs) {
112
- this.chartjs.destroy();
113
- this.chartjs = null;
114
- }
115
- }
116
- /** 현재 테마의 CSS 변수를 읽어 Chart.defaults에 전역 적용 */
117
- applyTheme() {
118
- const css = (v) => getComputedStyle(this).getPropertyValue(v).trim();
119
- const textColor = css("--u-txt-color");
120
- const weakColor = css("--u-txt-color-weak");
121
- const borderColor = css("--u-border-color");
122
- const bgColor = css("--u-bg-color");
123
- Chart.defaults.color = textColor;
124
- Chart.defaults.borderColor = borderColor;
125
- Chart.defaults.plugins.tooltip.backgroundColor = bgColor;
126
- Chart.defaults.plugins.tooltip.titleColor = textColor;
127
- Chart.defaults.plugins.tooltip.bodyColor = weakColor;
128
- Chart.defaults.plugins.tooltip.borderColor = borderColor;
129
- Chart.defaults.plugins.tooltip.borderWidth = 1;
130
- Chart.defaults.scale.ticks.color = weakColor;
131
- Chart.defaults.scale.grid.color = borderColor;
132
- }
133
- handleDownloadPNG() {
134
- if (!this.chartjs) return;
135
- const url = this.chartjs.toBase64Image("image/png", 1);
136
- const a = document.createElement("a");
137
- a.href = url;
138
- a.download = "chart-image.png";
139
- a.click();
140
- }
141
- handleDownloadJSON() {
142
- if (!this.data) return;
143
- const json = JSON.stringify(this.data, null, 2);
144
- const blob = new Blob([json], { type: "application/json;charset=utf-8;" });
145
- const url = URL.createObjectURL(blob);
146
- const a = document.createElement("a");
147
- a.href = url;
148
- a.download = "chart-data.json";
149
- a.click();
150
- URL.revokeObjectURL(url);
151
- }
152
- handleFullscreen() {
153
- const target = this.viewport ?? this;
154
- if (document.fullscreenElement) {
155
- document.exitFullscreen();
156
- } else {
157
- target.requestFullscreen?.();
158
- }
159
- }
160
- }
161
- __decorateClass([
162
- property({ type: String })
163
- ], UChartWidget.prototype, "type");
164
- __decorateClass([
165
- property({ type: Object })
166
- ], UChartWidget.prototype, "data");
167
- __decorateClass([
168
- property({ type: Object })
169
- ], UChartWidget.prototype, "options");
170
- __decorateClass([
171
- query("canvas")
172
- ], UChartWidget.prototype, "canvas");
173
- __decorateClass([
174
- query(".viewport")
175
- ], UChartWidget.prototype, "viewport");
176
- __decorateClass([
177
- state()
178
- ], UChartWidget.prototype, "error");
179
-
180
- export { UChartWidget };
@@ -1,7 +0,0 @@
1
- import { UChartWidget } from './UChartWidget.component.js';
2
- declare global {
3
- interface HTMLElementTagNameMap {
4
- "u-chart-widget": UChartWidget;
5
- }
6
- }
7
- export { UChartWidget };
@@ -1,5 +0,0 @@
1
- import { UChartWidget } from './UChartWidget.component.js';
2
-
3
- UChartWidget.define("u-chart-widget");
4
-
5
- export { UChartWidget };