@eclipse-lyra/core 0.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/dist/api/base-classes.d.ts +7 -0
- package/dist/api/base-classes.d.ts.map +1 -0
- package/dist/api/constants.d.ts +2 -0
- package/dist/api/constants.d.ts.map +1 -0
- package/dist/api/index.d.ts +6 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +84 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/services.d.ts +28 -0
- package/dist/api/services.d.ts.map +1 -0
- package/dist/api/types.d.ts +11 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/commands/editor.d.ts +1 -0
- package/dist/commands/editor.d.ts.map +1 -0
- package/dist/commands/files.d.ts +2 -0
- package/dist/commands/files.d.ts.map +1 -0
- package/dist/commands/global.d.ts +1 -0
- package/dist/commands/global.d.ts.map +1 -0
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/open-view-as-editor.d.ts +2 -0
- package/dist/commands/open-view-as-editor.d.ts.map +1 -0
- package/dist/commands/version-info.d.ts +2 -0
- package/dist/commands/version-info.d.ts.map +1 -0
- package/dist/components/app-selector.d.ts +17 -0
- package/dist/components/app-selector.d.ts.map +1 -0
- package/dist/components/app-switcher.d.ts +13 -0
- package/dist/components/app-switcher.d.ts.map +1 -0
- package/dist/components/command.d.ts +31 -0
- package/dist/components/command.d.ts.map +1 -0
- package/dist/components/extensions.d.ts +32 -0
- package/dist/components/extensions.d.ts.map +1 -0
- package/dist/components/fastviews.d.ts +34 -0
- package/dist/components/fastviews.d.ts.map +1 -0
- package/dist/components/filebrowser.d.ts +45 -0
- package/dist/components/filebrowser.d.ts.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/language-selector.d.ts +12 -0
- package/dist/components/language-selector.d.ts.map +1 -0
- package/dist/components/log-terminal.d.ts +36 -0
- package/dist/components/log-terminal.d.ts.map +1 -0
- package/dist/components/part-name.d.ts +12 -0
- package/dist/components/part-name.d.ts.map +1 -0
- package/dist/components/tasks.d.ts +13 -0
- package/dist/components/tasks.d.ts.map +1 -0
- package/dist/contributions/default-ui-contributions.d.ts +2 -0
- package/dist/contributions/default-ui-contributions.d.ts.map +1 -0
- package/dist/contributions/index.d.ts +1 -0
- package/dist/contributions/index.d.ts.map +1 -0
- package/dist/contributions/marketplace-catalog-contributions.d.ts +2 -0
- package/dist/contributions/marketplace-catalog-contributions.d.ts.map +1 -0
- package/dist/core/app-host-config.d.ts +7 -0
- package/dist/core/app-host-config.d.ts.map +1 -0
- package/dist/core/apploader.d.ts +214 -0
- package/dist/core/apploader.d.ts.map +1 -0
- package/dist/core/appstate.d.ts +12 -0
- package/dist/core/appstate.d.ts.map +1 -0
- package/dist/core/commandregistry.d.ts +79 -0
- package/dist/core/commandregistry.d.ts.map +1 -0
- package/dist/core/config.d.ts +15 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/constants.d.ts +22 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/contributionregistry.d.ts +53 -0
- package/dist/core/contributionregistry.d.ts.map +1 -0
- package/dist/core/di.d.ts +18 -0
- package/dist/core/di.d.ts.map +1 -0
- package/dist/core/dialogservice.d.ts +33 -0
- package/dist/core/dialogservice.d.ts.map +1 -0
- package/dist/core/editorregistry.d.ts +87 -0
- package/dist/core/editorregistry.d.ts.map +1 -0
- package/dist/core/esmsh-service.d.ts +40 -0
- package/dist/core/esmsh-service.d.ts.map +1 -0
- package/dist/core/events.d.ts +7 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/events.js +63 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/extensionregistry.d.ts +98 -0
- package/dist/core/extensionregistry.d.ts.map +1 -0
- package/dist/core/filesys/common.d.ts +122 -0
- package/dist/core/filesys/common.d.ts.map +1 -0
- package/dist/core/filesys/fs-access.d.ts +31 -0
- package/dist/core/filesys/fs-access.d.ts.map +1 -0
- package/dist/core/filesys/index.d.ts +5 -0
- package/dist/core/filesys/index.d.ts.map +1 -0
- package/dist/core/filesys/indexeddb.d.ts +41 -0
- package/dist/core/filesys/indexeddb.d.ts.map +1 -0
- package/dist/core/filesys/opfs.d.ts +14 -0
- package/dist/core/filesys/opfs.d.ts.map +1 -0
- package/dist/core/i18n.d.ts +50 -0
- package/dist/core/i18n.d.ts.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/keybindings.d.ts +67 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/logger.d.ts +44 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/marketplaceregistry.d.ts +25 -0
- package/dist/core/marketplaceregistry.d.ts.map +1 -0
- package/dist/core/packageinfoservice.d.ts +16 -0
- package/dist/core/packageinfoservice.d.ts.map +1 -0
- package/dist/core/persistenceservice.d.ts +6 -0
- package/dist/core/persistenceservice.d.ts.map +1 -0
- package/dist/core/settingsservice.d.ts +54 -0
- package/dist/core/settingsservice.d.ts.map +1 -0
- package/dist/core/signals.d.ts +3 -0
- package/dist/core/signals.d.ts.map +1 -0
- package/dist/core/taskservice.d.ts +20 -0
- package/dist/core/taskservice.d.ts.map +1 -0
- package/dist/core/toast.d.ts +4 -0
- package/dist/core/toast.d.ts.map +1 -0
- package/dist/core/tree-utils.d.ts +16 -0
- package/dist/core/tree-utils.d.ts.map +1 -0
- package/dist/dialogs/confirm-dialog.d.ts +14 -0
- package/dist/dialogs/confirm-dialog.d.ts.map +1 -0
- package/dist/dialogs/index.d.ts +5 -0
- package/dist/dialogs/index.d.ts.map +1 -0
- package/dist/dialogs/info-dialog.d.ts +13 -0
- package/dist/dialogs/info-dialog.d.ts.map +1 -0
- package/dist/dialogs/navigable-info-dialog.d.ts +33 -0
- package/dist/dialogs/navigable-info-dialog.d.ts.map +1 -0
- package/dist/dialogs/prompt-dialog.d.ts +21 -0
- package/dist/dialogs/prompt-dialog.d.ts.map +1 -0
- package/dist/externals/lit.d.ts +21 -0
- package/dist/externals/lit.d.ts.map +1 -0
- package/dist/externals/lit.js +24 -0
- package/dist/externals/lit.js.map +1 -0
- package/dist/externals/third-party.d.ts +7 -0
- package/dist/externals/third-party.d.ts.map +1 -0
- package/dist/externals/third-party.js +7 -0
- package/dist/externals/third-party.js.map +1 -0
- package/dist/externals/webawesome.d.ts +1 -0
- package/dist/externals/webawesome.d.ts.map +1 -0
- package/dist/externals/webawesome.js +75 -0
- package/dist/externals/webawesome.js.map +1 -0
- package/dist/i18n/extensions.json.d.ts +42 -0
- package/dist/i18n/fastviews.json.d.ts +13 -0
- package/dist/i18n/filebrowser.json.d.ts +29 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/logterminal.json.d.ts +45 -0
- package/dist/i18n/partname.json.d.ts +15 -0
- package/dist/i18n/tasks.json.d.ts +15 -0
- package/dist/i18n/workspace.json.d.ts +15 -0
- package/dist/icon-DN6fp0dg.js +487 -0
- package/dist/icon-DN6fp0dg.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +84 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts/standard-layout.d.ts +16 -0
- package/dist/layouts/standard-layout.d.ts.map +1 -0
- package/dist/nocontent-BhrN6yxJ.js +48 -0
- package/dist/nocontent-BhrN6yxJ.js.map +1 -0
- package/dist/parts/container.d.ts +4 -0
- package/dist/parts/container.d.ts.map +1 -0
- package/dist/parts/contextmenu.d.ts +50 -0
- package/dist/parts/contextmenu.d.ts.map +1 -0
- package/dist/parts/dialog-content.d.ts +9 -0
- package/dist/parts/dialog-content.d.ts.map +1 -0
- package/dist/parts/element.d.ts +36 -0
- package/dist/parts/element.d.ts.map +1 -0
- package/dist/parts/index.d.ts +1 -0
- package/dist/parts/index.d.ts.map +1 -0
- package/dist/parts/index.js +3 -0
- package/dist/parts/index.js.map +1 -0
- package/dist/parts/part.d.ts +96 -0
- package/dist/parts/part.d.ts.map +1 -0
- package/dist/parts/resizable-grid.d.ts +31 -0
- package/dist/parts/resizable-grid.d.ts.map +1 -0
- package/dist/parts/tabs.d.ts +75 -0
- package/dist/parts/tabs.d.ts.map +1 -0
- package/dist/parts/toolbar.d.ts +35 -0
- package/dist/parts/toolbar.d.ts.map +1 -0
- package/dist/resizable-grid-BRH3MyZK.js +3813 -0
- package/dist/resizable-grid-BRH3MyZK.js.map +1 -0
- package/dist/standard-layout-BSGa06lP.js +4907 -0
- package/dist/standard-layout-BSGa06lP.js.map +1 -0
- package/dist/widgets/icon.d.ts +10 -0
- package/dist/widgets/icon.d.ts.map +1 -0
- package/dist/widgets/index.d.ts +1 -0
- package/dist/widgets/index.d.ts.map +1 -0
- package/dist/widgets/index.js +3 -0
- package/dist/widgets/index.js.map +1 -0
- package/dist/widgets/nocontent.d.ts +13 -0
- package/dist/widgets/nocontent.d.ts.map +1 -0
- package/dist/widgets/widget.d.ts +25 -0
- package/dist/widgets/widget.d.ts.map +1 -0
- package/package.json +81 -0
- package/src/api/base-classes.ts +10 -0
- package/src/api/constants.ts +3 -0
- package/src/api/index.ts +31 -0
- package/src/api/services.ts +58 -0
- package/src/api/types.ts +46 -0
- package/src/commands/editor.ts +1 -0
- package/src/commands/files.ts +425 -0
- package/src/commands/global.ts +198 -0
- package/src/commands/index.ts +6 -0
- package/src/commands/open-view-as-editor.ts +28 -0
- package/src/commands/version-info.ts +214 -0
- package/src/components/app-selector.ts +233 -0
- package/src/components/app-switcher.ts +126 -0
- package/src/components/command.ts +236 -0
- package/src/components/extensions.ts +615 -0
- package/src/components/fastviews.ts +314 -0
- package/src/components/filebrowser.ts +518 -0
- package/src/components/index.ts +9 -0
- package/src/components/language-selector.ts +166 -0
- package/src/components/log-terminal.ts +337 -0
- package/src/components/part-name.ts +54 -0
- package/src/components/tasks.ts +275 -0
- package/src/contributions/default-ui-contributions.ts +44 -0
- package/src/contributions/index.ts +3 -0
- package/src/contributions/marketplace-catalog-contributions.ts +6 -0
- package/src/core/app-host-config.ts +23 -0
- package/src/core/apploader.ts +630 -0
- package/src/core/appstate.ts +15 -0
- package/src/core/commandregistry.ts +210 -0
- package/src/core/config.ts +29 -0
- package/src/core/constants.ts +29 -0
- package/src/core/contributionregistry.ts +81 -0
- package/src/core/di.ts +54 -0
- package/src/core/dialogservice.ts +266 -0
- package/src/core/editorregistry.ts +347 -0
- package/src/core/esmsh-service.ts +404 -0
- package/src/core/events.ts +68 -0
- package/src/core/extensionregistry.ts +399 -0
- package/src/core/filesys/common.ts +474 -0
- package/src/core/filesys/fs-access.ts +339 -0
- package/src/core/filesys/index.ts +5 -0
- package/src/core/filesys/indexeddb.ts +596 -0
- package/src/core/filesys/opfs.ts +95 -0
- package/src/core/i18n.ts +221 -0
- package/src/core/index.ts +51 -0
- package/src/core/keybindings.ts +274 -0
- package/src/core/logger.ts +187 -0
- package/src/core/marketplaceregistry.ts +197 -0
- package/src/core/packageinfoservice.ts +56 -0
- package/src/core/persistenceservice.ts +46 -0
- package/src/core/settingsservice.ts +191 -0
- package/src/core/signals.ts +18 -0
- package/src/core/taskservice.ts +72 -0
- package/src/core/toast.ts +21 -0
- package/src/core/tree-utils.ts +24 -0
- package/src/dialogs/confirm-dialog.ts +72 -0
- package/src/dialogs/index.ts +4 -0
- package/src/dialogs/info-dialog.ts +67 -0
- package/src/dialogs/navigable-info-dialog.ts +256 -0
- package/src/dialogs/prompt-dialog.ts +123 -0
- package/src/externals/lit.ts +36 -0
- package/src/externals/third-party.ts +10 -0
- package/src/externals/webawesome.ts +76 -0
- package/src/i18n/extensions.json +39 -0
- package/src/i18n/fastviews.json +10 -0
- package/src/i18n/filebrowser.json +27 -0
- package/src/i18n/index.ts +25 -0
- package/src/i18n/logterminal.json +42 -0
- package/src/i18n/partname.json +12 -0
- package/src/i18n/tasks.json +12 -0
- package/src/i18n/workspace.json +12 -0
- package/src/icons/icons.txt +3 -0
- package/src/icons/js.svg +6 -0
- package/src/icons/jupyter.svg +18 -0
- package/src/icons/python.svg +15 -0
- package/src/index.ts +3 -0
- package/src/layouts/standard-layout.ts +174 -0
- package/src/parts/container.ts +4 -0
- package/src/parts/contextmenu.ts +266 -0
- package/src/parts/dialog-content.ts +31 -0
- package/src/parts/element.ts +100 -0
- package/src/parts/index.ts +5 -0
- package/src/parts/part.ts +158 -0
- package/src/parts/resizable-grid.ts +366 -0
- package/src/parts/tabs.ts +581 -0
- package/src/parts/toolbar.ts +260 -0
- package/src/vite-env.d.ts +16 -0
- package/src/widgets/icon.ts +38 -0
- package/src/widgets/index.ts +2 -0
- package/src/widgets/nocontent.ts +40 -0
- package/src/widgets/widget.ts +92 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {activeTasksSignal} from "./appstate";
|
|
2
|
+
import {rootContext} from "./di";
|
|
3
|
+
|
|
4
|
+
export interface ProgressMonitor {
|
|
5
|
+
name: string
|
|
6
|
+
message: string
|
|
7
|
+
currentStep: number
|
|
8
|
+
totalSteps: number
|
|
9
|
+
progress: number // Manual progress percentage (0-100), overrides step-based calculation if >= 0
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type Task = (progressMonitor: ProgressMonitor) => any
|
|
13
|
+
export type AsyncTask = (progressMonitor: ProgressMonitor) => Promise<any>
|
|
14
|
+
|
|
15
|
+
export class TaskService {
|
|
16
|
+
private tasks: ProgressMonitor[] = []
|
|
17
|
+
private updateCounter = 0
|
|
18
|
+
|
|
19
|
+
private notifyUpdate() {
|
|
20
|
+
// Always increment counter to ensure signal value changes and triggers re-render
|
|
21
|
+
this.updateCounter++
|
|
22
|
+
activeTasksSignal.set(this.updateCounter)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public run(name: string, task: Task) {
|
|
26
|
+
const progressMonitor = this.createProgressMonitor(name)
|
|
27
|
+
try {
|
|
28
|
+
this.tasks.push(progressMonitor)
|
|
29
|
+
this.notifyUpdate()
|
|
30
|
+
task(progressMonitor)
|
|
31
|
+
} finally {
|
|
32
|
+
this.tasks.splice(this.tasks.indexOf(progressMonitor), 1)
|
|
33
|
+
this.notifyUpdate()
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public async runAsync(name: string, task: AsyncTask) {
|
|
38
|
+
const progressMonitor = this.createProgressMonitor(name)
|
|
39
|
+
this.tasks.push(progressMonitor)
|
|
40
|
+
this.notifyUpdate()
|
|
41
|
+
return task(progressMonitor).finally(() => {
|
|
42
|
+
this.tasks.splice(this.tasks.indexOf(progressMonitor), 1)
|
|
43
|
+
this.notifyUpdate()
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private createProgressMonitor(name: string): ProgressMonitor {
|
|
48
|
+
const monitor = {
|
|
49
|
+
name: name,
|
|
50
|
+
message: "",
|
|
51
|
+
currentStep: 0,
|
|
52
|
+
totalSteps: -1, // -1 indicates indefinite progress
|
|
53
|
+
progress: -1 // -1 means use step-based calculation
|
|
54
|
+
} as ProgressMonitor
|
|
55
|
+
|
|
56
|
+
// Create a proxy to detect property changes and trigger UI updates
|
|
57
|
+
return new Proxy(monitor, {
|
|
58
|
+
set: (target, prop, value) => {
|
|
59
|
+
(target as any)[prop] = value
|
|
60
|
+
this.notifyUpdate()
|
|
61
|
+
return true
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getActiveTasks() {
|
|
67
|
+
return this.tasks
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const taskService = new TaskService()
|
|
72
|
+
rootContext.put("taskService", taskService)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Toastify from 'toastify-js';
|
|
2
|
+
import 'toastify-js/src/toastify.css';
|
|
3
|
+
|
|
4
|
+
const DURATION = 4000;
|
|
5
|
+
const BASE = { duration: DURATION, gravity: 'bottom' as const, position: 'right' as const, close: true };
|
|
6
|
+
|
|
7
|
+
const show = (msg: string, style: { background: string; color: string }) => {
|
|
8
|
+
Toastify({ ...BASE, text: msg, style }).showToast();
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const toastInfo = (msg: string) => {
|
|
12
|
+
show(msg, { background: 'var(--wa-color-brand-50)', color: 'var(--wa-color-brand-on)' });
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const toastError = (msg: string) => {
|
|
16
|
+
show(msg, { background: 'var(--wa-color-danger-50)', color: 'var(--wa-color-danger-on)' });
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const toastWarning = (msg: string) => {
|
|
20
|
+
show(msg, { background: 'var(--wa-color-warning-50)', color: 'var(--wa-color-warning-on)' });
|
|
21
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {Contribution} from "./contributionregistry";
|
|
2
|
+
|
|
3
|
+
export interface TreeNode {
|
|
4
|
+
data: any;
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: string;
|
|
7
|
+
leaf: boolean;
|
|
8
|
+
children: TreeNode[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const treeNodeComparator = (c1: TreeNode, c2: TreeNode) => {
|
|
12
|
+
if (!c1.leaf && c2.leaf) {
|
|
13
|
+
return -1
|
|
14
|
+
}
|
|
15
|
+
if (c1.leaf && !c2.leaf) {
|
|
16
|
+
return 1
|
|
17
|
+
}
|
|
18
|
+
return c1.label.localeCompare(c2.label)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface TreeContribution extends Contribution {
|
|
22
|
+
contributionId?: string;
|
|
23
|
+
state?: { [key: string]: any }
|
|
24
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { html } from "lit";
|
|
2
|
+
import { customElement, property } from "lit/decorators.js";
|
|
3
|
+
import { LyraDialogContent } from "../parts/dialog-content";
|
|
4
|
+
import { contributionRegistry } from "../core/contributionregistry";
|
|
5
|
+
import { DIALOG_CONTRIBUTION_TARGET, OK_BUTTON, CANCEL_BUTTON, DialogContribution, dialogService } from "../core/dialogservice";
|
|
6
|
+
|
|
7
|
+
@customElement('lyra-confirm-dialog-content')
|
|
8
|
+
export class LyraConfirmDialogContent extends LyraDialogContent {
|
|
9
|
+
@property({ type: String })
|
|
10
|
+
message: string = '';
|
|
11
|
+
|
|
12
|
+
@property({ type: Boolean })
|
|
13
|
+
markdown: boolean = false;
|
|
14
|
+
|
|
15
|
+
getResult(): boolean {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
render() {
|
|
20
|
+
return html`
|
|
21
|
+
${this.renderMessage(this.message, this.markdown)}
|
|
22
|
+
`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare global {
|
|
27
|
+
interface HTMLElementTagNameMap {
|
|
28
|
+
'lyra-confirm-dialog-content': LyraConfirmDialogContent;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
contributionRegistry.registerContribution(DIALOG_CONTRIBUTION_TARGET, {
|
|
33
|
+
id: 'confirm',
|
|
34
|
+
label: 'Confirm',
|
|
35
|
+
buttons: [OK_BUTTON, CANCEL_BUTTON],
|
|
36
|
+
component: (state?: any) => {
|
|
37
|
+
if (!state) {
|
|
38
|
+
return html`<div>Error: No confirm dialog state</div>`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return html`
|
|
42
|
+
<lyra-confirm-dialog-content
|
|
43
|
+
.message="${state.message}"
|
|
44
|
+
.markdown="${state.markdown}"
|
|
45
|
+
></lyra-confirm-dialog-content>
|
|
46
|
+
`;
|
|
47
|
+
},
|
|
48
|
+
onButton: async (id: string, result: any, state?: any) => {
|
|
49
|
+
if (!state) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (id === 'ok') {
|
|
54
|
+
state.resolve(true);
|
|
55
|
+
} else {
|
|
56
|
+
state.resolve(false);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export async function confirmDialog(message: string, markdown: boolean = false): Promise<boolean> {
|
|
64
|
+
return new Promise((resolve) => {
|
|
65
|
+
dialogService.open('confirm', {
|
|
66
|
+
message,
|
|
67
|
+
markdown,
|
|
68
|
+
resolve
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { html } from "lit";
|
|
2
|
+
import { customElement, property } from "lit/decorators.js";
|
|
3
|
+
import { LyraDialogContent } from "../parts/dialog-content";
|
|
4
|
+
import { contributionRegistry } from "../core/contributionregistry";
|
|
5
|
+
import { DIALOG_CONTRIBUTION_TARGET, OK_BUTTON, DialogContribution, dialogService } from "../core/dialogservice";
|
|
6
|
+
|
|
7
|
+
@customElement('lyra-info-dialog-content')
|
|
8
|
+
export class LyraInfoDialogContent extends LyraDialogContent {
|
|
9
|
+
@property({ type: String })
|
|
10
|
+
message: string = '';
|
|
11
|
+
|
|
12
|
+
@property({ type: Boolean })
|
|
13
|
+
markdown: boolean = false;
|
|
14
|
+
|
|
15
|
+
render() {
|
|
16
|
+
return html`
|
|
17
|
+
${this.renderMessage(this.message, this.markdown)}
|
|
18
|
+
`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare global {
|
|
23
|
+
interface HTMLElementTagNameMap {
|
|
24
|
+
'lyra-info-dialog-content': LyraInfoDialogContent;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
contributionRegistry.registerContribution(DIALOG_CONTRIBUTION_TARGET, {
|
|
29
|
+
id: 'info',
|
|
30
|
+
label: 'Information',
|
|
31
|
+
buttons: [OK_BUTTON],
|
|
32
|
+
component: (state?: any) => {
|
|
33
|
+
if (!state) {
|
|
34
|
+
return html`<div>Error: No info dialog state</div>`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return html`
|
|
38
|
+
<lyra-info-dialog-content
|
|
39
|
+
.message="${state.message}"
|
|
40
|
+
.markdown="${state.markdown}"
|
|
41
|
+
></lyra-info-dialog-content>
|
|
42
|
+
`;
|
|
43
|
+
},
|
|
44
|
+
onButton: async (id: string, result: any, state?: any) => {
|
|
45
|
+
if (!state) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (state.resolve) {
|
|
50
|
+
state.resolve();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export async function infoDialog(title: string, message: string, markdown: boolean = false): Promise<void> {
|
|
58
|
+
return new Promise((resolve) => {
|
|
59
|
+
dialogService.open('info', {
|
|
60
|
+
title,
|
|
61
|
+
message,
|
|
62
|
+
markdown,
|
|
63
|
+
resolve
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { html, css, PropertyValues } from "lit";
|
|
2
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
3
|
+
import { LyraDialogContent } from "../parts/dialog-content";
|
|
4
|
+
import { contributionRegistry } from "../core/contributionregistry";
|
|
5
|
+
import { DIALOG_CONTRIBUTION_TARGET, CLOSE_BUTTON, DialogContribution, dialogService } from "../core/dialogservice";
|
|
6
|
+
|
|
7
|
+
export interface NavigableDialogAction {
|
|
8
|
+
label: string;
|
|
9
|
+
variant?: 'default' | 'primary' | 'success' | 'neutral' | 'warning' | 'danger';
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
callback: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@customElement('lyra-navigable-info-dialog-content')
|
|
15
|
+
export class LyraNavigableInfoDialogContent extends LyraDialogContent {
|
|
16
|
+
@property({ type: String })
|
|
17
|
+
title: string = '';
|
|
18
|
+
|
|
19
|
+
@property({ type: String })
|
|
20
|
+
message: string = '';
|
|
21
|
+
|
|
22
|
+
@property({ type: Boolean })
|
|
23
|
+
markdown: boolean = false;
|
|
24
|
+
|
|
25
|
+
@state()
|
|
26
|
+
actions: NavigableDialogAction[] = [];
|
|
27
|
+
|
|
28
|
+
@state()
|
|
29
|
+
private currentTitle: string = '';
|
|
30
|
+
|
|
31
|
+
@state()
|
|
32
|
+
private currentMessage: string = '';
|
|
33
|
+
|
|
34
|
+
resolveCallback?: () => void;
|
|
35
|
+
private dialogElement: HTMLElement | null = null;
|
|
36
|
+
|
|
37
|
+
async firstUpdated(changedProperties: PropertyValues) {
|
|
38
|
+
super.firstUpdated(changedProperties);
|
|
39
|
+
this.currentTitle = this.title;
|
|
40
|
+
this.currentMessage = this.message;
|
|
41
|
+
|
|
42
|
+
await this.updateComplete;
|
|
43
|
+
const dialog = this.closest('wa-dialog');
|
|
44
|
+
if (dialog) {
|
|
45
|
+
this.dialogElement = dialog as HTMLElement;
|
|
46
|
+
this.updateDialogLabel();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const contentContainer = this.closest('.dialog-service-content');
|
|
50
|
+
if (contentContainer) {
|
|
51
|
+
const footer = contentContainer.parentElement?.querySelector('.dialog-service-footer');
|
|
52
|
+
if (footer) {
|
|
53
|
+
(footer as HTMLElement).style.display = 'none';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
updated(changedProperties: PropertyValues) {
|
|
59
|
+
super.updated(changedProperties);
|
|
60
|
+
if (changedProperties.has('title')) {
|
|
61
|
+
this.currentTitle = this.title;
|
|
62
|
+
this.updateDialogLabel();
|
|
63
|
+
}
|
|
64
|
+
if (changedProperties.has('message')) {
|
|
65
|
+
this.currentMessage = this.message;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private updateDialogLabel() {
|
|
70
|
+
if (this.dialogElement) {
|
|
71
|
+
this.dialogElement.setAttribute('label', this.currentTitle);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
updateDialog(newTitle: string, newMessage: string, newActions: NavigableDialogAction[]) {
|
|
76
|
+
this.currentTitle = newTitle;
|
|
77
|
+
this.currentMessage = newMessage;
|
|
78
|
+
this.actions = [...newActions];
|
|
79
|
+
this.updateDialogLabel();
|
|
80
|
+
this.requestUpdate();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private handleActionClick(action: NavigableDialogAction) {
|
|
84
|
+
action.callback();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private handleClose() {
|
|
88
|
+
const dialog = this.closest('wa-dialog');
|
|
89
|
+
if (dialog && this.resolveCallback) {
|
|
90
|
+
this.resolveCallback();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static styles = [
|
|
95
|
+
...LyraDialogContent.styles,
|
|
96
|
+
css`
|
|
97
|
+
:host {
|
|
98
|
+
display: block;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
:host-context(.dialog-service-content) {
|
|
102
|
+
padding: 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.dialog-content {
|
|
106
|
+
display: flex;
|
|
107
|
+
flex-direction: column;
|
|
108
|
+
gap: 1rem;
|
|
109
|
+
min-width: 400px;
|
|
110
|
+
max-width: 600px;
|
|
111
|
+
height: 500px;
|
|
112
|
+
padding: 1rem;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.dialog-scroller {
|
|
116
|
+
flex: 1;
|
|
117
|
+
overflow-y: auto;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.dialog-actions {
|
|
121
|
+
display: flex;
|
|
122
|
+
gap: 0.5rem;
|
|
123
|
+
justify-content: space-between;
|
|
124
|
+
margin-top: 0.5rem;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.dialog-actions-left,
|
|
128
|
+
.dialog-actions-right {
|
|
129
|
+
display: flex;
|
|
130
|
+
gap: 0.5rem;
|
|
131
|
+
}
|
|
132
|
+
`
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
render() {
|
|
136
|
+
const leftActions = this.actions.filter(a => a.label !== 'Close');
|
|
137
|
+
const rightActions = this.actions.filter(a => a.label === 'Close');
|
|
138
|
+
|
|
139
|
+
return html`
|
|
140
|
+
<div class="dialog-content">
|
|
141
|
+
<wa-scroller class="dialog-scroller">
|
|
142
|
+
${this.renderMessage(this.currentMessage, this.markdown)}
|
|
143
|
+
</wa-scroller>
|
|
144
|
+
|
|
145
|
+
<div class="dialog-actions">
|
|
146
|
+
<div class="dialog-actions-left">
|
|
147
|
+
${leftActions.map(action => html`
|
|
148
|
+
<wa-button
|
|
149
|
+
variant="${action.variant || 'default'}"
|
|
150
|
+
?disabled=${action.disabled}
|
|
151
|
+
@click=${() => this.handleActionClick(action)}
|
|
152
|
+
>
|
|
153
|
+
${action.label}
|
|
154
|
+
</wa-button>
|
|
155
|
+
`)}
|
|
156
|
+
</div>
|
|
157
|
+
<div class="dialog-actions-right">
|
|
158
|
+
${rightActions.map(action => html`
|
|
159
|
+
<wa-button
|
|
160
|
+
variant="${action.variant || 'primary'}"
|
|
161
|
+
@click=${() => {
|
|
162
|
+
this.handleActionClick(action);
|
|
163
|
+
this.handleClose();
|
|
164
|
+
}}
|
|
165
|
+
>
|
|
166
|
+
${action.label}
|
|
167
|
+
</wa-button>
|
|
168
|
+
`)}
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
`;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
declare global {
|
|
177
|
+
interface HTMLElementTagNameMap {
|
|
178
|
+
'lyra-navigable-info-dialog-content': LyraNavigableInfoDialogContent;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
contributionRegistry.registerContribution(DIALOG_CONTRIBUTION_TARGET, {
|
|
183
|
+
id: 'navigable-info',
|
|
184
|
+
label: 'Information',
|
|
185
|
+
buttons: [CLOSE_BUTTON],
|
|
186
|
+
component: (state?: any) => {
|
|
187
|
+
if (!state) {
|
|
188
|
+
return html`<div>Error: No navigable info dialog state</div>`;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const componentHtml = html`
|
|
192
|
+
<lyra-navigable-info-dialog-content
|
|
193
|
+
.title="${state.title}"
|
|
194
|
+
.message="${state.message}"
|
|
195
|
+
.markdown="${state.markdown}"
|
|
196
|
+
></lyra-navigable-info-dialog-content>
|
|
197
|
+
`;
|
|
198
|
+
|
|
199
|
+
(async () => {
|
|
200
|
+
const element = document.querySelector('lyra-navigable-info-dialog-content') as LyraNavigableInfoDialogContent;
|
|
201
|
+
if (element) {
|
|
202
|
+
await element.updateComplete;
|
|
203
|
+
element.actions = state.actions || [];
|
|
204
|
+
element.resolveCallback = state.resolve;
|
|
205
|
+
if (state.updateDialogRef) {
|
|
206
|
+
state.updateDialogRef.current = (newTitle: string, newMessage: string, newActions: NavigableDialogAction[]) => {
|
|
207
|
+
element.updateDialog(newTitle, newMessage, newActions);
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
})();
|
|
212
|
+
|
|
213
|
+
return componentHtml;
|
|
214
|
+
},
|
|
215
|
+
onButton: async (id: string, result: any, state?: any) => {
|
|
216
|
+
if (!state) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (id === 'close' && state.resolve) {
|
|
221
|
+
state.resolve();
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
export async function navigableInfoDialog(
|
|
230
|
+
title: string,
|
|
231
|
+
message: string,
|
|
232
|
+
actions: NavigableDialogAction[],
|
|
233
|
+
markdown: boolean = false
|
|
234
|
+
): Promise<void> {
|
|
235
|
+
return new Promise((resolve) => {
|
|
236
|
+
const updateDialogRef: { current?: (title: string, message: string, actions: NavigableDialogAction[]) => void } = {};
|
|
237
|
+
|
|
238
|
+
dialogService.open('navigable-info', {
|
|
239
|
+
title,
|
|
240
|
+
message,
|
|
241
|
+
actions,
|
|
242
|
+
markdown,
|
|
243
|
+
resolve,
|
|
244
|
+
updateDialogRef
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
const updateDialog = (newTitle: string, newMessage: string, newActions: NavigableDialogAction[]) => {
|
|
248
|
+
if (updateDialogRef.current) {
|
|
249
|
+
updateDialogRef.current(newTitle, newMessage, newActions);
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
(actions as any).updateDialog = updateDialog;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { html, css, PropertyValues } from "lit";
|
|
2
|
+
import { customElement, state, property } from "lit/decorators.js";
|
|
3
|
+
import { LyraDialogContent } from "../parts/dialog-content";
|
|
4
|
+
import { contributionRegistry } from "../core/contributionregistry";
|
|
5
|
+
import { DIALOG_CONTRIBUTION_TARGET, OK_BUTTON, CANCEL_BUTTON, DialogContribution, dialogService } from "../core/dialogservice";
|
|
6
|
+
|
|
7
|
+
@customElement('lyra-prompt-dialog-content')
|
|
8
|
+
export class LyraPromptDialogContent extends LyraDialogContent {
|
|
9
|
+
@property({ type: String })
|
|
10
|
+
message: string = '';
|
|
11
|
+
|
|
12
|
+
@property({ type: String, attribute: 'default-value' })
|
|
13
|
+
defaultValue: string = '';
|
|
14
|
+
|
|
15
|
+
@property({ type: Boolean })
|
|
16
|
+
markdown: boolean = false;
|
|
17
|
+
|
|
18
|
+
@state()
|
|
19
|
+
private inputValue: string = '';
|
|
20
|
+
|
|
21
|
+
static styles = [
|
|
22
|
+
...LyraDialogContent.styles,
|
|
23
|
+
css`
|
|
24
|
+
wa-input {
|
|
25
|
+
width: 100%;
|
|
26
|
+
}
|
|
27
|
+
`
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
async firstUpdated(changedProperties: PropertyValues) {
|
|
31
|
+
super.firstUpdated(changedProperties);
|
|
32
|
+
this.inputValue = this.defaultValue;
|
|
33
|
+
|
|
34
|
+
await this.updateComplete;
|
|
35
|
+
const input = this.shadowRoot?.querySelector('wa-input');
|
|
36
|
+
if (input) {
|
|
37
|
+
const inputEl = (input as any).shadowRoot?.querySelector('input');
|
|
38
|
+
if (inputEl) {
|
|
39
|
+
inputEl.focus();
|
|
40
|
+
inputEl.select();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getResult(): string | null {
|
|
46
|
+
return this.inputValue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private handleInput(e: Event) {
|
|
50
|
+
this.inputValue = (e.target as any).value;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private handleKeyDown(e: KeyboardEvent) {
|
|
54
|
+
if (e.key === 'Enter') {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
this.dispatchEvent(new CustomEvent('dialog-ok', { bubbles: true, composed: true }));
|
|
57
|
+
} else if (e.key === 'Escape') {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
this.dispatchEvent(new CustomEvent('dialog-cancel', { bubbles: true, composed: true }));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
render() {
|
|
64
|
+
return html`
|
|
65
|
+
${this.renderMessage(this.message, this.markdown)}
|
|
66
|
+
<wa-input
|
|
67
|
+
value="${this.inputValue}"
|
|
68
|
+
@input=${this.handleInput}
|
|
69
|
+
@keydown=${this.handleKeyDown}
|
|
70
|
+
autofocus
|
|
71
|
+
></wa-input>
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
declare global {
|
|
77
|
+
interface HTMLElementTagNameMap {
|
|
78
|
+
'lyra-prompt-dialog-content': LyraPromptDialogContent;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
contributionRegistry.registerContribution(DIALOG_CONTRIBUTION_TARGET, {
|
|
83
|
+
id: 'prompt',
|
|
84
|
+
label: 'Input',
|
|
85
|
+
buttons: [OK_BUTTON, CANCEL_BUTTON],
|
|
86
|
+
component: (state?: any) => {
|
|
87
|
+
if (!state) {
|
|
88
|
+
return html`<div>Error: No prompt dialog state</div>`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return html`
|
|
92
|
+
<lyra-prompt-dialog-content
|
|
93
|
+
.message="${state.message}"
|
|
94
|
+
.defaultValue="${state.defaultValue}"
|
|
95
|
+
.markdown="${state.markdown}"
|
|
96
|
+
></lyra-prompt-dialog-content>
|
|
97
|
+
`;
|
|
98
|
+
},
|
|
99
|
+
onButton: async (id: string, result: any, state?: any) => {
|
|
100
|
+
if (!state) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (id === 'ok') {
|
|
105
|
+
state.resolve(result || '');
|
|
106
|
+
} else {
|
|
107
|
+
state.resolve(null);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
export async function promptDialog(message: string, defaultValue: string = '', markdown: boolean = false): Promise<string | null> {
|
|
115
|
+
return new Promise((resolve) => {
|
|
116
|
+
dialogService.open('prompt', {
|
|
117
|
+
message,
|
|
118
|
+
defaultValue,
|
|
119
|
+
markdown,
|
|
120
|
+
resolve
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lit library exports
|
|
3
|
+
* Centralized Lit imports for use across packages.
|
|
4
|
+
* This ensures a single source of truth for Lit dependencies.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Re-export everything from lit core
|
|
8
|
+
export * from "lit";
|
|
9
|
+
|
|
10
|
+
// Re-export decorators
|
|
11
|
+
export * from "lit/decorators.js";
|
|
12
|
+
|
|
13
|
+
// Re-export commonly used directives
|
|
14
|
+
export * from "lit/directives/when.js";
|
|
15
|
+
export * from "lit/directives/repeat.js";
|
|
16
|
+
export * from "lit/directives/keyed.js";
|
|
17
|
+
export * from "lit/directives/class-map.js";
|
|
18
|
+
export * from "lit/directives/style-map.js";
|
|
19
|
+
export * from "lit/directives/if-defined.js";
|
|
20
|
+
export * from "lit/directives/guard.js";
|
|
21
|
+
export * from "lit/directives/cache.js";
|
|
22
|
+
export * from "lit/directives/unsafe-html.js";
|
|
23
|
+
export * from "lit/directives/until.js";
|
|
24
|
+
export * from "lit/directives/live.js";
|
|
25
|
+
export * from "lit/directives/ref.js";
|
|
26
|
+
|
|
27
|
+
// Re-export only signal APIs to avoid conflict with lit's html/svg
|
|
28
|
+
export {
|
|
29
|
+
signal,
|
|
30
|
+
computed,
|
|
31
|
+
Signal,
|
|
32
|
+
watch,
|
|
33
|
+
SignalWatcher,
|
|
34
|
+
withWatch,
|
|
35
|
+
} from "@lit-labs/signals";
|
|
36
|
+
|