@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.
Files changed (281) hide show
  1. package/dist/api/base-classes.d.ts +7 -0
  2. package/dist/api/base-classes.d.ts.map +1 -0
  3. package/dist/api/constants.d.ts +2 -0
  4. package/dist/api/constants.d.ts.map +1 -0
  5. package/dist/api/index.d.ts +6 -0
  6. package/dist/api/index.d.ts.map +1 -0
  7. package/dist/api/index.js +84 -0
  8. package/dist/api/index.js.map +1 -0
  9. package/dist/api/services.d.ts +28 -0
  10. package/dist/api/services.d.ts.map +1 -0
  11. package/dist/api/types.d.ts +11 -0
  12. package/dist/api/types.d.ts.map +1 -0
  13. package/dist/commands/editor.d.ts +1 -0
  14. package/dist/commands/editor.d.ts.map +1 -0
  15. package/dist/commands/files.d.ts +2 -0
  16. package/dist/commands/files.d.ts.map +1 -0
  17. package/dist/commands/global.d.ts +1 -0
  18. package/dist/commands/global.d.ts.map +1 -0
  19. package/dist/commands/index.d.ts +1 -0
  20. package/dist/commands/index.d.ts.map +1 -0
  21. package/dist/commands/open-view-as-editor.d.ts +2 -0
  22. package/dist/commands/open-view-as-editor.d.ts.map +1 -0
  23. package/dist/commands/version-info.d.ts +2 -0
  24. package/dist/commands/version-info.d.ts.map +1 -0
  25. package/dist/components/app-selector.d.ts +17 -0
  26. package/dist/components/app-selector.d.ts.map +1 -0
  27. package/dist/components/app-switcher.d.ts +13 -0
  28. package/dist/components/app-switcher.d.ts.map +1 -0
  29. package/dist/components/command.d.ts +31 -0
  30. package/dist/components/command.d.ts.map +1 -0
  31. package/dist/components/extensions.d.ts +32 -0
  32. package/dist/components/extensions.d.ts.map +1 -0
  33. package/dist/components/fastviews.d.ts +34 -0
  34. package/dist/components/fastviews.d.ts.map +1 -0
  35. package/dist/components/filebrowser.d.ts +45 -0
  36. package/dist/components/filebrowser.d.ts.map +1 -0
  37. package/dist/components/index.d.ts +1 -0
  38. package/dist/components/index.d.ts.map +1 -0
  39. package/dist/components/language-selector.d.ts +12 -0
  40. package/dist/components/language-selector.d.ts.map +1 -0
  41. package/dist/components/log-terminal.d.ts +36 -0
  42. package/dist/components/log-terminal.d.ts.map +1 -0
  43. package/dist/components/part-name.d.ts +12 -0
  44. package/dist/components/part-name.d.ts.map +1 -0
  45. package/dist/components/tasks.d.ts +13 -0
  46. package/dist/components/tasks.d.ts.map +1 -0
  47. package/dist/contributions/default-ui-contributions.d.ts +2 -0
  48. package/dist/contributions/default-ui-contributions.d.ts.map +1 -0
  49. package/dist/contributions/index.d.ts +1 -0
  50. package/dist/contributions/index.d.ts.map +1 -0
  51. package/dist/contributions/marketplace-catalog-contributions.d.ts +2 -0
  52. package/dist/contributions/marketplace-catalog-contributions.d.ts.map +1 -0
  53. package/dist/core/app-host-config.d.ts +7 -0
  54. package/dist/core/app-host-config.d.ts.map +1 -0
  55. package/dist/core/apploader.d.ts +214 -0
  56. package/dist/core/apploader.d.ts.map +1 -0
  57. package/dist/core/appstate.d.ts +12 -0
  58. package/dist/core/appstate.d.ts.map +1 -0
  59. package/dist/core/commandregistry.d.ts +79 -0
  60. package/dist/core/commandregistry.d.ts.map +1 -0
  61. package/dist/core/config.d.ts +15 -0
  62. package/dist/core/config.d.ts.map +1 -0
  63. package/dist/core/constants.d.ts +22 -0
  64. package/dist/core/constants.d.ts.map +1 -0
  65. package/dist/core/contributionregistry.d.ts +53 -0
  66. package/dist/core/contributionregistry.d.ts.map +1 -0
  67. package/dist/core/di.d.ts +18 -0
  68. package/dist/core/di.d.ts.map +1 -0
  69. package/dist/core/dialogservice.d.ts +33 -0
  70. package/dist/core/dialogservice.d.ts.map +1 -0
  71. package/dist/core/editorregistry.d.ts +87 -0
  72. package/dist/core/editorregistry.d.ts.map +1 -0
  73. package/dist/core/esmsh-service.d.ts +40 -0
  74. package/dist/core/esmsh-service.d.ts.map +1 -0
  75. package/dist/core/events.d.ts +7 -0
  76. package/dist/core/events.d.ts.map +1 -0
  77. package/dist/core/events.js +63 -0
  78. package/dist/core/events.js.map +1 -0
  79. package/dist/core/extensionregistry.d.ts +98 -0
  80. package/dist/core/extensionregistry.d.ts.map +1 -0
  81. package/dist/core/filesys/common.d.ts +122 -0
  82. package/dist/core/filesys/common.d.ts.map +1 -0
  83. package/dist/core/filesys/fs-access.d.ts +31 -0
  84. package/dist/core/filesys/fs-access.d.ts.map +1 -0
  85. package/dist/core/filesys/index.d.ts +5 -0
  86. package/dist/core/filesys/index.d.ts.map +1 -0
  87. package/dist/core/filesys/indexeddb.d.ts +41 -0
  88. package/dist/core/filesys/indexeddb.d.ts.map +1 -0
  89. package/dist/core/filesys/opfs.d.ts +14 -0
  90. package/dist/core/filesys/opfs.d.ts.map +1 -0
  91. package/dist/core/i18n.d.ts +50 -0
  92. package/dist/core/i18n.d.ts.map +1 -0
  93. package/dist/core/index.d.ts +1 -0
  94. package/dist/core/index.d.ts.map +1 -0
  95. package/dist/core/keybindings.d.ts +67 -0
  96. package/dist/core/keybindings.d.ts.map +1 -0
  97. package/dist/core/logger.d.ts +44 -0
  98. package/dist/core/logger.d.ts.map +1 -0
  99. package/dist/core/marketplaceregistry.d.ts +25 -0
  100. package/dist/core/marketplaceregistry.d.ts.map +1 -0
  101. package/dist/core/packageinfoservice.d.ts +16 -0
  102. package/dist/core/packageinfoservice.d.ts.map +1 -0
  103. package/dist/core/persistenceservice.d.ts +6 -0
  104. package/dist/core/persistenceservice.d.ts.map +1 -0
  105. package/dist/core/settingsservice.d.ts +54 -0
  106. package/dist/core/settingsservice.d.ts.map +1 -0
  107. package/dist/core/signals.d.ts +3 -0
  108. package/dist/core/signals.d.ts.map +1 -0
  109. package/dist/core/taskservice.d.ts +20 -0
  110. package/dist/core/taskservice.d.ts.map +1 -0
  111. package/dist/core/toast.d.ts +4 -0
  112. package/dist/core/toast.d.ts.map +1 -0
  113. package/dist/core/tree-utils.d.ts +16 -0
  114. package/dist/core/tree-utils.d.ts.map +1 -0
  115. package/dist/dialogs/confirm-dialog.d.ts +14 -0
  116. package/dist/dialogs/confirm-dialog.d.ts.map +1 -0
  117. package/dist/dialogs/index.d.ts +5 -0
  118. package/dist/dialogs/index.d.ts.map +1 -0
  119. package/dist/dialogs/info-dialog.d.ts +13 -0
  120. package/dist/dialogs/info-dialog.d.ts.map +1 -0
  121. package/dist/dialogs/navigable-info-dialog.d.ts +33 -0
  122. package/dist/dialogs/navigable-info-dialog.d.ts.map +1 -0
  123. package/dist/dialogs/prompt-dialog.d.ts +21 -0
  124. package/dist/dialogs/prompt-dialog.d.ts.map +1 -0
  125. package/dist/externals/lit.d.ts +21 -0
  126. package/dist/externals/lit.d.ts.map +1 -0
  127. package/dist/externals/lit.js +24 -0
  128. package/dist/externals/lit.js.map +1 -0
  129. package/dist/externals/third-party.d.ts +7 -0
  130. package/dist/externals/third-party.d.ts.map +1 -0
  131. package/dist/externals/third-party.js +7 -0
  132. package/dist/externals/third-party.js.map +1 -0
  133. package/dist/externals/webawesome.d.ts +1 -0
  134. package/dist/externals/webawesome.d.ts.map +1 -0
  135. package/dist/externals/webawesome.js +75 -0
  136. package/dist/externals/webawesome.js.map +1 -0
  137. package/dist/i18n/extensions.json.d.ts +42 -0
  138. package/dist/i18n/fastviews.json.d.ts +13 -0
  139. package/dist/i18n/filebrowser.json.d.ts +29 -0
  140. package/dist/i18n/index.d.ts +2 -0
  141. package/dist/i18n/index.d.ts.map +1 -0
  142. package/dist/i18n/logterminal.json.d.ts +45 -0
  143. package/dist/i18n/partname.json.d.ts +15 -0
  144. package/dist/i18n/tasks.json.d.ts +15 -0
  145. package/dist/i18n/workspace.json.d.ts +15 -0
  146. package/dist/icon-DN6fp0dg.js +487 -0
  147. package/dist/icon-DN6fp0dg.js.map +1 -0
  148. package/dist/index.d.ts +2 -0
  149. package/dist/index.d.ts.map +1 -0
  150. package/dist/index.js +84 -0
  151. package/dist/index.js.map +1 -0
  152. package/dist/layouts/standard-layout.d.ts +16 -0
  153. package/dist/layouts/standard-layout.d.ts.map +1 -0
  154. package/dist/nocontent-BhrN6yxJ.js +48 -0
  155. package/dist/nocontent-BhrN6yxJ.js.map +1 -0
  156. package/dist/parts/container.d.ts +4 -0
  157. package/dist/parts/container.d.ts.map +1 -0
  158. package/dist/parts/contextmenu.d.ts +50 -0
  159. package/dist/parts/contextmenu.d.ts.map +1 -0
  160. package/dist/parts/dialog-content.d.ts +9 -0
  161. package/dist/parts/dialog-content.d.ts.map +1 -0
  162. package/dist/parts/element.d.ts +36 -0
  163. package/dist/parts/element.d.ts.map +1 -0
  164. package/dist/parts/index.d.ts +1 -0
  165. package/dist/parts/index.d.ts.map +1 -0
  166. package/dist/parts/index.js +3 -0
  167. package/dist/parts/index.js.map +1 -0
  168. package/dist/parts/part.d.ts +96 -0
  169. package/dist/parts/part.d.ts.map +1 -0
  170. package/dist/parts/resizable-grid.d.ts +31 -0
  171. package/dist/parts/resizable-grid.d.ts.map +1 -0
  172. package/dist/parts/tabs.d.ts +75 -0
  173. package/dist/parts/tabs.d.ts.map +1 -0
  174. package/dist/parts/toolbar.d.ts +35 -0
  175. package/dist/parts/toolbar.d.ts.map +1 -0
  176. package/dist/resizable-grid-BRH3MyZK.js +3813 -0
  177. package/dist/resizable-grid-BRH3MyZK.js.map +1 -0
  178. package/dist/standard-layout-BSGa06lP.js +4907 -0
  179. package/dist/standard-layout-BSGa06lP.js.map +1 -0
  180. package/dist/widgets/icon.d.ts +10 -0
  181. package/dist/widgets/icon.d.ts.map +1 -0
  182. package/dist/widgets/index.d.ts +1 -0
  183. package/dist/widgets/index.d.ts.map +1 -0
  184. package/dist/widgets/index.js +3 -0
  185. package/dist/widgets/index.js.map +1 -0
  186. package/dist/widgets/nocontent.d.ts +13 -0
  187. package/dist/widgets/nocontent.d.ts.map +1 -0
  188. package/dist/widgets/widget.d.ts +25 -0
  189. package/dist/widgets/widget.d.ts.map +1 -0
  190. package/package.json +81 -0
  191. package/src/api/base-classes.ts +10 -0
  192. package/src/api/constants.ts +3 -0
  193. package/src/api/index.ts +31 -0
  194. package/src/api/services.ts +58 -0
  195. package/src/api/types.ts +46 -0
  196. package/src/commands/editor.ts +1 -0
  197. package/src/commands/files.ts +425 -0
  198. package/src/commands/global.ts +198 -0
  199. package/src/commands/index.ts +6 -0
  200. package/src/commands/open-view-as-editor.ts +28 -0
  201. package/src/commands/version-info.ts +214 -0
  202. package/src/components/app-selector.ts +233 -0
  203. package/src/components/app-switcher.ts +126 -0
  204. package/src/components/command.ts +236 -0
  205. package/src/components/extensions.ts +615 -0
  206. package/src/components/fastviews.ts +314 -0
  207. package/src/components/filebrowser.ts +518 -0
  208. package/src/components/index.ts +9 -0
  209. package/src/components/language-selector.ts +166 -0
  210. package/src/components/log-terminal.ts +337 -0
  211. package/src/components/part-name.ts +54 -0
  212. package/src/components/tasks.ts +275 -0
  213. package/src/contributions/default-ui-contributions.ts +44 -0
  214. package/src/contributions/index.ts +3 -0
  215. package/src/contributions/marketplace-catalog-contributions.ts +6 -0
  216. package/src/core/app-host-config.ts +23 -0
  217. package/src/core/apploader.ts +630 -0
  218. package/src/core/appstate.ts +15 -0
  219. package/src/core/commandregistry.ts +210 -0
  220. package/src/core/config.ts +29 -0
  221. package/src/core/constants.ts +29 -0
  222. package/src/core/contributionregistry.ts +81 -0
  223. package/src/core/di.ts +54 -0
  224. package/src/core/dialogservice.ts +266 -0
  225. package/src/core/editorregistry.ts +347 -0
  226. package/src/core/esmsh-service.ts +404 -0
  227. package/src/core/events.ts +68 -0
  228. package/src/core/extensionregistry.ts +399 -0
  229. package/src/core/filesys/common.ts +474 -0
  230. package/src/core/filesys/fs-access.ts +339 -0
  231. package/src/core/filesys/index.ts +5 -0
  232. package/src/core/filesys/indexeddb.ts +596 -0
  233. package/src/core/filesys/opfs.ts +95 -0
  234. package/src/core/i18n.ts +221 -0
  235. package/src/core/index.ts +51 -0
  236. package/src/core/keybindings.ts +274 -0
  237. package/src/core/logger.ts +187 -0
  238. package/src/core/marketplaceregistry.ts +197 -0
  239. package/src/core/packageinfoservice.ts +56 -0
  240. package/src/core/persistenceservice.ts +46 -0
  241. package/src/core/settingsservice.ts +191 -0
  242. package/src/core/signals.ts +18 -0
  243. package/src/core/taskservice.ts +72 -0
  244. package/src/core/toast.ts +21 -0
  245. package/src/core/tree-utils.ts +24 -0
  246. package/src/dialogs/confirm-dialog.ts +72 -0
  247. package/src/dialogs/index.ts +4 -0
  248. package/src/dialogs/info-dialog.ts +67 -0
  249. package/src/dialogs/navigable-info-dialog.ts +256 -0
  250. package/src/dialogs/prompt-dialog.ts +123 -0
  251. package/src/externals/lit.ts +36 -0
  252. package/src/externals/third-party.ts +10 -0
  253. package/src/externals/webawesome.ts +76 -0
  254. package/src/i18n/extensions.json +39 -0
  255. package/src/i18n/fastviews.json +10 -0
  256. package/src/i18n/filebrowser.json +27 -0
  257. package/src/i18n/index.ts +25 -0
  258. package/src/i18n/logterminal.json +42 -0
  259. package/src/i18n/partname.json +12 -0
  260. package/src/i18n/tasks.json +12 -0
  261. package/src/i18n/workspace.json +12 -0
  262. package/src/icons/icons.txt +3 -0
  263. package/src/icons/js.svg +6 -0
  264. package/src/icons/jupyter.svg +18 -0
  265. package/src/icons/python.svg +15 -0
  266. package/src/index.ts +3 -0
  267. package/src/layouts/standard-layout.ts +174 -0
  268. package/src/parts/container.ts +4 -0
  269. package/src/parts/contextmenu.ts +266 -0
  270. package/src/parts/dialog-content.ts +31 -0
  271. package/src/parts/element.ts +100 -0
  272. package/src/parts/index.ts +5 -0
  273. package/src/parts/part.ts +158 -0
  274. package/src/parts/resizable-grid.ts +366 -0
  275. package/src/parts/tabs.ts +581 -0
  276. package/src/parts/toolbar.ts +260 -0
  277. package/src/vite-env.d.ts +16 -0
  278. package/src/widgets/icon.ts +38 -0
  279. package/src/widgets/index.ts +2 -0
  280. package/src/widgets/nocontent.ts +40 -0
  281. 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,2 @@
1
+ import "./nocontent"
2
+ import "./icon"
@@ -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
+ }