@kispace-io/core 0.7.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 +80 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/services.d.ts +27 -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/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/version-info.d.ts +2 -0
- package/dist/commands/version-info.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/k-app-selector.d.ts +17 -0
- package/dist/components/k-app-selector.d.ts.map +1 -0
- package/dist/components/k-app-switcher.d.ts +13 -0
- package/dist/components/k-app-switcher.d.ts.map +1 -0
- package/dist/components/k-command.d.ts +31 -0
- package/dist/components/k-command.d.ts.map +1 -0
- package/dist/components/k-extensions.d.ts +32 -0
- package/dist/components/k-extensions.d.ts.map +1 -0
- package/dist/components/k-fastviews.d.ts +34 -0
- package/dist/components/k-fastviews.d.ts.map +1 -0
- package/dist/components/k-filebrowser.d.ts +40 -0
- package/dist/components/k-filebrowser.d.ts.map +1 -0
- package/dist/components/k-language-selector.d.ts +12 -0
- package/dist/components/k-language-selector.d.ts.map +1 -0
- package/dist/components/k-log-terminal.d.ts +36 -0
- package/dist/components/k-log-terminal.d.ts.map +1 -0
- package/dist/components/k-part-name.d.ts +12 -0
- package/dist/components/k-part-name.d.ts.map +1 -0
- package/dist/components/k-tasks.d.ts +13 -0
- package/dist/components/k-tasks.d.ts.map +1 -0
- package/dist/components/k-workspace-name.d.ts +14 -0
- package/dist/components/k-workspace-name.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 +21 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/contributionregistry.d.ts +49 -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 +73 -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.d.ts +139 -0
- package/dist/core/filesys.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/k-utils.d.ts +2 -0
- package/dist/core/k-utils.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 +19 -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 +20 -0
- package/dist/externals/lit.d.ts.map +1 -0
- package/dist/externals/lit.js +15 -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 +2 -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 +52 -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 +35 -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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/k-icon-BZC7dQV0.js +492 -0
- package/dist/k-icon-BZC7dQV0.js.map +1 -0
- package/dist/k-nocontent-Bh_yToGh.js +48 -0
- package/dist/k-nocontent-Bh_yToGh.js.map +1 -0
- package/dist/k-resizable-grid-Ch3iWZaL.js +3157 -0
- package/dist/k-resizable-grid-Ch3iWZaL.js.map +1 -0
- package/dist/k-standard-layout-CQ1VZoxa.js +5011 -0
- package/dist/k-standard-layout-CQ1VZoxa.js.map +1 -0
- package/dist/layouts/k-standard-layout.d.ts +16 -0
- package/dist/layouts/k-standard-layout.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 +53 -0
- package/dist/parts/index.js.map +1 -0
- package/dist/parts/k-app.d.ts +11 -0
- package/dist/parts/k-app.d.ts.map +1 -0
- package/dist/parts/k-container.d.ts +4 -0
- package/dist/parts/k-container.d.ts.map +1 -0
- package/dist/parts/k-contextmenu.d.ts +38 -0
- package/dist/parts/k-contextmenu.d.ts.map +1 -0
- package/dist/parts/k-dialog-content.d.ts +9 -0
- package/dist/parts/k-dialog-content.d.ts.map +1 -0
- package/dist/parts/k-element.d.ts +36 -0
- package/dist/parts/k-element.d.ts.map +1 -0
- package/dist/parts/k-part.d.ts +96 -0
- package/dist/parts/k-part.d.ts.map +1 -0
- package/dist/parts/k-resizable-grid.d.ts +31 -0
- package/dist/parts/k-resizable-grid.d.ts.map +1 -0
- package/dist/parts/k-tabs.d.ts +74 -0
- package/dist/parts/k-tabs.d.ts.map +1 -0
- package/dist/parts/k-toolbar.d.ts +21 -0
- package/dist/parts/k-toolbar.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/k-icon.d.ts +10 -0
- package/dist/widgets/k-icon.d.ts.map +1 -0
- package/dist/widgets/k-nocontent.d.ts +13 -0
- package/dist/widgets/k-nocontent.d.ts.map +1 -0
- package/dist/widgets/k-widget.d.ts +25 -0
- package/dist/widgets/k-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 +52 -0
- package/src/api/types.ts +46 -0
- package/src/commands/files.ts +829 -0
- package/src/commands/global.ts +225 -0
- package/src/commands/index.ts +4 -0
- package/src/commands/version-info.ts +214 -0
- package/src/components/index.ts +10 -0
- package/src/components/k-app-selector.ts +233 -0
- package/src/components/k-app-switcher.ts +126 -0
- package/src/components/k-command.ts +236 -0
- package/src/components/k-extensions.ts +615 -0
- package/src/components/k-fastviews.ts +314 -0
- package/src/components/k-filebrowser.ts +442 -0
- package/src/components/k-language-selector.ts +166 -0
- package/src/components/k-log-terminal.ts +337 -0
- package/src/components/k-part-name.ts +54 -0
- package/src/components/k-tasks.ts +267 -0
- package/src/components/k-workspace-name.ts +56 -0
- package/src/contributions/default-ui-contributions.ts +51 -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 +27 -0
- package/src/core/contributionregistry.ts +77 -0
- package/src/core/di.ts +54 -0
- package/src/core/dialogservice.ts +266 -0
- package/src/core/editorregistry.ts +303 -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.ts +618 -0
- package/src/core/i18n.ts +221 -0
- package/src/core/index.ts +51 -0
- package/src/core/k-utils.ts +11 -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 +15 -0
- package/src/core/settingsservice.ts +70 -0
- package/src/core/signals.ts +18 -0
- package/src/core/taskservice.ts +72 -0
- package/src/core/toast.ts +11 -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 +26 -0
- package/src/externals/third-party.ts +9 -0
- package/src/externals/webawesome.ts +54 -0
- package/src/i18n/extensions.json +39 -0
- package/src/i18n/fastviews.json +10 -0
- package/src/i18n/filebrowser.json +33 -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/k-standard-layout.ts +174 -0
- package/src/parts/index.ts +6 -0
- package/src/parts/k-app.ts +29 -0
- package/src/parts/k-container.ts +4 -0
- package/src/parts/k-contextmenu.ts +245 -0
- package/src/parts/k-dialog-content.ts +31 -0
- package/src/parts/k-element.ts +100 -0
- package/src/parts/k-part.ts +158 -0
- package/src/parts/k-resizable-grid.ts +366 -0
- package/src/parts/k-tabs.ts +574 -0
- package/src/parts/k-toolbar.ts +158 -0
- package/src/vite-env.d.ts +2 -0
- package/src/widgets/index.ts +2 -0
- package/src/widgets/k-icon.ts +39 -0
- package/src/widgets/k-nocontent.ts +40 -0
- package/src/widgets/k-widget.ts +90 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import {css, html} from 'lit'
|
|
2
|
+
import {customElement, property, state} from 'lit/decorators.js'
|
|
3
|
+
import {KElement} from "./k-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
|
+
@customElement('k-toolbar')
|
|
18
|
+
export class KToolbar extends KElement {
|
|
19
|
+
@property()
|
|
20
|
+
private position: "start" | "center" | "end" = "start";
|
|
21
|
+
|
|
22
|
+
@property({type: Boolean, attribute: 'is-editor'})
|
|
23
|
+
private isEditor: boolean = false;
|
|
24
|
+
|
|
25
|
+
@property({attribute: false})
|
|
26
|
+
public partToolbarContent?: any = undefined;
|
|
27
|
+
|
|
28
|
+
@property({attribute: false})
|
|
29
|
+
public partToolbarRenderer?: () => any = undefined;
|
|
30
|
+
|
|
31
|
+
@state()
|
|
32
|
+
private contributions: Contribution[] = [];
|
|
33
|
+
|
|
34
|
+
protected doBeforeUI() {
|
|
35
|
+
const id = this.getAttribute("id");
|
|
36
|
+
if (id) {
|
|
37
|
+
this.loadContributions(id);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
subscribe(TOPIC_CONTRIBUTEIONS_CHANGED, (event: ContributionChangeEvent) => {
|
|
41
|
+
if (!id) return;
|
|
42
|
+
|
|
43
|
+
const shouldReload = this.matchesTarget(id, event.target);
|
|
44
|
+
if (shouldReload) {
|
|
45
|
+
this.loadContributions(id);
|
|
46
|
+
this.requestUpdate()
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
private matchesTarget(id: string, target: string): boolean {
|
|
53
|
+
if (target === id) return true;
|
|
54
|
+
|
|
55
|
+
if (!id.includes(':')) return false;
|
|
56
|
+
|
|
57
|
+
const [prefix] = id.split(':');
|
|
58
|
+
if (target === `${prefix}:*`) return true;
|
|
59
|
+
|
|
60
|
+
const targetParts = target.split(':');
|
|
61
|
+
if (targetParts.length === 2) {
|
|
62
|
+
const categoryToken = targetParts[1];
|
|
63
|
+
if (categoryToken === 'system.editors' || categoryToken === '.system.editors') {
|
|
64
|
+
return this.isEditor && id.startsWith(`${prefix}:`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private loadContributions(id: string) {
|
|
72
|
+
const specific = contributionRegistry.getContributions(id);
|
|
73
|
+
|
|
74
|
+
if (!id.includes(':')) {
|
|
75
|
+
this.contributions = specific;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const [prefix] = id.split(':');
|
|
80
|
+
const wildcardId = `${prefix}:*`;
|
|
81
|
+
const wildcard = contributionRegistry.getContributions(wildcardId);
|
|
82
|
+
|
|
83
|
+
const categoryMatches: Contribution[] = [];
|
|
84
|
+
|
|
85
|
+
if (this.isEditor) {
|
|
86
|
+
const allCategories = ['system.editors', '.system.editors'];
|
|
87
|
+
for (const category of allCategories) {
|
|
88
|
+
const categoryId = `${prefix}:${category}`;
|
|
89
|
+
const matches = contributionRegistry.getContributions(categoryId);
|
|
90
|
+
categoryMatches.push(...matches);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
this.contributions = [...wildcard, ...categoryMatches, ...specific];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
contributionCreator(contribution: Contribution) {
|
|
98
|
+
if ("command" in contribution) {
|
|
99
|
+
const commandContribution = contribution as CommandContribution
|
|
100
|
+
const showLabel = !!commandContribution.showLabel
|
|
101
|
+
return html`
|
|
102
|
+
<wa-button @click=${() => this.executeCommand(commandContribution.command, commandContribution.params || {})}
|
|
103
|
+
title=${commandContribution.label}
|
|
104
|
+
?disabled="${(commandContribution.disabled as Signal.Computed<boolean>)?.get()}"
|
|
105
|
+
appearance="plain" size="small">
|
|
106
|
+
<wa-icon name=${commandContribution.icon} label="${commandContribution.label}"></wa-icon>
|
|
107
|
+
${showLabel ? commandContribution.label : ''}
|
|
108
|
+
</wa-button>
|
|
109
|
+
`
|
|
110
|
+
} else if ("html" in contribution) {
|
|
111
|
+
const contents = (contribution as HTMLContribution).html
|
|
112
|
+
if (contents instanceof Function) {
|
|
113
|
+
return contents()
|
|
114
|
+
}
|
|
115
|
+
return unsafeHTML(contents)
|
|
116
|
+
} else {
|
|
117
|
+
return html`<span>unknown contribution type: ${typeof contribution}</span>`
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
render() {
|
|
122
|
+
const partContent = this.partToolbarRenderer ? this.partToolbarRenderer() :
|
|
123
|
+
(this.partToolbarContent ? this.partToolbarContent : '');
|
|
124
|
+
|
|
125
|
+
return html`
|
|
126
|
+
<div class="toolbar-items" style=${styleMap({"justify-content": this.position})}>
|
|
127
|
+
<slot name="start">
|
|
128
|
+
${this.contributions.filter(c => c.slot === "start").map(this.contributionCreator.bind(this))}
|
|
129
|
+
</slot>
|
|
130
|
+
${partContent}
|
|
131
|
+
${this.contributions.filter(c => c.slot === undefined).map(this.contributionCreator.bind(this))}
|
|
132
|
+
<slot>
|
|
133
|
+
</slot>
|
|
134
|
+
<slot name="end">
|
|
135
|
+
${this.contributions.filter(c => c.slot === "end").map(this.contributionCreator.bind(this))}
|
|
136
|
+
</slot>
|
|
137
|
+
</div>
|
|
138
|
+
`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
static styles = css`
|
|
142
|
+
:host {
|
|
143
|
+
display: flex;
|
|
144
|
+
flex-direction: row;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.toolbar-items {
|
|
148
|
+
display: flex;
|
|
149
|
+
flex: 1;
|
|
150
|
+
}
|
|
151
|
+
`
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
declare global {
|
|
155
|
+
interface HTMLElementTagNameMap {
|
|
156
|
+
'k-toolbar': KToolbar
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {customElement, property} from 'lit/decorators.js'
|
|
2
|
+
import {html, nothing, css} from 'lit';
|
|
3
|
+
|
|
4
|
+
import {KWidget} from "./k-widget";
|
|
5
|
+
import "../core/k-utils";
|
|
6
|
+
|
|
7
|
+
@customElement('k-icon')
|
|
8
|
+
export class KIcon extends KWidget {
|
|
9
|
+
|
|
10
|
+
@property()
|
|
11
|
+
name?: string;
|
|
12
|
+
|
|
13
|
+
@property()
|
|
14
|
+
family?: string = "regular";
|
|
15
|
+
|
|
16
|
+
@property()
|
|
17
|
+
variant?: string;
|
|
18
|
+
|
|
19
|
+
@property()
|
|
20
|
+
label?: string;
|
|
21
|
+
|
|
22
|
+
render() {
|
|
23
|
+
if (!this.name) {
|
|
24
|
+
return ""
|
|
25
|
+
}
|
|
26
|
+
const parts = this.name.trim().split(/ +/)
|
|
27
|
+
const iconName = parts.pop()
|
|
28
|
+
const library = parts.pop()
|
|
29
|
+
return html`
|
|
30
|
+
<wa-icon library="${library || nothing}" variant="${this.variant || nothing}"
|
|
31
|
+
family="${this.family || nothing}" name=${iconName} label="${this.label || this.name || nothing}"></wa-icon>`
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static styles = css`
|
|
35
|
+
:host {
|
|
36
|
+
display: contents;
|
|
37
|
+
}
|
|
38
|
+
`
|
|
39
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {css, html} from 'lit'
|
|
2
|
+
import {customElement, property} from 'lit/decorators.js'
|
|
3
|
+
|
|
4
|
+
import {KWidget} from "./k-widget";
|
|
5
|
+
|
|
6
|
+
@customElement('k-no-content')
|
|
7
|
+
export class KNoContent extends KWidget {
|
|
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
|
+
'k-no-content': KNoContent
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
export abstract class KWidget extends SignalWatcher(LitElement) {
|
|
15
|
+
private signalCleanups = new Set<() => void>();
|
|
16
|
+
private eventSubscriptions = new Set<SubscriptionToken>();
|
|
17
|
+
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
super.connectedCallback();
|
|
20
|
+
this.doBeforeUI()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
disconnectedCallback() {
|
|
24
|
+
super.disconnectedCallback();
|
|
25
|
+
this.eventSubscriptions.forEach(token => event_unsubscribe(token));
|
|
26
|
+
this.eventSubscriptions.clear();
|
|
27
|
+
this.signalCleanups.forEach(cleanup => cleanup());
|
|
28
|
+
this.signalCleanups.clear();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
protected subscribe(topic: string, callback: Function): void {
|
|
32
|
+
const token = event_subscribe(topic, callback.bind(this));
|
|
33
|
+
this.eventSubscriptions.add(token);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
protected showInfo(msg: string) {
|
|
37
|
+
toastInfo(msg)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected showError(msg: string) {
|
|
41
|
+
toastError(msg)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
protected nobubble(wrap: (event: Event) => void) {
|
|
45
|
+
return (event: Event) => {
|
|
46
|
+
event.stopPropagation();
|
|
47
|
+
wrap.bind(this)(event);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected command(command: string, state: {} = {}) {
|
|
52
|
+
return () => {
|
|
53
|
+
this.executeCommand(command, state)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected executeCommand(command: string, params: ExecuteParams) {
|
|
58
|
+
const execContext = commandRegistry.createExecutionContext(params);
|
|
59
|
+
commandRegistry.execute(command, execContext);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
protected watch(signal: Signal.State<any> | Signal.Computed<any>, callback: (value: any) => void): void {
|
|
63
|
+
const cleanup = watchSignal(signal as Signal.State<any>, callback.bind(this));
|
|
64
|
+
this.signalCleanups.add(cleanup);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
protected firstUpdated(_changedProperties: PropertyValues) {
|
|
68
|
+
super.firstUpdated(_changedProperties);
|
|
69
|
+
this.doInitUI()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
protected updateIdle() {
|
|
73
|
+
requestIdleCallback(() => this.requestUpdate())
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public updateLater() {
|
|
77
|
+
requestAnimationFrame(() => this.requestUpdate())
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
protected doBeforeUI() {
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
protected doInitUI() {
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
withRefresh(callback: () => void) {
|
|
87
|
+
callback()
|
|
88
|
+
this.updateLater()
|
|
89
|
+
}
|
|
90
|
+
}
|