@hcu-lab.me/mcp-device 1.0.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/LICENSE +21 -0
- package/README.md +51 -0
- package/dist/bootstrap.d.ts +1 -0
- package/dist/bootstrap.js +22 -0
- package/dist/command-manager.d.ts +8 -0
- package/dist/command-manager.js +241 -0
- package/dist/config-field-definitions.d.ts +41 -0
- package/dist/config-field-definitions.js +37 -0
- package/dist/config-manager.d.ts +102 -0
- package/dist/config-manager.js +291 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.js +10 -0
- package/dist/custom-stdio.d.ts +51 -0
- package/dist/custom-stdio.js +358 -0
- package/dist/data/official-app-ca.pem +12 -0
- package/dist/data/onboarding-prompts.json +70 -0
- package/dist/device/device-state.d.ts +13 -0
- package/dist/device/device-state.js +100 -0
- package/dist/device/device-status.d.ts +81 -0
- package/dist/device/device-status.js +156 -0
- package/dist/device/device.d.ts +16 -0
- package/dist/device/device.js +190 -0
- package/dist/device/execution-engine.d.ts +144 -0
- package/dist/device/execution-engine.js +195 -0
- package/dist/device/gateway-channel.d.ts +48 -0
- package/dist/device/gateway-channel.js +384 -0
- package/dist/device/gateway-config.d.ts +40 -0
- package/dist/device/gateway-config.js +207 -0
- package/dist/device/gateway-identity.d.ts +35 -0
- package/dist/device/gateway-identity.js +178 -0
- package/dist/device/gateway-pairing.d.ts +25 -0
- package/dist/device/gateway-pairing.js +105 -0
- package/dist/device/gateway-secure-transport.d.ts +25 -0
- package/dist/device/gateway-secure-transport.js +117 -0
- package/dist/device/gateway-tool-adapter.d.ts +17 -0
- package/dist/device/gateway-tool-adapter.js +284 -0
- package/dist/device/gateway-url-policy.d.ts +3 -0
- package/dist/device/gateway-url-policy.js +43 -0
- package/dist/device/linux-service.d.ts +70 -0
- package/dist/device/linux-service.js +268 -0
- package/dist/device/official-trust.d.ts +7 -0
- package/dist/device/official-trust.js +49 -0
- package/dist/device/project-inspection.d.ts +1 -0
- package/dist/device/project-inspection.js +180 -0
- package/dist/device/runtime-owner.d.ts +41 -0
- package/dist/device/runtime-owner.js +177 -0
- package/dist/device/windows-dpapi.d.ts +11 -0
- package/dist/device/windows-dpapi.js +67 -0
- package/dist/device/windows-service.d.ts +56 -0
- package/dist/device/windows-service.js +238 -0
- package/dist/error-handlers.d.ts +7 -0
- package/dist/error-handlers.js +15 -0
- package/dist/handlers/edit-search-handlers.d.ts +6 -0
- package/dist/handlers/edit-search-handlers.js +6 -0
- package/dist/handlers/filesystem-handlers.d.ts +38 -0
- package/dist/handlers/filesystem-handlers.js +440 -0
- package/dist/handlers/history-handlers.d.ts +12 -0
- package/dist/handlers/history-handlers.js +67 -0
- package/dist/handlers/index.d.ts +6 -0
- package/dist/handlers/index.js +7 -0
- package/dist/handlers/process-handlers.d.ts +9 -0
- package/dist/handlers/process-handlers.js +15 -0
- package/dist/handlers/search-handlers.d.ts +17 -0
- package/dist/handlers/search-handlers.js +224 -0
- package/dist/handlers/terminal-handlers.d.ts +21 -0
- package/dist/handlers/terminal-handlers.js +35 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +138 -0
- package/dist/mcp-device.d.ts +2 -0
- package/dist/mcp-device.js +7 -0
- package/dist/npm-scripts/remote.d.ts +3 -0
- package/dist/npm-scripts/remote.js +314 -0
- package/dist/search-manager.d.ts +147 -0
- package/dist/search-manager.js +828 -0
- package/dist/server.d.ts +46 -0
- package/dist/server.js +1563 -0
- package/dist/terminal-manager.d.ts +104 -0
- package/dist/terminal-manager.js +635 -0
- package/dist/tools/config.d.ts +96 -0
- package/dist/tools/config.js +260 -0
- package/dist/tools/edit.d.ts +38 -0
- package/dist/tools/edit.js +435 -0
- package/dist/tools/feedback.d.ts +8 -0
- package/dist/tools/feedback.js +132 -0
- package/dist/tools/filesystem.d.ts +79 -0
- package/dist/tools/filesystem.js +947 -0
- package/dist/tools/fuzzySearch.d.ts +12 -0
- package/dist/tools/fuzzySearch.js +74 -0
- package/dist/tools/fuzzySearchCore.d.ts +52 -0
- package/dist/tools/fuzzySearchCore.js +125 -0
- package/dist/tools/improved-process-tools.d.ts +24 -0
- package/dist/tools/improved-process-tools.js +627 -0
- package/dist/tools/mime-types.d.ts +3 -0
- package/dist/tools/mime-types.js +28 -0
- package/dist/tools/pdf/extract-images.d.ts +34 -0
- package/dist/tools/pdf/extract-images.js +132 -0
- package/dist/tools/pdf/index.d.ts +6 -0
- package/dist/tools/pdf/index.js +3 -0
- package/dist/tools/pdf/lib/pdf2md.d.ts +36 -0
- package/dist/tools/pdf/lib/pdf2md.js +76 -0
- package/dist/tools/pdf/manipulations.d.ts +13 -0
- package/dist/tools/pdf/manipulations.js +99 -0
- package/dist/tools/pdf/markdown.d.ts +26 -0
- package/dist/tools/pdf/markdown.js +275 -0
- package/dist/tools/pdf/utils.d.ts +12 -0
- package/dist/tools/pdf/utils.js +34 -0
- package/dist/tools/process.d.ts +3 -0
- package/dist/tools/process.js +56 -0
- package/dist/tools/prompts.d.ts +28 -0
- package/dist/tools/prompts.js +259 -0
- package/dist/tools/schemas.d.ts +454 -0
- package/dist/tools/schemas.js +242 -0
- package/dist/tools/usage.d.ts +5 -0
- package/dist/tools/usage.js +24 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.js +1 -0
- package/dist/ui/config-editor/config-editor-runtime.js +150 -0
- package/dist/ui/config-editor/index.html +13 -0
- package/dist/ui/config-editor/src/app.d.ts +43 -0
- package/dist/ui/config-editor/src/app.js +831 -0
- package/dist/ui/config-editor/src/array-modal.d.ts +19 -0
- package/dist/ui/config-editor/src/array-modal.js +185 -0
- package/dist/ui/config-editor/src/main.d.ts +1 -0
- package/dist/ui/config-editor/src/main.js +2 -0
- package/dist/ui/config-editor/styles.css +587 -0
- package/dist/ui/contracts.d.ts +14 -0
- package/dist/ui/contracts.js +21 -0
- package/dist/ui/file-preview/index.html +16 -0
- package/dist/ui/file-preview/preview-runtime.js +469 -0
- package/dist/ui/file-preview/shared/preview-file-types.d.ts +5 -0
- package/dist/ui/file-preview/shared/preview-file-types.js +59 -0
- package/dist/ui/file-preview/src/app.d.ts +4 -0
- package/dist/ui/file-preview/src/app.js +680 -0
- package/dist/ui/file-preview/src/components/code-viewer.d.ts +6 -0
- package/dist/ui/file-preview/src/components/code-viewer.js +73 -0
- package/dist/ui/file-preview/src/components/highlighting.d.ts +2 -0
- package/dist/ui/file-preview/src/components/highlighting.js +54 -0
- package/dist/ui/file-preview/src/components/html-renderer.d.ts +5 -0
- package/dist/ui/file-preview/src/components/html-renderer.js +47 -0
- package/dist/ui/file-preview/src/components/markdown-renderer.d.ts +1 -0
- package/dist/ui/file-preview/src/components/markdown-renderer.js +59 -0
- package/dist/ui/file-preview/src/directory-controller.d.ts +8 -0
- package/dist/ui/file-preview/src/directory-controller.js +240 -0
- package/dist/ui/file-preview/src/document-layout.d.ts +20 -0
- package/dist/ui/file-preview/src/document-layout.js +109 -0
- package/dist/ui/file-preview/src/document-outline.d.ts +17 -0
- package/dist/ui/file-preview/src/document-outline.js +97 -0
- package/dist/ui/file-preview/src/document-workspace.d.ts +19 -0
- package/dist/ui/file-preview/src/document-workspace.js +33 -0
- package/dist/ui/file-preview/src/file-type-handlers.d.ts +10 -0
- package/dist/ui/file-preview/src/file-type-handlers.js +109 -0
- package/dist/ui/file-preview/src/host/external-actions.d.ts +8 -0
- package/dist/ui/file-preview/src/host/external-actions.js +55 -0
- package/dist/ui/file-preview/src/host/selection-context.d.ts +9 -0
- package/dist/ui/file-preview/src/host/selection-context.js +106 -0
- package/dist/ui/file-preview/src/image-preview.d.ts +3 -0
- package/dist/ui/file-preview/src/image-preview.js +21 -0
- package/dist/ui/file-preview/src/main.d.ts +1 -0
- package/dist/ui/file-preview/src/main.js +5 -0
- package/dist/ui/file-preview/src/markdown/conflict-dialog.d.ts +40 -0
- package/dist/ui/file-preview/src/markdown/conflict-dialog.js +163 -0
- package/dist/ui/file-preview/src/markdown/controller.d.ts +44 -0
- package/dist/ui/file-preview/src/markdown/controller.js +1043 -0
- package/dist/ui/file-preview/src/markdown/editor.d.ts +131 -0
- package/dist/ui/file-preview/src/markdown/editor.js +1479 -0
- package/dist/ui/file-preview/src/markdown/linking.d.ts +16 -0
- package/dist/ui/file-preview/src/markdown/linking.js +228 -0
- package/dist/ui/file-preview/src/markdown/outline.d.ts +2 -0
- package/dist/ui/file-preview/src/markdown/outline.js +16 -0
- package/dist/ui/file-preview/src/markdown/parser.d.ts +30 -0
- package/dist/ui/file-preview/src/markdown/parser.js +38 -0
- package/dist/ui/file-preview/src/markdown/preview.d.ts +1 -0
- package/dist/ui/file-preview/src/markdown/preview.js +20 -0
- package/dist/ui/file-preview/src/markdown/slugify.d.ts +3 -0
- package/dist/ui/file-preview/src/markdown/slugify.js +31 -0
- package/dist/ui/file-preview/src/markdown/utils.d.ts +1 -0
- package/dist/ui/file-preview/src/markdown/utils.js +15 -0
- package/dist/ui/file-preview/src/model.d.ts +35 -0
- package/dist/ui/file-preview/src/model.js +1 -0
- package/dist/ui/file-preview/src/panel-actions.d.ts +17 -0
- package/dist/ui/file-preview/src/panel-actions.js +182 -0
- package/dist/ui/file-preview/src/path-utils.d.ts +6 -0
- package/dist/ui/file-preview/src/path-utils.js +64 -0
- package/dist/ui/file-preview/src/payload-utils.d.ts +11 -0
- package/dist/ui/file-preview/src/payload-utils.js +119 -0
- package/dist/ui/file-preview/src/types.d.ts +1 -0
- package/dist/ui/file-preview/src/types.js +1 -0
- package/dist/ui/file-preview/styles.css +1631 -0
- package/dist/ui/resources.d.ts +28 -0
- package/dist/ui/resources.js +86 -0
- package/dist/ui/shared/compact-row.d.ts +11 -0
- package/dist/ui/shared/compact-row.js +18 -0
- package/dist/ui/shared/escape-html.d.ts +4 -0
- package/dist/ui/shared/escape-html.js +11 -0
- package/dist/ui/shared/host-context.d.ts +15 -0
- package/dist/ui/shared/host-context.js +51 -0
- package/dist/ui/shared/tool-bridge.d.ts +30 -0
- package/dist/ui/shared/tool-bridge.js +137 -0
- package/dist/ui/shared/tool-shell.d.ts +25 -0
- package/dist/ui/shared/tool-shell.js +107 -0
- package/dist/ui/shared/ui-event-tracker.d.ts +9 -0
- package/dist/ui/shared/ui-event-tracker.js +27 -0
- package/dist/ui/shared/widget-state.d.ts +33 -0
- package/dist/ui/shared/widget-state.js +158 -0
- package/dist/utils/ab-test.d.ts +12 -0
- package/dist/utils/ab-test.js +104 -0
- package/dist/utils/capture.d.ts +35 -0
- package/dist/utils/capture.js +481 -0
- package/dist/utils/dockerPrompt.d.ts +17 -0
- package/dist/utils/dockerPrompt.js +53 -0
- package/dist/utils/feature-flags.d.ts +59 -0
- package/dist/utils/feature-flags.js +215 -0
- package/dist/utils/files/base.d.ts +173 -0
- package/dist/utils/files/base.js +5 -0
- package/dist/utils/files/binary.d.ts +21 -0
- package/dist/utils/files/binary.js +65 -0
- package/dist/utils/files/docx.d.ts +47 -0
- package/dist/utils/files/docx.js +679 -0
- package/dist/utils/files/excel.d.ts +24 -0
- package/dist/utils/files/excel.js +437 -0
- package/dist/utils/files/factory.d.ts +41 -0
- package/dist/utils/files/factory.js +113 -0
- package/dist/utils/files/image.d.ts +21 -0
- package/dist/utils/files/image.js +78 -0
- package/dist/utils/files/index.d.ts +10 -0
- package/dist/utils/files/index.js +13 -0
- package/dist/utils/files/pdf.d.ts +32 -0
- package/dist/utils/files/pdf.js +142 -0
- package/dist/utils/files/text.d.ts +63 -0
- package/dist/utils/files/text.js +370 -0
- package/dist/utils/fuzzySearchLogger.d.ts +30 -0
- package/dist/utils/fuzzySearchLogger.js +126 -0
- package/dist/utils/lineEndingHandler.d.ts +21 -0
- package/dist/utils/lineEndingHandler.js +77 -0
- package/dist/utils/logger.d.ts +32 -0
- package/dist/utils/logger.js +72 -0
- package/dist/utils/mcp-ui-ab-test.d.ts +13 -0
- package/dist/utils/mcp-ui-ab-test.js +62 -0
- package/dist/utils/open-browser.d.ts +9 -0
- package/dist/utils/open-browser.js +42 -0
- package/dist/utils/process-detection.d.ts +23 -0
- package/dist/utils/process-detection.js +150 -0
- package/dist/utils/ripgrep-resolver.d.ts +9 -0
- package/dist/utils/ripgrep-resolver.js +74 -0
- package/dist/utils/system-info.d.ts +71 -0
- package/dist/utils/system-info.js +712 -0
- package/dist/utils/toolHistory.d.ts +86 -0
- package/dist/utils/toolHistory.js +257 -0
- package/dist/utils/trackTools.d.ts +6 -0
- package/dist/utils/trackTools.js +54 -0
- package/dist/utils/unsupportedParams.d.ts +24 -0
- package/dist/utils/unsupportedParams.js +66 -0
- package/dist/utils/usageTracker.d.ts +133 -0
- package/dist/utils/usageTracker.js +477 -0
- package/dist/utils/welcome-onboarding.d.ts +11 -0
- package/dist/utils/welcome-onboarding.js +99 -0
- package/dist/utils/withTimeout.d.ts +28 -0
- package/dist/utils/withTimeout.js +85 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/package.json +131 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface ArrayModalEntry {
|
|
2
|
+
key: string;
|
|
3
|
+
label?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
value: unknown;
|
|
6
|
+
}
|
|
7
|
+
interface CreateArrayModalControllerOptions {
|
|
8
|
+
container: HTMLElement;
|
|
9
|
+
parseEntryItems: (entry: ArrayModalEntry) => string[];
|
|
10
|
+
formatEntryTitle: (entry: ArrayModalEntry) => string;
|
|
11
|
+
onSave: (entryKey: string, items: string[]) => void | Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export interface ArrayModalController {
|
|
14
|
+
open: (entry: ArrayModalEntry) => void;
|
|
15
|
+
close: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function renderArrayModalMarkup(initialTitle: string): string;
|
|
18
|
+
export declare function createArrayModalController(options: CreateArrayModalControllerOptions): ArrayModalController;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { escapeHtml } from '../../shared/escape-html.js';
|
|
2
|
+
export function renderArrayModalMarkup(initialTitle) {
|
|
3
|
+
return `
|
|
4
|
+
<div class="array-modal" id="array-modal" hidden>
|
|
5
|
+
<div class="array-modal-card">
|
|
6
|
+
<header>
|
|
7
|
+
<h3 id="array-modal-title">${escapeHtml(initialTitle)}</h3>
|
|
8
|
+
<div class="array-modal-actions">
|
|
9
|
+
<button type="button" id="array-modal-save" aria-label="Save list changes">
|
|
10
|
+
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M5 13l4 4L19 7"></path></svg>
|
|
11
|
+
</button>
|
|
12
|
+
<button type="button" id="array-modal-close" aria-label="Close list editor">
|
|
13
|
+
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M7 7l10 10M17 7L7 17"></path></svg>
|
|
14
|
+
</button>
|
|
15
|
+
</div>
|
|
16
|
+
</header>
|
|
17
|
+
<p class="array-modal-description" id="array-modal-description"></p>
|
|
18
|
+
<p class="array-modal-hint">Type an item, then press Enter (or click away) to add it. A new empty row appears automatically.</p>
|
|
19
|
+
<p class="array-modal-error hidden" id="array-modal-error" role="status" aria-live="polite"></p>
|
|
20
|
+
<div class="array-modal-list" id="array-modal-list"></div>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
export function createArrayModalController(options) {
|
|
26
|
+
const { container, parseEntryItems, formatEntryTitle, onSave } = options;
|
|
27
|
+
const modal = container.querySelector('#array-modal');
|
|
28
|
+
const modalList = container.querySelector('#array-modal-list');
|
|
29
|
+
const modalTitleElement = container.querySelector('#array-modal-title');
|
|
30
|
+
const modalDescriptionElement = container.querySelector('#array-modal-description');
|
|
31
|
+
const modalErrorElement = container.querySelector('#array-modal-error');
|
|
32
|
+
const modalClose = container.querySelector('#array-modal-close');
|
|
33
|
+
const modalSave = container.querySelector('#array-modal-save');
|
|
34
|
+
let modalEntryKey = null;
|
|
35
|
+
let modalItems = [];
|
|
36
|
+
const clearError = () => {
|
|
37
|
+
if (!modalErrorElement) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
modalErrorElement.textContent = '';
|
|
41
|
+
modalErrorElement.classList.add('hidden');
|
|
42
|
+
};
|
|
43
|
+
const showError = (message) => {
|
|
44
|
+
if (!modalErrorElement) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
modalErrorElement.textContent = message;
|
|
48
|
+
modalErrorElement.classList.remove('hidden');
|
|
49
|
+
};
|
|
50
|
+
const collectModalItemsFromDom = () => {
|
|
51
|
+
if (!modalList) {
|
|
52
|
+
return [...modalItems];
|
|
53
|
+
}
|
|
54
|
+
const existing = Array.from(modalList.querySelectorAll('.array-modal-item-input'))
|
|
55
|
+
.map((input) => input.value.trim())
|
|
56
|
+
.filter((value) => value.length > 0);
|
|
57
|
+
const newInput = modalList.querySelector('#array-modal-new-item');
|
|
58
|
+
const newValue = newInput?.value.trim() ?? '';
|
|
59
|
+
if (newValue.length > 0) {
|
|
60
|
+
return [newValue, ...existing];
|
|
61
|
+
}
|
|
62
|
+
return existing;
|
|
63
|
+
};
|
|
64
|
+
const renderModalList = () => {
|
|
65
|
+
if (!modalList) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
modalList.innerHTML = `
|
|
69
|
+
<div class="array-modal-row array-modal-row--new">
|
|
70
|
+
<input id="array-modal-new-item" type="text" placeholder="Add item" aria-label="Add new item" />
|
|
71
|
+
</div>
|
|
72
|
+
${modalItems.map((item, index) => `
|
|
73
|
+
<div class="array-modal-row" data-modal-index="${index}">
|
|
74
|
+
<input class="array-modal-item-input" type="text" value="${escapeHtml(item)}" aria-label="Item ${index + 1}" />
|
|
75
|
+
<button type="button" class="array-modal-item-remove" aria-label="Remove item ${index + 1}">
|
|
76
|
+
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14M10 10v7M14 10v7"></path></svg>
|
|
77
|
+
</button>
|
|
78
|
+
</div>
|
|
79
|
+
`).join('')}
|
|
80
|
+
`;
|
|
81
|
+
const addModalItem = (value) => {
|
|
82
|
+
const normalized = value.trim();
|
|
83
|
+
if (!normalized) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const exists = modalItems.some((item) => item.trim() === normalized);
|
|
87
|
+
if (!exists) {
|
|
88
|
+
modalItems.unshift(normalized);
|
|
89
|
+
}
|
|
90
|
+
renderModalList();
|
|
91
|
+
};
|
|
92
|
+
const newInput = modalList.querySelector('#array-modal-new-item');
|
|
93
|
+
newInput?.addEventListener('blur', () => {
|
|
94
|
+
const value = newInput.value.trim();
|
|
95
|
+
if (!value) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
addModalItem(value);
|
|
99
|
+
const refreshedNewInput = modalList.querySelector('#array-modal-new-item');
|
|
100
|
+
refreshedNewInput?.focus();
|
|
101
|
+
});
|
|
102
|
+
newInput?.addEventListener('keydown', (event) => {
|
|
103
|
+
if (event.key !== 'Enter') {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
const value = newInput.value.trim();
|
|
108
|
+
if (!value) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
addModalItem(value);
|
|
112
|
+
const refreshedNewInput = modalList.querySelector('#array-modal-new-item');
|
|
113
|
+
refreshedNewInput?.focus();
|
|
114
|
+
});
|
|
115
|
+
modalList.querySelectorAll('.array-modal-row[data-modal-index]').forEach((rowElement) => {
|
|
116
|
+
const row = rowElement;
|
|
117
|
+
const index = Number(row.dataset.modalIndex);
|
|
118
|
+
const input = row.querySelector('.array-modal-item-input');
|
|
119
|
+
const removeButton = row.querySelector('.array-modal-item-remove');
|
|
120
|
+
input?.addEventListener('blur', () => {
|
|
121
|
+
modalItems[index] = input.value.trim();
|
|
122
|
+
modalItems = modalItems.filter((item) => item.length > 0);
|
|
123
|
+
renderModalList();
|
|
124
|
+
});
|
|
125
|
+
removeButton?.addEventListener('click', () => {
|
|
126
|
+
modalItems = modalItems.filter((_, itemIndex) => itemIndex !== index);
|
|
127
|
+
renderModalList();
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
const close = () => {
|
|
132
|
+
if (modal) {
|
|
133
|
+
modal.hidden = true;
|
|
134
|
+
}
|
|
135
|
+
modalEntryKey = null;
|
|
136
|
+
clearError();
|
|
137
|
+
};
|
|
138
|
+
const open = (entry) => {
|
|
139
|
+
modalEntryKey = entry.key;
|
|
140
|
+
modalItems = parseEntryItems(entry);
|
|
141
|
+
clearError();
|
|
142
|
+
if (modalTitleElement) {
|
|
143
|
+
modalTitleElement.textContent = formatEntryTitle(entry);
|
|
144
|
+
}
|
|
145
|
+
if (modalDescriptionElement) {
|
|
146
|
+
modalDescriptionElement.textContent = entry.description ?? '';
|
|
147
|
+
modalDescriptionElement.classList.toggle('hidden', !modalDescriptionElement.textContent.trim());
|
|
148
|
+
}
|
|
149
|
+
renderModalList();
|
|
150
|
+
if (modal) {
|
|
151
|
+
modal.hidden = false;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
modalClose?.addEventListener('click', close);
|
|
155
|
+
modal?.addEventListener('click', (event) => {
|
|
156
|
+
if (event.target === modal) {
|
|
157
|
+
close();
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
modalSave?.addEventListener('click', async () => {
|
|
161
|
+
if (!modalEntryKey) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const changedKey = modalEntryKey;
|
|
165
|
+
modalItems = collectModalItemsFromDom();
|
|
166
|
+
clearError();
|
|
167
|
+
if (modalSave) {
|
|
168
|
+
modalSave.disabled = true;
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
await onSave(changedKey, modalItems);
|
|
172
|
+
close();
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
176
|
+
showError(message.trim().length > 0 ? message : 'Failed to save list changes.');
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
if (modalSave) {
|
|
180
|
+
modalSave.disabled = false;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
return { open, close };
|
|
185
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|