@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.
- package/CHANGELOG.md +83 -52
- package/README.md +133 -16
- package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/decorate.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/decorateMetadata.js +6 -0
- package/dist/_virtual/_glob-assets_raw/intent-prompt.md.1907474e.js +4 -0
- package/dist/_virtual/_glob-assets_raw/view-prompt.md.e0dbcffe.js +4 -0
- package/dist/components/blocks/UCodeBlock.d.ts +24 -2
- package/dist/components/blocks/UCodeBlock.js +65 -2
- package/dist/components/blocks/UCodeBlock.styles.js +4 -4
- package/dist/components/blocks/UFileBlock.d.ts +33 -0
- package/dist/components/blocks/UFileBlock.js +154 -0
- package/dist/components/blocks/{UFilesBlock.styles.js → UFileBlock.styles.js} +12 -90
- package/dist/components/blocks/UJsonBlock.d.ts +44 -2
- package/dist/components/blocks/UJsonBlock.js +128 -3
- package/dist/components/blocks/UJsonBlock.styles.js +4 -4
- package/dist/components/blocks/UMarkedBlock.d.ts +44 -2
- package/dist/components/blocks/UMarkedBlock.js +154 -4
- package/dist/components/blocks/UMarkedBlock.styles.js +4 -4
- package/dist/components/blocks/URefBlock.d.ts +16 -2
- package/dist/components/blocks/URefBlock.js +58 -3
- package/dist/components/blocks/URefBlock.styles.js +4 -4
- package/dist/components/blocks/UTableBlock.d.ts +47 -2
- package/dist/components/blocks/UTableBlock.js +197 -4
- package/dist/components/blocks/UTableBlock.styles.js +4 -5
- package/dist/components/blocks/UTextBlock.d.ts +36 -2
- package/dist/components/blocks/UTextBlock.js +94 -4
- package/dist/components/blocks/UTextBlock.styles.js +4 -4
- package/dist/components/blocks/UThinkBlock.d.ts +30 -2
- package/dist/components/blocks/UThinkBlock.js +86 -4
- package/dist/components/blocks/UThinkBlock.styles.js +4 -4
- package/dist/components/blocks/UToolBlock.d.ts +19 -2
- package/dist/components/blocks/UToolBlock.js +68 -3
- package/dist/components/blocks/UToolBlock.styles.js +4 -4
- package/dist/components/buttons/UAttachButton.d.ts +21 -2
- package/dist/components/buttons/UAttachButton.js +61 -3
- package/dist/components/buttons/UAttachButton.styles.js +4 -4
- package/dist/components/buttons/UCopyButton.d.ts +19 -2
- package/dist/components/buttons/UCopyButton.js +57 -3
- package/dist/components/buttons/UCopyButton.styles.js +4 -4
- package/dist/components/buttons/UVoteButton.d.ts +14 -3
- package/dist/components/buttons/UVoteButton.js +62 -3
- package/dist/components/buttons/UVoteButton.styles.js +4 -4
- package/dist/components/{actions/UQuestionAction.component.d.ts → intents/UQuestionIntent.d.ts} +6 -2
- package/dist/components/intents/UQuestionIntent.js +41 -0
- package/dist/components/{actions/UQuestionAction.styles.js → intents/UQuestionIntent.styles.js} +4 -6
- package/dist/components/message/UMessage.d.ts +18 -2
- package/dist/components/message/UMessage.js +47 -2
- package/dist/components/message/UMessage.styles.js +4 -4
- package/dist/components/prompt/UPrompt.d.ts +37 -2
- package/dist/components/prompt/UPrompt.js +139 -2
- package/dist/components/prompt/UPrompt.styles.js +15 -5
- package/dist/components/references/URefCard.d.ts +30 -2
- package/dist/components/references/URefCard.js +97 -2
- package/dist/components/references/URefCard.styles.js +4 -4
- package/dist/components/references/URefCardGroup.d.ts +25 -2
- package/dist/components/references/URefCardGroup.js +69 -4
- package/dist/components/references/URefCardGroup.styles.js +4 -4
- package/dist/components/references/URefTag.d.ts +12 -2
- package/dist/components/references/URefTag.js +37 -2
- package/dist/components/references/URefTag.styles.js +4 -4
- package/dist/components/{widgets/UChartWidget.component.d.ts → views/UChartView.d.ts} +7 -4
- package/dist/components/views/UChartView.js +167 -0
- package/dist/components/{widgets/UChartWidget.styles.js → views/UChartView.styles.js} +4 -4
- package/dist/components/{widgets/UImagesWidget.component.d.ts → views/UImagesView.d.ts} +7 -4
- package/dist/components/views/UImagesView.js +144 -0
- package/dist/components/{widgets/UImagesWidget.styles.js → views/UImagesView.styles.js} +6 -5
- package/dist/components/{widgets/UMapWidget.component.d.ts → views/UMapView.d.ts} +7 -3
- package/dist/components/views/UMapView.js +45 -0
- package/dist/components/{widgets/UMapWidget.styles.js → views/UMapView.styles.js} +4 -4
- package/dist/components/{widgets/UVideoWidget.component.d.ts → views/UVideoView.d.ts} +7 -3
- package/dist/components/views/UVideoView.js +81 -0
- package/dist/components/{widgets/UVideoWidget.styles.js → views/UVideoView.styles.js} +4 -4
- package/dist/components/{widgets/UWidget.component.d.ts → views/UView.d.ts} +8 -5
- package/dist/components/views/UView.js +113 -0
- package/dist/components/{widgets/UWidget.styles.js → views/UView.styles.js} +4 -4
- package/dist/events/AttachEvent.d.ts +9 -0
- package/dist/events/ChoiceEvent.d.ts +9 -0
- package/dist/events/SendEvent.d.ts +21 -0
- package/dist/events/StopEvent.d.ts +17 -0
- package/dist/index.d.ts +13 -16
- package/dist/index.js +28 -56
- package/dist/react/UAttachButton.d.ts +11 -0
- package/dist/react/UAttachButton.js +12 -0
- package/dist/react/UChartView.d.ts +9 -0
- package/dist/react/UChartView.js +10 -0
- package/dist/react/UCodeBlock.d.ts +9 -0
- package/dist/react/UCodeBlock.js +10 -0
- package/dist/react/UCopyButton.d.ts +9 -0
- package/dist/react/UCopyButton.js +10 -0
- package/dist/react/UFileBlock.d.ts +11 -0
- package/dist/react/UFileBlock.js +12 -0
- package/dist/react/UImagesView.d.ts +9 -0
- package/dist/react/UImagesView.js +10 -0
- package/dist/react/UJsonBlock.d.ts +9 -0
- package/dist/react/UJsonBlock.js +10 -0
- package/dist/react/UMapView.d.ts +9 -0
- package/dist/react/UMapView.js +10 -0
- package/dist/react/UMarkedBlock.d.ts +9 -0
- package/dist/react/UMarkedBlock.js +10 -0
- package/dist/react/UMessage.d.ts +9 -0
- package/dist/react/UMessage.js +10 -0
- package/dist/react/UPrompt.d.ts +13 -0
- package/dist/react/UPrompt.js +13 -0
- package/dist/react/UQuestionIntent.d.ts +11 -0
- package/dist/react/UQuestionIntent.js +12 -0
- package/dist/react/URefBlock.d.ts +9 -0
- package/dist/react/URefBlock.js +10 -0
- package/dist/react/URefCard.d.ts +9 -0
- package/dist/react/URefCard.js +10 -0
- package/dist/react/URefCardGroup.d.ts +9 -0
- package/dist/react/URefCardGroup.js +10 -0
- package/dist/react/URefTag.d.ts +9 -0
- package/dist/react/URefTag.js +10 -0
- package/dist/react/UTableBlock.d.ts +9 -0
- package/dist/react/UTableBlock.js +10 -0
- package/dist/react/UTextBlock.d.ts +9 -0
- package/dist/react/UTextBlock.js +10 -0
- package/dist/react/UThinkBlock.d.ts +9 -0
- package/dist/react/UThinkBlock.js +10 -0
- package/dist/react/UToolBlock.d.ts +9 -0
- package/dist/react/UToolBlock.js +10 -0
- package/dist/react/UVideoView.d.ts +9 -0
- package/dist/react/UVideoView.js +10 -0
- package/dist/react/UView.d.ts +9 -0
- package/dist/react/UView.js +10 -0
- package/dist/react/UVoteButton.d.ts +9 -0
- package/dist/react/UVoteButton.js +10 -0
- package/dist/react/index.d.ts +23 -0
- package/dist/react/index.js +23 -0
- package/dist/types/BlockItem.d.ts +21 -32
- package/dist/types/Intents.d.ts +26 -0
- package/dist/types/Intents.js +30 -0
- package/dist/types/{Widgets.d.ts → Views.d.ts} +8 -8
- package/dist/types/Views.js +150 -0
- package/dist/utilities/IntentPromptBuilder.d.ts +40 -0
- package/dist/utilities/IntentPromptBuilder.js +95 -0
- package/dist/utilities/ViewPromptBuilder.d.ts +28 -0
- package/dist/utilities/ViewPromptBuilder.js +76 -0
- package/dist/utilities/dom-agent/DOMAgent.d.ts +74 -0
- package/dist/utilities/dom-agent/DOMController.d.ts +78 -0
- package/dist/utilities/dom-agent/DOMPromptBuilder.d.ts +54 -0
- package/dist/utilities/dom-agent/DOMScanner.d.ts +83 -0
- package/dist/utilities/dom-agent/index.d.ts +9 -0
- package/dist/utilities/dom-agent/types.d.ts +209 -0
- package/package.json +33 -16
- package/skills/iyulab-chat-components/SKILL.md +107 -0
- package/skills/iyulab-chat-components/references/components/attach-button.md +69 -0
- package/skills/iyulab-chat-components/references/components/chart-view.md +65 -0
- package/skills/iyulab-chat-components/references/components/code-block.md +42 -0
- package/skills/iyulab-chat-components/references/components/copy-button.md +46 -0
- package/skills/iyulab-chat-components/references/components/file-block.md +64 -0
- package/skills/iyulab-chat-components/references/components/images-view.md +63 -0
- package/skills/iyulab-chat-components/references/components/json-block.md +41 -0
- package/skills/iyulab-chat-components/references/components/map-view.md +54 -0
- package/skills/iyulab-chat-components/references/components/marked-block.md +53 -0
- package/skills/iyulab-chat-components/references/components/message.md +60 -0
- package/skills/iyulab-chat-components/references/components/prompt.md +102 -0
- package/skills/iyulab-chat-components/references/components/question-intent.md +75 -0
- package/skills/iyulab-chat-components/references/components/ref-block.md +45 -0
- package/skills/iyulab-chat-components/references/components/ref-card-group.md +41 -0
- package/skills/iyulab-chat-components/references/components/ref-card.md +48 -0
- package/skills/iyulab-chat-components/references/components/ref-tag.md +40 -0
- package/skills/iyulab-chat-components/references/components/table-block.md +63 -0
- package/skills/iyulab-chat-components/references/components/text-block.md +59 -0
- package/skills/iyulab-chat-components/references/components/think-block.md +48 -0
- package/skills/iyulab-chat-components/references/components/tool-block.md +57 -0
- package/skills/iyulab-chat-components/references/components/video-view.md +55 -0
- package/skills/iyulab-chat-components/references/components/view.md +51 -0
- package/skills/iyulab-chat-components/references/components/vote-button.md +60 -0
- package/skills/iyulab-chat-components/references/types.md +115 -0
- package/skills/iyulab-chat-components/references/usage.md +254 -0
- package/skills/iyulab-chat-components/references/utilities/intent-prompt-builder.md +123 -0
- package/skills/iyulab-chat-components/references/utilities/view-prompt-builder.md +112 -0
- package/dist/assets/action-prompt.md.js +0 -3
- package/dist/assets/widget-prompt.md.js +0 -3
- package/dist/components/actions/UQuestionAction.component.js +0 -58
- package/dist/components/actions/UQuestionAction.d.ts +0 -7
- package/dist/components/actions/UQuestionAction.js +0 -5
- package/dist/components/blocks/UCodeBlock.component.d.ts +0 -25
- package/dist/components/blocks/UCodeBlock.component.js +0 -88
- package/dist/components/blocks/UFilesBlock.component.d.ts +0 -22
- package/dist/components/blocks/UFilesBlock.component.js +0 -192
- package/dist/components/blocks/UFilesBlock.d.ts +0 -7
- package/dist/components/blocks/UFilesBlock.js +0 -5
- package/dist/components/blocks/UJsonBlock.component.d.ts +0 -45
- package/dist/components/blocks/UJsonBlock.component.js +0 -140
- package/dist/components/blocks/UMarkedBlock.component.d.ts +0 -40
- package/dist/components/blocks/UMarkedBlock.component.js +0 -159
- package/dist/components/blocks/URefBlock.component.d.ts +0 -17
- package/dist/components/blocks/URefBlock.component.js +0 -73
- package/dist/components/blocks/UTableBlock.component.d.ts +0 -49
- package/dist/components/blocks/UTableBlock.component.js +0 -228
- package/dist/components/blocks/UTextBlock.component.d.ts +0 -37
- package/dist/components/blocks/UTextBlock.component.js +0 -123
- package/dist/components/blocks/UThinkBlock.component.d.ts +0 -23
- package/dist/components/blocks/UThinkBlock.component.js +0 -90
- package/dist/components/blocks/UToolBlock.component.d.ts +0 -20
- package/dist/components/blocks/UToolBlock.component.js +0 -80
- package/dist/components/buttons/UAttachButton.component.d.ts +0 -22
- package/dist/components/buttons/UAttachButton.component.js +0 -89
- package/dist/components/buttons/UCopyButton.component.d.ts +0 -20
- package/dist/components/buttons/UCopyButton.component.js +0 -81
- package/dist/components/buttons/UReportButton.component.d.ts +0 -9
- package/dist/components/buttons/UReportButton.component.js +0 -36
- package/dist/components/buttons/UReportButton.d.ts +0 -7
- package/dist/components/buttons/UReportButton.js +0 -5
- package/dist/components/buttons/UReportButton.styles.js +0 -14
- package/dist/components/buttons/URetryButton.component.d.ts +0 -11
- package/dist/components/buttons/URetryButton.component.js +0 -53
- package/dist/components/buttons/URetryButton.d.ts +0 -7
- package/dist/components/buttons/URetryButton.js +0 -5
- package/dist/components/buttons/URetryButton.styles.js +0 -26
- package/dist/components/buttons/UShareButton.component.d.ts +0 -9
- package/dist/components/buttons/UShareButton.component.js +0 -36
- package/dist/components/buttons/UShareButton.d.ts +0 -7
- package/dist/components/buttons/UShareButton.js +0 -5
- package/dist/components/buttons/UShareButton.styles.js +0 -14
- package/dist/components/buttons/UVoteButton.component.d.ts +0 -15
- package/dist/components/buttons/UVoteButton.component.js +0 -73
- package/dist/components/message/UMessage.component.d.ts +0 -19
- package/dist/components/message/UMessage.component.js +0 -56
- package/dist/components/prompt/UPrompt.component.d.ts +0 -25
- package/dist/components/prompt/UPrompt.component.js +0 -113
- package/dist/components/references/URefCard.component.d.ts +0 -27
- package/dist/components/references/URefCard.component.js +0 -109
- package/dist/components/references/URefCardGroup.component.d.ts +0 -26
- package/dist/components/references/URefCardGroup.component.js +0 -88
- package/dist/components/references/URefTag.component.d.ts +0 -13
- package/dist/components/references/URefTag.component.js +0 -54
- package/dist/components/widgets/UChartWidget.component.js +0 -180
- package/dist/components/widgets/UChartWidget.d.ts +0 -7
- package/dist/components/widgets/UChartWidget.js +0 -5
- package/dist/components/widgets/UImagesWidget.component.js +0 -164
- package/dist/components/widgets/UImagesWidget.d.ts +0 -7
- package/dist/components/widgets/UImagesWidget.js +0 -5
- package/dist/components/widgets/UMapWidget.component.js +0 -65
- package/dist/components/widgets/UMapWidget.d.ts +0 -7
- package/dist/components/widgets/UMapWidget.js +0 -5
- package/dist/components/widgets/UMapWidget.styles.d.ts +0 -1
- package/dist/components/widgets/UVideoWidget.component.js +0 -106
- package/dist/components/widgets/UVideoWidget.d.ts +0 -7
- package/dist/components/widgets/UVideoWidget.js +0 -5
- package/dist/components/widgets/UVideoWidget.styles.d.ts +0 -1
- package/dist/components/widgets/UWidget.component.js +0 -140
- package/dist/components/widgets/UWidget.d.ts +0 -7
- package/dist/components/widgets/UWidget.js +0 -5
- package/dist/components/widgets/UWidget.styles.d.ts +0 -1
- package/dist/events/UCancelEvent.d.ts +0 -6
- package/dist/events/USubmitEvent.d.ts +0 -6
- package/dist/types/Actions.d.ts +0 -24
- package/dist/types/Actions.js +0 -34
- package/dist/types/Widgets.js +0 -115
- package/dist/utilities/ActionPromptBuilder.d.ts +0 -40
- package/dist/utilities/ActionPromptBuilder.js +0 -93
- package/dist/utilities/WidgetPromptBuilder.d.ts +0 -28
- package/dist/utilities/WidgetPromptBuilder.js +0 -87
- package/dist/utilities/converters.d.ts +0 -9
- package/dist/utilities/converters.js +0 -19
- /package/dist/components/{actions/UQuestionAction.styles.d.ts → blocks/UFileBlock.styles.d.ts} +0 -0
- /package/dist/components/{blocks/UFilesBlock.styles.d.ts → intents/UQuestionIntent.styles.d.ts} +0 -0
- /package/dist/components/{buttons/UReportButton.styles.d.ts → views/UChartView.styles.d.ts} +0 -0
- /package/dist/components/{buttons/URetryButton.styles.d.ts → views/UImagesView.styles.d.ts} +0 -0
- /package/dist/components/{buttons/UShareButton.styles.d.ts → views/UMapView.styles.d.ts} +0 -0
- /package/dist/components/{widgets/UChartWidget.styles.d.ts → views/UVideoView.styles.d.ts} +0 -0
- /package/dist/components/{widgets/UImagesWidget.styles.d.ts → views/UView.styles.d.ts} +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ScanResult, ScanOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* DOM 스캔 엔진
|
|
4
|
+
* Shadow DOM을 포함한 전체 DOM 트리를 순회하며 인터랙티브 요소를 추출
|
|
5
|
+
*/
|
|
6
|
+
export declare class DOMScanner {
|
|
7
|
+
private elementMap;
|
|
8
|
+
private idMap;
|
|
9
|
+
private totalElementsScanned;
|
|
10
|
+
private debug;
|
|
11
|
+
private cachedScan;
|
|
12
|
+
private prioritizeLandmarks;
|
|
13
|
+
/**
|
|
14
|
+
* DOM 스캔 수행 (Shadow DOM 포함)
|
|
15
|
+
* @param root 스캔 시작 루트 (기본값 document.body)
|
|
16
|
+
* @param options 스캔 옵션
|
|
17
|
+
*/
|
|
18
|
+
scan(root?: Element | ShadowRoot, options?: ScanOptions): ScanResult;
|
|
19
|
+
/**
|
|
20
|
+
* ID로 요소 객체 가져오기 (빠른 조회)
|
|
21
|
+
*/
|
|
22
|
+
getElement(id: string): Element | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* 요소에서 ID 가져오기
|
|
25
|
+
*/
|
|
26
|
+
getElementId(element: Element): string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* 단일 요소를 스캔하고 Shadow DOM도 탐색
|
|
29
|
+
*/
|
|
30
|
+
private scanElement;
|
|
31
|
+
/**
|
|
32
|
+
* Shadow DOM 내부 스캔
|
|
33
|
+
*/
|
|
34
|
+
private scanShadowRoot;
|
|
35
|
+
/**
|
|
36
|
+
* 인터랙티브 요소 여부 판단
|
|
37
|
+
*/
|
|
38
|
+
private isInteractive;
|
|
39
|
+
/**
|
|
40
|
+
* 필터링 기준 충족 여부 (LLM에게 보여줄 가치가 있는지)
|
|
41
|
+
*/
|
|
42
|
+
private shouldInclude;
|
|
43
|
+
/**
|
|
44
|
+
* 짧은 랜덤 ID 생성 (예: elm_a1b2c3)
|
|
45
|
+
*/
|
|
46
|
+
private generateId;
|
|
47
|
+
/**
|
|
48
|
+
* 요소 정보 추출
|
|
49
|
+
*/
|
|
50
|
+
private getElementInfo;
|
|
51
|
+
/**
|
|
52
|
+
* 요소의 레이블 가져오기
|
|
53
|
+
*/
|
|
54
|
+
private getLabel;
|
|
55
|
+
/**
|
|
56
|
+
* 요소 타입 결정
|
|
57
|
+
*/
|
|
58
|
+
private getElementType;
|
|
59
|
+
/**
|
|
60
|
+
* 요소가 시각적으로 보이는지 확인
|
|
61
|
+
*/
|
|
62
|
+
private isVisible;
|
|
63
|
+
/**
|
|
64
|
+
* 우선순위 계산
|
|
65
|
+
*/
|
|
66
|
+
private calculatePriority;
|
|
67
|
+
/**
|
|
68
|
+
* 요소 트리를 평탄화
|
|
69
|
+
*/
|
|
70
|
+
private flattenElements;
|
|
71
|
+
/**
|
|
72
|
+
* 우선순위 기반 필터링
|
|
73
|
+
*/
|
|
74
|
+
private filterByPriority;
|
|
75
|
+
/**
|
|
76
|
+
* DOM 해시 생성 (변경 감지용)
|
|
77
|
+
*/
|
|
78
|
+
private generateDOMHash;
|
|
79
|
+
/**
|
|
80
|
+
* 디버그 로그 출력 (debug 모드일 때만)
|
|
81
|
+
*/
|
|
82
|
+
private log;
|
|
83
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM Interaction Module
|
|
3
|
+
* LLM이 웹 페이지를 스캔하고 인터랙션할 수 있게 하는 유틸리티
|
|
4
|
+
*/
|
|
5
|
+
export { DOMScanner } from './DOMScanner.js';
|
|
6
|
+
export { DOMController } from './DOMController.js';
|
|
7
|
+
export { DOMAgent } from './DOMAgent.js';
|
|
8
|
+
export { DOMPromptBuilder } from './DOMPromptBuilder.js';
|
|
9
|
+
export type { ElementType, ScannedElement, ScanResult, FilterStrategy, ScanOptions, DOMAction, DOMCommand, ExecutionResult, DOMAgentEvents, AutomationOptions, HistoryItem, LLMCallback } from './types.js';
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM Interaction Types
|
|
3
|
+
* LLM이 웹 페이지를 스캔하고 인터랙션할 수 있게 하는 타입 정의
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 스캔된 요소의 타입
|
|
7
|
+
*/
|
|
8
|
+
export type ElementType = 'button' | 'input' | 'link' | 'select' | 'textarea' | 'checkbox' | 'radio' | 'custom' | 'other';
|
|
9
|
+
/**
|
|
10
|
+
* 스캔된 DOM 요소
|
|
11
|
+
*/
|
|
12
|
+
export interface ScannedElement {
|
|
13
|
+
/** 랜덤 생성된 고유 식별자 (예: elm_a1b2c3) */
|
|
14
|
+
id: string;
|
|
15
|
+
/** 요소 타입 */
|
|
16
|
+
type: ElementType;
|
|
17
|
+
/** HTML 태그명 */
|
|
18
|
+
tag: string;
|
|
19
|
+
/** 텍스트 콘텐츠 */
|
|
20
|
+
text?: string;
|
|
21
|
+
/** input 값 */
|
|
22
|
+
value?: string;
|
|
23
|
+
/** placeholder 텍스트 */
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
/** aria-label 또는 연결된 label */
|
|
26
|
+
label?: string;
|
|
27
|
+
/** data-llm-description 값 (LLM을 위한 설명) */
|
|
28
|
+
description?: string;
|
|
29
|
+
/** ARIA role */
|
|
30
|
+
role?: string;
|
|
31
|
+
/** disabled 상태 */
|
|
32
|
+
disabled: boolean;
|
|
33
|
+
/** 시각적으로 보이는지 여부 */
|
|
34
|
+
visible: boolean;
|
|
35
|
+
/** 포커스 상태 */
|
|
36
|
+
focused: boolean;
|
|
37
|
+
/** 체크 상태 (checkbox/radio) */
|
|
38
|
+
checked?: boolean;
|
|
39
|
+
/** Shadow DOM 내부 요소 여부 */
|
|
40
|
+
inShadowDom: boolean;
|
|
41
|
+
/** 화면 상 x 위치 */
|
|
42
|
+
x: number;
|
|
43
|
+
/** 화면 상 y 위치 */
|
|
44
|
+
y: number;
|
|
45
|
+
/** 너비 */
|
|
46
|
+
width: number;
|
|
47
|
+
/** 높이 */
|
|
48
|
+
height: number;
|
|
49
|
+
/** 우선순위 점수 (필터링용) */
|
|
50
|
+
priority: number;
|
|
51
|
+
/** 자식 요소들 (필터링된) */
|
|
52
|
+
children?: ScannedElement[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* DOM 스캔 결과
|
|
56
|
+
*/
|
|
57
|
+
export interface ScanResult {
|
|
58
|
+
/** 스캔 타임스탬프 */
|
|
59
|
+
timestamp: number;
|
|
60
|
+
/** 현재 URL */
|
|
61
|
+
url: string;
|
|
62
|
+
/** 페이지 제목 */
|
|
63
|
+
title: string;
|
|
64
|
+
/** 스캔된 요소들 */
|
|
65
|
+
elements: ScannedElement[];
|
|
66
|
+
/** Base64 인코딩된 스크린샷 (optional) */
|
|
67
|
+
screenshot?: string;
|
|
68
|
+
/** 스크롤 위치 */
|
|
69
|
+
scrollPosition: {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
};
|
|
73
|
+
/** 뷰포트 크기 */
|
|
74
|
+
viewport: {
|
|
75
|
+
width: number;
|
|
76
|
+
height: number;
|
|
77
|
+
};
|
|
78
|
+
/** 전체 DOM 요소 수 */
|
|
79
|
+
totalElements: number;
|
|
80
|
+
/** LLM에게 제공되는 필터링된 요소 수 */
|
|
81
|
+
filteredElements: number;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 필터링 전략
|
|
85
|
+
*/
|
|
86
|
+
export type FilterStrategy = 'all' | 'interactive' | 'described' | 'visible';
|
|
87
|
+
/**
|
|
88
|
+
* 스캔 옵션
|
|
89
|
+
*/
|
|
90
|
+
export interface ScanOptions {
|
|
91
|
+
/** 스크린샷 포함 여부 */
|
|
92
|
+
includeScreenshot?: boolean;
|
|
93
|
+
/** 최대 요소 수 제한 */
|
|
94
|
+
maxElements?: number;
|
|
95
|
+
/** 최대 깊이 제한 */
|
|
96
|
+
maxDepth?: number;
|
|
97
|
+
/** 필터링 전략 */
|
|
98
|
+
filterStrategy?: FilterStrategy;
|
|
99
|
+
/** 디버그 로그 활성화 (기본값: false) */
|
|
100
|
+
debug?: boolean;
|
|
101
|
+
/** 캐싱 사용 여부 (기본값: true) */
|
|
102
|
+
useCache?: boolean;
|
|
103
|
+
/** iframe 포함 여부 (기본값: false) */
|
|
104
|
+
includeIframes?: boolean;
|
|
105
|
+
/** ARIA Landmark 우선순위 증가 (기본값: true) */
|
|
106
|
+
prioritizeLandmarks?: boolean;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* DOM 명령 액션
|
|
110
|
+
*/
|
|
111
|
+
export type DOMAction = 'click' | 'input' | 'select' | 'focus' | 'blur' | 'scroll' | 'scrollTo' | 'hover' | 'clear' | 'check' | 'wait';
|
|
112
|
+
/**
|
|
113
|
+
* DOM 명령
|
|
114
|
+
*/
|
|
115
|
+
export interface DOMCommand {
|
|
116
|
+
/** 실행할 액션 */
|
|
117
|
+
action: DOMAction;
|
|
118
|
+
/** 대상 요소 ID (DOMScanner가 생성한 랜덤 ID) */
|
|
119
|
+
target?: string;
|
|
120
|
+
/** 명령 값 (input 텍스트, select 옵션 등) */
|
|
121
|
+
value?: string | number | boolean;
|
|
122
|
+
/** 추가 옵션 */
|
|
123
|
+
options?: {
|
|
124
|
+
/** 명령 실행 전 대기 시간 (ms) */
|
|
125
|
+
delay?: number;
|
|
126
|
+
/** 네비게이션 대기 여부 */
|
|
127
|
+
waitForNavigation?: boolean;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 명령 실행 결과
|
|
132
|
+
*/
|
|
133
|
+
export interface ExecutionResult {
|
|
134
|
+
/** 성공 여부 */
|
|
135
|
+
success: boolean;
|
|
136
|
+
/** 실행된 명령 */
|
|
137
|
+
command: DOMCommand;
|
|
138
|
+
/** 에러 메시지 (실패 시) */
|
|
139
|
+
error?: string;
|
|
140
|
+
/** 실행 타임스탬프 */
|
|
141
|
+
timestamp: number;
|
|
142
|
+
/** 페이지 네비게이션 발생 여부 */
|
|
143
|
+
navigationOccurred?: boolean;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* DOMAgent 이벤트 타입
|
|
147
|
+
*/
|
|
148
|
+
export interface DOMAgentEvents {
|
|
149
|
+
/** 스캔 완료 */
|
|
150
|
+
scan: ScanResult;
|
|
151
|
+
/** 명령 수신 */
|
|
152
|
+
command: DOMCommand;
|
|
153
|
+
/** 명령 실행 완료 */
|
|
154
|
+
execute: ExecutionResult;
|
|
155
|
+
/** 에러 발생 */
|
|
156
|
+
error: Error;
|
|
157
|
+
/** 반복 횟수 */
|
|
158
|
+
iteration: number;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* 자동화 옵션
|
|
162
|
+
*/
|
|
163
|
+
export interface AutomationOptions {
|
|
164
|
+
/** 최대 반복 횟수 */
|
|
165
|
+
maxIterations?: number;
|
|
166
|
+
/** 중지 조건 함수 */
|
|
167
|
+
stopCondition?: (scan: ScanResult) => boolean;
|
|
168
|
+
/** 스크린샷 포함 여부 */
|
|
169
|
+
includeScreenshot?: boolean;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* 히스토리 항목
|
|
173
|
+
*/
|
|
174
|
+
export interface HistoryItem {
|
|
175
|
+
/** 스캔 결과 */
|
|
176
|
+
scan: ScanResult;
|
|
177
|
+
/** 실행된 명령들 */
|
|
178
|
+
commands: DOMCommand[];
|
|
179
|
+
/** 실행 결과들 */
|
|
180
|
+
results: ExecutionResult[];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* LLM 콜백 함수 타입
|
|
184
|
+
*/
|
|
185
|
+
export type LLMCallback = (scan: ScanResult) => Promise<DOMCommand[]>;
|
|
186
|
+
/**
|
|
187
|
+
* 캐시 항목
|
|
188
|
+
*/
|
|
189
|
+
export interface CachedScan {
|
|
190
|
+
/** 캐시된 스캔 결과 */
|
|
191
|
+
result: ScanResult;
|
|
192
|
+
/** 캐시 생성 시간 */
|
|
193
|
+
timestamp: number;
|
|
194
|
+
/** DOM 해시 (변경 감지용) */
|
|
195
|
+
domHash: string;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Diff 결과
|
|
199
|
+
*/
|
|
200
|
+
export interface ScanDiff {
|
|
201
|
+
/** 추가된 요소 */
|
|
202
|
+
added: ScannedElement[];
|
|
203
|
+
/** 제거된 요소 */
|
|
204
|
+
removed: ScannedElement[];
|
|
205
|
+
/** 변경된 요소 */
|
|
206
|
+
modified: ScannedElement[];
|
|
207
|
+
/** 변경되지 않은 요소 */
|
|
208
|
+
unchanged: ScannedElement[];
|
|
209
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iyulab/chat-components",
|
|
3
3
|
"description": "llm chat components for building chat interfaces",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.1",
|
|
5
5
|
"author": "iyulab",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"dist",
|
|
21
|
+
"skills",
|
|
21
22
|
"package.json",
|
|
22
23
|
"README.md",
|
|
23
24
|
"CHANGELOG.md",
|
|
@@ -31,34 +32,50 @@
|
|
|
31
32
|
"types": "./dist/index.d.ts",
|
|
32
33
|
"import": "./dist/index.js"
|
|
33
34
|
},
|
|
34
|
-
"./dist/*":
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
35
|
+
"./dist/*": "./dist/*",
|
|
36
|
+
"./react": "./dist/react/index.js",
|
|
37
|
+
"./react/*": "./dist/react/*"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"test": "vite",
|
|
41
41
|
"build": "eslint && vite build"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@iyulab/components": "^0.
|
|
45
|
-
"chart.js": "^4.5.1",
|
|
44
|
+
"@iyulab/components": "^1.0.3",
|
|
46
45
|
"highlight.js": "^11.11.1",
|
|
46
|
+
"html2canvas": "^1.4.1",
|
|
47
47
|
"lit": "^3.3.2",
|
|
48
|
-
"marked": "^17.0.
|
|
48
|
+
"marked": "^17.0.5",
|
|
49
49
|
"marked-katex-extension": "^5.1.7"
|
|
50
50
|
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"@lit/react": ">=1.0.8",
|
|
53
|
+
"chart.js": ">=4.5.1",
|
|
54
|
+
"react": ">=18.0.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependenciesMeta": {
|
|
57
|
+
"@lit/react": {
|
|
58
|
+
"optional": true
|
|
59
|
+
},
|
|
60
|
+
"chart.js": {
|
|
61
|
+
"optional": true
|
|
62
|
+
},
|
|
63
|
+
"react": {
|
|
64
|
+
"optional": true
|
|
65
|
+
}
|
|
66
|
+
},
|
|
51
67
|
"devDependencies": {
|
|
52
|
-
"@eslint/js": "^9.39.
|
|
53
|
-
"@
|
|
54
|
-
"
|
|
55
|
-
"eslint": "^9.39.
|
|
68
|
+
"@eslint/js": "^9.39.4",
|
|
69
|
+
"@types/node": "^25.5.0",
|
|
70
|
+
"chart.js": "^4.5.1",
|
|
71
|
+
"eslint": "^9.39.4",
|
|
56
72
|
"eslint-plugin-lit": "^2.2.1",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
73
|
+
"glob": "^13.0.6",
|
|
74
|
+
"globals": "^17.4.0",
|
|
75
|
+
"openai": "^6.33.0",
|
|
59
76
|
"typescript": "^5.9.3",
|
|
60
|
-
"typescript-eslint": "^8.
|
|
61
|
-
"vite": "^
|
|
77
|
+
"typescript-eslint": "^8.58.0",
|
|
78
|
+
"vite": "^8.0.3",
|
|
62
79
|
"vite-plugin-dts": "^4.5.4"
|
|
63
80
|
}
|
|
64
81
|
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: iyulab-chat-components
|
|
3
|
+
description: LLM chat UI component library. Covers all u-* custom elements for building chat interfaces — message rendering, chat input, markdown/code blocks, file attachments, reference citations, and the Intent/View system. Use when working with @iyulab/chat-components package.
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
author: iyulab
|
|
7
|
+
version: "0.5.0"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# @iyulab/chat-components
|
|
11
|
+
|
|
12
|
+
Web component library for building LLM chat interfaces, built on [Lit](https://lit.dev/). All components are custom elements (`u-*` tags) that work in any framework or vanilla HTML.
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @iyulab/chat-components
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Import all components at once:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import '@iyulab/chat-components';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Import individual components (tree-shakable):
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import '@iyulab/chat-components/dist/components/message/UMessage.js';
|
|
30
|
+
import '@iyulab/chat-components/dist/components/prompt/UPrompt.js';
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
> For detailed setup and usage patterns, see [./references/usage.md](./references/usage.md).
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Components
|
|
38
|
+
|
|
39
|
+
### Message & Input
|
|
40
|
+
|
|
41
|
+
- [`u-message`](./references/components/message.md) — Chat message wrapper. Slot-based block layout, loading animation, bubble/default style variants
|
|
42
|
+
- [`u-prompt`](./references/components/prompt.md) — Chat input component. File attachment preview, auto-resize textarea, integrated send/stop button
|
|
43
|
+
|
|
44
|
+
### Content Blocks
|
|
45
|
+
|
|
46
|
+
- [`u-marked-block`](./references/components/marked-block.md) — Renders markdown to HTML. KaTeX math, code highlighting, citation insertion, view-json/intent-json handling
|
|
47
|
+
- [`u-code-block`](./references/components/code-block.md) — Highlight.js code block with language label and clipboard copy
|
|
48
|
+
- [`u-text-block`](./references/components/text-block.md) — Plain text display or editable textarea
|
|
49
|
+
- [`u-think-block`](./references/components/think-block.md) — LLM reasoning (thinking) block. Collapse/expand, auto-scroll
|
|
50
|
+
- [`u-tool-block`](./references/components/tool-block.md) — Tool call input/output display. Collapse/expand
|
|
51
|
+
- [`u-file-block`](./references/components/file-block.md) — File attachment card. Type icon, upload status, download, remove
|
|
52
|
+
- [`u-ref-block`](./references/components/ref-block.md) — Reference source group block. Collapse/expand, grid of ref cards
|
|
53
|
+
- [`u-json-block`](./references/components/json-block.md) — Visualizes JSON data as a collapsible tree
|
|
54
|
+
- [`u-table-block`](./references/components/table-block.md) — Markdown table renderer. Column sort, search filter, CSV/XLS download
|
|
55
|
+
|
|
56
|
+
### Action Buttons
|
|
57
|
+
|
|
58
|
+
- [`u-copy-button`](./references/components/copy-button.md) — Clipboard copy button; icon changes after copy
|
|
59
|
+
- [`u-vote-button`](./references/components/vote-button.md) — Thumbs-up / thumbs-down vote button pair
|
|
60
|
+
- [`u-attach-button`](./references/components/attach-button.md) — File picker button; fires `attach` event with selected files
|
|
61
|
+
|
|
62
|
+
### Reference Components
|
|
63
|
+
|
|
64
|
+
- [`u-ref-tag`](./references/components/ref-tag.md) — Inline citation tag. Tooltip and external-link icon
|
|
65
|
+
- [`u-ref-card`](./references/components/ref-card.md) — Reference source card. web/document type, favicon, tags
|
|
66
|
+
- [`u-ref-card-group`](./references/components/ref-card-group.md) — Paginated group of reference cards
|
|
67
|
+
|
|
68
|
+
### Intent Components
|
|
69
|
+
|
|
70
|
+
- [`u-question-intent`](./references/components/question-intent.md) — LLM-generated question with clickable choice buttons
|
|
71
|
+
|
|
72
|
+
### View Components
|
|
73
|
+
|
|
74
|
+
- [`u-images-view`](./references/components/images-view.md) — Image gallery (carousel + lightbox)
|
|
75
|
+
- [`u-video-view`](./references/components/video-view.md) — YouTube / Vimeo / direct video file player
|
|
76
|
+
- [`u-chart-view`](./references/components/chart-view.md) — Chart.js charts (bar, line, pie, etc.)
|
|
77
|
+
- [`u-map-view`](./references/components/map-view.md) — OpenStreetMap embed
|
|
78
|
+
- [`u-view`](./references/components/view.md) — Dynamic custom element renderer (runtime for view-json blocks)
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Utilities
|
|
83
|
+
|
|
84
|
+
- [`IntentPromptBuilder`](./references/utilities/intent-prompt-builder.md) — Build LLM system prompt instructions for intents and parse intent-json responses
|
|
85
|
+
- [`ViewPromptBuilder`](./references/utilities/view-prompt-builder.md) — Build LLM system prompt instructions for views
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Types
|
|
90
|
+
|
|
91
|
+
- [`BlockItem`](./references/types.md) — Union type for message content blocks (text, markdown, file, tool, reference, thinking)
|
|
92
|
+
- `ReferenceSource` / `ReferenceCitation` — Citation source and inline citation position types
|
|
93
|
+
- `IntentDefinition` / `PresetIntent` — Intent definition and preset bit flags
|
|
94
|
+
- `ViewDefinition` / `PresetView` — View definition and preset bit flags
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Events
|
|
99
|
+
|
|
100
|
+
| Event | Source | Detail Type | Description |
|
|
101
|
+
|-------|--------|-------------|-------------|
|
|
102
|
+
| `send` | `u-prompt` | `unknown` | Send button clicked or Enter pressed |
|
|
103
|
+
| `stop` | `u-prompt` | `unknown` | Stop button clicked while loading |
|
|
104
|
+
| `attach` | `u-attach-button` | `{ files: File[] }` | File selection completed |
|
|
105
|
+
| `choice` | `u-question-intent` | `{ value: string }` | Choice button clicked |
|
|
106
|
+
| `change` | `u-vote-button` | `Event` | Vote state changed |
|
|
107
|
+
| `remove` | `u-file-block` | `RemoveEventDetail` | Remove button clicked |
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# u-attach-button
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import '@iyulab/chat-components/dist/components/buttons/UAttachButton.js';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**Tag:** `u-attach-button`
|
|
8
|
+
|
|
9
|
+
Opens a file picker dialog. Fires an `attach` event with the selected files. Place in `u-prompt`'s `left-actions` slot.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<!-- Basic usage -->
|
|
13
|
+
<u-attach-button></u-attach-button>
|
|
14
|
+
|
|
15
|
+
<!-- Images only -->
|
|
16
|
+
<u-attach-button accept="image/*">Add image</u-attach-button>
|
|
17
|
+
|
|
18
|
+
<!-- Multiple files allowed -->
|
|
19
|
+
<u-attach-button multiple accept="image/*,application/pdf">Attach files</u-attach-button>
|
|
20
|
+
|
|
21
|
+
<!-- Inside u-prompt -->
|
|
22
|
+
<u-prompt>
|
|
23
|
+
<u-attach-button
|
|
24
|
+
slot="left-actions"
|
|
25
|
+
multiple
|
|
26
|
+
accept="image/*,application/pdf,text/*"
|
|
27
|
+
@attach=${handleAttach}
|
|
28
|
+
>
|
|
29
|
+
Files
|
|
30
|
+
</u-attach-button>
|
|
31
|
+
</u-prompt>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
const attachBtn = document.querySelector('u-attach-button');
|
|
36
|
+
|
|
37
|
+
attachBtn.addEventListener('attach', (e) => {
|
|
38
|
+
const { files } = e.detail; // File[]
|
|
39
|
+
console.log('Selected files:', files.map(f => f.name));
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Slots
|
|
46
|
+
|
|
47
|
+
| Name | Description |
|
|
48
|
+
|------|-------------|
|
|
49
|
+
| *(default)* | Tooltip label text |
|
|
50
|
+
|
|
51
|
+
## Properties
|
|
52
|
+
|
|
53
|
+
| Property | Type | Default | Description |
|
|
54
|
+
|----------|------|---------|-------------|
|
|
55
|
+
| `accept` | `string` | `undefined` | Accepted MIME types (comma-separated). E.g. `"image/*"`, `"image/*,application/pdf"` |
|
|
56
|
+
| `multiple` | `boolean` | `false` | Allow selecting multiple files |
|
|
57
|
+
|
|
58
|
+
## Events
|
|
59
|
+
|
|
60
|
+
| Event | Detail | Description |
|
|
61
|
+
|-------|--------|-------------|
|
|
62
|
+
| `attach` | `{ files: File[] }` | Fired after file selection. The file input is reset automatically |
|
|
63
|
+
|
|
64
|
+
## CSS Parts
|
|
65
|
+
|
|
66
|
+
| Part | Description |
|
|
67
|
+
|------|-------------|
|
|
68
|
+
| `base` | The button element (`u-button`) |
|
|
69
|
+
| `icon` | Paperclip icon |
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# u-chart-view
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import '@iyulab/chat-components/dist/components/views/UChartView.js';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**Tag:** `u-chart-view`
|
|
8
|
+
|
|
9
|
+
Renders charts using Chart.js (lazy-loaded). Supports PNG and JSON download. Automatically re-renders when the page theme changes.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<!-- Bar chart -->
|
|
13
|
+
<u-chart-view
|
|
14
|
+
type="bar"
|
|
15
|
+
.data=${{
|
|
16
|
+
labels: ['Jan', 'Feb', 'Mar'],
|
|
17
|
+
datasets: [{ label: 'Revenue', data: [100, 200, 150] }]
|
|
18
|
+
}}
|
|
19
|
+
></u-chart-view>
|
|
20
|
+
|
|
21
|
+
<!-- Line chart with options -->
|
|
22
|
+
<u-chart-view
|
|
23
|
+
type="line"
|
|
24
|
+
.data=${{
|
|
25
|
+
labels: ['A', 'B', 'C', 'D'],
|
|
26
|
+
datasets: [{ label: 'Trend', data: [10, 40, 30, 60], fill: true }]
|
|
27
|
+
}}
|
|
28
|
+
.options=${{ plugins: { legend: { position: 'bottom' } } }}
|
|
29
|
+
></u-chart-view>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
LLM output example (`view-json` code block):
|
|
33
|
+
|
|
34
|
+
````
|
|
35
|
+
```view-json
|
|
36
|
+
{
|
|
37
|
+
"tag": "u-chart-view",
|
|
38
|
+
"properties": {
|
|
39
|
+
"type": "bar",
|
|
40
|
+
"data": {
|
|
41
|
+
"labels": ["Jan", "Feb", "Mar"],
|
|
42
|
+
"datasets": [{ "label": "Revenue", "data": [100, 200, 150] }]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
````
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Properties
|
|
52
|
+
|
|
53
|
+
| Property | Type | Default | Description |
|
|
54
|
+
|----------|------|---------|-------------|
|
|
55
|
+
| `type` | `ChartType` | `undefined` | Chart type: `'bar'`, `'line'`, `'pie'`, `'doughnut'`, `'radar'`, `'polarArea'`, `'bubble'`, `'scatter'` |
|
|
56
|
+
| `data` | `ChartData` | `undefined` | Chart.js data object with `labels` and `datasets` |
|
|
57
|
+
| `options` | `ChartOptions` | `undefined` | Chart.js options object |
|
|
58
|
+
|
|
59
|
+
## Features
|
|
60
|
+
|
|
61
|
+
| Feature | Description |
|
|
62
|
+
|---------|-------------|
|
|
63
|
+
| Lazy load | Chart.js is dynamically imported on first render |
|
|
64
|
+
| Download | Export chart as PNG or raw JSON data |
|
|
65
|
+
| Theme sync | Watches `document.documentElement[theme]` and re-renders on change |
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# u-code-block
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import '@iyulab/chat-components/dist/components/blocks/UCodeBlock.js';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**Tag:** `u-code-block`
|
|
8
|
+
|
|
9
|
+
Syntax-highlighted code block powered by Highlight.js. Shows a language label, clipboard copy button, and loading spinner. Automatically rendered inside `u-marked-block` for fenced code blocks.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<!-- Direct usage -->
|
|
13
|
+
<u-code-block lang="typescript" .value=${"const x: number = 42;"}></u-code-block>
|
|
14
|
+
|
|
15
|
+
<!-- Without header -->
|
|
16
|
+
<u-code-block lang="json" headless .value=${JSON.stringify({key: 'value'}, null, 2)}></u-code-block>
|
|
17
|
+
|
|
18
|
+
<!-- Loading state (streaming) -->
|
|
19
|
+
<u-code-block lang="python" loading .value=${"def hello():"}></u-code-block>
|
|
20
|
+
|
|
21
|
+
<!-- Inject code via slot -->
|
|
22
|
+
<u-code-block lang="javascript">
|
|
23
|
+
console.log("Hello from slot");
|
|
24
|
+
</u-code-block>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Properties
|
|
30
|
+
|
|
31
|
+
| Property | Type | Default | Reflect | Description |
|
|
32
|
+
|----------|------|---------|---------|-------------|
|
|
33
|
+
| `lang` | `string` | `'plaintext'` | ✓ | Code language. Falls back to `plaintext` if not supported by Highlight.js |
|
|
34
|
+
| `value` | `string` | `undefined` | — | Code content. Can also be set via slot `textContent` |
|
|
35
|
+
| `loading` | `boolean` | `false` | ✓ | Loading state. Replaces the code icon with a spinner in the header |
|
|
36
|
+
| `headless` | `boolean` | `false` | ✓ | Hides the header (language label + copy button) |
|
|
37
|
+
|
|
38
|
+
## Slots
|
|
39
|
+
|
|
40
|
+
| Name | Description |
|
|
41
|
+
|------|-------------|
|
|
42
|
+
| *(default, hidden)* | Code text injected directly as content; updates `value` on `slotchange` |
|