@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,260 @@
|
|
|
1
|
+
import {css, html} from 'lit'
|
|
2
|
+
import {customElement, property, state} from 'lit/decorators.js'
|
|
3
|
+
import {LyraElement} from "./element";
|
|
4
|
+
import {styleMap} from 'lit/directives/style-map.js';
|
|
5
|
+
import {
|
|
6
|
+
CommandContribution,
|
|
7
|
+
Contribution,
|
|
8
|
+
ContributionChangeEvent,
|
|
9
|
+
contributionRegistry,
|
|
10
|
+
HTMLContribution,
|
|
11
|
+
TOPIC_CONTRIBUTEIONS_CHANGED
|
|
12
|
+
} from "../core/contributionregistry";
|
|
13
|
+
import {Signal} from '@lit-labs/signals';
|
|
14
|
+
import {unsafeHTML} from "lit/directives/unsafe-html.js";
|
|
15
|
+
import {subscribe} from "../core/events";
|
|
16
|
+
|
|
17
|
+
const RESIZE_DEBOUNCE_MS = 150;
|
|
18
|
+
|
|
19
|
+
type ToolbarSlotName = 'start' | undefined | 'end';
|
|
20
|
+
|
|
21
|
+
function renderButtonGroup(
|
|
22
|
+
slotName: ToolbarSlotName,
|
|
23
|
+
orientation: 'horizontal' | 'vertical',
|
|
24
|
+
contributions: Contribution[],
|
|
25
|
+
isToolbarItem: (c: Contribution) => boolean,
|
|
26
|
+
contributionCreator: (c: Contribution) => unknown
|
|
27
|
+
) {
|
|
28
|
+
const slot = slotName ?? 'default';
|
|
29
|
+
const label = `Toolbar ${slot}`;
|
|
30
|
+
const items = contributions.filter(c => c.slot === slotName && isToolbarItem(c));
|
|
31
|
+
const slotHtml = slotName === 'start'
|
|
32
|
+
? html`<slot name="start"></slot>`
|
|
33
|
+
: slotName === 'end'
|
|
34
|
+
? html`<slot name="end"></slot>`
|
|
35
|
+
: html`<slot></slot>`;
|
|
36
|
+
return html`
|
|
37
|
+
<wa-button-group orientation=${orientation} label=${label}>
|
|
38
|
+
${slotHtml}
|
|
39
|
+
${items.map(contributionCreator)}
|
|
40
|
+
</wa-button-group>
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@customElement('lyra-toolbar')
|
|
45
|
+
export class LyraToolbar extends LyraElement {
|
|
46
|
+
@property()
|
|
47
|
+
private position: "start" | "center" | "end" = "start";
|
|
48
|
+
|
|
49
|
+
@property({reflect: true})
|
|
50
|
+
orientation: "horizontal" | "vertical" = "horizontal";
|
|
51
|
+
|
|
52
|
+
@property({reflect: true})
|
|
53
|
+
align: "start" | "center" | "end" = "start";
|
|
54
|
+
|
|
55
|
+
@property({reflect: true})
|
|
56
|
+
size: "small" | "medium" | "large" = "small";
|
|
57
|
+
|
|
58
|
+
@property({type: Boolean, attribute: 'is-editor'})
|
|
59
|
+
private isEditor: boolean = false;
|
|
60
|
+
|
|
61
|
+
@property({attribute: false})
|
|
62
|
+
public partToolbarContent?: any = undefined;
|
|
63
|
+
|
|
64
|
+
@property({attribute: false})
|
|
65
|
+
public partToolbarRenderer?: () => any = undefined;
|
|
66
|
+
|
|
67
|
+
@state()
|
|
68
|
+
private contributions: Contribution[] = [];
|
|
69
|
+
|
|
70
|
+
@state()
|
|
71
|
+
private compact = false;
|
|
72
|
+
|
|
73
|
+
private resizeObserver: ResizeObserver | null = null;
|
|
74
|
+
private resizeDebounceTimer: ReturnType<typeof setTimeout> | null = null;
|
|
75
|
+
private overflowCheckScheduled = false;
|
|
76
|
+
|
|
77
|
+
private updateCompactFromSpace() {
|
|
78
|
+
const toolbarItems = this.shadowRoot?.querySelector('.toolbar-items') as HTMLElement | null;
|
|
79
|
+
if (!toolbarItems) return;
|
|
80
|
+
const trimmed = toolbarItems.scrollWidth > toolbarItems.clientWidth;
|
|
81
|
+
if (this.compact !== trimmed) {
|
|
82
|
+
this.compact = trimmed;
|
|
83
|
+
this.requestUpdate();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private scheduleOverflowCheck() {
|
|
88
|
+
if (this.overflowCheckScheduled) return;
|
|
89
|
+
this.overflowCheckScheduled = true;
|
|
90
|
+
requestAnimationFrame(() => {
|
|
91
|
+
this.overflowCheckScheduled = false;
|
|
92
|
+
this.updateCompactFromSpace();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private onResize = () => {
|
|
97
|
+
if (this.resizeDebounceTimer !== null) clearTimeout(this.resizeDebounceTimer);
|
|
98
|
+
this.resizeDebounceTimer = setTimeout(() => {
|
|
99
|
+
this.resizeDebounceTimer = null;
|
|
100
|
+
this.updateCompactFromSpace();
|
|
101
|
+
}, RESIZE_DEBOUNCE_MS);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
connectedCallback() {
|
|
105
|
+
super.connectedCallback();
|
|
106
|
+
this.resizeObserver = new ResizeObserver(this.onResize);
|
|
107
|
+
this.resizeObserver.observe(this);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
disconnectedCallback() {
|
|
111
|
+
this.resizeObserver?.disconnect();
|
|
112
|
+
this.resizeObserver = null;
|
|
113
|
+
if (this.resizeDebounceTimer !== null) {
|
|
114
|
+
clearTimeout(this.resizeDebounceTimer);
|
|
115
|
+
this.resizeDebounceTimer = null;
|
|
116
|
+
}
|
|
117
|
+
super.disconnectedCallback();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
updated(changedProperties: Map<string, unknown>) {
|
|
121
|
+
super.updated?.(changedProperties);
|
|
122
|
+
if (!this.compact) this.scheduleOverflowCheck();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
protected doBeforeUI() {
|
|
126
|
+
const id = this.getAttribute("id");
|
|
127
|
+
if (id) {
|
|
128
|
+
this.loadContributions(id);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
subscribe(TOPIC_CONTRIBUTEIONS_CHANGED, (event: ContributionChangeEvent) => {
|
|
132
|
+
if (!id) return;
|
|
133
|
+
|
|
134
|
+
const shouldReload = this.matchesTarget(id, event.target);
|
|
135
|
+
if (shouldReload) {
|
|
136
|
+
this.loadContributions(id);
|
|
137
|
+
this.requestUpdate()
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
private matchesTarget(id: string, target: string): boolean {
|
|
144
|
+
if (target === id) return true;
|
|
145
|
+
|
|
146
|
+
if (!id.includes(':')) return false;
|
|
147
|
+
|
|
148
|
+
const [prefix] = id.split(':');
|
|
149
|
+
if (target === `${prefix}:*`) return true;
|
|
150
|
+
|
|
151
|
+
const targetParts = target.split(':');
|
|
152
|
+
if (targetParts.length === 2) {
|
|
153
|
+
const categoryToken = targetParts[1];
|
|
154
|
+
if (categoryToken === 'system.editors' || categoryToken === '.system.editors') {
|
|
155
|
+
return this.isEditor && id.startsWith(`${prefix}:`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private loadContributions(id: string) {
|
|
163
|
+
const specific = contributionRegistry.getContributions(id);
|
|
164
|
+
|
|
165
|
+
if (!id.includes(':')) {
|
|
166
|
+
this.contributions = specific;
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const [prefix] = id.split(':');
|
|
171
|
+
const wildcardId = `${prefix}:*`;
|
|
172
|
+
const wildcard = contributionRegistry.getContributions(wildcardId);
|
|
173
|
+
|
|
174
|
+
const categoryMatches: Contribution[] = [];
|
|
175
|
+
|
|
176
|
+
if (this.isEditor) {
|
|
177
|
+
const allCategories = ['system.editors', '.system.editors'];
|
|
178
|
+
for (const category of allCategories) {
|
|
179
|
+
const categoryId = `${prefix}:${category}`;
|
|
180
|
+
const matches = contributionRegistry.getContributions(categoryId);
|
|
181
|
+
categoryMatches.push(...matches);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
this.contributions = [...wildcard, ...categoryMatches, ...specific];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
private isToolbarItem(contribution: Contribution): boolean {
|
|
189
|
+
return "command" in contribution || "html" in contribution;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
contributionCreator(contribution: Contribution) {
|
|
193
|
+
if ("command" in contribution) {
|
|
194
|
+
const commandContribution = contribution as CommandContribution;
|
|
195
|
+
const showLabel = !this.compact && !!commandContribution.showLabel;
|
|
196
|
+
return html`
|
|
197
|
+
<wa-button @click=${() => this.executeCommand(commandContribution.command, commandContribution.params || {})}
|
|
198
|
+
title=${commandContribution.label}
|
|
199
|
+
?disabled="${(commandContribution.disabled as Signal.Computed<boolean>)?.get()}"
|
|
200
|
+
appearance="plain" size=${this.size}>
|
|
201
|
+
<wa-icon name=${commandContribution.icon} label="${commandContribution.label}"></wa-icon>
|
|
202
|
+
${showLabel ? commandContribution.label : ''}
|
|
203
|
+
</wa-button>
|
|
204
|
+
`;
|
|
205
|
+
}
|
|
206
|
+
if ("html" in contribution) {
|
|
207
|
+
const contents = (contribution as HTMLContribution).html
|
|
208
|
+
if (contents instanceof Function) {
|
|
209
|
+
return contents()
|
|
210
|
+
}
|
|
211
|
+
return unsafeHTML(contents)
|
|
212
|
+
}
|
|
213
|
+
return html`<span>unknown contribution type: ${typeof contribution}</span>`
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
render() {
|
|
217
|
+
const partContent = this.partToolbarRenderer ? this.partToolbarRenderer() :
|
|
218
|
+
(this.partToolbarContent ? this.partToolbarContent : '');
|
|
219
|
+
const flexDir = this.orientation === "vertical" ? "column" : "row";
|
|
220
|
+
const alignMap = { start: "flex-start", center: "center", end: "flex-end" } as const;
|
|
221
|
+
const bindCreator = this.contributionCreator.bind(this);
|
|
222
|
+
const bindIsItem = this.isToolbarItem.bind(this);
|
|
223
|
+
return html`
|
|
224
|
+
<div class="toolbar-items" style=${styleMap({
|
|
225
|
+
"flex-direction": flexDir,
|
|
226
|
+
"align-items": alignMap[this.align],
|
|
227
|
+
"justify-content": this.position
|
|
228
|
+
})}>
|
|
229
|
+
${renderButtonGroup('start', this.orientation, this.contributions, bindIsItem, bindCreator)}
|
|
230
|
+
${partContent}
|
|
231
|
+
${renderButtonGroup(undefined, this.orientation, this.contributions, bindIsItem, bindCreator)}
|
|
232
|
+
${renderButtonGroup('end', this.orientation, this.contributions, bindIsItem, bindCreator)}
|
|
233
|
+
</div>
|
|
234
|
+
`;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
static styles = css`
|
|
238
|
+
:host {
|
|
239
|
+
display: flex;
|
|
240
|
+
flex-direction: row;
|
|
241
|
+
--wa-form-control-padding-inline: var(--wa-space-2xs);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
:host([orientation="vertical"]) {
|
|
245
|
+
flex-direction: column;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.toolbar-items {
|
|
249
|
+
display: flex;
|
|
250
|
+
flex: 1;
|
|
251
|
+
gap: var(--wa-space-2xs);
|
|
252
|
+
}
|
|
253
|
+
`
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
declare global {
|
|
257
|
+
interface HTMLElementTagNameMap {
|
|
258
|
+
'lyra-toolbar': LyraToolbar
|
|
259
|
+
}
|
|
260
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
declare module 'toastify-js' {
|
|
4
|
+
interface ToastifyOptions {
|
|
5
|
+
text?: string;
|
|
6
|
+
duration?: number;
|
|
7
|
+
gravity?: 'top' | 'bottom';
|
|
8
|
+
position?: 'left' | 'center' | 'right';
|
|
9
|
+
close?: boolean;
|
|
10
|
+
style?: { background?: string };
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
function Toastify(options: ToastifyOptions): { showToast(): void };
|
|
14
|
+
export default Toastify;
|
|
15
|
+
}
|
|
16
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {customElement, property} from 'lit/decorators.js'
|
|
2
|
+
import {html, nothing, css} from 'lit';
|
|
3
|
+
|
|
4
|
+
import {LyraWidget} from "./widget";
|
|
5
|
+
|
|
6
|
+
@customElement('lyra-icon')
|
|
7
|
+
export class LyraIcon extends LyraWidget {
|
|
8
|
+
|
|
9
|
+
@property()
|
|
10
|
+
name?: string;
|
|
11
|
+
|
|
12
|
+
@property()
|
|
13
|
+
family?: string = "regular";
|
|
14
|
+
|
|
15
|
+
@property()
|
|
16
|
+
variant?: string;
|
|
17
|
+
|
|
18
|
+
@property()
|
|
19
|
+
label?: string;
|
|
20
|
+
|
|
21
|
+
render() {
|
|
22
|
+
if (!this.name) {
|
|
23
|
+
return ""
|
|
24
|
+
}
|
|
25
|
+
const parts = this.name.trim().split(/ +/)
|
|
26
|
+
const iconName = parts.pop()
|
|
27
|
+
const library = parts.pop()
|
|
28
|
+
return html`
|
|
29
|
+
<wa-icon library="${library || nothing}" variant="${this.variant || nothing}"
|
|
30
|
+
family="${this.family || nothing}" name=${iconName} label="${this.label || this.name || nothing}"></wa-icon>`
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static styles = css`
|
|
34
|
+
:host {
|
|
35
|
+
display: contents;
|
|
36
|
+
}
|
|
37
|
+
`
|
|
38
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {css, html} from 'lit'
|
|
2
|
+
import {customElement, property} from 'lit/decorators.js'
|
|
3
|
+
|
|
4
|
+
import {LyraWidget} from "./widget";
|
|
5
|
+
|
|
6
|
+
@customElement('lyra-no-content')
|
|
7
|
+
export class LyraNoContent extends LyraWidget {
|
|
8
|
+
|
|
9
|
+
@property()
|
|
10
|
+
private message: string = "No content.";
|
|
11
|
+
|
|
12
|
+
@property()
|
|
13
|
+
private icon: string = "info-circle";
|
|
14
|
+
|
|
15
|
+
render() {
|
|
16
|
+
return html`
|
|
17
|
+
<h3>
|
|
18
|
+
<wa-icon name=${this.icon} label="${this.message}"></wa-icon>
|
|
19
|
+
${this.message}
|
|
20
|
+
</h3>
|
|
21
|
+
`
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static styles = css`
|
|
25
|
+
:host {
|
|
26
|
+
display: flex;
|
|
27
|
+
margin: 10px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
* {
|
|
31
|
+
flex: 1;
|
|
32
|
+
}
|
|
33
|
+
`
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare global {
|
|
37
|
+
interface HTMLElementTagNameMap {
|
|
38
|
+
'lyra-no-content': LyraNoContent
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {LitElement, PropertyValues} from "lit";
|
|
2
|
+
import {subscribe as event_subscribe, unsubscribe as event_unsubscribe, type SubscriptionToken} from "../core/events";
|
|
3
|
+
import {toastError, toastInfo} from "../core/toast";
|
|
4
|
+
import {commandRegistry, ExecuteParams} from "../core/commandregistry";
|
|
5
|
+
import {Signal, SignalWatcher} from "@lit-labs/signals";
|
|
6
|
+
import {watchSignal} from "../core/signals";
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(LitElement.prototype, "model", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const LyraWidgetBase = SignalWatcher(LitElement) as unknown as typeof LitElement;
|
|
15
|
+
|
|
16
|
+
export abstract class LyraWidget extends LyraWidgetBase {
|
|
17
|
+
private signalCleanups = new Set<() => void>();
|
|
18
|
+
private eventSubscriptions = new Set<SubscriptionToken>();
|
|
19
|
+
|
|
20
|
+
connectedCallback() {
|
|
21
|
+
super.connectedCallback();
|
|
22
|
+
this.doBeforeUI()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
disconnectedCallback() {
|
|
26
|
+
super.disconnectedCallback();
|
|
27
|
+
this.eventSubscriptions.forEach(token => event_unsubscribe(token));
|
|
28
|
+
this.eventSubscriptions.clear();
|
|
29
|
+
this.signalCleanups.forEach(cleanup => cleanup());
|
|
30
|
+
this.signalCleanups.clear();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
protected subscribe(topic: string, callback: Function): void {
|
|
34
|
+
const token = event_subscribe(topic, callback.bind(this));
|
|
35
|
+
this.eventSubscriptions.add(token);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
protected showInfo(msg: string) {
|
|
39
|
+
toastInfo(msg)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
protected showError(msg: string) {
|
|
43
|
+
toastError(msg)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
protected nobubble(wrap: (event: Event) => void) {
|
|
47
|
+
return (event: Event) => {
|
|
48
|
+
event.stopPropagation();
|
|
49
|
+
wrap.bind(this)(event);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
protected command(command: string, state: {} = {}) {
|
|
54
|
+
return () => {
|
|
55
|
+
this.executeCommand(command, state)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
protected executeCommand(command: string, params: ExecuteParams) {
|
|
60
|
+
const execContext = commandRegistry.createExecutionContext(params);
|
|
61
|
+
commandRegistry.execute(command, execContext);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected watch(signal: Signal.State<any> | Signal.Computed<any>, callback: (value: any) => void): void {
|
|
65
|
+
const cleanup = watchSignal(signal as Signal.State<any>, callback.bind(this));
|
|
66
|
+
this.signalCleanups.add(cleanup);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
protected firstUpdated(_changedProperties: PropertyValues) {
|
|
70
|
+
super.firstUpdated(_changedProperties);
|
|
71
|
+
this.doInitUI()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
protected updateIdle() {
|
|
75
|
+
requestIdleCallback(() => this.requestUpdate())
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public updateLater() {
|
|
79
|
+
requestAnimationFrame(() => this.requestUpdate())
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
protected doBeforeUI() {
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
protected doInitUI() {
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
withRefresh(callback: () => void) {
|
|
89
|
+
callback()
|
|
90
|
+
this.updateLater()
|
|
91
|
+
}
|
|
92
|
+
}
|