@iyulab/chat-components 0.1.1 → 0.2.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 (109) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/dist/components/blocks/UCodeBlock.component.d.ts +7 -8
  3. package/dist/components/blocks/UCodeBlock.component.js +32 -21
  4. package/dist/components/blocks/UCodeBlock.styles.js +7 -6
  5. package/dist/components/{json-viewer/UJsonViewer.component.d.ts → blocks/UJsonBlock.component.d.ts} +5 -4
  6. package/dist/components/{json-viewer/UJsonViewer.component.js → blocks/UJsonBlock.component.js} +20 -17
  7. package/dist/components/blocks/UJsonBlock.d.ts +7 -0
  8. package/dist/components/blocks/UJsonBlock.js +5 -0
  9. package/dist/components/blocks/UMarkedBlock.component.d.ts +30 -9
  10. package/dist/components/blocks/UMarkedBlock.component.js +75 -26
  11. package/dist/components/blocks/UMarkedBlock.styles.js +288 -949
  12. package/dist/components/blocks/UThinkBlock.component.d.ts +3 -8
  13. package/dist/components/blocks/UThinkBlock.component.js +28 -22
  14. package/dist/components/blocks/UThinkBlock.styles.js +35 -54
  15. package/dist/components/blocks/UToolBlock.component.d.ts +13 -9
  16. package/dist/components/blocks/UToolBlock.component.js +30 -76
  17. package/dist/components/blocks/UToolBlock.styles.js +21 -62
  18. package/dist/components/buttons/UAttachButton.component.d.ts +3 -5
  19. package/dist/components/buttons/UAttachButton.component.js +30 -19
  20. package/dist/components/buttons/UAttachButton.styles.js +5 -12
  21. package/dist/components/buttons/UCopyButton.component.d.ts +3 -8
  22. package/dist/components/buttons/UCopyButton.component.js +29 -53
  23. package/dist/components/buttons/UCopyButton.styles.js +8 -37
  24. package/dist/components/buttons/UReportButton.component.d.ts +9 -0
  25. package/dist/components/buttons/UReportButton.component.js +36 -0
  26. package/dist/components/buttons/UReportButton.d.ts +7 -0
  27. package/dist/components/buttons/UReportButton.js +5 -0
  28. package/dist/components/buttons/UReportButton.styles.js +14 -0
  29. package/dist/components/buttons/URetryButton.component.d.ts +11 -0
  30. package/dist/components/buttons/URetryButton.component.js +53 -0
  31. package/dist/components/buttons/URetryButton.d.ts +7 -0
  32. package/dist/components/buttons/URetryButton.js +5 -0
  33. package/dist/components/buttons/URetryButton.styles.js +26 -0
  34. package/dist/components/buttons/UShareButton.component.d.ts +9 -0
  35. package/dist/components/buttons/UShareButton.component.js +36 -0
  36. package/dist/components/buttons/UShareButton.d.ts +7 -0
  37. package/dist/components/buttons/UShareButton.js +5 -0
  38. package/dist/components/buttons/UShareButton.styles.d.ts +1 -0
  39. package/dist/components/buttons/UShareButton.styles.js +14 -0
  40. package/dist/components/buttons/UVoteButton.component.d.ts +15 -0
  41. package/dist/components/buttons/UVoteButton.component.js +70 -0
  42. package/dist/components/buttons/UVoteButton.d.ts +8 -0
  43. package/dist/components/buttons/UVoteButton.js +5 -0
  44. package/dist/components/buttons/UVoteButton.styles.d.ts +1 -0
  45. package/dist/components/buttons/UVoteButton.styles.js +19 -0
  46. package/dist/components/loaders/UDotLoader.component.d.ts +9 -0
  47. package/dist/components/loaders/UDotLoader.component.js +23 -0
  48. package/dist/components/loaders/UDotLoader.d.ts +7 -0
  49. package/dist/components/loaders/UDotLoader.js +5 -0
  50. package/dist/components/loaders/UDotLoader.styles.d.ts +1 -0
  51. package/dist/components/loaders/UDotLoader.styles.js +50 -0
  52. package/dist/components/message/UMessage.component.d.ts +12 -6
  53. package/dist/components/message/UMessage.component.js +39 -59
  54. package/dist/components/message/UMessage.d.ts +0 -1
  55. package/dist/components/message/UMessage.styles.js +30 -49
  56. package/dist/components/prompt/UPrompt.component.d.ts +25 -0
  57. package/dist/components/prompt/UPrompt.component.js +113 -0
  58. package/dist/components/prompt/UPrompt.d.ts +7 -0
  59. package/dist/components/prompt/UPrompt.js +5 -0
  60. package/dist/components/prompt/UPrompt.styles.d.ts +1 -0
  61. package/dist/components/prompt/UPrompt.styles.js +42 -0
  62. package/dist/components/references/URefCard.component.d.ts +22 -0
  63. package/dist/components/references/URefCard.component.js +96 -0
  64. package/dist/components/references/URefCard.d.ts +7 -0
  65. package/dist/components/references/URefCard.js +5 -0
  66. package/dist/components/references/URefCard.styles.d.ts +1 -0
  67. package/dist/components/references/URefCard.styles.js +103 -0
  68. package/dist/components/references/URefCardGroup.component.d.ts +25 -0
  69. package/dist/components/references/URefCardGroup.component.js +88 -0
  70. package/dist/components/references/URefCardGroup.d.ts +7 -0
  71. package/dist/components/references/URefCardGroup.js +5 -0
  72. package/dist/components/references/URefCardGroup.styles.d.ts +1 -0
  73. package/dist/components/references/URefCardGroup.styles.js +69 -0
  74. package/dist/components/references/URefTag.component.d.ts +11 -0
  75. package/dist/components/{buttons/USendButton.component.js → references/URefTag.component.js} +17 -14
  76. package/dist/components/references/URefTag.d.ts +7 -0
  77. package/dist/components/references/URefTag.js +5 -0
  78. package/dist/components/references/URefTag.styles.d.ts +1 -0
  79. package/dist/components/references/URefTag.styles.js +51 -0
  80. package/dist/events/UCancelEvent.d.ts +6 -0
  81. package/dist/index.d.ts +15 -5
  82. package/dist/index.js +20 -6
  83. package/dist/types/BlockItem.d.ts +36 -0
  84. package/dist/types/BlockReference.d.ts +32 -0
  85. package/dist/types/JsonNode.d.ts +20 -0
  86. package/dist/utilities/converters.d.ts +9 -0
  87. package/dist/utilities/converters.js +19 -0
  88. package/package.json +9 -10
  89. package/dist/components/buttons/USendButton.component.d.ts +0 -13
  90. package/dist/components/buttons/USendButton.d.ts +0 -7
  91. package/dist/components/buttons/USendButton.js +0 -5
  92. package/dist/components/buttons/USendButton.styles.js +0 -23
  93. package/dist/components/buttons/UThinkButton.component.d.ts +0 -19
  94. package/dist/components/buttons/UThinkButton.component.js +0 -73
  95. package/dist/components/buttons/UThinkButton.d.ts +0 -7
  96. package/dist/components/buttons/UThinkButton.js +0 -5
  97. package/dist/components/buttons/UThinkButton.styles.js +0 -72
  98. package/dist/components/json-viewer/UJsonViewer.d.ts +0 -7
  99. package/dist/components/json-viewer/UJsonViewer.js +0 -5
  100. package/dist/components/json-viewer/UJsonViewer.lib.d.ts +0 -16
  101. package/dist/components/json-viewer/UJsonViewer.lib.js +0 -28
  102. package/dist/components/message/UMessage.types.d.ts +0 -21
  103. package/dist/events/UStopEvent.d.ts +0 -6
  104. package/dist/internals/date-helpers.d.ts +0 -8
  105. package/dist/internals/date-helpers.js +0 -27
  106. /package/dist/components/{buttons/USendButton.styles.d.ts → blocks/UJsonBlock.styles.d.ts} +0 -0
  107. /package/dist/components/{json-viewer/UJsonViewer.styles.js → blocks/UJsonBlock.styles.js} +0 -0
  108. /package/dist/components/buttons/{UThinkButton.styles.d.ts → UReportButton.styles.d.ts} +0 -0
  109. /package/dist/components/{json-viewer/UJsonViewer.styles.d.ts → buttons/URetryButton.styles.d.ts} +0 -0
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.1.1",
4
+ "version": "0.2.0",
5
5
  "author": "iyulab",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -41,25 +41,24 @@
41
41
  "build": "eslint && vite build"
42
42
  },
43
43
  "dependencies": {
44
- "@iyulab/components": "0.1.10",
44
+ "@iyulab/components": "0.2.0",
45
45
  "dompurify": "^3.3.1",
46
46
  "highlight.js": "^11.11.1",
47
- "lit": "^3.3.1",
47
+ "lit": "^3.3.2",
48
48
  "marked": "^17.0.1",
49
- "marked-alert": "^2.1.2",
50
- "marked-footnote": "^1.4.0",
51
49
  "marked-katex-extension": "^5.1.6"
52
50
  },
53
51
  "devDependencies": {
54
- "@lit/react": "^1.0.8",
55
52
  "@eslint/js": "^9.39.2",
56
- "@types/node": "^25.0.3",
53
+ "@lit/react": "^1.0.8",
54
+ "@types/node": "^25.0.9",
57
55
  "eslint": "^9.39.2",
58
56
  "eslint-plugin-lit": "^2.1.1",
59
- "globals": "^16.5.0",
57
+ "globals": "^17.0.0",
58
+ "openai": "^6.16.0",
60
59
  "typescript": "^5.9.3",
61
- "typescript-eslint": "^8.50.0",
62
- "vite": "^7.3.0",
60
+ "typescript-eslint": "^8.53.0",
61
+ "vite": "^7.3.1",
63
62
  "vite-plugin-dts": "^4.5.4"
64
63
  }
65
64
  }
@@ -1,13 +0,0 @@
1
- import { BaseElement } from '@iyulab/components/dist/components/BaseElement.js';
2
- /**
3
- * 메시지 전송/중단 버튼 컴포넌트입니다.
4
- */
5
- export declare class USendButton extends BaseElement {
6
- static styles: import('lit').CSSResultGroup[];
7
- static dependencies: Record<string, typeof BaseElement>;
8
- /** 로딩 상태 (로딩 중일 때 중단 버튼으로 변경됨) */
9
- mode: "send" | "stop" | "retry";
10
- /** 비활성화 상태 */
11
- disabled: boolean;
12
- render(): import('lit-html').TemplateResult<1>;
13
- }
@@ -1,7 +0,0 @@
1
- import { USendButton } from './USendButton.component.js';
2
- declare global {
3
- interface HTMLElementTagNameMap {
4
- "u-send-button": USendButton;
5
- }
6
- }
7
- export { USendButton };
@@ -1,5 +0,0 @@
1
- import { USendButton } from './USendButton.component.js';
2
-
3
- USendButton.define("u-send-button");
4
-
5
- export { USendButton };
@@ -1,23 +0,0 @@
1
- import { css } from 'lit';
2
-
3
- const styles = css`
4
- :host {
5
- display: inline-flex;
6
- padding: 8px;
7
- border: none;
8
- border-radius: 8px;
9
- font-size: 16px;
10
- border: 1px solid var(--u-border-color, #d1d5db);
11
- background-color: var(--u-neutral-200, #e5e7eb);
12
- cursor: pointer;
13
- }
14
- :host(:hover) {
15
- background-color: var(--u-neutral-300, #d1d5db);
16
- }
17
- :host([disabled]) {
18
- pointer-events: none;
19
- opacity: 0.5;
20
- }
21
- `;
22
-
23
- export { styles };
@@ -1,19 +0,0 @@
1
- import { BaseElement } from '@iyulab/components/dist/components/BaseElement.js';
2
- export type ThinkingValue = "low" | "medium" | "high" | "none";
3
- /**
4
- * 모델이 추론을 사용하고자 할 때 사용하는 버튼입니다.
5
- */
6
- export declare class UThinkButton extends BaseElement {
7
- static styles: import('lit').CSSResultGroup[];
8
- static dependencies: Record<string, typeof BaseElement>;
9
- private readonly states;
10
- /** 비활성화 상태 */
11
- disabled: boolean;
12
- /** 추론 활성화 값 */
13
- value: ThinkingValue;
14
- render(): import('lit-html').TemplateResult<1>;
15
- /** 현재 추론 상태에 따라 아이콘 이름을 반환합니다. */
16
- private getIconName;
17
- /** 현재 추론 상태를 변경합니다. */
18
- private changeValue;
19
- }
@@ -1,73 +0,0 @@
1
- import { 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 { styles } from './UThinkButton.styles.js';
6
-
7
- var __defProp = Object.defineProperty;
8
- var __decorateClass = (decorators, target, key, kind) => {
9
- var result = void 0 ;
10
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
11
- if (decorator = decorators[i])
12
- result = (decorator(target, key, result) ) || result;
13
- if (result) __defProp(target, key, result);
14
- return result;
15
- };
16
- class UThinkButton extends BaseElement {
17
- constructor() {
18
- super(...arguments);
19
- this.states = ["none", "low", "medium", "high"];
20
- this.disabled = false;
21
- this.value = "none";
22
- }
23
- static {
24
- this.styles = [super.styles, styles];
25
- }
26
- static {
27
- this.dependencies = {
28
- "u-icon": UIcon
29
- };
30
- }
31
- render() {
32
- return html`
33
- <div class="container" @click="${this.changeValue}">
34
- <u-icon lib="internal" name=${this.getIconName()}></u-icon>
35
- <div class="indicators">
36
- <span></span>
37
- <span></span>
38
- <span></span>
39
- </div>
40
- </div>
41
- `;
42
- }
43
- /** 현재 추론 상태에 따라 아이콘 이름을 반환합니다. */
44
- getIconName() {
45
- switch (this.value) {
46
- case "low":
47
- return "lightbulb";
48
- case "medium":
49
- return "lightbulb";
50
- case "high":
51
- return "lightbulb-fill";
52
- default:
53
- return "lightbulb-off";
54
- }
55
- }
56
- /** 현재 추론 상태를 변경합니다. */
57
- changeValue() {
58
- if (this.disabled) return;
59
- this.value ||= "none";
60
- const currentIdx = this.states.indexOf(this.value);
61
- const nextIdx = (currentIdx + 1) % this.states.length;
62
- this.value = this.states[nextIdx];
63
- this.emit("change", this.value);
64
- }
65
- }
66
- __decorateClass([
67
- property({ type: Boolean, reflect: true })
68
- ], UThinkButton.prototype, "disabled");
69
- __decorateClass([
70
- property({ type: String, reflect: true })
71
- ], UThinkButton.prototype, "value");
72
-
73
- export { UThinkButton };
@@ -1,7 +0,0 @@
1
- import { UThinkButton } from './UThinkButton.component.js';
2
- declare global {
3
- interface HTMLElementTagNameMap {
4
- "u-think-button": UThinkButton;
5
- }
6
- }
7
- export { UThinkButton };
@@ -1,5 +0,0 @@
1
- import { UThinkButton } from './UThinkButton.component.js';
2
-
3
- UThinkButton.define("u-think-button");
4
-
5
- export { UThinkButton };
@@ -1,72 +0,0 @@
1
- import { css } from 'lit';
2
-
3
- const styles = css`
4
- :host {
5
- position: relative;
6
- padding: 8px;
7
- font-size: 16px;
8
- border-radius: 8px;
9
- cursor: pointer;
10
- user-select: none;
11
- }
12
- :host(:hover) {
13
- background-color: var(--u-neutral-100);
14
- }
15
- :host([disabled]) {
16
- opacity: 0.5;
17
- pointer-events: none;
18
- background-color: transparent;
19
- cursor: not-allowed;
20
- }
21
- /* u-icon 스타일 */
22
- :host([value="low"]) u-icon {
23
- filter: brightness(0.8);
24
- color: var(--u-yellow-700);
25
- }
26
- :host([value="medium"]) u-icon {
27
- color: var(--u-yellow-700);
28
- }
29
- :host([value="high"]) u-icon {
30
- color: var(--u-yellow-700);
31
- }
32
- /* indicators 스타일 */
33
- :host([value="low"]) .indicators > span:last-child {
34
- background-color: var(--u-yellow-700);
35
- }
36
- :host([value="medium"]) .indicators > span:nth-last-child(-n+2) {
37
- background-color: var(--u-yellow-700);
38
- }
39
- :host([value="high"]) .indicators > span {
40
- background-color: var(--u-yellow-700);
41
- }
42
-
43
- .container {
44
- display: flex;
45
- flex-direction: row;
46
- align-items: center;
47
- gap: 4px;
48
- }
49
-
50
- u-icon {
51
- font-size: inherit;
52
- color: #e0e0e0;
53
- transition: color 0.3s ease, filter 0.3s ease;
54
- }
55
-
56
- .indicators {
57
- height: 1em;
58
- display: flex;
59
- flex-direction: column;
60
- align-items: center;
61
- justify-content: space-between;
62
- }
63
- .indicators > span {
64
- width: 0.5em;
65
- height: 0.2em;
66
- border-radius: 2px;
67
- background-color: #e0e0e0;
68
- transition: background-color 0.3s ease;
69
- }
70
- `;
71
-
72
- export { styles };
@@ -1,7 +0,0 @@
1
- import { UJsonViewer } from './UJsonViewer.component.js';
2
- declare global {
3
- interface HTMLElementTagNameMap {
4
- 'u-json-viewer': UJsonViewer;
5
- }
6
- }
7
- export { UJsonViewer };
@@ -1,5 +0,0 @@
1
- import { UJsonViewer } from './UJsonViewer.component.js';
2
-
3
- UJsonViewer.define("u-json-viewer");
4
-
5
- export { UJsonViewer };
@@ -1,16 +0,0 @@
1
- export type JsonValue = string | number | boolean | null;
2
- export type JsonObject = {
3
- [x: string]: JsonNode;
4
- };
5
- export type JsonArray = Array<JsonNode>;
6
- export type JsonNode = JsonValue | JsonObject | JsonArray;
7
- /**
8
- * 이 컨버터는 JsonNode 타입을 사용하여 JSON 데이터를 처리합니다.
9
- * 문자열 어트리뷰트로 전달된 JSON 문자열을 객체로 변환/직렬화합니다.
10
- */
11
- export declare const jsonConverter: {
12
- fromAttribute: (value: string | null) => JsonNode;
13
- toAttribute: (value: JsonNode) => string;
14
- };
15
- export declare const isValueType: (value: JsonNode) => boolean;
16
- export declare const getNodeName: (value: JsonNode) => string;
@@ -1,28 +0,0 @@
1
- const jsonConverter = {
2
- fromAttribute: (value) => {
3
- if (!value || !value.trim()) return {};
4
- try {
5
- return JSON.parse(value);
6
- } catch {
7
- return {};
8
- }
9
- },
10
- toAttribute: (value) => {
11
- try {
12
- return JSON.stringify(value);
13
- } catch {
14
- return "{}";
15
- }
16
- }
17
- };
18
- const isValueType = (value) => {
19
- return value !== Object(value);
20
- };
21
- const getNodeName = (value) => {
22
- if (value === null) return "null";
23
- if (Array.isArray(value)) return "array";
24
- if (typeof value === "object") return "object";
25
- return typeof value;
26
- };
27
-
28
- export { getNodeName, isValueType, jsonConverter };
@@ -1,21 +0,0 @@
1
- export interface TextBlockItem {
2
- type: "text";
3
- value?: string;
4
- }
5
- export interface MarkdownBlockItem {
6
- type: "markdown";
7
- value?: string;
8
- }
9
- export interface ThinkingBlockItem {
10
- type: "thinking";
11
- value?: string;
12
- }
13
- export type ToolBlockStatus = ("pending" | "paused" | "inProgress" | "success" | "failure");
14
- export interface ToolBlockItem {
15
- type: "tool";
16
- status: ToolBlockStatus;
17
- name?: string;
18
- input?: string;
19
- output?: string;
20
- }
21
- export type BlockItem = (TextBlockItem | MarkdownBlockItem | ThinkingBlockItem | ToolBlockItem);
@@ -1,6 +0,0 @@
1
- export type UStopEvent = CustomEvent<undefined>;
2
- declare global {
3
- interface HTMLElementEventMap {
4
- 'u-stop': UStopEvent;
5
- }
6
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * 문자열 날짜를 현지 시간으로 비교하여 시간 경과를 표시합니다.
3
- */
4
- export declare const since: (value?: string) => string;
5
- /**
6
- * 문자열 날짜를 현지 시간으로 기본 포맷
7
- */
8
- export declare const format: (value?: string, options?: Intl.DateTimeFormatOptions) => string;
@@ -1,27 +0,0 @@
1
- const format = (value, options) => {
2
- if (!value) return "";
3
- const today = /* @__PURE__ */ new Date();
4
- const locale = navigator.language;
5
- const defaultOptions = {
6
- year: "numeric",
7
- month: "2-digit",
8
- day: "2-digit",
9
- hour: "2-digit",
10
- minute: "2-digit"
11
- };
12
- let date = new Date(value);
13
- const offset = value.endsWith("Z") ? 0 : date.getTimezoneOffset() * 60 * 1e3;
14
- date = new Date(date.getTime() - offset);
15
- if (date.getFullYear() === today.getFullYear() && date.getMonth() === today.getMonth() && date.getDate() === today.getDate()) {
16
- const timeFormatter = new Intl.DateTimeFormat(locale, {
17
- hour: "2-digit",
18
- minute: "2-digit"
19
- });
20
- return timeFormatter.format(date);
21
- } else {
22
- const formatter = new Intl.DateTimeFormat(locale, { ...defaultOptions, ...options });
23
- return formatter.format(date);
24
- }
25
- };
26
-
27
- export { format };