@iyulab/chat-components 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +124 -21
- package/README.md +133 -16
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.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 +32 -2
- package/dist/components/prompt/UPrompt.js +118 -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 +7 -0
- package/dist/events/StopEvent.d.ts +7 -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 +32 -16
- 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
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { nothing, html } from 'lit';
|
|
2
|
-
import { property } from 'lit/decorators.js';
|
|
3
|
-
import { repeat } from 'lit/directives/repeat.js';
|
|
4
|
-
import { UElement } from '@iyulab/components/dist/components/UElement.js';
|
|
5
|
-
import { UIcon } from '@iyulab/components/dist/components/icon/UIcon.component.js';
|
|
6
|
-
import { UButton } from '@iyulab/components/dist/components/button/UButton.component.js';
|
|
7
|
-
import { UProgressBar } from '@iyulab/components/dist/components/progress-bar/UProgressBar.component.js';
|
|
8
|
-
import { styles } from './UFilesBlock.styles.js';
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
12
|
-
var result = void 0 ;
|
|
13
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
14
|
-
if (decorator = decorators[i])
|
|
15
|
-
result = (decorator(target, key, result) ) || result;
|
|
16
|
-
if (result) __defProp(target, key, result);
|
|
17
|
-
return result;
|
|
18
|
-
};
|
|
19
|
-
class UFilesBlock extends UElement {
|
|
20
|
-
constructor() {
|
|
21
|
-
super(...arguments);
|
|
22
|
-
this.files = [];
|
|
23
|
-
this.removable = false;
|
|
24
|
-
this.handleDownloadClick = (e) => {
|
|
25
|
-
e.stopPropagation();
|
|
26
|
-
const index = e.currentTarget.dataset.index;
|
|
27
|
-
if (index == null) return;
|
|
28
|
-
const file = this.files.at(Number(index));
|
|
29
|
-
if (!file?.downloadUrl) return;
|
|
30
|
-
const a = document.createElement("a");
|
|
31
|
-
a.href = file.downloadUrl;
|
|
32
|
-
a.download = file.name;
|
|
33
|
-
a.target = "_blank";
|
|
34
|
-
a.rel = "noopener noreferrer";
|
|
35
|
-
document.body.appendChild(a);
|
|
36
|
-
a.click();
|
|
37
|
-
a.remove();
|
|
38
|
-
};
|
|
39
|
-
this.handleRemoveClick = (e) => {
|
|
40
|
-
e.stopPropagation();
|
|
41
|
-
const index = e.currentTarget.dataset.index;
|
|
42
|
-
if (index == null) return;
|
|
43
|
-
const file = this.files.at(Number(index));
|
|
44
|
-
if (!file) return;
|
|
45
|
-
this.emit("u-remove", { index, file });
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
static {
|
|
49
|
-
this.styles = [super.styles, styles];
|
|
50
|
-
}
|
|
51
|
-
static {
|
|
52
|
-
this.dependencies = {
|
|
53
|
-
"u-icon": UIcon,
|
|
54
|
-
"u-button": UButton,
|
|
55
|
-
"u-progress-bar": UProgressBar
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
render() {
|
|
59
|
-
if (!this.files?.length) return nothing;
|
|
60
|
-
return repeat(this.files, (_, i) => i, (f, i) => {
|
|
61
|
-
const phase = f.upload?.phase ?? "done";
|
|
62
|
-
const isUploading = phase === "uploading";
|
|
63
|
-
const isError = phase === "error";
|
|
64
|
-
return html`
|
|
65
|
-
<div class="item" phase=${phase}>
|
|
66
|
-
<div class="thumbnail">
|
|
67
|
-
<u-icon lib="bootstrap" name=${this.resolveIcon(f.type)}></u-icon>
|
|
68
|
-
<div class="thumbnail-overlay" ?hidden=${!isUploading}>
|
|
69
|
-
<u-icon lib="bootstrap" name="cloud-arrow-up"></u-icon>
|
|
70
|
-
</div>
|
|
71
|
-
<div class="thumbnail-overlay" ?hidden=${!isError}>
|
|
72
|
-
<u-icon lib="bootstrap" name="exclamation-circle-fill"></u-icon>
|
|
73
|
-
</div>
|
|
74
|
-
<u-button class="download-btn"
|
|
75
|
-
?hidden=${!f.downloadUrl || isUploading}
|
|
76
|
-
data-index=${i}
|
|
77
|
-
title="Download"
|
|
78
|
-
variant="borderless"
|
|
79
|
-
@click=${this.handleDownloadClick}>
|
|
80
|
-
<u-icon lib="bootstrap" name="download"></u-icon>
|
|
81
|
-
</u-button>
|
|
82
|
-
</div>
|
|
83
|
-
<div class="info">
|
|
84
|
-
<div class="name" title=${f.name}>${f.name}</div>
|
|
85
|
-
<div class="meta">
|
|
86
|
-
<span class="type" ?hidden=${!f.type || isError}>
|
|
87
|
-
${this.resolveExt(f.name, f.type)}
|
|
88
|
-
</span>
|
|
89
|
-
<span class="size" ?hidden=${f.size == null || isError}>
|
|
90
|
-
${this.formatSize(f.size || 0)}
|
|
91
|
-
</span>
|
|
92
|
-
<span class="error-msg" ?hidden=${!isError}>
|
|
93
|
-
<u-icon lib="bootstrap" name="exclamation-triangle"></u-icon>
|
|
94
|
-
${f.upload?.message ?? "File upload failed"}
|
|
95
|
-
</span>
|
|
96
|
-
</div>
|
|
97
|
-
</div>
|
|
98
|
-
<u-progress-bar class="upload-progress"
|
|
99
|
-
?hidden=${!isUploading}
|
|
100
|
-
?indeterminate=${f.upload?.progress == null}
|
|
101
|
-
value=${f.upload?.progress ?? 0}
|
|
102
|
-
></u-progress-bar>
|
|
103
|
-
<u-button class="remove-btn"
|
|
104
|
-
?hidden=${!this.removable}
|
|
105
|
-
data-index=${i}
|
|
106
|
-
title="Remove"
|
|
107
|
-
variant="borderless"
|
|
108
|
-
@click=${this.handleRemoveClick}>
|
|
109
|
-
<u-icon lib="bootstrap" name="x-lg"></u-icon>
|
|
110
|
-
</u-button>
|
|
111
|
-
</div>
|
|
112
|
-
`;
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
/** MIME 타입 → Bootstrap Icon 이름 */
|
|
116
|
-
resolveIcon(mimeType) {
|
|
117
|
-
if (!mimeType) return "file-earmark";
|
|
118
|
-
if (mimeType.startsWith("image/")) return "file-earmark-image";
|
|
119
|
-
if (mimeType.startsWith("video/")) return "file-earmark-play";
|
|
120
|
-
if (mimeType.startsWith("audio/")) return "file-earmark-music";
|
|
121
|
-
if (mimeType === "application/pdf") return "file-earmark-pdf";
|
|
122
|
-
const codeTypes = [
|
|
123
|
-
"application/json",
|
|
124
|
-
"application/javascript",
|
|
125
|
-
"application/typescript",
|
|
126
|
-
"application/xml",
|
|
127
|
-
"text/html",
|
|
128
|
-
"text/css",
|
|
129
|
-
"text/javascript",
|
|
130
|
-
"text/x-python",
|
|
131
|
-
"text/x-java-source"
|
|
132
|
-
];
|
|
133
|
-
if (codeTypes.includes(mimeType) || mimeType.startsWith("text/x-"))
|
|
134
|
-
return "file-earmark-code";
|
|
135
|
-
if ([
|
|
136
|
-
"application/vnd.ms-excel",
|
|
137
|
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
138
|
-
"text/csv"
|
|
139
|
-
].includes(mimeType))
|
|
140
|
-
return "file-earmark-spreadsheet";
|
|
141
|
-
if ([
|
|
142
|
-
"application/zip",
|
|
143
|
-
"application/x-zip-compressed",
|
|
144
|
-
"application/x-tar",
|
|
145
|
-
"application/x-rar-compressed",
|
|
146
|
-
"application/gzip",
|
|
147
|
-
"application/x-7z-compressed"
|
|
148
|
-
].includes(mimeType))
|
|
149
|
-
return "file-earmark-zip";
|
|
150
|
-
if (mimeType.startsWith("text/")) return "file-earmark-text";
|
|
151
|
-
return "file-earmark";
|
|
152
|
-
}
|
|
153
|
-
/** 파일명 또는 MIME 타입에서 확장자를 추출합니다. */
|
|
154
|
-
resolveExt(name, mimeType) {
|
|
155
|
-
if (name) {
|
|
156
|
-
const dot = name.lastIndexOf(".");
|
|
157
|
-
if (dot !== -1 && dot < name.length - 1)
|
|
158
|
-
return name.slice(dot + 1).toLowerCase();
|
|
159
|
-
}
|
|
160
|
-
const map = {
|
|
161
|
-
"image/jpeg": "jpg",
|
|
162
|
-
"image/png": "png",
|
|
163
|
-
"image/gif": "gif",
|
|
164
|
-
"image/webp": "webp",
|
|
165
|
-
"image/svg+xml": "svg",
|
|
166
|
-
"application/pdf": "pdf",
|
|
167
|
-
"text/plain": "txt",
|
|
168
|
-
"text/csv": "csv",
|
|
169
|
-
"application/json": "json",
|
|
170
|
-
"application/zip": "zip"
|
|
171
|
-
};
|
|
172
|
-
return mimeType ? map[mimeType] ?? mimeType.split("/").pop() ?? "" : "";
|
|
173
|
-
}
|
|
174
|
-
/** bytes → 읽기 좋은 크기 문자열 */
|
|
175
|
-
formatSize(bytes) {
|
|
176
|
-
if (bytes < 1024)
|
|
177
|
-
return `${bytes} B`;
|
|
178
|
-
if (bytes < 1024 ** 2)
|
|
179
|
-
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
180
|
-
if (bytes < 1024 ** 3)
|
|
181
|
-
return `${(bytes / 1024 ** 2).toFixed(1)} MB`;
|
|
182
|
-
return `${(bytes / 1024 ** 3).toFixed(2)} GB`;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
__decorateClass([
|
|
186
|
-
property({ type: Array })
|
|
187
|
-
], UFilesBlock.prototype, "files");
|
|
188
|
-
__decorateClass([
|
|
189
|
-
property({ type: Boolean, reflect: true })
|
|
190
|
-
], UFilesBlock.prototype, "removable");
|
|
191
|
-
|
|
192
|
-
export { UFilesBlock };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { PropertyValues, TemplateResult } from 'lit';
|
|
2
|
-
import { UElement } from '@iyulab/components/dist/components/UElement.js';
|
|
3
|
-
import { JsonNode } from '../../types/JsonNode.js';
|
|
4
|
-
/**
|
|
5
|
-
* json 데이터를 트리 형태로 시각화하는 컴포넌트입니다.
|
|
6
|
-
*/
|
|
7
|
-
export declare class UJsonBlock extends UElement {
|
|
8
|
-
static styles: import('lit').CSSResultGroup[];
|
|
9
|
-
static dependencies: Record<string, typeof UElement>;
|
|
10
|
-
state: Record<string, boolean>;
|
|
11
|
-
/** 초기 확장 상태를 관리하는 속성입니다. */
|
|
12
|
-
expanded: boolean;
|
|
13
|
-
/** JSON 데이터 (속성으로 전달 가능) */
|
|
14
|
-
value: JsonNode;
|
|
15
|
-
connectedCallback(): void;
|
|
16
|
-
protected willUpdate(changedProperties: PropertyValues): void;
|
|
17
|
-
render(): TemplateResult<1>;
|
|
18
|
-
/**
|
|
19
|
-
* JsonNode를 렌더링합니다.
|
|
20
|
-
* @param value - JsonNode (JsonObject, JsonArray, 또는 JsonValue)
|
|
21
|
-
* @param parent - 부모 노드의 경로
|
|
22
|
-
*/
|
|
23
|
-
private renderNode;
|
|
24
|
-
/**
|
|
25
|
-
* JsonValue를 렌더링합니다.
|
|
26
|
-
* @param node - JsonValue (string, number, boolean, null 등)
|
|
27
|
-
*/
|
|
28
|
-
private renderValue;
|
|
29
|
-
/**
|
|
30
|
-
* JsonObject 또는 JsonArray를 렌더링합니다.
|
|
31
|
-
* @param node - JsonObject 또는 JsonArray
|
|
32
|
-
* @param depth - 현재 깊이
|
|
33
|
-
*/
|
|
34
|
-
private renderObject;
|
|
35
|
-
/**
|
|
36
|
-
* 노드의 미리보기를 렌더링합니다.
|
|
37
|
-
* @param node - JsonObject 또는 JsonArray
|
|
38
|
-
*/
|
|
39
|
-
private renderPreview;
|
|
40
|
-
/** JSON 데이터를 순회하며 각 경로의 확장 상태를 설정합니다. */
|
|
41
|
-
private setState;
|
|
42
|
-
private isValueType;
|
|
43
|
-
/** 노드 확장/축소 클릭 핸들러 */
|
|
44
|
-
private handlePropertyKeyClick;
|
|
45
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
2
|
-
import { state, property } from 'lit/decorators.js';
|
|
3
|
-
import { map } from 'lit/directives/map.js';
|
|
4
|
-
import { when } from 'lit/directives/when.js';
|
|
5
|
-
import { UElement } from '@iyulab/components/dist/components/UElement.js';
|
|
6
|
-
import { jsonAttrConverter } from '../../utilities/converters.js';
|
|
7
|
-
import { styles } from './UJsonBlock.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 UJsonBlock extends UElement {
|
|
19
|
-
constructor() {
|
|
20
|
-
super(...arguments);
|
|
21
|
-
this.state = {};
|
|
22
|
-
this.expanded = true;
|
|
23
|
-
this.value = {};
|
|
24
|
-
this.isValueType = (value) => {
|
|
25
|
-
return value !== Object(value);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
static {
|
|
29
|
-
this.styles = [super.styles, styles];
|
|
30
|
-
}
|
|
31
|
-
static {
|
|
32
|
-
this.dependencies = {};
|
|
33
|
-
}
|
|
34
|
-
connectedCallback() {
|
|
35
|
-
super.connectedCallback();
|
|
36
|
-
this.setAttribute("tabindex", "0");
|
|
37
|
-
}
|
|
38
|
-
willUpdate(changedProperties) {
|
|
39
|
-
super.willUpdate(changedProperties);
|
|
40
|
-
if (changedProperties.has("value") || changedProperties.has("expanded")) {
|
|
41
|
-
this.state = this.setState(this.value);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
render() {
|
|
45
|
-
return html`
|
|
46
|
-
<div part="base">
|
|
47
|
-
${this.renderNode(this.value)}
|
|
48
|
-
</div>
|
|
49
|
-
`;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* JsonNode를 렌더링합니다.
|
|
53
|
-
* @param value - JsonNode (JsonObject, JsonArray, 또는 JsonValue)
|
|
54
|
-
* @param parent - 부모 노드의 경로
|
|
55
|
-
*/
|
|
56
|
-
renderNode(value, parent = "") {
|
|
57
|
-
return this.isValueType(value) ? this.renderValue(value) : this.renderObject(value, parent);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* JsonValue를 렌더링합니다.
|
|
61
|
-
* @param node - JsonValue (string, number, boolean, null 등)
|
|
62
|
-
*/
|
|
63
|
-
renderValue(node) {
|
|
64
|
-
const type = node === null ? "null" : Array.isArray(node) ? "array" : typeof node === "object" ? "object" : typeof node;
|
|
65
|
-
return html`
|
|
66
|
-
<span part="${type}" class="${type}" role="treeitem">
|
|
67
|
-
${JSON.stringify(node)}
|
|
68
|
-
</span>
|
|
69
|
-
`;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* JsonObject 또는 JsonArray를 렌더링합니다.
|
|
73
|
-
* @param node - JsonObject 또는 JsonArray
|
|
74
|
-
* @param depth - 현재 깊이
|
|
75
|
-
*/
|
|
76
|
-
renderObject(node, parent) {
|
|
77
|
-
return html`
|
|
78
|
-
<ul part="object" role="group">
|
|
79
|
-
${map(Object.entries(node), ([key, value]) => {
|
|
80
|
-
const path = parent ? `${parent}.${key}` : key;
|
|
81
|
-
const isValue = this.isValueType(value);
|
|
82
|
-
const isExpanded = this.state[path] ?? this.expanded;
|
|
83
|
-
return html`
|
|
84
|
-
<li part="property" role="treeitem"
|
|
85
|
-
data-path="${path}"
|
|
86
|
-
aria-expanded="${isExpanded ? "true" : "false"}">
|
|
87
|
-
<span part="key"
|
|
88
|
-
class="key"
|
|
89
|
-
?collapsable="${!isValue}"
|
|
90
|
-
?collapsed="${!isValue && !isExpanded}"
|
|
91
|
-
@click=${!isValue ? () => this.handlePropertyKeyClick(path) : null}>
|
|
92
|
-
${key}:
|
|
93
|
-
${when(!isValue && !isExpanded, () => this.renderPreview(value))}
|
|
94
|
-
</span>
|
|
95
|
-
|
|
96
|
-
${when(isValue || isExpanded, () => this.renderNode(value, path))}
|
|
97
|
-
</li>`;
|
|
98
|
-
})}
|
|
99
|
-
</ul>
|
|
100
|
-
`;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* 노드의 미리보기를 렌더링합니다.
|
|
104
|
-
* @param node - JsonObject 또는 JsonArray
|
|
105
|
-
*/
|
|
106
|
-
renderPreview(node) {
|
|
107
|
-
return html`
|
|
108
|
-
<span part="preview" class="preview">
|
|
109
|
-
${Array.isArray(node) ? node.length === 0 ? "[ ]" : `[ ${node.length} items ]` : Object.keys(node).length === 0 ? "{ }" : `{ ${Object.keys(node).length} properties }`}
|
|
110
|
-
</span>
|
|
111
|
-
`;
|
|
112
|
-
}
|
|
113
|
-
/** JSON 데이터를 순회하며 각 경로의 확장 상태를 설정합니다. */
|
|
114
|
-
setState(value, parent = "") {
|
|
115
|
-
if (typeof value !== "object" || value === null) return {};
|
|
116
|
-
const state2 = {};
|
|
117
|
-
Object.entries(value).forEach(([key, item]) => {
|
|
118
|
-
const path = parent ? `${parent}.${key}` : key;
|
|
119
|
-
state2[path] = this.expanded;
|
|
120
|
-
Object.assign(state2, this.setState(item, path));
|
|
121
|
-
});
|
|
122
|
-
return state2;
|
|
123
|
-
}
|
|
124
|
-
/** 노드 확장/축소 클릭 핸들러 */
|
|
125
|
-
handlePropertyKeyClick(path) {
|
|
126
|
-
const isExpanded = this.state[path] ?? false;
|
|
127
|
-
this.state = { ...this.state, [path]: !isExpanded };
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
__decorateClass([
|
|
131
|
-
state()
|
|
132
|
-
], UJsonBlock.prototype, "state");
|
|
133
|
-
__decorateClass([
|
|
134
|
-
property({ type: Boolean })
|
|
135
|
-
], UJsonBlock.prototype, "expanded");
|
|
136
|
-
__decorateClass([
|
|
137
|
-
property({ type: Object, converter: jsonAttrConverter })
|
|
138
|
-
], UJsonBlock.prototype, "value");
|
|
139
|
-
|
|
140
|
-
export { UJsonBlock };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { UElement } from '@iyulab/components/dist/components/UElement.js';
|
|
2
|
-
import { ReferenceCitation } from '../../types/References.js';
|
|
3
|
-
/**
|
|
4
|
-
* 마크다운 컨텐츠를 렌더링하는 컴포넌트입니다.
|
|
5
|
-
*
|
|
6
|
-
* 주의:
|
|
7
|
-
* - refs로 삽입되는 커스텀 태그(u-ref-*)는 속성/내용을 모두 escape하여 XSS를 방지합니다.
|
|
8
|
-
* - 코드블록 내부는 HTML을 전부 텍스트로 취급(escape)하며, refs 태그는 통째 제거합니다.
|
|
9
|
-
* - 인덱스 기반 삽입(ref.endIndex)이 깨지지 않도록 "normalize(제로폭 제거)"를 insertRefs 전에 1회 수행합니다.
|
|
10
|
-
*/
|
|
11
|
-
export declare class UMarkedBlock extends UElement {
|
|
12
|
-
static styles: import('lit').CSSResultGroup[];
|
|
13
|
-
static dependencies: Record<string, typeof UElement>;
|
|
14
|
-
/** 마크다운 컨텐츠를 렌더링할 때 사용할 값입니다. */
|
|
15
|
-
value?: string;
|
|
16
|
-
/** 컨텐츠의 인용 출처들입니다. */
|
|
17
|
-
refs?: ReferenceCitation[];
|
|
18
|
-
/** Marked 인스턴스: 커스텀 렌더러와 KaTeX 확장 포함 */
|
|
19
|
-
private parser;
|
|
20
|
-
/** Marked 파싱 중 ref HTML을 임시 보관하는 플레이스홀더 */
|
|
21
|
-
private placeholder;
|
|
22
|
-
render(): import('lit-html/directive.js').DirectiveResult<typeof import('lit-html/directives/unsafe-html.js').UnsafeHTMLDirective>;
|
|
23
|
-
/**
|
|
24
|
-
* 코드블록은 별도의 컴포넌트로 렌더링 합니다.
|
|
25
|
-
*/
|
|
26
|
-
private renderCode;
|
|
27
|
-
/**
|
|
28
|
-
* 테이블은 JSON 데이터로 변환하여 별도의 컴포넌트로 렌더링합니다.
|
|
29
|
-
*/
|
|
30
|
-
private renderTable;
|
|
31
|
-
/**
|
|
32
|
-
* 인용/출처 참조객체가 있을때 ref 태그 HTML을 this.placeholder에 보관하고
|
|
33
|
-
* 마크다운 문자열의 해당 위치에 주석 플레이스홀더를 삽입합니다.
|
|
34
|
-
*/
|
|
35
|
-
private insertRefs;
|
|
36
|
-
/**
|
|
37
|
-
* 코드블록 내부의 <!--ref:idx--> 플레이스홀더와 그 외 refs 태그를 모두 제거하여 HTML이 코드로 렌더링되도록 합니다.
|
|
38
|
-
*/
|
|
39
|
-
private removeRefs;
|
|
40
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { nothing } from 'lit';
|
|
2
|
-
import { property } from 'lit/decorators.js';
|
|
3
|
-
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
4
|
-
import { Marked } from 'marked';
|
|
5
|
-
import markedKatex from 'marked-katex-extension';
|
|
6
|
-
import { UElement } from '@iyulab/components/dist/components/UElement.js';
|
|
7
|
-
import { UJsonElement } from '@iyulab/components/dist/components/UJsonElement.js';
|
|
8
|
-
import { stripZeroWidth, escapeHtmlText } from '@iyulab/components/dist/utilities/sanitizers.js';
|
|
9
|
-
import { buildElementHTML } from '@iyulab/components/dist/utilities/elements.js';
|
|
10
|
-
import { UTooltip } from '@iyulab/components/dist/components/tooltip/UTooltip.component.js';
|
|
11
|
-
import { UCodeBlock } from './UCodeBlock.component.js';
|
|
12
|
-
import { UTableBlock } from './UTableBlock.component.js';
|
|
13
|
-
import { URefTag } from '../references/URefTag.component.js';
|
|
14
|
-
import { URefCard } from '../references/URefCard.component.js';
|
|
15
|
-
import { URefCardGroup } from '../references/URefCardGroup.component.js';
|
|
16
|
-
import { UWidget } from '../widgets/UWidget.component.js';
|
|
17
|
-
import { styles } from './UMarkedBlock.styles.js';
|
|
18
|
-
|
|
19
|
-
var __defProp = Object.defineProperty;
|
|
20
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
21
|
-
var result = void 0 ;
|
|
22
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
23
|
-
if (decorator = decorators[i])
|
|
24
|
-
result = (decorator(target, key, result) ) || result;
|
|
25
|
-
if (result) __defProp(target, key, result);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
class UMarkedBlock extends UElement {
|
|
29
|
-
constructor() {
|
|
30
|
-
super(...arguments);
|
|
31
|
-
/** Marked 인스턴스: 커스텀 렌더러와 KaTeX 확장 포함 */
|
|
32
|
-
this.parser = new Marked({
|
|
33
|
-
pedantic: false,
|
|
34
|
-
gfm: true,
|
|
35
|
-
breaks: true,
|
|
36
|
-
silent: true,
|
|
37
|
-
renderer: {
|
|
38
|
-
code: (token) => this.renderCode(token),
|
|
39
|
-
table: (token) => this.renderTable(token)
|
|
40
|
-
}
|
|
41
|
-
}).use(markedKatex({ output: "mathml" }));
|
|
42
|
-
/** Marked 파싱 중 ref HTML을 임시 보관하는 플레이스홀더 */
|
|
43
|
-
this.placeholder = new HtmlPlaceholder();
|
|
44
|
-
}
|
|
45
|
-
static {
|
|
46
|
-
this.styles = [super.styles, styles];
|
|
47
|
-
}
|
|
48
|
-
static {
|
|
49
|
-
this.dependencies = {
|
|
50
|
-
"u-tooltip": UTooltip,
|
|
51
|
-
"u-code-block": UCodeBlock,
|
|
52
|
-
"u-table-block": UTableBlock,
|
|
53
|
-
"u-ref-tag": URefTag,
|
|
54
|
-
"u-ref-card": URefCard,
|
|
55
|
-
"u-ref-card-group": URefCardGroup,
|
|
56
|
-
"u-widget": UWidget
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
render() {
|
|
60
|
-
if (!this.value) return nothing;
|
|
61
|
-
this.placeholder.reset();
|
|
62
|
-
let value = stripZeroWidth(this.value);
|
|
63
|
-
if (this.refs?.length) {
|
|
64
|
-
value = this.insertRefs(value, this.refs);
|
|
65
|
-
}
|
|
66
|
-
let html = this.parser.parse(value, { async: false });
|
|
67
|
-
return unsafeHTML(this.placeholder.restore(html));
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* 코드블록은 별도의 컴포넌트로 렌더링 합니다.
|
|
71
|
-
*/
|
|
72
|
-
renderCode(token) {
|
|
73
|
-
const lang = token.lang ?? "plaintext";
|
|
74
|
-
const trimmed = token.raw.trimEnd();
|
|
75
|
-
const isClosed = trimmed.endsWith("```") || trimmed.endsWith("~~~");
|
|
76
|
-
if (lang === "widget-json") {
|
|
77
|
-
return UJsonElement.buildHTML("u-widget", token.text, { loading: !isClosed });
|
|
78
|
-
}
|
|
79
|
-
if (lang === "action-json") {
|
|
80
|
-
return "";
|
|
81
|
-
}
|
|
82
|
-
const safeText = this.removeRefs(token.text);
|
|
83
|
-
return buildElementHTML("u-code-block", { lang, loading: !isClosed }, safeText);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* 테이블은 JSON 데이터로 변환하여 별도의 컴포넌트로 렌더링합니다.
|
|
87
|
-
*/
|
|
88
|
-
renderTable(token) {
|
|
89
|
-
const headers = token.header.map((h) => ({
|
|
90
|
-
text: h.text,
|
|
91
|
-
align: h.align
|
|
92
|
-
}));
|
|
93
|
-
const rows = token.rows.map(
|
|
94
|
-
(row) => row.map((cell) => ({
|
|
95
|
-
text: cell.text,
|
|
96
|
-
align: cell.align
|
|
97
|
-
}))
|
|
98
|
-
);
|
|
99
|
-
return UJsonElement.buildHTML("u-table-block", { headers, rows });
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* 인용/출처 참조객체가 있을때 ref 태그 HTML을 this.placeholder에 보관하고
|
|
103
|
-
* 마크다운 문자열의 해당 위치에 주석 플레이스홀더를 삽입합니다.
|
|
104
|
-
*/
|
|
105
|
-
insertRefs(value, refs) {
|
|
106
|
-
const sorted = [...refs].sort((a, b) => b.endIndex - a.endIndex);
|
|
107
|
-
for (const ref of sorted) {
|
|
108
|
-
const sources = ref.sources ?? [];
|
|
109
|
-
const label = escapeHtmlText(ref.label ?? `[${refs.indexOf(ref) + 1}]`);
|
|
110
|
-
const link = sources.at(0)?.url;
|
|
111
|
-
let tooltip = "";
|
|
112
|
-
if (sources.length > 0) {
|
|
113
|
-
const cards = sources.map((s) => UJsonElement.buildHTML("u-ref-card", s)).join("");
|
|
114
|
-
tooltip = buildElementHTML("u-ref-card-group", { slot: "tooltip" }, cards);
|
|
115
|
-
}
|
|
116
|
-
const html = buildElementHTML("u-ref-tag", { href: link }, label + tooltip);
|
|
117
|
-
const key = this.placeholder.store(html);
|
|
118
|
-
value = value.slice(0, ref.endIndex) + key + value.slice(ref.endIndex);
|
|
119
|
-
}
|
|
120
|
-
return value;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* 코드블록 내부의 <!--ref:idx--> 플레이스홀더와 그 외 refs 태그를 모두 제거하여 HTML이 코드로 렌더링되도록 합니다.
|
|
124
|
-
*/
|
|
125
|
-
removeRefs(value) {
|
|
126
|
-
value = value.replace(/<u-ref-tag\b[^>]*>[\s\S]*?<\/u-ref-tag>/gi, "");
|
|
127
|
-
value = value.replace(/<!--ref:\d+-->/g, "");
|
|
128
|
-
return value;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
__decorateClass([
|
|
132
|
-
property({ type: String })
|
|
133
|
-
], UMarkedBlock.prototype, "value");
|
|
134
|
-
__decorateClass([
|
|
135
|
-
property({ type: Array })
|
|
136
|
-
], UMarkedBlock.prototype, "refs");
|
|
137
|
-
class HtmlPlaceholder {
|
|
138
|
-
constructor() {
|
|
139
|
-
this.map = {};
|
|
140
|
-
this.idx = 0;
|
|
141
|
-
}
|
|
142
|
-
reset() {
|
|
143
|
-
this.map = {};
|
|
144
|
-
this.idx = 0;
|
|
145
|
-
}
|
|
146
|
-
/** html을 저장하고 대응하는 플레이스홀더 키를 반환합니다. */
|
|
147
|
-
store(html) {
|
|
148
|
-
const key = `<!--ref:${this.idx++}-->`;
|
|
149
|
-
this.map[key] = html;
|
|
150
|
-
return key;
|
|
151
|
-
}
|
|
152
|
-
/** html 안의 등록된 모든 플레이스홀더를 원래 HTML로 복원합니다. */
|
|
153
|
-
restore(html) {
|
|
154
|
-
if (this.idx === 0) return html;
|
|
155
|
-
return html.replace(/<!--ref:\d+-->/g, (key) => this.map[key] ?? "");
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export { UMarkedBlock };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { UElement } from '@iyulab/components/dist/components/UElement.js';
|
|
2
|
-
import { ReferenceSource } from '../../types/References.js';
|
|
3
|
-
/**
|
|
4
|
-
* 레퍼런스 정보를 블록 형태로 표시하는 컴포넌트입니다.
|
|
5
|
-
* 단일 또는 다중 레퍼런스 카드를 그리드 레이아웃으로 표시합니다.
|
|
6
|
-
*/
|
|
7
|
-
export declare class URefBlock extends UElement {
|
|
8
|
-
static styles: import('lit').CSSResultGroup[];
|
|
9
|
-
static dependencies: Record<string, typeof UElement>;
|
|
10
|
-
/** 접힘 상태 @default: true */
|
|
11
|
-
collapsed: boolean;
|
|
12
|
-
/** 블록 제목 */
|
|
13
|
-
heading?: string;
|
|
14
|
-
/** 출처 목록 */
|
|
15
|
-
sources?: ReferenceSource[];
|
|
16
|
-
render(): import('lit-html').TemplateResult<1>;
|
|
17
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
2
|
-
import { property } from 'lit/decorators.js';
|
|
3
|
-
import { UElement } from '@iyulab/components/dist/components/UElement.js';
|
|
4
|
-
import { URefCard } from '../references/URefCard.component.js';
|
|
5
|
-
import { styles } from './URefBlock.styles.js';
|
|
6
|
-
import { repeat } from 'lit/directives/repeat.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 URefBlock extends UElement {
|
|
18
|
-
constructor() {
|
|
19
|
-
super(...arguments);
|
|
20
|
-
this.collapsed = true;
|
|
21
|
-
}
|
|
22
|
-
static {
|
|
23
|
-
this.styles = [super.styles, styles];
|
|
24
|
-
}
|
|
25
|
-
static {
|
|
26
|
-
this.dependencies = {
|
|
27
|
-
"u-ref-card": URefCard
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
render() {
|
|
31
|
-
return html`
|
|
32
|
-
<button class="header" @click=${() => this.collapsed = !this.collapsed}>
|
|
33
|
-
<u-icon
|
|
34
|
-
?collapsed=${this.collapsed}
|
|
35
|
-
lib="internal"
|
|
36
|
-
name="chevron-down"
|
|
37
|
-
></u-icon>
|
|
38
|
-
<div class="title">
|
|
39
|
-
${this.heading || "References"}
|
|
40
|
-
</div>
|
|
41
|
-
<div style="flex: 1;"></div>
|
|
42
|
-
<div class="count">
|
|
43
|
-
${this.sources ? this.sources.length : 0}
|
|
44
|
-
</div>
|
|
45
|
-
</button>
|
|
46
|
-
|
|
47
|
-
<div class="body" ?collapsed=${this.collapsed}>
|
|
48
|
-
${repeat(this.sources || [], (_, idx) => idx, (source) => {
|
|
49
|
-
return html`
|
|
50
|
-
<u-ref-card
|
|
51
|
-
.type=${source.type}
|
|
52
|
-
.url=${source.url}
|
|
53
|
-
.title=${source.title || ""}
|
|
54
|
-
.snippet=${source.snippet || ""}
|
|
55
|
-
.tags=${source.tags}
|
|
56
|
-
></u-ref-card>
|
|
57
|
-
`;
|
|
58
|
-
})}
|
|
59
|
-
</div>
|
|
60
|
-
`;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
__decorateClass([
|
|
64
|
-
property({ type: Boolean, reflect: true })
|
|
65
|
-
], URefBlock.prototype, "collapsed");
|
|
66
|
-
__decorateClass([
|
|
67
|
-
property({ type: String })
|
|
68
|
-
], URefBlock.prototype, "heading");
|
|
69
|
-
__decorateClass([
|
|
70
|
-
property({ type: Array })
|
|
71
|
-
], URefBlock.prototype, "sources");
|
|
72
|
-
|
|
73
|
-
export { URefBlock };
|