@compas-oscd/open-scd 0.34.22 → 0.34.24

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 (241) hide show
  1. package/dist/WizardDivider.d.ts +1 -0
  2. package/dist/WizardDivider.d.ts.map +1 -0
  3. package/dist/Wizarding.d.ts +20 -0
  4. package/dist/Wizarding.d.ts.map +1 -0
  5. package/dist/Wizarding.js +4 -1
  6. package/dist/Wizarding.js.map +1 -1
  7. package/dist/action-icon.d.ts +1 -0
  8. package/dist/action-icon.d.ts.map +1 -0
  9. package/dist/action-pane.d.ts +1 -0
  10. package/dist/action-pane.d.ts.map +1 -0
  11. package/dist/addons/Editor.d.ts +1 -0
  12. package/dist/addons/Editor.d.ts.map +1 -0
  13. package/dist/addons/History.d.ts +12 -1
  14. package/dist/addons/History.d.ts.map +1 -0
  15. package/dist/addons/History.js +10 -0
  16. package/dist/addons/History.js.map +1 -1
  17. package/dist/addons/Layout.d.ts +1 -0
  18. package/dist/addons/Layout.d.ts.map +1 -0
  19. package/dist/addons/Settings.d.ts +1 -0
  20. package/dist/addons/Settings.d.ts.map +1 -0
  21. package/dist/addons/Waiter.d.ts +1 -0
  22. package/dist/addons/Waiter.d.ts.map +1 -0
  23. package/dist/addons/Wizards.d.ts +1 -0
  24. package/dist/addons/Wizards.d.ts.map +1 -0
  25. package/dist/addons/editor/edit-action-to-v1-converter.d.ts +1 -0
  26. package/dist/addons/editor/edit-action-to-v1-converter.d.ts.map +1 -0
  27. package/dist/addons/editor/edit-v1-to-v2-converter.d.ts +1 -0
  28. package/dist/addons/editor/edit-v1-to-v2-converter.d.ts.map +1 -0
  29. package/dist/addons/history/get-log-text.d.ts +1 -0
  30. package/dist/addons/history/get-log-text.d.ts.map +1 -0
  31. package/dist/addons/menu-tabs/menu-tabs.d.ts +1 -0
  32. package/dist/addons/menu-tabs/menu-tabs.d.ts.map +1 -0
  33. package/dist/addons/plugin-manager/custom-plugin-dialog.d.ts +1 -0
  34. package/dist/addons/plugin-manager/custom-plugin-dialog.d.ts.map +1 -0
  35. package/dist/addons/plugin-manager/plugin-manager.d.ts +1 -0
  36. package/dist/addons/plugin-manager/plugin-manager.d.ts.map +1 -0
  37. package/dist/filtered-list.d.ts +1 -0
  38. package/dist/filtered-list.d.ts.map +1 -0
  39. package/dist/finder-list.d.ts +1 -0
  40. package/dist/finder-list.d.ts.map +1 -0
  41. package/dist/foundation/compare.d.ts +1 -0
  42. package/dist/foundation/compare.d.ts.map +1 -0
  43. package/dist/foundation/dai.d.ts +1 -0
  44. package/dist/foundation/dai.d.ts.map +1 -0
  45. package/dist/foundation/generators.d.ts +1 -0
  46. package/dist/foundation/generators.d.ts.map +1 -0
  47. package/dist/foundation/ied.d.ts +1 -0
  48. package/dist/foundation/ied.d.ts.map +1 -0
  49. package/dist/foundation/nsd.d.ts +1 -0
  50. package/dist/foundation/nsd.d.ts.map +1 -0
  51. package/dist/foundation/nsdoc.d.ts +1 -0
  52. package/dist/foundation/nsdoc.d.ts.map +1 -0
  53. package/dist/foundation/scl.d.ts +1 -0
  54. package/dist/foundation/scl.d.ts.map +1 -0
  55. package/dist/foundation.d.ts +1 -0
  56. package/dist/foundation.d.ts.map +1 -0
  57. package/dist/icons/compare.d.ts +1 -0
  58. package/dist/icons/compare.d.ts.map +1 -0
  59. package/dist/icons/icons.d.ts +1 -0
  60. package/dist/icons/icons.d.ts.map +1 -0
  61. package/dist/icons/ied-icons.d.ts +1 -0
  62. package/dist/icons/ied-icons.d.ts.map +1 -0
  63. package/dist/icons/lnode.d.ts +1 -0
  64. package/dist/icons/lnode.d.ts.map +1 -0
  65. package/dist/index.d.ts +22 -0
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/index.js +24 -0
  68. package/dist/index.js.map +1 -0
  69. package/dist/open-scd.d.ts +1 -0
  70. package/dist/open-scd.d.ts.map +1 -0
  71. package/dist/oscd-filter-button.d.ts +1 -0
  72. package/dist/oscd-filter-button.d.ts.map +1 -0
  73. package/dist/plain-compare-list.d.ts +1 -0
  74. package/dist/plain-compare-list.d.ts.map +1 -0
  75. package/dist/plugin-tag.d.ts +1 -0
  76. package/dist/plugin-tag.d.ts.map +1 -0
  77. package/dist/plugin.d.ts +1 -0
  78. package/dist/plugin.d.ts.map +1 -0
  79. package/dist/plugin.events.d.ts +1 -0
  80. package/dist/plugin.events.d.ts.map +1 -0
  81. package/dist/plugins.d.ts +1 -0
  82. package/dist/plugins.d.ts.map +1 -0
  83. package/dist/schemas.d.ts +1 -0
  84. package/dist/schemas.d.ts.map +1 -0
  85. package/dist/themes.d.ts +1 -0
  86. package/dist/themes.d.ts.map +1 -0
  87. package/dist/translations/de.d.ts +1 -0
  88. package/dist/translations/de.d.ts.map +1 -0
  89. package/dist/translations/en.d.ts +1 -0
  90. package/dist/translations/en.d.ts.map +1 -0
  91. package/dist/translations/loader.d.ts +1 -0
  92. package/dist/translations/loader.d.ts.map +1 -0
  93. package/dist/wizard-checkbox.d.ts +1 -0
  94. package/dist/wizard-checkbox.d.ts.map +1 -0
  95. package/dist/wizard-dialog.d.ts +1 -0
  96. package/dist/wizard-dialog.d.ts.map +1 -0
  97. package/dist/wizard-select.d.ts +1 -0
  98. package/dist/wizard-select.d.ts.map +1 -0
  99. package/dist/wizard-textfield.d.ts +2 -1
  100. package/dist/wizard-textfield.d.ts.map +1 -0
  101. package/dist/wizards.d.ts +1 -0
  102. package/dist/wizards.d.ts.map +1 -0
  103. package/package.json +317 -47
  104. package/dist/core/api/api.js +0 -7
  105. package/dist/core/api/api.js.map +0 -1
  106. package/dist/core/api/editor/subject.js +0 -22
  107. package/dist/core/api/editor/subject.js.map +0 -1
  108. package/dist/core/api/editor/xml-editor.js +0 -82
  109. package/dist/core/api/editor/xml-editor.js.map +0 -1
  110. package/dist/core/api/plugin-state-api.js +0 -27
  111. package/dist/core/api/plugin-state-api.js.map +0 -1
  112. package/dist/core/foundation/cyrb64.js +0 -26
  113. package/dist/core/foundation/cyrb64.js.map +0 -1
  114. package/dist/core/foundation/deprecated/edit-event.js +0 -44
  115. package/dist/core/foundation/deprecated/edit-event.js.map +0 -1
  116. package/dist/core/foundation/deprecated/editor.js +0 -94
  117. package/dist/core/foundation/deprecated/editor.js.map +0 -1
  118. package/dist/core/foundation/deprecated/history.js +0 -17
  119. package/dist/core/foundation/deprecated/history.js.map +0 -1
  120. package/dist/core/foundation/deprecated/open-event.js +0 -9
  121. package/dist/core/foundation/deprecated/open-event.js.map +0 -1
  122. package/dist/core/foundation/deprecated/settings.js +0 -19
  123. package/dist/core/foundation/deprecated/settings.js.map +0 -1
  124. package/dist/core/foundation/deprecated/validation.js +0 -8
  125. package/dist/core/foundation/deprecated/validation.js.map +0 -1
  126. package/dist/core/foundation/deprecated/waiter.js +0 -12
  127. package/dist/core/foundation/deprecated/waiter.js.map +0 -1
  128. package/dist/core/foundation/edit-completed-event.js +0 -11
  129. package/dist/core/foundation/edit-completed-event.js.map +0 -1
  130. package/dist/core/foundation/edit-event.js +0 -8
  131. package/dist/core/foundation/edit-event.js.map +0 -1
  132. package/dist/core/foundation/edit.js +0 -31
  133. package/dist/core/foundation/edit.js.map +0 -1
  134. package/dist/core/foundation/handle-edit.js +0 -151
  135. package/dist/core/foundation/handle-edit.js.map +0 -1
  136. package/dist/core/foundation/open-event.js +0 -8
  137. package/dist/core/foundation/open-event.js.map +0 -1
  138. package/dist/core/foundation/plugin.js +0 -2
  139. package/dist/core/foundation/plugin.js.map +0 -1
  140. package/dist/core/foundation.js +0 -14
  141. package/dist/core/foundation.js.map +0 -1
  142. package/dist/core/locales.js +0 -21
  143. package/dist/core/locales.js.map +0 -1
  144. package/dist/openscd/src/WizardDivider.js +0 -37
  145. package/dist/openscd/src/WizardDivider.js.map +0 -1
  146. package/dist/openscd/src/Wizarding.js +0 -38
  147. package/dist/openscd/src/Wizarding.js.map +0 -1
  148. package/dist/openscd/src/action-icon.js +0 -220
  149. package/dist/openscd/src/action-icon.js.map +0 -1
  150. package/dist/openscd/src/action-pane.js +0 -176
  151. package/dist/openscd/src/action-pane.js.map +0 -1
  152. package/dist/openscd/src/addons/Editor.js +0 -106
  153. package/dist/openscd/src/addons/Editor.js.map +0 -1
  154. package/dist/openscd/src/addons/History.js +0 -581
  155. package/dist/openscd/src/addons/History.js.map +0 -1
  156. package/dist/openscd/src/addons/Layout.js +0 -619
  157. package/dist/openscd/src/addons/Layout.js.map +0 -1
  158. package/dist/openscd/src/addons/Settings.js +0 -465
  159. package/dist/openscd/src/addons/Settings.js.map +0 -1
  160. package/dist/openscd/src/addons/Waiter.js +0 -45
  161. package/dist/openscd/src/addons/Waiter.js.map +0 -1
  162. package/dist/openscd/src/addons/Wizards.js +0 -48
  163. package/dist/openscd/src/addons/Wizards.js.map +0 -1
  164. package/dist/openscd/src/addons/editor/edit-action-to-v1-converter.js +0 -96
  165. package/dist/openscd/src/addons/editor/edit-action-to-v1-converter.js.map +0 -1
  166. package/dist/openscd/src/addons/editor/edit-v1-to-v2-converter.js +0 -37
  167. package/dist/openscd/src/addons/editor/edit-v1-to-v2-converter.js.map +0 -1
  168. package/dist/openscd/src/addons/history/get-log-text.js +0 -26
  169. package/dist/openscd/src/addons/history/get-log-text.js.map +0 -1
  170. package/dist/openscd/src/addons/menu-tabs/menu-tabs.js +0 -74
  171. package/dist/openscd/src/addons/menu-tabs/menu-tabs.js.map +0 -1
  172. package/dist/openscd/src/addons/plugin-manager/custom-plugin-dialog.js +0 -177
  173. package/dist/openscd/src/addons/plugin-manager/custom-plugin-dialog.js.map +0 -1
  174. package/dist/openscd/src/addons/plugin-manager/plugin-manager.js +0 -165
  175. package/dist/openscd/src/addons/plugin-manager/plugin-manager.js.map +0 -1
  176. package/dist/openscd/src/filtered-list.js +0 -168
  177. package/dist/openscd/src/filtered-list.js.map +0 -1
  178. package/dist/openscd/src/finder-list.js +0 -207
  179. package/dist/openscd/src/finder-list.js.map +0 -1
  180. package/dist/openscd/src/foundation/compare.js +0 -273
  181. package/dist/openscd/src/foundation/compare.js.map +0 -1
  182. package/dist/openscd/src/foundation/dai.js +0 -127
  183. package/dist/openscd/src/foundation/dai.js.map +0 -1
  184. package/dist/openscd/src/foundation/generators.js +0 -67
  185. package/dist/openscd/src/foundation/generators.js.map +0 -1
  186. package/dist/openscd/src/foundation/ied.js +0 -84
  187. package/dist/openscd/src/foundation/ied.js.map +0 -1
  188. package/dist/openscd/src/foundation/nsd.js +0 -13
  189. package/dist/openscd/src/foundation/nsd.js.map +0 -1
  190. package/dist/openscd/src/foundation/nsdoc.js +0 -180
  191. package/dist/openscd/src/foundation/nsdoc.js.map +0 -1
  192. package/dist/openscd/src/foundation/scl.js +0 -64
  193. package/dist/openscd/src/foundation/scl.js.map +0 -1
  194. package/dist/openscd/src/foundation.js +0 -1922
  195. package/dist/openscd/src/foundation.js.map +0 -1
  196. package/dist/openscd/src/icons/compare.js +0 -11
  197. package/dist/openscd/src/icons/compare.js.map +0 -1
  198. package/dist/openscd/src/icons/icons.js +0 -611
  199. package/dist/openscd/src/icons/icons.js.map +0 -1
  200. package/dist/openscd/src/icons/ied-icons.js +0 -11
  201. package/dist/openscd/src/icons/ied-icons.js.map +0 -1
  202. package/dist/openscd/src/icons/lnode.js +0 -50
  203. package/dist/openscd/src/icons/lnode.js.map +0 -1
  204. package/dist/openscd/src/open-scd.js +0 -483
  205. package/dist/openscd/src/open-scd.js.map +0 -1
  206. package/dist/openscd/src/oscd-filter-button.js +0 -89
  207. package/dist/openscd/src/oscd-filter-button.js.map +0 -1
  208. package/dist/openscd/src/plain-compare-list.js +0 -132
  209. package/dist/openscd/src/plain-compare-list.js.map +0 -1
  210. package/dist/openscd/src/plugin-tag.js +0 -23
  211. package/dist/openscd/src/plugin-tag.js.map +0 -1
  212. package/dist/openscd/src/plugin.events.js +0 -12
  213. package/dist/openscd/src/plugin.events.js.map +0 -1
  214. package/dist/openscd/src/plugin.js +0 -2
  215. package/dist/openscd/src/plugin.js.map +0 -1
  216. package/dist/openscd/src/plugins.js +0 -256
  217. package/dist/openscd/src/plugins.js.map +0 -1
  218. package/dist/openscd/src/schemas.js +0 -9325
  219. package/dist/openscd/src/schemas.js.map +0 -1
  220. package/dist/openscd/src/themes.js +0 -122
  221. package/dist/openscd/src/themes.js.map +0 -1
  222. package/dist/openscd/src/translations/de.js +0 -954
  223. package/dist/openscd/src/translations/de.js.map +0 -1
  224. package/dist/openscd/src/translations/en.js +0 -950
  225. package/dist/openscd/src/translations/en.js.map +0 -1
  226. package/dist/openscd/src/translations/loader.js +0 -10
  227. package/dist/openscd/src/translations/loader.js.map +0 -1
  228. package/dist/openscd/src/wizard-checkbox.js +0 -152
  229. package/dist/openscd/src/wizard-checkbox.js.map +0 -1
  230. package/dist/openscd/src/wizard-dialog.js +0 -374
  231. package/dist/openscd/src/wizard-dialog.js.map +0 -1
  232. package/dist/openscd/src/wizard-select.js +0 -115
  233. package/dist/openscd/src/wizard-select.js.map +0 -1
  234. package/dist/openscd/src/wizard-textfield.js +0 -191
  235. package/dist/openscd/src/wizard-textfield.js.map +0 -1
  236. package/dist/openscd/src/wizards.js +0 -196
  237. package/dist/openscd/src/wizards.js.map +0 -1
  238. package/dist/xml/src/foundation.js +0 -67
  239. package/dist/xml/src/foundation.js.map +0 -1
  240. package/dist/xml/src/index.js +0 -2
  241. package/dist/xml/src/index.js.map +0 -1
@@ -1,619 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { customElement, html, LitElement, property, state, query, css, } from 'lit-element';
3
- import { get } from 'lit-translate';
4
- import { newPendingStateEvent } from '@openscd/core/foundation/deprecated/waiter.js';
5
- import { newSettingsUIEvent } from '@openscd/core/foundation/deprecated/settings.js';
6
- import { pluginIcons, } from '../open-scd.js';
7
- import { HistoryUIKind, newEmptyIssuesEvent, newHistoryUIEvent } from './History.js';
8
- import { List } from '@material/mwc-list';
9
- import '@material/mwc-drawer';
10
- import '@material/mwc-list';
11
- import '@material/mwc-dialog';
12
- import '@material/mwc-switch';
13
- import '@material/mwc-select';
14
- import '@material/mwc-textfield';
15
- import { pluginTag } from '../plugin-tag.js';
16
- import "./plugin-manager/plugin-manager.js";
17
- import "./plugin-manager/custom-plugin-dialog.js";
18
- import "./menu-tabs/menu-tabs.js";
19
- let OscdLayout = class OscdLayout extends LitElement {
20
- constructor() {
21
- super(...arguments);
22
- /** The `XMLDocument` to be edited */
23
- this.doc = null;
24
- /** The name of the current [[`doc`]] */
25
- this.docName = '';
26
- /** Index of the last [[`EditorAction`]] applied. */
27
- this.editCount = -1;
28
- /** The plugins to render the layout. */
29
- this.plugins = [];
30
- this.validated = Promise.resolve();
31
- this.shouldValidate = false;
32
- this.activeEditor = this.calcActiveEditors()[0];
33
- }
34
- render() {
35
- return html `
36
- <div
37
- @open-plugin-download=${() => this.pluginDownloadUI.show()}
38
- @oscd-activate-editor=${this.handleActivateEditorByEvent}
39
- @oscd-run-menu=${this.handleRunMenuByEvent}
40
- >
41
- <slot></slot>
42
- ${this.renderHeader()} ${this.renderAside()} ${this.renderMenuContent()}
43
- ${this.renderContent()} ${this.renderLanding()} ${this.renderPlugging()}
44
- </div>
45
- `;
46
- }
47
- renderPlugging() {
48
- return html ` ${this.renderPluginUI()} ${this.renderDownloadUI()} `;
49
- }
50
- getMenuContent(src) {
51
- const tag = pluginTag(src);
52
- return this.menuContent.querySelector(tag);
53
- }
54
- /** Renders the "Add Custom Plug-in" UI*/
55
- renderDownloadUI() {
56
- return html `
57
- <oscd-custom-plugin-dialog id="pluginAdd"></oscd-custom-plugin-dialog>
58
- `;
59
- }
60
- /**
61
- * Renders the plug-in management UI (turning plug-ins on/off)
62
- */
63
- renderPluginUI() {
64
- return html `
65
- <oscd-plugin-manager id="pluginManager" .plugins=${this.plugins}></oscd-plugin-manager>
66
- `;
67
- }
68
- // Computed properties
69
- get validators() {
70
- return this.plugins.filter(plugin => plugin.active && plugin.kind === 'validator');
71
- }
72
- get menuEntries() {
73
- return this.plugins.filter(plugin => plugin.active && plugin.kind === 'menu');
74
- }
75
- get topMenu() {
76
- return this.menuEntries.filter(plugin => plugin.position === 'top');
77
- }
78
- get middleMenu() {
79
- return this.menuEntries.filter(plugin => plugin.position === 'middle');
80
- }
81
- get bottomMenu() {
82
- return this.menuEntries.filter(plugin => plugin.position === 'bottom');
83
- }
84
- get menu() {
85
- const topMenu = this.generateMenu(this.topMenu, 'top');
86
- const middleMenu = this.generateMenu(this.middleMenu, 'middle');
87
- const bottomMenu = this.generateMenu(this.bottomMenu, 'bottom');
88
- const validators = this.generateValidatorMenus(this.validators);
89
- if (middleMenu.length > 0)
90
- middleMenu.push('divider');
91
- if (bottomMenu.length > 0)
92
- bottomMenu.push('divider');
93
- return [
94
- 'divider',
95
- ...topMenu,
96
- 'divider',
97
- {
98
- icon: 'undo',
99
- name: 'undo',
100
- actionItem: true,
101
- action: () => {
102
- this.editor.undo();
103
- },
104
- disabled: () => !this.editor.canUndo,
105
- kind: 'static',
106
- content: () => html ``,
107
- },
108
- {
109
- icon: 'redo',
110
- name: 'redo',
111
- actionItem: true,
112
- action: () => {
113
- this.editor.redo();
114
- },
115
- disabled: () => !this.editor.canRedo,
116
- kind: 'static',
117
- content: () => html ``,
118
- },
119
- ...validators,
120
- {
121
- icon: 'list',
122
- name: 'menu.viewLog',
123
- actionItem: true,
124
- action: () => {
125
- this.dispatchEvent(newHistoryUIEvent(true, HistoryUIKind.log));
126
- },
127
- kind: 'static',
128
- content: () => html ``,
129
- },
130
- {
131
- icon: 'history',
132
- name: 'menu.viewHistory',
133
- actionItem: true,
134
- action: () => {
135
- this.dispatchEvent(newHistoryUIEvent(true, HistoryUIKind.history));
136
- },
137
- kind: 'static',
138
- content: () => html ``,
139
- },
140
- {
141
- icon: 'rule',
142
- name: 'menu.viewDiag',
143
- actionItem: true,
144
- action: () => {
145
- this.dispatchEvent(newHistoryUIEvent(true, HistoryUIKind.diagnostic));
146
- },
147
- kind: 'static',
148
- content: () => html ``,
149
- },
150
- 'divider',
151
- ...middleMenu,
152
- {
153
- icon: 'settings',
154
- name: 'settings.title',
155
- action: () => {
156
- this.dispatchEvent(newSettingsUIEvent(true));
157
- },
158
- kind: 'static',
159
- content: () => html ``,
160
- },
161
- ...bottomMenu,
162
- {
163
- icon: 'extension',
164
- name: 'plugins.heading',
165
- action: () => this.pluginUI.show(),
166
- kind: 'static',
167
- content: () => html ``,
168
- },
169
- ];
170
- }
171
- get editors() {
172
- return this.plugins.filter(plugin => plugin.active && plugin.kind === 'editor');
173
- }
174
- // Keyboard Shortcuts
175
- handleKeyPress(e) {
176
- // currently we only handley key shortcuts when users press ctrl
177
- if (!e.ctrlKey) {
178
- return;
179
- }
180
- const keyFunctionMap = {
181
- 'm': () => this.menuUI.open = !this.menuUI.open,
182
- 'o': () => this.menuUI.querySelector('mwc-list-item[iconid="folder_open"]')?.click(),
183
- 'O': () => this.menuUI.querySelector('mwc-list-item[iconid="create_new_folder"]')?.click(),
184
- 's': () => this.menuUI.querySelector('mwc-list-item[iconid="save"]')?.click(),
185
- 'P': () => this.pluginUI.show(),
186
- };
187
- const fn = keyFunctionMap[e.key];
188
- if (!fn) {
189
- return;
190
- }
191
- e.preventDefault();
192
- fn();
193
- }
194
- connectedCallback() {
195
- super.connectedCallback();
196
- this.host.addEventListener('close-drawer', async () => {
197
- this.menuUI.open = false;
198
- });
199
- this.host.addEventListener('validate', async () => {
200
- this.shouldValidate = true;
201
- await this.validated;
202
- if (!this.shouldValidate) {
203
- return;
204
- }
205
- this.shouldValidate = false;
206
- this.validated = Promise.allSettled(this.menuUI
207
- .querySelector('mwc-list')
208
- .items.filter(item => item.className === 'validator')
209
- .map(item => {
210
- const src = item.dataset.src ?? '';
211
- const menuContentElement = this.getMenuContent(src);
212
- if (!menuContentElement) {
213
- return;
214
- }
215
- return menuContentElement.validate();
216
- })).then();
217
- this.dispatchEvent(newPendingStateEvent(this.validated));
218
- });
219
- this.handleKeyPress = this.handleKeyPress.bind(this);
220
- document.onkeydown = this.handleKeyPress;
221
- document.addEventListener("open-plugin-download", () => {
222
- this.pluginDownloadUI.show();
223
- });
224
- }
225
- generateMenu(plugins, kind) {
226
- return plugins.map(plugin => {
227
- return {
228
- icon: plugin.icon || pluginIcons['menu'],
229
- name: plugin.name,
230
- src: plugin.src,
231
- action: ae => {
232
- const menuContentElement = this.getMenuContent(plugin.src);
233
- if (!menuContentElement) {
234
- return;
235
- }
236
- this.dispatchEvent(newPendingStateEvent(menuContentElement.run()));
237
- },
238
- disabled: () => plugin.requireDoc && this.doc === null,
239
- content: () => {
240
- if (plugin.content) {
241
- return plugin.content();
242
- }
243
- return html ``;
244
- },
245
- kind: kind,
246
- };
247
- });
248
- }
249
- generateValidatorMenus(plugins) {
250
- return plugins.map(plugin => {
251
- return {
252
- icon: plugin.icon || pluginIcons['validator'],
253
- name: plugin.name,
254
- src: plugin.src,
255
- action: ae => {
256
- this.dispatchEvent(newEmptyIssuesEvent(plugin.src));
257
- const menuContentElement = this.getMenuContent(plugin.src);
258
- if (!menuContentElement) {
259
- return;
260
- }
261
- this.dispatchEvent(newPendingStateEvent(menuContentElement.validate()));
262
- },
263
- disabled: () => this.doc === null,
264
- content: plugin.content ?? (() => html ``),
265
- kind: 'validator',
266
- };
267
- });
268
- }
269
- renderMenuItem(me) {
270
- const isDivider = me === 'divider';
271
- const hasActionItem = me !== 'divider' && me.actionItem;
272
- if (isDivider) {
273
- return html `<li divider padded role="separator"></li>`;
274
- }
275
- if (hasActionItem) {
276
- return html ``;
277
- }
278
- return html `
279
- <mwc-list-item
280
- class="${me.kind}"
281
- iconid="${me.icon}"
282
- graphic="icon"
283
- data-name="${me.name}"
284
- data-src="${me.src ?? ''}"
285
- .disabled=${me.disabled?.() || !me.action}
286
- ><mwc-icon slot="graphic">${me.icon}</mwc-icon>
287
- <span>${get(me.name)}</span>
288
- ${me.hint
289
- ? html `<span slot="secondary"><tt>${me.hint}</tt></span>`
290
- : ''}
291
- </mwc-list-item>
292
- `;
293
- }
294
- renderActionItem(me) {
295
- if (me === 'divider' || !me.actionItem) {
296
- return html ``;
297
- }
298
- return html `
299
- <mwc-icon-button
300
- slot="actionItems"
301
- icon="${me.icon}"
302
- label="${me.name}"
303
- ?disabled=${me.disabled?.() || !me.action}
304
- @click=${me.action}
305
- ></mwc-icon-button>`;
306
- }
307
- renderEditorTab({ name, icon }) {
308
- return html `<mwc-tab label=${name} icon=${icon || 'edit'}> </mwc-tab>`;
309
- }
310
- /** Renders top bar which features icon buttons for undo, redo, log, scl history and diagnostics*/
311
- renderHeader() {
312
- return html `<mwc-top-app-bar-fixed>
313
- <mwc-icon-button
314
- icon="menu"
315
- label="Menu"
316
- slot="navigationIcon"
317
- @click=${() => (this.menuUI.open = true)}
318
- ></mwc-icon-button>
319
- ${this.renderTitle()}
320
- ${this.renderActionItems()}
321
- </mwc-top-app-bar-fixed>`;
322
- }
323
- /**
324
- * Renders the title section in the top bar
325
- * Make sure to use slot="title" for the returned template
326
- */
327
- renderTitle() {
328
- return html `<div slot="title" id="title">${this.docName}</div>`;
329
- }
330
- /**
331
- * Renders the action items for the top bar
332
- * Make sure to use slot="actionItems" for each element
333
- */
334
- renderActionItems() {
335
- return html `${this.menu.map(this.renderActionItem)}`;
336
- }
337
- renderMenuContent() {
338
- return html `
339
- <div id="menuContent">
340
- ${this.menu
341
- .filter(p => p.content)
342
- .map(p => p.content())}
343
- </div>
344
- `;
345
- }
346
- /**
347
- * Renders a drawer toolbar featuring the scl filename, enabled menu plugins,
348
- * settings, help, scl history and plug-ins management
349
- */
350
- renderAside() {
351
- return html `
352
- <mwc-drawer class="mdc-theme--surface" hasheader type="modal" id="menu">
353
- <span slot="title">${get('menu.title')}</span>
354
- ${renderTitle(this.docName)}
355
- <mwc-list
356
- wrapFocus
357
- @action=${makeListAction(this.menu)}
358
- >
359
- ${this.menu.map(this.renderMenuItem)}
360
- </mwc-list>
361
- </mwc-drawer>
362
- `;
363
- function renderTitle(docName) {
364
- if (!docName)
365
- return html ``;
366
- return html `<span slot="subtitle">${docName}</span>`;
367
- }
368
- function makeListAction(menuItems) {
369
- return function listAction(ae) {
370
- //FIXME: dirty hack to be fixed in open-scd-core
371
- // if clause not necessary when oscd... components in open-scd not list
372
- if (ae.target instanceof List)
373
- (menuItems.filter(item => item !== 'divider' && !item.actionItem)[ae.detail.index])?.action?.(ae);
374
- };
375
- }
376
- }
377
- calcActiveEditors() {
378
- const hasActiveDoc = Boolean(this.doc);
379
- return this.editors
380
- .filter(editor => {
381
- // this is necessary because `requireDoc` can be undefined
382
- // and that is not the same as false
383
- const doesNotRequireDoc = editor.requireDoc === false;
384
- return doesNotRequireDoc || hasActiveDoc;
385
- });
386
- }
387
- /** Renders the enabled editor plugins and a tab bar to switch between them*/
388
- renderContent() {
389
- const activeEditors = this.calcActiveEditors()
390
- .map(this.renderEditorTab);
391
- const hasActiveEditors = activeEditors.length > 0;
392
- if (!hasActiveEditors) {
393
- return html ``;
394
- }
395
- return html `
396
- <oscd-menu-tabs
397
- .editors=${this.calcActiveEditors()}
398
- .activeEditor=${this.activeEditor}
399
- @oscd-editor-tab-activated=${this.handleEditorTabActivated}
400
- >
401
- </oscd-menu-tabs>
402
- ${renderEditorContent(this.doc, this.activeEditor)}
403
- `;
404
- function renderEditorContent(doc, activeEditor) {
405
- const editor = activeEditor;
406
- const requireDoc = editor?.requireDoc;
407
- if (requireDoc && !doc) {
408
- return html ``;
409
- }
410
- const content = editor?.content;
411
- if (!content) {
412
- return html ``;
413
- }
414
- return html `${content()}`;
415
- }
416
- }
417
- handleEditorTabActivated(e) {
418
- this.activeEditor = e.detail.editor;
419
- }
420
- handleActivateEditorByEvent(e) {
421
- const { name, src } = e.detail;
422
- const editors = this.calcActiveEditors();
423
- const wantedEditor = editors.find(editor => editor.name === name || editor.src === src);
424
- if (!wantedEditor) {
425
- return;
426
- } // TODO: log error
427
- this.activeEditor = wantedEditor;
428
- }
429
- handleRunMenuByEvent(e) {
430
- // TODO: this is a workaround, fix it
431
- this.menuUI.open = true;
432
- const menuEntry = this.menuUI.querySelector(`[data-name="${e.detail.name}"]`);
433
- const menuContentElement = this.getMenuContent(menuEntry.dataset.src ?? '');
434
- if (!menuContentElement) {
435
- return;
436
- }
437
- menuContentElement.run();
438
- }
439
- /**
440
- * Renders the landing buttons (open project and new project)
441
- * it no document loaded we display the menu item that are in the position
442
- * 'top' and are not disabled
443
- *
444
- * To enable replacement of this part we have to convert it to either an addon
445
- * or a plugin
446
- */
447
- renderLanding() {
448
- if (this.doc) {
449
- return html ``;
450
- }
451
- return html `
452
- <div class="landing">
453
- ${renderMenuItems(this.menu, this.menuUI)}
454
- </div>`;
455
- function renderMenuItems(menuItemsAndDividers, menuUI) {
456
- const menuItems = menuItemsAndDividers.filter(mi => mi !== 'divider');
457
- return menuItems.map((mi, index) => {
458
- if (mi.kind !== 'top' || mi.disabled?.()) {
459
- return html ``;
460
- }
461
- return html `
462
- <mwc-icon-button
463
- class="landing_icon"
464
- icon="${mi.icon}"
465
- @click="${() => clickListItem(index)}"
466
- >
467
- <div class="landing_label">${mi.name}</div>
468
- </mwc-icon-button>
469
- `;
470
- });
471
- function clickListItem(index) {
472
- const listItem = menuUI.querySelector('mwc-list').items[index];
473
- listItem.click();
474
- }
475
- }
476
- }
477
- };
478
- OscdLayout.styles = css `
479
- mwc-drawer {
480
- position: absolute;
481
- top: 0;
482
- }
483
-
484
- mwc-top-app-bar-fixed {
485
- --mdc-theme-text-disabled-on-light: rgba(255, 255, 255, 0.38);
486
- } /* hack to fix disabled icon buttons rendering black */
487
-
488
- mwc-tab {
489
- background-color: var(--primary);
490
- --mdc-theme-primary: var(--mdc-theme-on-primary);
491
- }
492
-
493
- input[type='file'] {
494
- display: none;
495
- }
496
-
497
- mwc-dialog {
498
- --mdc-dialog-max-width: 98vw;
499
- }
500
-
501
- mwc-dialog > form {
502
- display: flex;
503
- flex-direction: column;
504
- }
505
-
506
- mwc-dialog > form > * {
507
- display: block;
508
- margin-top: 16px;
509
- }
510
-
511
- mwc-linear-progress {
512
- position: fixed;
513
- --mdc-linear-progress-buffer-color: var(--primary);
514
- --mdc-theme-primary: var(--secondary);
515
- left: 0px;
516
- top: 0px;
517
- width: 100%;
518
- pointer-events: none;
519
- z-index: 1000;
520
- }
521
-
522
- tt {
523
- font-family: 'Roboto Mono', monospace;
524
- font-weight: 300;
525
- }
526
-
527
- .landing {
528
- position: absolute;
529
- text-align: center;
530
- top: 50%;
531
- left: 50%;
532
- transform: translate(-50%, -50%);
533
- width: 100%;
534
- }
535
-
536
- .landing_icon:hover {
537
- box-shadow: 0 12px 17px 2px rgba(0, 0, 0, 0.14),
538
- 0 5px 22px 4px rgba(0, 0, 0, 0.12), 0 7px 8px -4px rgba(0, 0, 0, 0.2);
539
- }
540
-
541
- .landing_icon {
542
- margin: 12px;
543
- border-radius: 16px;
544
- width: 160px;
545
- height: 140px;
546
- text-align: center;
547
- color: var(--mdc-theme-on-secondary);
548
- background: var(--secondary);
549
- --mdc-icon-button-size: 100px;
550
- --mdc-icon-size: 100px;
551
- --mdc-ripple-color: rgba(0, 0, 0, 0);
552
- box-shadow: rgb(0 0 0 / 14%) 0px 6px 10px 0px,
553
- rgb(0 0 0 / 12%) 0px 1px 18px 0px, rgb(0 0 0 / 20%) 0px 3px 5px -1px;
554
- transition: box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);
555
- }
556
-
557
- .landing_label {
558
- width: 160px;
559
- height: 50px;
560
- margin-top: 100px;
561
- margin-left: -30px;
562
- font-family: 'Roboto', sans-serif;
563
- }
564
-
565
- .plugin.menu {
566
- display: flex;
567
- }
568
-
569
- .plugin.validator {
570
- display: flex;
571
- }
572
- `;
573
- __decorate([
574
- property({ attribute: false })
575
- ], OscdLayout.prototype, "doc", void 0);
576
- __decorate([
577
- property({ type: String })
578
- ], OscdLayout.prototype, "docName", void 0);
579
- __decorate([
580
- property({ type: Number })
581
- ], OscdLayout.prototype, "editCount", void 0);
582
- __decorate([
583
- property({ type: Object })
584
- ], OscdLayout.prototype, "editor", void 0);
585
- __decorate([
586
- property({ type: Array })
587
- ], OscdLayout.prototype, "plugins", void 0);
588
- __decorate([
589
- property({ type: Object })
590
- ], OscdLayout.prototype, "host", void 0);
591
- __decorate([
592
- state()
593
- ], OscdLayout.prototype, "validated", void 0);
594
- __decorate([
595
- state()
596
- ], OscdLayout.prototype, "shouldValidate", void 0);
597
- __decorate([
598
- state()
599
- ], OscdLayout.prototype, "activeEditor", void 0);
600
- __decorate([
601
- query('#menu')
602
- ], OscdLayout.prototype, "menuUI", void 0);
603
- __decorate([
604
- query('#menuContent')
605
- ], OscdLayout.prototype, "menuContent", void 0);
606
- __decorate([
607
- query('#pluginManager')
608
- ], OscdLayout.prototype, "pluginUI", void 0);
609
- __decorate([
610
- query('#pluginList')
611
- ], OscdLayout.prototype, "pluginList", void 0);
612
- __decorate([
613
- query('#pluginAdd')
614
- ], OscdLayout.prototype, "pluginDownloadUI", void 0);
615
- OscdLayout = __decorate([
616
- customElement('oscd-layout')
617
- ], OscdLayout);
618
- export { OscdLayout };
619
- //# sourceMappingURL=Layout.js.map