@iyulab/chat-components 0.1.1 → 0.3.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 (115) hide show
  1. package/CHANGELOG.md +31 -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/URefBlock.component.d.ts +17 -0
  13. package/dist/components/blocks/URefBlock.component.js +74 -0
  14. package/dist/components/blocks/URefBlock.d.ts +7 -0
  15. package/dist/components/blocks/URefBlock.js +5 -0
  16. package/dist/components/blocks/URefBlock.styles.js +75 -0
  17. package/dist/components/blocks/UThinkBlock.component.d.ts +3 -8
  18. package/dist/components/blocks/UThinkBlock.component.js +28 -22
  19. package/dist/components/blocks/UThinkBlock.styles.js +35 -54
  20. package/dist/components/blocks/UToolBlock.component.d.ts +13 -9
  21. package/dist/components/blocks/UToolBlock.component.js +30 -76
  22. package/dist/components/blocks/UToolBlock.styles.js +21 -62
  23. package/dist/components/buttons/UAttachButton.component.d.ts +3 -5
  24. package/dist/components/buttons/UAttachButton.component.js +30 -19
  25. package/dist/components/buttons/UAttachButton.styles.js +5 -12
  26. package/dist/components/buttons/UCopyButton.component.d.ts +3 -8
  27. package/dist/components/buttons/UCopyButton.component.js +29 -53
  28. package/dist/components/buttons/UCopyButton.styles.js +8 -37
  29. package/dist/components/buttons/UReportButton.component.d.ts +9 -0
  30. package/dist/components/buttons/UReportButton.component.js +36 -0
  31. package/dist/components/buttons/UReportButton.d.ts +7 -0
  32. package/dist/components/buttons/UReportButton.js +5 -0
  33. package/dist/components/buttons/UReportButton.styles.js +14 -0
  34. package/dist/components/buttons/URetryButton.component.d.ts +11 -0
  35. package/dist/components/buttons/{USendButton.component.js → URetryButton.component.js} +21 -14
  36. package/dist/components/buttons/URetryButton.d.ts +7 -0
  37. package/dist/components/buttons/URetryButton.js +5 -0
  38. package/dist/components/buttons/URetryButton.styles.d.ts +1 -0
  39. package/dist/components/buttons/URetryButton.styles.js +26 -0
  40. package/dist/components/buttons/UShareButton.component.d.ts +9 -0
  41. package/dist/components/buttons/UShareButton.component.js +36 -0
  42. package/dist/components/buttons/UShareButton.d.ts +7 -0
  43. package/dist/components/buttons/UShareButton.js +5 -0
  44. package/dist/components/buttons/UShareButton.styles.d.ts +1 -0
  45. package/dist/components/buttons/UShareButton.styles.js +14 -0
  46. package/dist/components/buttons/UVoteButton.component.d.ts +15 -0
  47. package/dist/components/buttons/UVoteButton.component.js +70 -0
  48. package/dist/components/buttons/UVoteButton.d.ts +8 -0
  49. package/dist/components/buttons/UVoteButton.js +5 -0
  50. package/dist/components/buttons/UVoteButton.styles.d.ts +1 -0
  51. package/dist/components/buttons/UVoteButton.styles.js +19 -0
  52. package/dist/components/loaders/UDotLoader.component.d.ts +9 -0
  53. package/dist/components/loaders/UDotLoader.component.js +23 -0
  54. package/dist/components/loaders/UDotLoader.d.ts +7 -0
  55. package/dist/components/loaders/UDotLoader.js +5 -0
  56. package/dist/components/loaders/UDotLoader.styles.d.ts +1 -0
  57. package/dist/components/loaders/UDotLoader.styles.js +50 -0
  58. package/dist/components/message/UMessage.component.d.ts +12 -6
  59. package/dist/components/message/UMessage.component.js +45 -59
  60. package/dist/components/message/UMessage.d.ts +0 -1
  61. package/dist/components/message/UMessage.styles.js +30 -49
  62. package/dist/components/prompt/UPrompt.component.d.ts +25 -0
  63. package/dist/components/prompt/UPrompt.component.js +113 -0
  64. package/dist/components/prompt/UPrompt.d.ts +7 -0
  65. package/dist/components/prompt/UPrompt.js +5 -0
  66. package/dist/components/prompt/UPrompt.styles.d.ts +1 -0
  67. package/dist/components/prompt/UPrompt.styles.js +42 -0
  68. package/dist/components/references/URefCard.component.d.ts +24 -0
  69. package/dist/components/references/URefCard.component.js +105 -0
  70. package/dist/components/references/URefCard.d.ts +7 -0
  71. package/dist/components/references/URefCard.js +5 -0
  72. package/dist/components/references/URefCard.styles.d.ts +1 -0
  73. package/dist/components/references/URefCard.styles.js +103 -0
  74. package/dist/components/references/URefCardGroup.component.d.ts +25 -0
  75. package/dist/components/references/URefCardGroup.component.js +88 -0
  76. package/dist/components/references/URefCardGroup.d.ts +7 -0
  77. package/dist/components/references/URefCardGroup.js +5 -0
  78. package/dist/components/references/URefCardGroup.styles.d.ts +1 -0
  79. package/dist/components/references/URefCardGroup.styles.js +69 -0
  80. package/dist/components/references/URefTag.component.d.ts +13 -0
  81. package/dist/components/references/URefTag.component.js +54 -0
  82. package/dist/components/references/URefTag.d.ts +7 -0
  83. package/dist/components/references/URefTag.js +5 -0
  84. package/dist/components/references/URefTag.styles.d.ts +1 -0
  85. package/dist/components/references/URefTag.styles.js +51 -0
  86. package/dist/events/UCancelEvent.d.ts +6 -0
  87. package/dist/index.d.ts +16 -5
  88. package/dist/index.js +25 -9
  89. package/dist/types/BlockItem.d.ts +42 -0
  90. package/dist/types/JsonNode.d.ts +20 -0
  91. package/dist/types/References.d.ts +28 -0
  92. package/dist/utilities/converters.d.ts +9 -0
  93. package/dist/utilities/converters.js +19 -0
  94. package/package.json +10 -11
  95. package/dist/components/buttons/USendButton.component.d.ts +0 -13
  96. package/dist/components/buttons/USendButton.d.ts +0 -7
  97. package/dist/components/buttons/USendButton.js +0 -5
  98. package/dist/components/buttons/USendButton.styles.js +0 -23
  99. package/dist/components/buttons/UThinkButton.component.d.ts +0 -19
  100. package/dist/components/buttons/UThinkButton.component.js +0 -73
  101. package/dist/components/buttons/UThinkButton.d.ts +0 -7
  102. package/dist/components/buttons/UThinkButton.js +0 -5
  103. package/dist/components/buttons/UThinkButton.styles.js +0 -72
  104. package/dist/components/json-viewer/UJsonViewer.d.ts +0 -7
  105. package/dist/components/json-viewer/UJsonViewer.js +0 -5
  106. package/dist/components/json-viewer/UJsonViewer.lib.d.ts +0 -16
  107. package/dist/components/json-viewer/UJsonViewer.lib.js +0 -28
  108. package/dist/components/message/UMessage.types.d.ts +0 -21
  109. package/dist/events/UStopEvent.d.ts +0 -6
  110. package/dist/internals/date-helpers.d.ts +0 -8
  111. package/dist/internals/date-helpers.js +0 -27
  112. /package/dist/components/{buttons/USendButton.styles.d.ts → blocks/UJsonBlock.styles.d.ts} +0 -0
  113. /package/dist/components/{json-viewer/UJsonViewer.styles.js → blocks/UJsonBlock.styles.js} +0 -0
  114. /package/dist/components/{buttons/UThinkButton.styles.d.ts → blocks/URefBlock.styles.d.ts} +0 -0
  115. /package/dist/components/{json-viewer/UJsonViewer.styles.d.ts → buttons/UReportButton.styles.d.ts} +0 -0
@@ -0,0 +1,113 @@
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 { 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 BaseElement {
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 };
@@ -0,0 +1,7 @@
1
+ import { UPrompt } from './UPrompt.component.js';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ "u-prompt": UPrompt;
5
+ }
6
+ }
7
+ export { UPrompt };
@@ -0,0 +1,5 @@
1
+ import { UPrompt } from './UPrompt.component.js';
2
+
3
+ UPrompt.define("u-prompt");
4
+
5
+ export { UPrompt };
@@ -0,0 +1 @@
1
+ export declare const styles: import('lit').CSSResult;
@@ -0,0 +1,42 @@
1
+ import { css } from 'lit';
2
+
3
+ const styles = css`
4
+ :host {
5
+ display: flex;
6
+ flex-direction: column;
7
+ padding: 12px;
8
+ border: 1px solid var(--u-border-color, #e0e0e0);
9
+ border-radius: 8px;
10
+ background-color: var(--u-bg-color);
11
+ }
12
+ :host(:focus-within) {
13
+ outline: none;
14
+ border-color: var(--u-neutral-400, #9ca3af);
15
+ box-shadow: 0 0 0 1px var(--u-neutral-200, #9ca3af);
16
+ }
17
+
18
+ u-text-block {
19
+ flex: 1;
20
+ padding: 8px;
21
+ }
22
+
23
+ .control {
24
+ display: flex;
25
+ flex-direction: row;
26
+ align-items: center;
27
+ justify-content: space-between;
28
+ gap: 8px;
29
+ }
30
+
31
+ .send-btn {
32
+ font-size: 16px;
33
+ color: var(--u-neutral-0);
34
+ background-color: var(--u-neutral-800);
35
+ }
36
+ .send-btn[disabled] {
37
+ opacity: 0.5;
38
+ cursor: not-allowed;
39
+ }
40
+ `;
41
+
42
+ export { styles };
@@ -0,0 +1,24 @@
1
+ import { BaseElement } from '@iyulab/components/dist/components/BaseElement.js';
2
+ /**
3
+ * 참조 소스를 카드 형태로 표시하는 공통 컴포넌트입니다.
4
+ * Web과 Document 타입 모두 지원합니다.
5
+ */
6
+ export declare class URefCard extends BaseElement {
7
+ static styles: import('lit').CSSResultGroup[];
8
+ static dependencies: Record<string, typeof BaseElement>;
9
+ /** 카드 타입 (web 또는 document) */
10
+ type: 'web' | 'document';
11
+ /** 외부 링크 URL */
12
+ href?: string;
13
+ /** 카드 타이틀 */
14
+ heading?: string;
15
+ /** 태그 목록 */
16
+ tags?: string[];
17
+ render(): import('lit-html').TemplateResult<1>;
18
+ /** 링크 클릭 핸들러 */
19
+ private handleAnchorClick;
20
+ /** URL에서 Google의 파비콘 URL을 반환합니다. */
21
+ private getFaviconUrl;
22
+ /** URL에서 도메인 사이트 주소를 반환합니다. */
23
+ private getDomainName;
24
+ }
@@ -0,0 +1,105 @@
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 { BaseElement } from '@iyulab/components/dist/components/BaseElement.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 BaseElement {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.type = "web";
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
+ <a href="${ifDefined(this.href)}" target="_blank" rel="noopener noreferrer"
34
+ @click=${this.handleAnchorClick}>
35
+ <div class="header">
36
+ <img class="favicon"
37
+ src="${this.getFaviconUrl(this.href)}"
38
+ alt="favicon"
39
+ />
40
+ <div class="title" title="${ifDefined(this.heading)}">
41
+ ${this.heading || this.getDomainName(this.href)}
42
+ </div>
43
+
44
+ <div style="flex: 1;"></div>
45
+
46
+ <div class="badge" type=${this.type}>
47
+ <u-icon
48
+ lib="internal"
49
+ name=${this.type === "web" ? "globe" : "file-earmark"}
50
+ ></u-icon>
51
+ ${this.type.toUpperCase()}
52
+ </div>
53
+ </div>
54
+
55
+ <div class="body">
56
+ <slot></slot>
57
+ </div>
58
+
59
+ <div class="footer" ?hidden=${!this.tags || this.tags.length === 0}>
60
+ ${this.tags?.map((tag) => html`<span class="tag">${tag}</span>`)}
61
+ </div>
62
+ </a>
63
+ `;
64
+ }
65
+ /** 링크 클릭 핸들러 */
66
+ handleAnchorClick(e) {
67
+ if (!this.href) {
68
+ e.preventDefault();
69
+ e.stopPropagation();
70
+ }
71
+ }
72
+ /** URL에서 Google의 파비콘 URL을 반환합니다. */
73
+ getFaviconUrl(url) {
74
+ if (!url) return `/favicon.ico`;
75
+ try {
76
+ const hostname = new URL(url).hostname;
77
+ return `https://www.google.com/s2/favicons?sz=64&domain=${hostname}`;
78
+ } catch {
79
+ return `/favicon.ico`;
80
+ }
81
+ }
82
+ /** URL에서 도메인 사이트 주소를 반환합니다. */
83
+ getDomainName(url) {
84
+ if (!url) return "";
85
+ try {
86
+ return new URL(url).hostname;
87
+ } catch {
88
+ return "";
89
+ }
90
+ }
91
+ }
92
+ __decorateClass([
93
+ property({ type: String, reflect: true })
94
+ ], URefCard.prototype, "type");
95
+ __decorateClass([
96
+ property({ type: String })
97
+ ], URefCard.prototype, "href");
98
+ __decorateClass([
99
+ property({ type: String })
100
+ ], URefCard.prototype, "heading");
101
+ __decorateClass([
102
+ property({ type: Array, converter: arrayAttrConverter((v) => v) })
103
+ ], URefCard.prototype, "tags");
104
+
105
+ export { URefCard };
@@ -0,0 +1,7 @@
1
+ import { URefCard } from './URefCard.component.js';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ "u-ref-card": URefCard;
5
+ }
6
+ }
7
+ export { URefCard };
@@ -0,0 +1,5 @@
1
+ import { URefCard } from './URefCard.component.js';
2
+
3
+ URefCard.define("u-ref-card");
4
+
5
+ export { URefCard };
@@ -0,0 +1 @@
1
+ export declare const styles: import('lit').CSSResult;
@@ -0,0 +1,103 @@
1
+ import { css } from 'lit';
2
+
3
+ const styles = css`
4
+ :host {
5
+ display: block;
6
+ width: 380px;
7
+ padding: 6px;
8
+ border: 1px solid var(--u-border-color);
9
+ border-radius: 8px;
10
+ background: var(--u-panel-bg-color);
11
+ }
12
+
13
+ a {
14
+ display: flex;
15
+ flex-direction: column;
16
+ padding: 6px;
17
+ color: inherit;
18
+ text-decoration: none;
19
+ transition: all 0.2s ease;
20
+ }
21
+ a:hover {
22
+ color: var(--u-blue-600);
23
+ background-color: var(--u-neutral-50);
24
+ }
25
+
26
+ .header {
27
+ display: flex;
28
+ flex-direction: row;
29
+ align-items: center;
30
+ justify-content: space-between;
31
+ gap: 8px;
32
+ }
33
+
34
+ .favicon {
35
+ width: 20px;
36
+ height: 20px;
37
+ object-fit: contain;
38
+ }
39
+
40
+ .title {
41
+ font-size: 14px;
42
+ font-weight: 600;
43
+ line-height: 1.4;
44
+ white-space: nowrap;
45
+ text-overflow: ellipsis;
46
+ overflow: hidden;
47
+ }
48
+
49
+ .badge {
50
+ display: flex;
51
+ flex-direction: row;
52
+ align-items: center;
53
+ gap: 4px;
54
+ font-size: 12px;
55
+ line-height: 1;
56
+ font-weight: 600;
57
+ padding: 4px 8px;
58
+ border-radius: 4px;
59
+ white-space: nowrap;
60
+ }
61
+ .badge[type="web"] {
62
+ color: var(--u-blue-700);
63
+ background: var(--u-blue-0);
64
+ }
65
+ .badge[type="document"] {
66
+ color: var(--u-green-700);
67
+ background: var(--u-green-0);
68
+ }
69
+ .badge u-icon {
70
+ color: inherit;
71
+ }
72
+
73
+ .body {
74
+ display: -webkit-box;
75
+ color: var(--u-txt-color-weak);
76
+ font-size: 12px;
77
+ line-height: 1.5;
78
+ -webkit-line-clamp: 3;
79
+ -webkit-box-orient: vertical;
80
+ overflow: hidden;
81
+ text-overflow: ellipsis;
82
+ margin-top: 8px;
83
+ }
84
+
85
+ .footer {
86
+ display: flex;
87
+ gap: 4px;
88
+ flex-wrap: wrap;
89
+ margin-top: 8px;
90
+ }
91
+
92
+ .tag {
93
+ font-size: 10px;
94
+ line-height: 1.4;
95
+ color: var(--u-txt-color-weak);
96
+ background: var(--u-neutral-100);
97
+ padding: 2px 6px;
98
+ border-radius: 4px;
99
+ white-space: nowrap;
100
+ }
101
+ `;
102
+
103
+ export { styles };
@@ -0,0 +1,25 @@
1
+ import { BaseElement } from '@iyulab/components/dist/components/BaseElement.js';
2
+ import { URefCard } from './URefCard.component.js';
3
+ /**
4
+ * 여러 참조 카드를 그룹으로 표시하는 컴포넌트입니다.
5
+ * 페이지네이션 기능을 제공하여 각 카드를 하나씩 탐색할 수 있습니다.
6
+ */
7
+ export declare class URefCardGroup extends BaseElement {
8
+ static styles: import('lit').CSSResultGroup[];
9
+ static dependencies: Record<string, typeof BaseElement>;
10
+ /** slot으로 받은 카드 엘리먼트들 */
11
+ cards: URefCard[];
12
+ /** 현재 표시 중인 카드의 인덱스 */
13
+ currentIndex: number;
14
+ render(): import('lit-html').TemplateResult<1>;
15
+ /**
16
+ * 해당하는 인덱스에 해당하는 카드로 변경합니다.
17
+ */
18
+ switch(index: number): void;
19
+ /** 이전 카드로 이동합니다. */
20
+ private handlePreviousButtonClick;
21
+ /** 다음 카드로 이동합니다. */
22
+ private handleNextButtonClick;
23
+ /** slot 내용이 변경될 때 호출됩니다. */
24
+ private handleSlotChange;
25
+ }
@@ -0,0 +1,88 @@
1
+ import { html } from 'lit';
2
+ import { state } 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 { 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 BaseElement {
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">
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 };
@@ -0,0 +1,7 @@
1
+ import { URefCardGroup } from './URefCardGroup.component.js';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ "u-ref-card-group": URefCardGroup;
5
+ }
6
+ }
7
+ export { URefCardGroup };
@@ -0,0 +1,5 @@
1
+ import { URefCardGroup } from './URefCardGroup.component.js';
2
+
3
+ URefCardGroup.define("u-ref-card-group");
4
+
5
+ export { URefCardGroup };
@@ -0,0 +1 @@
1
+ export declare const styles: import('lit').CSSResult;
@@ -0,0 +1,69 @@
1
+ import { css } from 'lit';
2
+
3
+ const styles = css`
4
+ :host {
5
+ display: flex;
6
+ flex-direction: column;
7
+ width: 380px;
8
+ border: 1px solid var(--u-border-color);
9
+ border-radius: 8px;
10
+ background: var(--u-panel-bg-color);
11
+ overflow: hidden;
12
+ }
13
+
14
+ .header {
15
+ display: flex;
16
+ flex-direction: row;
17
+ align-items: center;
18
+ justify-content: space-between;
19
+ padding: 6px 8px;
20
+ color: var(--u-txt-color-weak);
21
+ background-color: var(--u-neutral-100);
22
+ border-bottom: 1px solid var(--u-border-color);
23
+ user-select: none;
24
+ }
25
+
26
+ .nav-button {
27
+ display: flex;
28
+ align-items: center;
29
+ justify-content: center;
30
+ padding: 0;
31
+ border: none;
32
+ background-color: transparent;
33
+ color: inherit;
34
+ font-size: 16px;
35
+ cursor: pointer;
36
+ }
37
+ .nav-button:hover u-icon {
38
+ opacity: 0.6;
39
+ }
40
+ .nav-button u-icon {
41
+ color: inherit;
42
+ }
43
+
44
+ .page-indicator {
45
+ font-size: 12px;
46
+ font-weight: 600;
47
+ }
48
+
49
+ .viewport {
50
+ width: 100%;
51
+ overflow: hidden;
52
+ }
53
+
54
+ .track {
55
+ display: flex;
56
+ flex-direction: row;
57
+ width: 100%;
58
+ will-change: transform;
59
+ transition: transform 260ms ease;
60
+ }
61
+
62
+ /* slot 안의 각 카드가 한 페이지(100%)를 차지하도록 */
63
+ ::slotted(u-ref-card) {
64
+ flex: 0 0 100%;
65
+ border: none;
66
+ }
67
+ `;
68
+
69
+ export { styles };
@@ -0,0 +1,13 @@
1
+ import { BaseElement } from '@iyulab/components/dist/components/BaseElement.js';
2
+ /**
3
+ * 인용 태그 컴포넌트입니다.
4
+ */
5
+ export declare class URefTag extends BaseElement {
6
+ static styles: import('lit').CSSResultGroup[];
7
+ static dependencies: Record<string, typeof BaseElement>;
8
+ /** 인용 출처 소스 데이터 */
9
+ href?: string;
10
+ render(): import('lit-html').TemplateResult<1>;
11
+ /** 링크 클릭 핸들러 */
12
+ private handleAnchorClick;
13
+ }