@iyulab/chat-components 0.1.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.
- package/CHANGELOG.md +4 -0
- package/LICENSE +21 -0
- package/README.md +20 -0
- package/dist/components/blocks/UCodeBlock.component.d.ts +24 -0
- package/dist/components/blocks/UCodeBlock.component.js +65 -0
- package/dist/components/blocks/UCodeBlock.d.ts +7 -0
- package/dist/components/blocks/UCodeBlock.js +5 -0
- package/dist/components/blocks/UCodeBlock.styles.d.ts +1 -0
- package/dist/components/blocks/UCodeBlock.styles.js +175 -0
- package/dist/components/blocks/UMarkedBlock.component.d.ts +24 -0
- package/dist/components/blocks/UMarkedBlock.component.js +80 -0
- package/dist/components/blocks/UMarkedBlock.d.ts +7 -0
- package/dist/components/blocks/UMarkedBlock.js +5 -0
- package/dist/components/blocks/UMarkedBlock.styles.d.ts +1 -0
- package/dist/components/blocks/UMarkedBlock.styles.js +1240 -0
- package/dist/components/blocks/UTextBlock.component.d.ts +37 -0
- package/dist/components/blocks/UTextBlock.component.js +123 -0
- package/dist/components/blocks/UTextBlock.d.ts +7 -0
- package/dist/components/blocks/UTextBlock.js +5 -0
- package/dist/components/blocks/UTextBlock.styles.d.ts +1 -0
- package/dist/components/blocks/UTextBlock.styles.js +71 -0
- package/dist/components/blocks/UThinkBlock.component.d.ts +28 -0
- package/dist/components/blocks/UThinkBlock.component.js +84 -0
- package/dist/components/blocks/UThinkBlock.d.ts +7 -0
- package/dist/components/blocks/UThinkBlock.js +5 -0
- package/dist/components/blocks/UThinkBlock.styles.d.ts +1 -0
- package/dist/components/blocks/UThinkBlock.styles.js +93 -0
- package/dist/components/blocks/UToolBlock.component.d.ts +16 -0
- package/dist/components/blocks/UToolBlock.component.js +126 -0
- package/dist/components/blocks/UToolBlock.d.ts +7 -0
- package/dist/components/blocks/UToolBlock.js +5 -0
- package/dist/components/blocks/UToolBlock.styles.d.ts +1 -0
- package/dist/components/blocks/UToolBlock.styles.js +107 -0
- package/dist/components/buttons/UAttachButton.component.d.ts +24 -0
- package/dist/components/buttons/UAttachButton.component.js +78 -0
- package/dist/components/buttons/UAttachButton.d.ts +7 -0
- package/dist/components/buttons/UAttachButton.js +5 -0
- package/dist/components/buttons/UAttachButton.styles.d.ts +1 -0
- package/dist/components/buttons/UAttachButton.styles.js +21 -0
- package/dist/components/buttons/UCopyButton.component.d.ts +25 -0
- package/dist/components/buttons/UCopyButton.component.js +105 -0
- package/dist/components/buttons/UCopyButton.d.ts +7 -0
- package/dist/components/buttons/UCopyButton.js +5 -0
- package/dist/components/buttons/UCopyButton.styles.d.ts +1 -0
- package/dist/components/buttons/UCopyButton.styles.js +47 -0
- package/dist/components/buttons/USendButton.component.d.ts +13 -0
- package/dist/components/buttons/USendButton.component.js +46 -0
- package/dist/components/buttons/USendButton.d.ts +7 -0
- package/dist/components/buttons/USendButton.js +5 -0
- package/dist/components/buttons/USendButton.styles.d.ts +1 -0
- package/dist/components/buttons/USendButton.styles.js +23 -0
- package/dist/components/buttons/UThinkButton.component.d.ts +19 -0
- package/dist/components/buttons/UThinkButton.component.js +73 -0
- package/dist/components/buttons/UThinkButton.d.ts +7 -0
- package/dist/components/buttons/UThinkButton.js +5 -0
- package/dist/components/buttons/UThinkButton.styles.d.ts +1 -0
- package/dist/components/buttons/UThinkButton.styles.js +72 -0
- package/dist/components/json-viewer/UJsonViewer.component.d.ts +44 -0
- package/dist/components/json-viewer/UJsonViewer.component.js +137 -0
- package/dist/components/json-viewer/UJsonViewer.d.ts +7 -0
- package/dist/components/json-viewer/UJsonViewer.js +5 -0
- package/dist/components/json-viewer/UJsonViewer.lib.d.ts +16 -0
- package/dist/components/json-viewer/UJsonViewer.lib.js +28 -0
- package/dist/components/json-viewer/UJsonViewer.styles.d.ts +1 -0
- package/dist/components/json-viewer/UJsonViewer.styles.js +115 -0
- package/dist/components/message/UMessage.component.d.ts +13 -0
- package/dist/components/message/UMessage.component.js +104 -0
- package/dist/components/message/UMessage.d.ts +8 -0
- package/dist/components/message/UMessage.js +5 -0
- package/dist/components/message/UMessage.styles.d.ts +1 -0
- package/dist/components/message/UMessage.styles.js +72 -0
- package/dist/components/message/UMessage.types.d.ts +21 -0
- package/dist/events/UStopEvent.d.ts +6 -0
- package/dist/events/USubmitEvent.d.ts +6 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +22 -0
- package/dist/internals/date-helpers.d.ts +8 -0
- package/dist/internals/date-helpers.js +27 -0
- package/package.json +65 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PropertyValues } from 'lit';
|
|
2
|
+
import { BaseElement } from '@iyulab/components/dist/components/BaseElement.js';
|
|
3
|
+
/**
|
|
4
|
+
* 텍스트를 표시하거나 편집할 수 있는 블록 컴포넌트입니다.
|
|
5
|
+
*/
|
|
6
|
+
export declare class UTextBlock extends BaseElement {
|
|
7
|
+
static styles: import('lit').CSSResultGroup[];
|
|
8
|
+
static dependencies: Record<string, typeof BaseElement>;
|
|
9
|
+
textareaEl: HTMLTextAreaElement;
|
|
10
|
+
preEl: HTMLPreElement;
|
|
11
|
+
/** 편집 가능 여부 */
|
|
12
|
+
editable: boolean;
|
|
13
|
+
/** 스펠체크 여부 */
|
|
14
|
+
spellcheck: boolean;
|
|
15
|
+
/** 플레이스홀더 텍스트 */
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
/** 최소 행 수, 기본값은 1 */
|
|
18
|
+
minRows: number;
|
|
19
|
+
/** 최대 행 수 */
|
|
20
|
+
maxRows?: number;
|
|
21
|
+
/** 텍스트 블록의 내용 */
|
|
22
|
+
value?: string;
|
|
23
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
24
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
25
|
+
/**
|
|
26
|
+
* textarea에 포커스를 줍니다.
|
|
27
|
+
*/
|
|
28
|
+
focus(options?: FocusOptions): void;
|
|
29
|
+
/**
|
|
30
|
+
* 텍스트 입력시 value를 업데이트하고 이벤트를 재전파합니다.
|
|
31
|
+
*/
|
|
32
|
+
private updateValueFrom;
|
|
33
|
+
/**
|
|
34
|
+
* pre 엘리먼트에 주입될 값을 정규화합니다.
|
|
35
|
+
*/
|
|
36
|
+
private normalizeValue;
|
|
37
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { query, property } from 'lit/decorators.js';
|
|
3
|
+
import { BaseElement } from '@iyulab/components/dist/components/BaseElement.js';
|
|
4
|
+
import { styles } from './UTextBlock.styles.js';
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
8
|
+
var result = void 0 ;
|
|
9
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10
|
+
if (decorator = decorators[i])
|
|
11
|
+
result = (decorator(target, key, result) ) || result;
|
|
12
|
+
if (result) __defProp(target, key, result);
|
|
13
|
+
return result;
|
|
14
|
+
};
|
|
15
|
+
class UTextBlock extends BaseElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.editable = false;
|
|
19
|
+
this.spellcheck = false;
|
|
20
|
+
this.minRows = 1;
|
|
21
|
+
/**
|
|
22
|
+
* 텍스트 입력시 value를 업데이트하고 이벤트를 재전파합니다.
|
|
23
|
+
*/
|
|
24
|
+
this.updateValueFrom = (event) => {
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
this.value = this.textareaEl.value;
|
|
27
|
+
this.dispatchEvent(new InputEvent("input", {
|
|
28
|
+
bubbles: true,
|
|
29
|
+
composed: true,
|
|
30
|
+
cancelable: true,
|
|
31
|
+
data: this.value,
|
|
32
|
+
inputType: event.inputType,
|
|
33
|
+
isComposing: event.isComposing,
|
|
34
|
+
dataTransfer: event.dataTransfer,
|
|
35
|
+
detail: event.detail,
|
|
36
|
+
targetRanges: event.getTargetRanges(),
|
|
37
|
+
view: event.view
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
static {
|
|
42
|
+
this.styles = [super.styles, styles];
|
|
43
|
+
}
|
|
44
|
+
static {
|
|
45
|
+
this.dependencies = {};
|
|
46
|
+
}
|
|
47
|
+
updated(changedProperties) {
|
|
48
|
+
super.updated(changedProperties);
|
|
49
|
+
if (changedProperties.has("minRows") && this.minRows > 0) {
|
|
50
|
+
const lineHeight = parseFloat(getComputedStyle(this.preEl).lineHeight);
|
|
51
|
+
this.preEl.style.minHeight = `${this.minRows * lineHeight}px`;
|
|
52
|
+
}
|
|
53
|
+
if (changedProperties.has("maxRows") && this.maxRows && this.maxRows > 0 && this.maxRows > this.minRows) {
|
|
54
|
+
const lineHeight = parseFloat(getComputedStyle(this.preEl).lineHeight);
|
|
55
|
+
this.preEl.style.maxHeight = `${this.maxRows * lineHeight}px`;
|
|
56
|
+
}
|
|
57
|
+
if (changedProperties.has("editable") && this.editable) {
|
|
58
|
+
requestAnimationFrame(() => {
|
|
59
|
+
this.textareaEl.focus();
|
|
60
|
+
this.textareaEl.setSelectionRange(this.value?.length || 0, this.value?.length || 0);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
render() {
|
|
65
|
+
return html`
|
|
66
|
+
<div class="container">
|
|
67
|
+
<textarea
|
|
68
|
+
name="message"
|
|
69
|
+
placeholder=${this.placeholder || ""}
|
|
70
|
+
spellcheck=${this.spellcheck}
|
|
71
|
+
.readOnly=${!this.editable}
|
|
72
|
+
.value=${this.value || ""}
|
|
73
|
+
@input=${this.updateValueFrom}
|
|
74
|
+
></textarea>
|
|
75
|
+
<pre
|
|
76
|
+
.textContent=${this.normalizeValue(this.value)}
|
|
77
|
+
></pre>
|
|
78
|
+
</div>
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* textarea에 포커스를 줍니다.
|
|
83
|
+
*/
|
|
84
|
+
focus(options) {
|
|
85
|
+
this.textareaEl.focus(options);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* pre 엘리먼트에 주입될 값을 정규화합니다.
|
|
89
|
+
*/
|
|
90
|
+
normalizeValue(value) {
|
|
91
|
+
if (!value) return "";
|
|
92
|
+
if (value.endsWith("\n")) {
|
|
93
|
+
return value + "";
|
|
94
|
+
}
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
__decorateClass([
|
|
99
|
+
query("textarea")
|
|
100
|
+
], UTextBlock.prototype, "textareaEl");
|
|
101
|
+
__decorateClass([
|
|
102
|
+
query("pre")
|
|
103
|
+
], UTextBlock.prototype, "preEl");
|
|
104
|
+
__decorateClass([
|
|
105
|
+
property({ type: Boolean, reflect: true })
|
|
106
|
+
], UTextBlock.prototype, "editable");
|
|
107
|
+
__decorateClass([
|
|
108
|
+
property({ type: Boolean })
|
|
109
|
+
], UTextBlock.prototype, "spellcheck");
|
|
110
|
+
__decorateClass([
|
|
111
|
+
property({ type: String })
|
|
112
|
+
], UTextBlock.prototype, "placeholder");
|
|
113
|
+
__decorateClass([
|
|
114
|
+
property({ type: Number })
|
|
115
|
+
], UTextBlock.prototype, "minRows");
|
|
116
|
+
__decorateClass([
|
|
117
|
+
property({ type: Number })
|
|
118
|
+
], UTextBlock.prototype, "maxRows");
|
|
119
|
+
__decorateClass([
|
|
120
|
+
property({ type: String })
|
|
121
|
+
], UTextBlock.prototype, "value");
|
|
122
|
+
|
|
123
|
+
export { UTextBlock };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import('lit').CSSResult;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
const styles = css`
|
|
4
|
+
:host {
|
|
5
|
+
display: block;
|
|
6
|
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
7
|
+
font-size: 16px;
|
|
8
|
+
font-weight: 400;
|
|
9
|
+
line-height: 1.5;
|
|
10
|
+
color: currentColor;
|
|
11
|
+
background-color: transparent;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.container {
|
|
15
|
+
position: relative;
|
|
16
|
+
display: block;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
textarea {
|
|
21
|
+
position: absolute;
|
|
22
|
+
top: 0;
|
|
23
|
+
left: 0;
|
|
24
|
+
bottom: 0;
|
|
25
|
+
right: 0;
|
|
26
|
+
|
|
27
|
+
display: block;
|
|
28
|
+
border: none;
|
|
29
|
+
outline: none;
|
|
30
|
+
resize: none;
|
|
31
|
+
color: inherit;
|
|
32
|
+
background-color: inherit;
|
|
33
|
+
|
|
34
|
+
/* 동일 스타일 크기 싱크 */
|
|
35
|
+
margin: 0;
|
|
36
|
+
padding: 0;
|
|
37
|
+
white-space: pre;
|
|
38
|
+
font-family: inherit;
|
|
39
|
+
font-size: inherit;
|
|
40
|
+
line-height: inherit;
|
|
41
|
+
overflow: auto;
|
|
42
|
+
scrollbar-width: thin;
|
|
43
|
+
scrollbar-color: var(--u-scrollbar-color) transparent;
|
|
44
|
+
}
|
|
45
|
+
textarea[readonly] {
|
|
46
|
+
cursor: default;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* 숨김 처리 */
|
|
50
|
+
pre {
|
|
51
|
+
visibility: hidden;
|
|
52
|
+
position: relative;
|
|
53
|
+
display: block;
|
|
54
|
+
color: red;
|
|
55
|
+
|
|
56
|
+
/* 동일 스타일 크기 싱크 */
|
|
57
|
+
margin: 0;
|
|
58
|
+
padding: 0;
|
|
59
|
+
white-space: pre;
|
|
60
|
+
font-family: inherit;
|
|
61
|
+
font-size: inherit;
|
|
62
|
+
line-height: inherit;
|
|
63
|
+
overflow: auto;
|
|
64
|
+
scrollbar-width: thin;
|
|
65
|
+
|
|
66
|
+
pointer-events: none;
|
|
67
|
+
min-height: 1.5em;
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
export { styles };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PropertyValues } from 'lit';
|
|
2
|
+
import { nothing } from 'lit/html.js';
|
|
3
|
+
import { BaseElement } from '@iyulab/components/dist/components/BaseElement.js';
|
|
4
|
+
/**
|
|
5
|
+
* 추론 내용을 표시하는 블록입니다.
|
|
6
|
+
* 로딩 중일 때는 "Thinking..." 메시지를 표시하고, 내용 펼치기/접기 기능을 제공합니다.
|
|
7
|
+
*/
|
|
8
|
+
export declare class UThinkBlock extends BaseElement {
|
|
9
|
+
static styles: import('lit').CSSResultGroup[];
|
|
10
|
+
static dependencies: Record<string, typeof BaseElement>;
|
|
11
|
+
bodyEl: HTMLElement;
|
|
12
|
+
/** 컨텐츠가 로딩 중인지 여부 */
|
|
13
|
+
loading: boolean;
|
|
14
|
+
/** 컨텐츠가 접혀있는지 여부 */
|
|
15
|
+
collapsed: boolean;
|
|
16
|
+
/** 추론 컨텐츠의 내용 */
|
|
17
|
+
value?: string;
|
|
18
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
19
|
+
render(): typeof nothing | import('lit-html').TemplateResult<1>;
|
|
20
|
+
/**
|
|
21
|
+
* 컨텐츠 접기/펼치기 토글
|
|
22
|
+
*/
|
|
23
|
+
private toggleCollapsed;
|
|
24
|
+
/**
|
|
25
|
+
* 컨텐츠가 로딩 중일 때, 스크롤을 맨 아래로 이동
|
|
26
|
+
*/
|
|
27
|
+
private scrollBodyContent;
|
|
28
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { query, property } from 'lit/decorators.js';
|
|
3
|
+
import { nothing } from 'lit/html.js';
|
|
4
|
+
import { BaseElement } from '@iyulab/components/dist/components/BaseElement.js';
|
|
5
|
+
import { UIcon } from '@iyulab/components/dist/components/icon/UIcon.component.js';
|
|
6
|
+
import { styles } from './UThinkBlock.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 UThinkBlock extends BaseElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.loading = false;
|
|
21
|
+
this.collapsed = true;
|
|
22
|
+
/**
|
|
23
|
+
* 컨텐츠 접기/펼치기 토글
|
|
24
|
+
*/
|
|
25
|
+
this.toggleCollapsed = () => {
|
|
26
|
+
if (this.loading) return;
|
|
27
|
+
this.collapsed = !this.collapsed;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* 컨텐츠가 로딩 중일 때, 스크롤을 맨 아래로 이동
|
|
31
|
+
*/
|
|
32
|
+
this.scrollBodyContent = () => {
|
|
33
|
+
if (!this.bodyEl) return;
|
|
34
|
+
requestAnimationFrame(() => {
|
|
35
|
+
this.bodyEl.scrollTo({
|
|
36
|
+
top: this.bodyEl.scrollHeight,
|
|
37
|
+
behavior: "smooth"
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
static {
|
|
43
|
+
this.styles = [super.styles, styles];
|
|
44
|
+
}
|
|
45
|
+
static {
|
|
46
|
+
this.dependencies = {
|
|
47
|
+
"u-icon": UIcon
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
updated(changedProperties) {
|
|
51
|
+
super.updated(changedProperties);
|
|
52
|
+
if (changedProperties.has("value") && this.loading) {
|
|
53
|
+
this.scrollBodyContent();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
render() {
|
|
57
|
+
if (!this.value) return nothing;
|
|
58
|
+
return html`
|
|
59
|
+
<div class="container">
|
|
60
|
+
<div class="header" @click=${this.toggleCollapsed}>
|
|
61
|
+
${this.loading ? html`<div class="title dots">🤔 Thinking</div>` : html`<div class="title">💡 Thought</div>
|
|
62
|
+
${this.collapsed ? html`<u-icon lib="internal" name="plus-lg"></u-icon>` : html`<u-icon lib="internal" name="dash-lg"></u-icon>`}`}
|
|
63
|
+
</div>
|
|
64
|
+
<div class="body scroll" ?collapsed=${!this.loading && this.collapsed}>
|
|
65
|
+
${this.value}
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
__decorateClass([
|
|
72
|
+
query(".body")
|
|
73
|
+
], UThinkBlock.prototype, "bodyEl");
|
|
74
|
+
__decorateClass([
|
|
75
|
+
property({ type: Boolean, reflect: true })
|
|
76
|
+
], UThinkBlock.prototype, "loading");
|
|
77
|
+
__decorateClass([
|
|
78
|
+
property({ type: Boolean })
|
|
79
|
+
], UThinkBlock.prototype, "collapsed");
|
|
80
|
+
__decorateClass([
|
|
81
|
+
property({ type: String })
|
|
82
|
+
], UThinkBlock.prototype, "value");
|
|
83
|
+
|
|
84
|
+
export { UThinkBlock };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import('lit').CSSResult;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
const styles = css`
|
|
4
|
+
:host {
|
|
5
|
+
--loading-rows: 3;
|
|
6
|
+
--max-rows: 10;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
:host {
|
|
10
|
+
display: block;
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: auto;
|
|
13
|
+
}
|
|
14
|
+
:host([loading]) .header {
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
cursor: wait;
|
|
17
|
+
}
|
|
18
|
+
:host([loading]) .body {
|
|
19
|
+
overflow: hidden !important;
|
|
20
|
+
max-height: calc(1.5em * var(--loading-rows) + 8px);
|
|
21
|
+
animation: pulse_action 1.5s infinite;
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
cursor: wait;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.container {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
width: 100%;
|
|
30
|
+
border: 1px solid var(--u-border-color);
|
|
31
|
+
border-radius: 8px;
|
|
32
|
+
font-size: 14px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.header {
|
|
36
|
+
width: 100%;
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: row;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: space-between;
|
|
41
|
+
padding: 8px;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
user-select: none;
|
|
44
|
+
}
|
|
45
|
+
.header .title {
|
|
46
|
+
flex: 1;
|
|
47
|
+
font-size: inherit;
|
|
48
|
+
font-weight: 600;
|
|
49
|
+
line-height: 1;
|
|
50
|
+
}
|
|
51
|
+
.header .title.dots::after {
|
|
52
|
+
content: '';
|
|
53
|
+
animation: dots_action 1.5s infinite;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.body {
|
|
57
|
+
overflow: auto;
|
|
58
|
+
padding: 8px;
|
|
59
|
+
max-height: calc(1.5em * var(--max-rows) + 8px);
|
|
60
|
+
font-size: inherit;
|
|
61
|
+
line-height: 1.5;
|
|
62
|
+
font-weight: 300;
|
|
63
|
+
border-bottom-left-radius: 8px;
|
|
64
|
+
border-bottom-right-radius: 8px;
|
|
65
|
+
transition: max-height 0.15s ease, padding 0.15s ease;
|
|
66
|
+
}
|
|
67
|
+
.body[collapsed] {
|
|
68
|
+
overflow: hidden !important;
|
|
69
|
+
padding: 0;
|
|
70
|
+
max-height: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@keyframes dots_action {
|
|
74
|
+
0%, 20% { content: ' '; }
|
|
75
|
+
40% { content: ' .'; }
|
|
76
|
+
60% { content: ' ..'; }
|
|
77
|
+
80%, 100% { content: ' ...'; }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@keyframes pulse_action {
|
|
81
|
+
0% {
|
|
82
|
+
box-shadow: inset 0px -20px 20px -15px rgb(0, 0, 0, 0.1);
|
|
83
|
+
}
|
|
84
|
+
50% {
|
|
85
|
+
box-shadow: inset 0px -20px 20px -15px rgb(0, 0, 0, 0.2);
|
|
86
|
+
}
|
|
87
|
+
100% {
|
|
88
|
+
box-shadow: inset 0px -20px 20px -15px rgb(0, 0, 0, 0.1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
`;
|
|
92
|
+
|
|
93
|
+
export { styles };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseElement } from '@iyulab/components/dist/components/BaseElement.js';
|
|
2
|
+
import { ToolBlockStatus } from '../message/UMessage.types.js';
|
|
3
|
+
export declare class UToolBlock extends BaseElement {
|
|
4
|
+
static styles: import('lit').CSSResultGroup[];
|
|
5
|
+
static dependencies: Record<string, typeof BaseElement>;
|
|
6
|
+
collapsed: boolean;
|
|
7
|
+
status: ToolBlockStatus;
|
|
8
|
+
index?: number;
|
|
9
|
+
name?: string;
|
|
10
|
+
input?: string;
|
|
11
|
+
output?: string;
|
|
12
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
13
|
+
private parseJson;
|
|
14
|
+
handleClickConfirm(): void;
|
|
15
|
+
handleClickDeny(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { nothing, html } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { BaseElement } from '@iyulab/components/dist/components/BaseElement.js';
|
|
4
|
+
import { UIcon } from '@iyulab/components/dist/components/icon/UIcon.component.js';
|
|
5
|
+
import { UTooltip } from '@iyulab/components/dist/components/tooltip/UTooltip.component.js';
|
|
6
|
+
import { UButton } from '@iyulab/components/dist/components/button/UButton.component.js';
|
|
7
|
+
import { USpinner } from '@iyulab/components/dist/components/spinner/USpinner.component.js';
|
|
8
|
+
import { UJsonViewer } from '../json-viewer/UJsonViewer.component.js';
|
|
9
|
+
import { styles } from './UToolBlock.styles.js';
|
|
10
|
+
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
13
|
+
var result = void 0 ;
|
|
14
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
15
|
+
if (decorator = decorators[i])
|
|
16
|
+
result = (decorator(target, key, result) ) || result;
|
|
17
|
+
if (result) __defProp(target, key, result);
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
class UToolBlock extends BaseElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.collapsed = true;
|
|
24
|
+
this.status = "pending";
|
|
25
|
+
}
|
|
26
|
+
static {
|
|
27
|
+
this.styles = [super.styles, styles];
|
|
28
|
+
}
|
|
29
|
+
static {
|
|
30
|
+
this.dependencies = {
|
|
31
|
+
"u-icon": UIcon,
|
|
32
|
+
"u-tooltip": UTooltip,
|
|
33
|
+
"u-button": UButton,
|
|
34
|
+
"u-spinner": USpinner,
|
|
35
|
+
"u-json-viewer": UJsonViewer
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
render() {
|
|
39
|
+
return html`
|
|
40
|
+
<div class="container">
|
|
41
|
+
<div class="header" @click=${() => this.collapsed = !this.collapsed}>
|
|
42
|
+
${this.status === "pending" || this.status === "paused" ? html`<u-icon lib="internal" name="eye"></u-icon>` : this.status === "inProgress" ? html`<u-spinner></u-spinner>` : this.status === "success" ? html`<u-icon lib="internal" name="check-lg"></u-icon>` : this.status === "failure" ? html`<u-icon lib="internal" name="x-lg"></u-icon>` : nothing}
|
|
43
|
+
<div class="display">
|
|
44
|
+
Tool Call [${this.name}]
|
|
45
|
+
</div>
|
|
46
|
+
<u-icon
|
|
47
|
+
lib="internal"
|
|
48
|
+
name=${this.collapsed ? "plus-lg" : "dash-lg"}
|
|
49
|
+
></u-icon>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<div class="body" ?hidden=${this.collapsed}>
|
|
53
|
+
<div class="viewer" ?hidden=${!this.input}>
|
|
54
|
+
<div class="label">
|
|
55
|
+
<u-icon lib="internal" name="chevron-right"></u-icon>
|
|
56
|
+
<u-tooltip placement="left">Input</u-tooltip>
|
|
57
|
+
</div>
|
|
58
|
+
<u-json-viewer
|
|
59
|
+
.value=${this.parseJson(this.input)}
|
|
60
|
+
></u-json-viewer>
|
|
61
|
+
</div>
|
|
62
|
+
<div class="viewer" ?hidden=${!this.output}>
|
|
63
|
+
<div class="label">
|
|
64
|
+
<u-icon lib="internal" name="chevron-right"></u-icon>
|
|
65
|
+
<u-tooltip placement="left">Output</u-tooltip>
|
|
66
|
+
</div>
|
|
67
|
+
<u-json-viewer
|
|
68
|
+
.value=${this.parseJson(this.output)}
|
|
69
|
+
></u-json-viewer>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<div class="footer" ?hidden=${this.status !== "paused"}>
|
|
74
|
+
<u-button @click=${this.handleClickConfirm}>
|
|
75
|
+
<u-icon slot="prefix" lib="internal" name="check-lg"></u-icon>
|
|
76
|
+
Confirm
|
|
77
|
+
</u-button>
|
|
78
|
+
<u-button @click=${this.handleClickDeny}>
|
|
79
|
+
<u-icon slot="prefix" lib="internal" name="x-lg"></u-icon>
|
|
80
|
+
Deny
|
|
81
|
+
</u-button>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
parseJson(value) {
|
|
87
|
+
if (!value || !value.trim()) return {};
|
|
88
|
+
try {
|
|
89
|
+
return JSON.parse(value);
|
|
90
|
+
} catch {
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
handleClickConfirm() {
|
|
95
|
+
this.emit("tool-approval", {
|
|
96
|
+
index: this.index,
|
|
97
|
+
isApproved: true
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
handleClickDeny() {
|
|
101
|
+
this.emit("tool-approval", {
|
|
102
|
+
index: this.index,
|
|
103
|
+
isApproved: false
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
__decorateClass([
|
|
108
|
+
property({ type: Boolean, reflect: true })
|
|
109
|
+
], UToolBlock.prototype, "collapsed");
|
|
110
|
+
__decorateClass([
|
|
111
|
+
property({ type: String })
|
|
112
|
+
], UToolBlock.prototype, "status");
|
|
113
|
+
__decorateClass([
|
|
114
|
+
property({ type: Number })
|
|
115
|
+
], UToolBlock.prototype, "index");
|
|
116
|
+
__decorateClass([
|
|
117
|
+
property({ type: String })
|
|
118
|
+
], UToolBlock.prototype, "name");
|
|
119
|
+
__decorateClass([
|
|
120
|
+
property({ type: String })
|
|
121
|
+
], UToolBlock.prototype, "input");
|
|
122
|
+
__decorateClass([
|
|
123
|
+
property({ type: String })
|
|
124
|
+
], UToolBlock.prototype, "output");
|
|
125
|
+
|
|
126
|
+
export { UToolBlock };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import('lit').CSSResult;
|