@omicronenergy/oscd-ui 0.0.20 → 0.1.1

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 (112) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/MIGRATION-0.1.0.md +201 -0
  3. package/README.md +7 -1
  4. package/THEMING.md +180 -0
  5. package/custom-elements.json +1799 -1485
  6. package/dist/about/{Catalog.stories.d.ts → ComponentCatalog.stories.d.ts} +1 -1
  7. package/dist/about/ComponentCatalog.stories.js +300 -0
  8. package/dist/about/ComponentCatalog.stories.js.map +1 -0
  9. package/dist/ace-editor/OscdAceEditor.d.ts +25 -2
  10. package/dist/ace-editor/OscdAceEditor.js +25 -2
  11. package/dist/ace-editor/OscdAceEditor.js.map +1 -1
  12. package/dist/ace-editor/OscdAceEditor.stories.d.ts +3 -1
  13. package/dist/ace-editor/OscdAceEditor.stories.js +11 -2
  14. package/dist/ace-editor/OscdAceEditor.stories.js.map +1 -1
  15. package/dist/ace-editor/internal/ace-editor-base/AceEditorBase.js +2 -1
  16. package/dist/ace-editor/internal/ace-editor-base/AceEditorBase.js.map +1 -1
  17. package/dist/ace-editor/internal/ace-theme-oscd.js +174 -99
  18. package/dist/ace-editor/internal/ace-theme-oscd.js.map +1 -1
  19. package/dist/action-icon/OscdActionIcon.d.ts +12 -5
  20. package/dist/action-icon/OscdActionIcon.js +53 -46
  21. package/dist/action-icon/OscdActionIcon.js.map +1 -1
  22. package/dist/action-icon/OscdActionIcon.spec.d.ts +1 -0
  23. package/dist/action-icon/OscdActionIcon.spec.js +81 -0
  24. package/dist/action-icon/OscdActionIcon.spec.js.map +1 -0
  25. package/dist/action-list/OscdActionList.js +1 -1
  26. package/dist/action-list/OscdActionList.js.map +1 -1
  27. package/dist/action-pane/OscdActionPane.d.ts +8 -6
  28. package/dist/action-pane/OscdActionPane.js +49 -33
  29. package/dist/action-pane/OscdActionPane.js.map +1 -1
  30. package/dist/action-pane/OscdActionPane.spec.d.ts +1 -0
  31. package/dist/action-pane/OscdActionPane.spec.js +95 -0
  32. package/dist/action-pane/OscdActionPane.spec.js.map +1 -0
  33. package/dist/action-tree/OscdActionTree.d.ts +6 -0
  34. package/dist/action-tree/OscdActionTree.js +28 -7
  35. package/dist/action-tree/OscdActionTree.js.map +1 -1
  36. package/dist/app-bar/OscdAppBar.d.ts +20 -11
  37. package/dist/app-bar/OscdAppBar.js +98 -59
  38. package/dist/app-bar/OscdAppBar.js.map +1 -1
  39. package/dist/app-bar/OscdAppBar.spec.d.ts +1 -0
  40. package/dist/app-bar/OscdAppBar.spec.js +73 -0
  41. package/dist/app-bar/OscdAppBar.spec.js.map +1 -0
  42. package/dist/app-bar/OscdAppBar.stories.d.ts +1 -0
  43. package/dist/app-bar/OscdAppBar.stories.js +11 -0
  44. package/dist/app-bar/OscdAppBar.stories.js.map +1 -1
  45. package/dist/dialog/warning/OscdWarnDialog.stories.d.ts +5 -0
  46. package/dist/dialog/warning/OscdWarnDialog.stories.js +43 -0
  47. package/dist/dialog/warning/OscdWarnDialog.stories.js.map +1 -0
  48. package/dist/filter-button/OscdFilterButton.js +0 -4
  49. package/dist/filter-button/OscdFilterButton.js.map +1 -1
  50. package/dist/icon/internal/icon.js +1 -1
  51. package/dist/icon/internal/icon.js.map +1 -1
  52. package/dist/navigation-drawer/OscdNavigationDrawer.stories.js +4 -2
  53. package/dist/navigation-drawer/OscdNavigationDrawer.stories.js.map +1 -1
  54. package/dist/navigation-drawer/OscdNavigationDrawerHeader.d.ts +10 -1
  55. package/dist/navigation-drawer/OscdNavigationDrawerHeader.js +11 -57
  56. package/dist/navigation-drawer/OscdNavigationDrawerHeader.js.map +1 -1
  57. package/dist/navigation-drawer/OscdNavigationDrawerHeader.spec.d.ts +1 -0
  58. package/dist/navigation-drawer/OscdNavigationDrawerHeader.spec.js +51 -0
  59. package/dist/navigation-drawer/OscdNavigationDrawerHeader.spec.js.map +1 -0
  60. package/dist/oscd-md3-mappings.d.ts +2 -0
  61. package/dist/oscd-md3-mappings.js +59 -0
  62. package/dist/oscd-md3-mappings.js.map +1 -0
  63. package/dist/oscd-md3-mappings.spec.d.ts +1 -0
  64. package/dist/oscd-md3-mappings.spec.js +82 -0
  65. package/dist/oscd-md3-mappings.spec.js.map +1 -0
  66. package/dist/scl-icon/OscdSclIcon.d.ts +3 -19
  67. package/dist/scl-icon/OscdSclIcon.js +3 -114
  68. package/dist/scl-icon/OscdSclIcon.js.map +1 -1
  69. package/dist/scl-icon/internal/scl-icons.d.ts +18 -0
  70. package/dist/scl-icon/internal/scl-icons.js +92 -0
  71. package/dist/scl-icon/internal/scl-icons.js.map +1 -0
  72. package/dist/scl-icon/internal/scl-icons.spec.d.ts +1 -0
  73. package/dist/scl-icon/internal/scl-icons.spec.js +18 -0
  74. package/dist/scl-icon/internal/scl-icons.spec.js.map +1 -0
  75. package/dist/search-field/OscdOutlinedSearchField.d.ts +2 -1
  76. package/dist/search-field/OscdOutlinedSearchField.js +2 -1
  77. package/dist/search-field/OscdOutlinedSearchField.js.map +1 -1
  78. package/dist/selection-list/OscdSelectionList.js +1 -1
  79. package/dist/selection-list/OscdSelectionList.js.map +1 -1
  80. package/dist/snackbar/OscdSnackbar.d.ts +32 -18
  81. package/dist/snackbar/OscdSnackbar.js +191 -67
  82. package/dist/snackbar/OscdSnackbar.js.map +1 -1
  83. package/dist/snackbar/OscdSnackbar.spec.js +67 -0
  84. package/dist/snackbar/OscdSnackbar.spec.js.map +1 -1
  85. package/dist/snackbar/OscdSnackbar.stories.d.ts +3 -1
  86. package/dist/snackbar/OscdSnackbar.stories.js +69 -0
  87. package/dist/snackbar/OscdSnackbar.stories.js.map +1 -1
  88. package/dist/tree/OscdTree.d.ts +3 -0
  89. package/dist/tree/OscdTree.js +3 -0
  90. package/dist/tree/OscdTree.js.map +1 -1
  91. package/dist/tree/OscdTreeItem.d.ts +2 -0
  92. package/dist/tree/OscdTreeItem.js +2 -0
  93. package/dist/tree/OscdTreeItem.js.map +1 -1
  94. package/dist/tree/OscdTreeItem.stories.d.ts +5 -0
  95. package/dist/tree/OscdTreeItem.stories.js +23 -0
  96. package/dist/tree/OscdTreeItem.stories.js.map +1 -0
  97. package/dist/tree/internal/Tree.js +30 -76
  98. package/dist/tree/internal/Tree.js.map +1 -1
  99. package/dist/tree/internal/TreeItem.js +17 -70
  100. package/dist/tree/internal/TreeItem.js.map +1 -1
  101. package/dist/tree-grid/OscdTreeGrid.js +2 -2
  102. package/dist/tree-grid/OscdTreeGrid.js.map +1 -1
  103. package/dist/tree-grid/oscd-tree-grid.spec.js +15 -0
  104. package/dist/tree-grid/oscd-tree-grid.spec.js.map +1 -1
  105. package/dist/utils/storybook/story-overrides/divider-overrides.js +1 -1
  106. package/dist/utils/storybook/story-overrides/divider-overrides.js.map +1 -1
  107. package/package.json +3 -1
  108. package/dist/about/Catalog.stories.js +0 -305
  109. package/dist/about/Catalog.stories.js.map +0 -1
  110. package/dist/utils/storybook/themingDecorator.d.ts +0 -19
  111. package/dist/utils/storybook/themingDecorator.js +0 -100
  112. package/dist/utils/storybook/themingDecorator.js.map +0 -1
@@ -2,4 +2,4 @@ import type { Meta, StoryObj } from '@storybook/web-components-vite';
2
2
  declare const meta: Meta;
3
3
  export default meta;
4
4
  type Story = StoryObj;
5
- export declare const AllComponents: Story;
5
+ export declare const Default: Story;
@@ -0,0 +1,300 @@
1
+ import { __decorate } from "tslib";
2
+ import { LitElement, css, html } from 'lit';
3
+ import { property, state } from 'lit/decorators.js';
4
+ import { useGlobals } from 'storybook/preview-api';
5
+ import { scopedWcDecorator } from '@/utils/storybook/scopedWcDecorator.js';
6
+ const sectionOrder = [
7
+ 'Actions & navigation',
8
+ 'Inputs & selection',
9
+ 'Data & SCL',
10
+ 'Feedback & overlays',
11
+ 'Foundations',
12
+ 'Editors',
13
+ 'Labs',
14
+ 'Other components',
15
+ ];
16
+ const categoryByTitle = {
17
+ 'Action Controls': 'Data & SCL',
18
+ 'App Bar': 'Actions & navigation',
19
+ Buttons: 'Actions & navigation',
20
+ Checkboxs: 'Inputs & selection',
21
+ Chips: 'Inputs & selection',
22
+ Dialogs: 'Feedback & overlays',
23
+ Dividers: 'Foundations',
24
+ Elevations: 'Foundations',
25
+ Editors: 'Editors',
26
+ Fabs: 'Actions & navigation',
27
+ Feedback: 'Feedback & overlays',
28
+ Fields: 'Inputs & selection',
29
+ Filtering: 'Inputs & selection',
30
+ Focus: 'Foundations',
31
+ Icons: 'Foundations',
32
+ Iconbuttons: 'Actions & navigation',
33
+ Inputs: 'Inputs & selection',
34
+ Labs: 'Labs',
35
+ Lists: 'Data & SCL',
36
+ Menus: 'Actions & navigation',
37
+ 'Navigation Drawer': 'Actions & navigation',
38
+ Progress: 'Feedback & overlays',
39
+ Radios: 'Inputs & selection',
40
+ Ripples: 'Foundations',
41
+ 'Scl Inputs': 'Inputs & selection',
42
+ Selects: 'Inputs & selection',
43
+ Sliders: 'Inputs & selection',
44
+ Switchs: 'Inputs & selection',
45
+ Tabs: 'Actions & navigation',
46
+ Textfields: 'Inputs & selection',
47
+ Tree: 'Data & SCL',
48
+ 'Tree Grid': 'Data & SCL',
49
+ };
50
+ function isRecord(value) {
51
+ return typeof value === 'object' && value !== null;
52
+ }
53
+ function isStoryIndexEntry(value) {
54
+ if (!isRecord(value)) {
55
+ return false;
56
+ }
57
+ return (typeof value['id'] === 'string' &&
58
+ typeof value['name'] === 'string' &&
59
+ typeof value['title'] === 'string' &&
60
+ (value['type'] === 'docs' || value['type'] === 'story') &&
61
+ (value['tags'] === undefined ||
62
+ (Array.isArray(value['tags']) &&
63
+ value['tags'].every(tag => typeof tag === 'string'))));
64
+ }
65
+ function readStoryIndex(value) {
66
+ if (!isRecord(value) || !isRecord(value['entries'])) {
67
+ throw new Error('Storybook returned an invalid story index.');
68
+ }
69
+ const entries = {};
70
+ for (const [id, entry] of Object.entries(value['entries'])) {
71
+ if (!isStoryIndexEntry(entry)) {
72
+ throw new Error('Storybook story index contains an invalid entry.');
73
+ }
74
+ entries[id] = entry;
75
+ }
76
+ return { entries };
77
+ }
78
+ function categoryFor(title) {
79
+ const group = title.split('/')[0].trim();
80
+ return categoryByTitle[group] ?? 'Other components';
81
+ }
82
+ function createSections(index) {
83
+ const entries = Object.values(index.entries);
84
+ const docsEntries = entries.filter(entry => entry.type === 'docs' && entry.tags?.includes('autodocs'));
85
+ const stories = entries.filter(entry => entry.type === 'story');
86
+ const sections = new Map();
87
+ for (const docs of docsEntries) {
88
+ const componentStories = stories.filter(story => story.title === docs.title);
89
+ const story = componentStories.find(item => item.name === 'Default') ??
90
+ componentStories[0];
91
+ if (!story) {
92
+ continue;
93
+ }
94
+ const category = categoryFor(docs.title);
95
+ const titleParts = docs.title.split('/');
96
+ const component = {
97
+ docs,
98
+ story,
99
+ category,
100
+ label: titleParts[titleParts.length - 1].trim(),
101
+ };
102
+ const section = sections.get(category) ?? [];
103
+ section.push(component);
104
+ sections.set(category, section);
105
+ }
106
+ return [...sections.entries()]
107
+ .map(([title, sectionEntries]) => ({
108
+ title,
109
+ entries: sectionEntries.sort((a, b) => a.label.localeCompare(b.label)),
110
+ }))
111
+ .sort((a, b) => sectionOrder.indexOf(a.title) - sectionOrder.indexOf(b.title));
112
+ }
113
+ function storybookUrl(path) {
114
+ const url = new URL('./', document.baseURI);
115
+ url.searchParams.set('path', path);
116
+ return `${url.pathname}${url.search}`;
117
+ }
118
+ function previewUrl(storyId, palette) {
119
+ const url = new URL('iframe.html', document.baseURI);
120
+ url.searchParams.set('id', storyId);
121
+ url.searchParams.set('viewMode', 'story');
122
+ url.searchParams.set('globals', `palette:${palette}`);
123
+ return url.href;
124
+ }
125
+ function renderEntry(entry, palette) {
126
+ const docsUrl = storybookUrl(`/docs/${entry.docs.id}`);
127
+ const storyUrl = storybookUrl(`/story/${entry.story.id}`);
128
+ return html `<article>
129
+ <header>
130
+ <h3><a href=${docsUrl} target="_top">${entry.label}</a></h3>
131
+ <span>${entry.story.name}</span>
132
+ </header>
133
+ <iframe
134
+ src=${previewUrl(entry.story.id, palette)}
135
+ title="${entry.label} — ${entry.story.name}"
136
+ loading="lazy"
137
+ ></iframe>
138
+ <footer>
139
+ <a href=${docsUrl} target="_top">Documentation</a>
140
+ <a href=${storyUrl} target="_top">Open story</a>
141
+ </footer>
142
+ </article>`;
143
+ }
144
+ class ComponentCatalog extends LitElement {
145
+ constructor() {
146
+ super(...arguments);
147
+ this.palette = 'solarized-light';
148
+ this.sections = [];
149
+ this.loading = true;
150
+ }
151
+ firstUpdated() {
152
+ void this.loadStoryIndex();
153
+ }
154
+ async loadStoryIndex() {
155
+ this.loading = true;
156
+ this.error = undefined;
157
+ try {
158
+ const indexUrl = new URL('index.json', document.baseURI);
159
+ const response = await fetch(indexUrl);
160
+ if (!response.ok) {
161
+ throw new Error(`Unable to load Storybook index (${response.status}).`);
162
+ }
163
+ this.sections = createSections(readStoryIndex(await response.json()));
164
+ }
165
+ catch (error) {
166
+ this.error =
167
+ error instanceof Error
168
+ ? error.message
169
+ : 'Unable to load the Storybook component catalog.';
170
+ }
171
+ finally {
172
+ this.loading = false;
173
+ }
174
+ }
175
+ render() {
176
+ if (this.loading) {
177
+ return html `<p role="status">Loading component catalog…</p>`;
178
+ }
179
+ if (this.error) {
180
+ return html `<p role="alert">${this.error}</p>
181
+ <button @click=${() => this.loadStoryIndex()}>Retry</button>`;
182
+ }
183
+ return html `
184
+ <main>
185
+ ${this.sections.map(section => html `
186
+ <section>
187
+ <h2>${section.title}</h2>
188
+ <div class="grid">
189
+ ${section.entries.map(entry => renderEntry(entry, this.palette))}
190
+ </div>
191
+ </section>
192
+ `)}
193
+ </main>
194
+ `;
195
+ }
196
+ }
197
+ ComponentCatalog.styles = css `
198
+ :host {
199
+ display: block;
200
+ padding: 24px;
201
+ }
202
+
203
+ section + section {
204
+ margin-top: 32px;
205
+ }
206
+
207
+ h2 {
208
+ margin: 0 0 16px;
209
+ }
210
+
211
+ .grid {
212
+ display: grid;
213
+ grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
214
+ gap: 16px;
215
+ }
216
+
217
+ article {
218
+ min-width: 0;
219
+ overflow: hidden;
220
+ border: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
221
+ border-radius: 12px;
222
+ background: var(--md-sys-color-surface, #fef7ff);
223
+ }
224
+
225
+ header,
226
+ footer {
227
+ display: flex;
228
+ align-items: center;
229
+ justify-content: space-between;
230
+ gap: 12px;
231
+ padding: 12px 16px;
232
+ }
233
+
234
+ h3 {
235
+ margin: 0;
236
+ font-size: 1rem;
237
+ }
238
+
239
+ header span {
240
+ color: var(--md-sys-color-on-surface-variant, #49454f);
241
+ font-size: 0.875rem;
242
+ }
243
+
244
+ iframe {
245
+ display: block;
246
+ width: 100%;
247
+ height: 180px;
248
+ border: 0;
249
+ background: var(--md-sys-color-surface, #fef7ff);
250
+ }
251
+
252
+ a {
253
+ color: var(--md-sys-color-primary, #6750a4);
254
+ }
255
+
256
+ footer {
257
+ justify-content: flex-start;
258
+ border-top: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
259
+ }
260
+
261
+ @media (max-width: 599px) {
262
+ :host {
263
+ padding: 16px;
264
+ }
265
+ }
266
+ `;
267
+ __decorate([
268
+ property({ type: String })
269
+ ], ComponentCatalog.prototype, "palette", void 0);
270
+ __decorate([
271
+ state()
272
+ ], ComponentCatalog.prototype, "sections", void 0);
273
+ __decorate([
274
+ state()
275
+ ], ComponentCatalog.prototype, "loading", void 0);
276
+ __decorate([
277
+ state()
278
+ ], ComponentCatalog.prototype, "error", void 0);
279
+ const meta = {
280
+ title: 'Open SCD/Component Catalog',
281
+ decorators: [scopedWcDecorator],
282
+ parameters: {
283
+ layout: 'fullscreen',
284
+ scopedElements: {
285
+ 'oscd-component-catalog': ComponentCatalog,
286
+ },
287
+ },
288
+ render: () => {
289
+ const [globals] = useGlobals();
290
+ const palette = typeof globals['palette'] === 'string'
291
+ ? globals['palette']
292
+ : 'solarized-light';
293
+ return html `<oscd-component-catalog
294
+ .palette=${palette}
295
+ ></oscd-component-catalog>`;
296
+ },
297
+ };
298
+ export default meta;
299
+ export const Default = {};
300
+ //# sourceMappingURL=ComponentCatalog.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentCatalog.stories.js","sourceRoot":"","sources":["../../about/ComponentCatalog.stories.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AA0B3E,MAAM,YAAY,GAAG;IACnB,sBAAsB;IACtB,oBAAoB;IACpB,YAAY;IACZ,qBAAqB;IACrB,aAAa;IACb,SAAS;IACT,MAAM;IACN,kBAAkB;CACnB,CAAC;AAEF,MAAM,eAAe,GAA2B;IAC9C,iBAAiB,EAAE,YAAY;IAC/B,SAAS,EAAE,sBAAsB;IACjC,OAAO,EAAE,sBAAsB;IAC/B,SAAS,EAAE,oBAAoB;IAC/B,KAAK,EAAE,oBAAoB;IAC3B,OAAO,EAAE,qBAAqB;IAC9B,QAAQ,EAAE,aAAa;IACvB,UAAU,EAAE,aAAa;IACzB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,sBAAsB;IAC5B,QAAQ,EAAE,qBAAqB;IAC/B,MAAM,EAAE,oBAAoB;IAC5B,SAAS,EAAE,oBAAoB;IAC/B,KAAK,EAAE,aAAa;IACpB,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,sBAAsB;IACnC,MAAM,EAAE,oBAAoB;IAC5B,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,YAAY;IACnB,KAAK,EAAE,sBAAsB;IAC7B,mBAAmB,EAAE,sBAAsB;IAC3C,QAAQ,EAAE,qBAAqB;IAC/B,MAAM,EAAE,oBAAoB;IAC5B,OAAO,EAAE,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AAC,KAAK;;kBAEf,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAC5B,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CACjC;;;WAGN,CACF;;KAEJ,CAAC;IACJ,CAAC;;AAEe,uBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqE3B,AArEqB,CAqEpB;AAtIF;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDACC;AAGpB;IADP,KAAK,EAAE;kDACkC;AAGlC;IADP,KAAK,EAAE;iDACe;AAGf;IADP,KAAK,EAAE;+CACe;AAgIzB,MAAM,IAAI,GAAS;IACjB,KAAK,EAAE,4BAA4B;IACnC,UAAU,EAAE,CAAC,iBAAiB,CAAC;IAC/B,UAAU,EAAE;QACV,MAAM,EAAE,YAAY;QACpB,cAAc,EAAE;YACd,wBAAwB,EAAE,gBAAgB;SAC3C;KACF;IACD,MAAM,EAAE,GAAG,EAAE;QACX,MAAM,CAAC,OAAO,CAAC,GAAG,UAAU,EAAE,CAAC;QAC/B,MAAM,OAAO,GACX,OAAO,OAAO,CAAC,SAAS,CAAC,KAAK,QAAQ;YACpC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;YACpB,CAAC,CAAC,iBAAiB,CAAC;QAExB,OAAO,IAAI,CAAA;iBACE,OAAO;+BACO,CAAC;IAC9B,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC;AAGpB,MAAM,CAAC,MAAM,OAAO,GAAU,EAAE,CAAC","sourcesContent":["import { LitElement, css, html } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport type { Meta, StoryObj } from '@storybook/web-components-vite';\nimport { useGlobals } from 'storybook/preview-api';\n\nimport { scopedWcDecorator } from '@/utils/storybook/scopedWcDecorator.js';\n\ninterface StoryIndexEntry {\n id: string;\n name: string;\n title: string;\n type: 'docs' | 'story';\n tags?: string[];\n}\n\ninterface StoryIndex {\n entries: Record<string, StoryIndexEntry>;\n}\n\ninterface ComponentEntry {\n docs: StoryIndexEntry;\n story: StoryIndexEntry;\n category: string;\n label: string;\n}\n\ninterface ComponentSection {\n title: string;\n entries: ComponentEntry[];\n}\n\nconst sectionOrder = [\n 'Actions & navigation',\n 'Inputs & selection',\n 'Data & SCL',\n 'Feedback & overlays',\n 'Foundations',\n 'Editors',\n 'Labs',\n 'Other components',\n];\n\nconst categoryByTitle: Record<string, string> = {\n 'Action Controls': 'Data & SCL',\n 'App Bar': 'Actions & navigation',\n Buttons: 'Actions & navigation',\n Checkboxs: 'Inputs & selection',\n Chips: 'Inputs & selection',\n Dialogs: 'Feedback & overlays',\n Dividers: 'Foundations',\n Elevations: 'Foundations',\n Editors: 'Editors',\n Fabs: 'Actions & navigation',\n Feedback: 'Feedback & overlays',\n Fields: 'Inputs & selection',\n Filtering: 'Inputs & selection',\n Focus: 'Foundations',\n Icons: 'Foundations',\n Iconbuttons: 'Actions & navigation',\n Inputs: 'Inputs & selection',\n Labs: 'Labs',\n Lists: 'Data & SCL',\n Menus: 'Actions & navigation',\n 'Navigation Drawer': 'Actions & navigation',\n Progress: 'Feedback & overlays',\n Radios: 'Inputs & selection',\n Ripples: 'Foundations',\n 'Scl Inputs': 'Inputs & selection',\n Selects: 'Inputs & selection',\n Sliders: 'Inputs & selection',\n Switchs: 'Inputs & selection',\n Tabs: 'Actions & navigation',\n Textfields: 'Inputs & selection',\n Tree: 'Data & SCL',\n 'Tree Grid': 'Data & SCL',\n};\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction isStoryIndexEntry(value: unknown): value is StoryIndexEntry {\n if (!isRecord(value)) {\n return false;\n }\n\n return (\n typeof value['id'] === 'string' &&\n typeof value['name'] === 'string' &&\n typeof value['title'] === 'string' &&\n (value['type'] === 'docs' || value['type'] === 'story') &&\n (value['tags'] === undefined ||\n (Array.isArray(value['tags']) &&\n value['tags'].every(tag => typeof tag === 'string')))\n );\n}\n\nfunction readStoryIndex(value: unknown): StoryIndex {\n if (!isRecord(value) || !isRecord(value['entries'])) {\n throw new Error('Storybook returned an invalid story index.');\n }\n\n const entries: Record<string, StoryIndexEntry> = {};\n for (const [id, entry] of Object.entries(value['entries'])) {\n if (!isStoryIndexEntry(entry)) {\n throw new Error('Storybook story index contains an invalid entry.');\n }\n entries[id] = entry;\n }\n\n return { entries };\n}\n\nfunction categoryFor(title: string): string {\n const group = title.split('/')[0].trim();\n return categoryByTitle[group] ?? 'Other components';\n}\n\nfunction createSections(index: StoryIndex): ComponentSection[] {\n const entries = Object.values(index.entries);\n const docsEntries = entries.filter(\n entry => entry.type === 'docs' && entry.tags?.includes('autodocs'),\n );\n const stories = entries.filter(entry => entry.type === 'story');\n const sections = new Map<string, ComponentEntry[]>();\n\n for (const docs of docsEntries) {\n const componentStories = stories.filter(\n story => story.title === docs.title,\n );\n const story =\n componentStories.find(item => item.name === 'Default') ??\n componentStories[0];\n if (!story) {\n continue;\n }\n\n const category = categoryFor(docs.title);\n const titleParts = docs.title.split('/');\n const component: ComponentEntry = {\n docs,\n story,\n category,\n label: titleParts[titleParts.length - 1].trim(),\n };\n const section = sections.get(category) ?? [];\n section.push(component);\n sections.set(category, section);\n }\n\n return [...sections.entries()]\n .map(([title, sectionEntries]) => ({\n title,\n entries: sectionEntries.sort((a, b) => a.label.localeCompare(b.label)),\n }))\n .sort(\n (a, b) => sectionOrder.indexOf(a.title) - sectionOrder.indexOf(b.title),\n );\n}\n\nfunction storybookUrl(path: string): string {\n const url = new URL('./', document.baseURI);\n url.searchParams.set('path', path);\n return `${url.pathname}${url.search}`;\n}\n\nfunction previewUrl(storyId: string, palette: string): string {\n const url = new URL('iframe.html', document.baseURI);\n url.searchParams.set('id', storyId);\n url.searchParams.set('viewMode', 'story');\n url.searchParams.set('globals', `palette:${palette}`);\n return url.href;\n}\n\nfunction renderEntry(entry: ComponentEntry, palette: string) {\n const docsUrl = storybookUrl(`/docs/${entry.docs.id}`);\n const storyUrl = storybookUrl(`/story/${entry.story.id}`);\n\n return html`<article>\n <header>\n <h3><a href=${docsUrl} target=\"_top\">${entry.label}</a></h3>\n <span>${entry.story.name}</span>\n </header>\n <iframe\n src=${previewUrl(entry.story.id, palette)}\n title=\"${entry.label} — ${entry.story.name}\"\n loading=\"lazy\"\n ></iframe>\n <footer>\n <a href=${docsUrl} target=\"_top\">Documentation</a>\n <a href=${storyUrl} target=\"_top\">Open story</a>\n </footer>\n </article>`;\n}\n\nclass ComponentCatalog extends LitElement {\n @property({ type: String })\n palette = 'solarized-light';\n\n @state()\n private sections: ComponentSection[] = [];\n\n @state()\n private loading = true;\n\n @state()\n private error?: string;\n\n override firstUpdated(): void {\n void this.loadStoryIndex();\n }\n\n private async loadStoryIndex(): Promise<void> {\n this.loading = true;\n this.error = undefined;\n\n try {\n const indexUrl = new URL('index.json', document.baseURI);\n const response = await fetch(indexUrl);\n if (!response.ok) {\n throw new Error(`Unable to load Storybook index (${response.status}).`);\n }\n\n this.sections = createSections(readStoryIndex(await response.json()));\n } catch (error) {\n this.error =\n error instanceof Error\n ? error.message\n : 'Unable to load the Storybook component catalog.';\n } finally {\n this.loading = false;\n }\n }\n\n override render() {\n if (this.loading) {\n return html`<p role=\"status\">Loading component catalog…</p>`;\n }\n\n if (this.error) {\n return html`<p role=\"alert\">${this.error}</p>\n <button @click=${() => this.loadStoryIndex()}>Retry</button>`;\n }\n\n return html`\n <main>\n ${this.sections.map(\n section => html`\n <section>\n <h2>${section.title}</h2>\n <div class=\"grid\">\n ${section.entries.map(entry =>\n renderEntry(entry, this.palette),\n )}\n </div>\n </section>\n `,\n )}\n </main>\n `;\n }\n\n static override styles = css`\n :host {\n display: block;\n padding: 24px;\n }\n\n section + section {\n margin-top: 32px;\n }\n\n h2 {\n margin: 0 0 16px;\n }\n\n .grid {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));\n gap: 16px;\n }\n\n article {\n min-width: 0;\n overflow: hidden;\n border: 1px solid var(--md-sys-color-outline-variant, #cac4d0);\n border-radius: 12px;\n background: var(--md-sys-color-surface, #fef7ff);\n }\n\n header,\n footer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n padding: 12px 16px;\n }\n\n h3 {\n margin: 0;\n font-size: 1rem;\n }\n\n header span {\n color: var(--md-sys-color-on-surface-variant, #49454f);\n font-size: 0.875rem;\n }\n\n iframe {\n display: block;\n width: 100%;\n height: 180px;\n border: 0;\n background: var(--md-sys-color-surface, #fef7ff);\n }\n\n a {\n color: var(--md-sys-color-primary, #6750a4);\n }\n\n footer {\n justify-content: flex-start;\n border-top: 1px solid var(--md-sys-color-outline-variant, #cac4d0);\n }\n\n @media (max-width: 599px) {\n :host {\n padding: 16px;\n }\n }\n `;\n}\n\nconst meta: Meta = {\n title: 'Open SCD/Component Catalog',\n decorators: [scopedWcDecorator],\n parameters: {\n layout: 'fullscreen',\n scopedElements: {\n 'oscd-component-catalog': ComponentCatalog,\n },\n },\n render: () => {\n const [globals] = useGlobals();\n const palette =\n typeof globals['palette'] === 'string'\n ? globals['palette']\n : 'solarized-light';\n\n return html`<oscd-component-catalog\n .palette=${palette}\n ></oscd-component-catalog>`;\n },\n};\n\nexport default meta;\ntype Story = StoryObj;\n\nexport const Default: Story = {};\n"]}
@@ -14,12 +14,35 @@ declare const OscdAceEditor_base: typeof AceEditor & import("@open-wc/scoped-ele
14
14
  * @summary Wraps the Ace editor for XML editing in OpenSCD.
15
15
  *
16
16
  * Provides syntax highlighting, code folding, and persisted editor settings.
17
- * Includes the OpenSCD Ace theme, which derives its colors from `--oscd-theme*`
18
- * CSS variables.
17
+ * The custom `ace/theme/oscd` theme uses the `--oscd-ace-editor-*` tokens
18
+ * below; they have no effect when another Ace theme is selected.
19
19
  *
20
20
  * The OpenSCD theme appears in both Ace's light and dark theme lists. This is
21
21
  * intentional: Ace separates themes by category, while the OpenSCD theme uses
22
22
  * the same theme definition in both modes and adapts through CSS variables.
23
+ * Import `oscdPaletteComponentMappings` to seed syntax colors from an OpenSCD
24
+ * palette without adding palette slots.
25
+ *
26
+ * @cssprop [--oscd-ace-editor-container-color=var(--md-sys-color-surface, #fef7ff)] - Editor background for `ace/theme/oscd` only.
27
+ * @cssprop [--oscd-ace-editor-text-color=var(--md-sys-color-on-surface, #1d1b20)] - Default editor text for `ace/theme/oscd` only.
28
+ * @cssprop [--oscd-ace-editor-gutter-color=var(--md-sys-color-surface-container-low, #f7f2fa)] - Gutter background for `ace/theme/oscd` only.
29
+ * @cssprop [--oscd-ace-editor-gutter-text-color=var(--md-sys-color-on-surface-variant, #49454f)] - Gutter text for `ace/theme/oscd` only.
30
+ * @cssprop [--oscd-ace-editor-active-line-color=var(--md-sys-color-surface-container, #f3edf7)] - Active line background for `ace/theme/oscd` only.
31
+ * @cssprop [--oscd-ace-editor-selection-color=var(--md-sys-color-primary, #6750a4)] - Selection background for `ace/theme/oscd` only.
32
+ * @cssprop [--oscd-ace-editor-cursor-color=var(--md-sys-color-primary, #6750a4)] - Cursor color for `ace/theme/oscd` only.
33
+ * @cssprop [--oscd-ace-editor-font-family=monospace] - Editor font for `ace/theme/oscd` only.
34
+ * @cssprop [--oscd-ace-editor-syntax-keyword-color=var(--md-sys-color-secondary, #625b71)] - Keyword color for `ace/theme/oscd` only.
35
+ * @cssprop [--oscd-ace-editor-syntax-string-color=var(--md-sys-color-on-surface, #1d1b20)] - String color for `ace/theme/oscd` only.
36
+ * @cssprop [--oscd-ace-editor-syntax-tag-color=var(--md-sys-color-secondary, #625b71)] - Tag color for `ace/theme/oscd` only.
37
+ * @cssprop [--oscd-ace-editor-syntax-attribute-name-color=var(--md-sys-color-primary, #6750a4)] - Attribute name color for `ace/theme/oscd` only.
38
+ * @cssprop [--oscd-ace-editor-syntax-comment-color=var(--md-sys-color-on-surface-variant, #49454f)] - Comment color for `ace/theme/oscd` only.
39
+ * @cssprop [--oscd-ace-editor-syntax-number-color=var(--md-sys-color-on-surface, #1d1b20)] - Number color for `ace/theme/oscd` only.
40
+ * @cssprop [--oscd-ace-editor-syntax-invalid-color=var(--md-sys-color-error, #b3261e)] - Invalid syntax text color for `ace/theme/oscd` only.
41
+ * @cssprop [--oscd-ace-editor-syntax-storage-color=var(--md-sys-color-primary, #6750a4)] - Storage and support symbol color for `ace/theme/oscd` only.
42
+ * @cssprop [--oscd-ace-editor-syntax-operator-color=var(--md-sys-color-on-surface-variant, #49454f)] - Operator and XML punctuation color for `ace/theme/oscd` only.
43
+ * @cssprop [--oscd-ace-editor-syntax-parameter-color=var(--md-sys-color-secondary, #625b71)] - Parameter color for `ace/theme/oscd` only.
44
+ * @cssprop [--oscd-ace-editor-syntax-regex-color=var(--md-sys-color-error, #b3261e)] - Regular expression color for `ace/theme/oscd` only.
45
+ * @cssprop [--oscd-ace-editor-step-color=var(--md-sys-color-secondary, #625b71)] - Debug execution-step marker color for `ace/theme/oscd` only.
23
46
  *
24
47
  * @event {CustomEvent<string>} change Fired when the editor content changes.
25
48
  * `detail` contains the current editor content.
@@ -12,12 +12,35 @@ export { AceGlobal };
12
12
  * @summary Wraps the Ace editor for XML editing in OpenSCD.
13
13
  *
14
14
  * Provides syntax highlighting, code folding, and persisted editor settings.
15
- * Includes the OpenSCD Ace theme, which derives its colors from `--oscd-theme*`
16
- * CSS variables.
15
+ * The custom `ace/theme/oscd` theme uses the `--oscd-ace-editor-*` tokens
16
+ * below; they have no effect when another Ace theme is selected.
17
17
  *
18
18
  * The OpenSCD theme appears in both Ace's light and dark theme lists. This is
19
19
  * intentional: Ace separates themes by category, while the OpenSCD theme uses
20
20
  * the same theme definition in both modes and adapts through CSS variables.
21
+ * Import `oscdPaletteComponentMappings` to seed syntax colors from an OpenSCD
22
+ * palette without adding palette slots.
23
+ *
24
+ * @cssprop [--oscd-ace-editor-container-color=var(--md-sys-color-surface, #fef7ff)] - Editor background for `ace/theme/oscd` only.
25
+ * @cssprop [--oscd-ace-editor-text-color=var(--md-sys-color-on-surface, #1d1b20)] - Default editor text for `ace/theme/oscd` only.
26
+ * @cssprop [--oscd-ace-editor-gutter-color=var(--md-sys-color-surface-container-low, #f7f2fa)] - Gutter background for `ace/theme/oscd` only.
27
+ * @cssprop [--oscd-ace-editor-gutter-text-color=var(--md-sys-color-on-surface-variant, #49454f)] - Gutter text for `ace/theme/oscd` only.
28
+ * @cssprop [--oscd-ace-editor-active-line-color=var(--md-sys-color-surface-container, #f3edf7)] - Active line background for `ace/theme/oscd` only.
29
+ * @cssprop [--oscd-ace-editor-selection-color=var(--md-sys-color-primary, #6750a4)] - Selection background for `ace/theme/oscd` only.
30
+ * @cssprop [--oscd-ace-editor-cursor-color=var(--md-sys-color-primary, #6750a4)] - Cursor color for `ace/theme/oscd` only.
31
+ * @cssprop [--oscd-ace-editor-font-family=monospace] - Editor font for `ace/theme/oscd` only.
32
+ * @cssprop [--oscd-ace-editor-syntax-keyword-color=var(--md-sys-color-secondary, #625b71)] - Keyword color for `ace/theme/oscd` only.
33
+ * @cssprop [--oscd-ace-editor-syntax-string-color=var(--md-sys-color-on-surface, #1d1b20)] - String color for `ace/theme/oscd` only.
34
+ * @cssprop [--oscd-ace-editor-syntax-tag-color=var(--md-sys-color-secondary, #625b71)] - Tag color for `ace/theme/oscd` only.
35
+ * @cssprop [--oscd-ace-editor-syntax-attribute-name-color=var(--md-sys-color-primary, #6750a4)] - Attribute name color for `ace/theme/oscd` only.
36
+ * @cssprop [--oscd-ace-editor-syntax-comment-color=var(--md-sys-color-on-surface-variant, #49454f)] - Comment color for `ace/theme/oscd` only.
37
+ * @cssprop [--oscd-ace-editor-syntax-number-color=var(--md-sys-color-on-surface, #1d1b20)] - Number color for `ace/theme/oscd` only.
38
+ * @cssprop [--oscd-ace-editor-syntax-invalid-color=var(--md-sys-color-error, #b3261e)] - Invalid syntax text color for `ace/theme/oscd` only.
39
+ * @cssprop [--oscd-ace-editor-syntax-storage-color=var(--md-sys-color-primary, #6750a4)] - Storage and support symbol color for `ace/theme/oscd` only.
40
+ * @cssprop [--oscd-ace-editor-syntax-operator-color=var(--md-sys-color-on-surface-variant, #49454f)] - Operator and XML punctuation color for `ace/theme/oscd` only.
41
+ * @cssprop [--oscd-ace-editor-syntax-parameter-color=var(--md-sys-color-secondary, #625b71)] - Parameter color for `ace/theme/oscd` only.
42
+ * @cssprop [--oscd-ace-editor-syntax-regex-color=var(--md-sys-color-error, #b3261e)] - Regular expression color for `ace/theme/oscd` only.
43
+ * @cssprop [--oscd-ace-editor-step-color=var(--md-sys-color-secondary, #625b71)] - Debug execution-step marker color for `ace/theme/oscd` only.
21
44
  *
22
45
  * @event {CustomEvent<string>} change Fired when the editor content changes.
23
46
  * `detail` contains the current editor content.
@@ -1 +1 @@
1
- {"version":3,"file":"OscdAceEditor.js","sourceRoot":"","sources":["../../ace-editor/OscdAceEditor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAK/D,OAAO,aAAa,MAAM,6CAA6C,CAAC;AAQxE,OAAO,EAAE,SAAS,EAAE,CAAC;AAGrB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,aAAc,SAAQ,mBAAmB,CAAC,SAAS,CAAC;;AACxD,4BAAc,GAAG;IACtB,YAAY,EAAE,SAAS;IACvB,iBAAiB,EAAE,aAAa;CACjC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 OMICRON electronics GmbH\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js';\nimport { AceEditor, AceGlobal } from './internal/AceEditor.js';\nimport type {\n AceEditorWithSettingsMenu,\n AceSettingsMenuModule,\n} from './internal/AceEditor.js';\nimport AceEditorBase from './internal/ace-editor-base/AceEditorBase.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'oscd-ace-editor': OscdAceEditor;\n }\n}\n\nexport { AceGlobal };\nexport type { AceSettingsMenuModule, AceEditorWithSettingsMenu };\n\n/**\n * @tagname oscd-ace-editor\n * @summary Wraps the Ace editor for XML editing in OpenSCD.\n *\n * Provides syntax highlighting, code folding, and persisted editor settings.\n * Includes the OpenSCD Ace theme, which derives its colors from `--oscd-theme*`\n * CSS variables.\n *\n * The OpenSCD theme appears in both Ace's light and dark theme lists. This is\n * intentional: Ace separates themes by category, while the OpenSCD theme uses\n * the same theme definition in both modes and adapts through CSS variables.\n *\n * @event {CustomEvent<string>} change Fired when the editor content changes.\n * `detail` contains the current editor content.\n * @final\n * @suppress {visibility}\n */\nexport class OscdAceEditor extends ScopedElementsMixin(AceEditor) {\n static scopedElements = {\n 'ace-editor': AceEditor,\n 'ace-editor-base': AceEditorBase,\n };\n}\n"]}
1
+ {"version":3,"file":"OscdAceEditor.js","sourceRoot":"","sources":["../../ace-editor/OscdAceEditor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAK/D,OAAO,aAAa,MAAM,6CAA6C,CAAC;AAQxE,OAAO,EAAE,SAAS,EAAE,CAAC;AAGrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,OAAO,aAAc,SAAQ,mBAAmB,CAAC,SAAS,CAAC;;AACxD,4BAAc,GAAG;IACtB,YAAY,EAAE,SAAS;IACvB,iBAAiB,EAAE,aAAa;CACjC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 OMICRON electronics GmbH\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js';\nimport { AceEditor, AceGlobal } from './internal/AceEditor.js';\nimport type {\n AceEditorWithSettingsMenu,\n AceSettingsMenuModule,\n} from './internal/AceEditor.js';\nimport AceEditorBase from './internal/ace-editor-base/AceEditorBase.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'oscd-ace-editor': OscdAceEditor;\n }\n}\n\nexport { AceGlobal };\nexport type { AceSettingsMenuModule, AceEditorWithSettingsMenu };\n\n/**\n * @tagname oscd-ace-editor\n * @summary Wraps the Ace editor for XML editing in OpenSCD.\n *\n * Provides syntax highlighting, code folding, and persisted editor settings.\n * The custom `ace/theme/oscd` theme uses the `--oscd-ace-editor-*` tokens\n * below; they have no effect when another Ace theme is selected.\n *\n * The OpenSCD theme appears in both Ace's light and dark theme lists. This is\n * intentional: Ace separates themes by category, while the OpenSCD theme uses\n * the same theme definition in both modes and adapts through CSS variables.\n * Import `oscdPaletteComponentMappings` to seed syntax colors from an OpenSCD\n * palette without adding palette slots.\n *\n * @cssprop [--oscd-ace-editor-container-color=var(--md-sys-color-surface, #fef7ff)] - Editor background for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-text-color=var(--md-sys-color-on-surface, #1d1b20)] - Default editor text for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-gutter-color=var(--md-sys-color-surface-container-low, #f7f2fa)] - Gutter background for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-gutter-text-color=var(--md-sys-color-on-surface-variant, #49454f)] - Gutter text for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-active-line-color=var(--md-sys-color-surface-container, #f3edf7)] - Active line background for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-selection-color=var(--md-sys-color-primary, #6750a4)] - Selection background for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-cursor-color=var(--md-sys-color-primary, #6750a4)] - Cursor color for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-font-family=monospace] - Editor font for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-syntax-keyword-color=var(--md-sys-color-secondary, #625b71)] - Keyword color for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-syntax-string-color=var(--md-sys-color-on-surface, #1d1b20)] - String color for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-syntax-tag-color=var(--md-sys-color-secondary, #625b71)] - Tag color for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-syntax-attribute-name-color=var(--md-sys-color-primary, #6750a4)] - Attribute name color for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-syntax-comment-color=var(--md-sys-color-on-surface-variant, #49454f)] - Comment color for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-syntax-number-color=var(--md-sys-color-on-surface, #1d1b20)] - Number color for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-syntax-invalid-color=var(--md-sys-color-error, #b3261e)] - Invalid syntax text color for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-syntax-storage-color=var(--md-sys-color-primary, #6750a4)] - Storage and support symbol color for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-syntax-operator-color=var(--md-sys-color-on-surface-variant, #49454f)] - Operator and XML punctuation color for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-syntax-parameter-color=var(--md-sys-color-secondary, #625b71)] - Parameter color for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-syntax-regex-color=var(--md-sys-color-error, #b3261e)] - Regular expression color for `ace/theme/oscd` only.\n * @cssprop [--oscd-ace-editor-step-color=var(--md-sys-color-secondary, #625b71)] - Debug execution-step marker color for `ace/theme/oscd` only.\n *\n * @event {CustomEvent<string>} change Fired when the editor content changes.\n * `detail` contains the current editor content.\n * @final\n * @suppress {visibility}\n */\nexport class OscdAceEditor extends ScopedElementsMixin(AceEditor) {\n static scopedElements = {\n 'ace-editor': AceEditor,\n 'ace-editor-base': AceEditorBase,\n };\n}\n"]}
@@ -3,6 +3,9 @@ import './oscd-ace-editor.js';
3
3
  declare const _default: {
4
4
  title: string;
5
5
  tags: string[];
6
+ parameters: {
7
+ layout: string;
8
+ };
6
9
  id?: import("storybook/internal/csf").ComponentId;
7
10
  includeStories?: RegExp | string[];
8
11
  excludeStories?: RegExp | string[];
@@ -15,7 +18,6 @@ declare const _default: {
15
18
  }> | import("storybook/internal/csf").DecoratorFunction<import("@storybook/web-components").WebComponentsRenderer, {
16
19
  [x: string]: any;
17
20
  }>[] | undefined;
18
- parameters?: import("@storybook/web-components-vite").Parameters | undefined;
19
21
  args?: Partial<import("@storybook/web-components-vite").Args> | undefined;
20
22
  argTypes?: Partial<import("@storybook/web-components-vite").ArgTypes<import("@storybook/web-components-vite").Args>> | undefined;
21
23
  loaders?: import("storybook/internal/csf").LoaderFunction<import("@storybook/web-components").WebComponentsRenderer, import("@storybook/web-components-vite").Args> | import("storybook/internal/csf").LoaderFunction<import("@storybook/web-components").WebComponentsRenderer, import("@storybook/web-components-vite").Args>[] | undefined;
@@ -7,16 +7,25 @@ export default {
7
7
  ...meta,
8
8
  title: 'Editors / Ace Editor',
9
9
  tags: ['autodocs'],
10
+ parameters: {
11
+ ...meta.parameters,
12
+ layout: 'fullscreen',
13
+ },
10
14
  };
11
15
  export const Default = {
12
16
  argTypes,
13
17
  args: {
14
18
  ...args,
15
19
  value: `<?xml version="1.0" encoding="UTF-8"?>
16
- <SCL version="2007" revision="B" xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:ens1="http://example.org/somePreexistingExtensionNamespace">
20
+ <SCL
21
+ version="2007"
22
+ revision="B"
23
+ xmlns="http://www.iec.ch/61850/2003/SCL"
24
+ xmlns:ens1="http://example.org/somePreexistingExtensionNamespace"
25
+ >
17
26
  <Substation ens1:foo="a" name="A1" desc="test substation"></Substation>
18
27
  </SCL>`,
19
- style: 'height: 400px; width: 600px;',
28
+ style: 'height: 100vh; width: 100%;',
20
29
  },
21
30
  };
22
31
  //# sourceMappingURL=OscdAceEditor.stories.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OscdAceEditor.stories.js","sourceRoot":"","sources":["../../ace-editor/OscdAceEditor.stories.ts"],"names":[],"mappings":"AACA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAgB;IAC/D,OAAO,EAAE,iBAAiB;CAC3B,CAAC,CAAC;AAEH,eAAe;IACb,GAAG,IAAI;IACP,KAAK,EAAE,sBAAsB;IAC7B,IAAI,EAAE,CAAC,UAAU,CAAC;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAa;IAC/B,QAAQ;IACR,IAAI,EAAE;QACJ,GAAG,IAAI;QACP,KAAK,EAAE;;;OAGJ;QACH,KAAK,EAAE,8BAA8B;KACtC;CACF,CAAC","sourcesContent":["import type { StoryObj } from '@storybook/web-components-vite';\nimport './oscd-ace-editor.js';\nimport { OscdAceEditor } from './OscdAceEditor.js';\nimport { getStorybookMeta } from '@/utils/storybook/getStorybookMeta.js';\n\nconst { args, argTypes, meta } = getStorybookMeta<OscdAceEditor>({\n tagName: 'oscd-ace-editor',\n});\n\nexport default {\n ...meta,\n title: 'Editors / Ace Editor',\n tags: ['autodocs'],\n};\n\nexport const Default: StoryObj = {\n argTypes,\n args: {\n ...args,\n value: `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<SCL version=\"2007\" revision=\"B\" xmlns=\"http://www.iec.ch/61850/2003/SCL\" xmlns:ens1=\"http://example.org/somePreexistingExtensionNamespace\">\n <Substation ens1:foo=\"a\" name=\"A1\" desc=\"test substation\"></Substation>\n</SCL>`,\n style: 'height: 400px; width: 600px;',\n },\n};\n"]}
1
+ {"version":3,"file":"OscdAceEditor.stories.js","sourceRoot":"","sources":["../../ace-editor/OscdAceEditor.stories.ts"],"names":[],"mappings":"AACA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAgB;IAC/D,OAAO,EAAE,iBAAiB;CAC3B,CAAC,CAAC;AAEH,eAAe;IACb,GAAG,IAAI;IACP,KAAK,EAAE,sBAAsB;IAC7B,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,UAAU,EAAE;QACV,GAAG,IAAI,CAAC,UAAU;QAClB,MAAM,EAAE,YAAY;KACrB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAa;IAC/B,QAAQ;IACR,IAAI,EAAE;QACJ,GAAG,IAAI;QACP,KAAK,EAAE;;;;;;;;OAQJ;QACH,KAAK,EAAE,6BAA6B;KACrC;CACF,CAAC","sourcesContent":["import type { StoryObj } from '@storybook/web-components-vite';\nimport './oscd-ace-editor.js';\nimport { OscdAceEditor } from './OscdAceEditor.js';\nimport { getStorybookMeta } from '@/utils/storybook/getStorybookMeta.js';\n\nconst { args, argTypes, meta } = getStorybookMeta<OscdAceEditor>({\n tagName: 'oscd-ace-editor',\n});\n\nexport default {\n ...meta,\n title: 'Editors / Ace Editor',\n tags: ['autodocs'],\n parameters: {\n ...meta.parameters,\n layout: 'fullscreen',\n },\n};\n\nexport const Default: StoryObj = {\n argTypes,\n args: {\n ...args,\n value: `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<SCL\n version=\"2007\"\n revision=\"B\"\n xmlns=\"http://www.iec.ch/61850/2003/SCL\"\n xmlns:ens1=\"http://example.org/somePreexistingExtensionNamespace\"\n>\n <Substation ens1:foo=\"a\" name=\"A1\" desc=\"test substation\"></Substation>\n</SCL>`,\n style: 'height: 100vh; width: 100%;',\n },\n};\n"]}
@@ -112,7 +112,8 @@ class AceEditorBase extends HTMLElement {
112
112
  ace-editor {
113
113
  display: block;
114
114
  width: 100%;
115
- height: 250px;
115
+ height: 100%;
116
+ min-height: 250px;
116
117
  }
117
118
  `;
118
119
  if (rootNode instanceof Document && rootNode.head) {
@@ -1 +1 @@
1
- {"version":3,"file":"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E;8DACS;AAGlC;IADC,sBAAsB,EAAE;sDACC;AAG1B;IADC,eAAe,EAAE;+CACA;AAiKpB,eAAe,aAAa,CAAC","sourcesContent":["/* eslint-disable class-methods-use-this */\n\nimport {\n NotifyAttribute,\n NotifyBooleanAttribute,\n NotifyNumericAttribute,\n} from './property-decorators.js';\n\nimport { Ace } from 'ace-builds';\nimport { debounce } from './debounce.js';\nimport type * as AceGlobal from 'ace-builds';\n\ndeclare global {\n interface Window {\n ace: typeof AceGlobal;\n }\n}\n\nenum ValueUpdateMode {\n start = 'start',\n end = 'end',\n select = 'select',\n}\n\nfunction getValueUpdateNumber(mode?: ValueUpdateMode): number {\n if (mode === ValueUpdateMode.start) {\n return -1;\n }\n if (mode === ValueUpdateMode.end) {\n return 1;\n }\n return 0;\n}\n\n/**\n * Custom element Ace code editor\n */\nclass AceEditorBase extends HTMLElement {\n private static _observedAttributes: string[] = [];\n\n private _editor?: Ace.Editor;\n get editor(): Ace.Editor | undefined {\n return this._editor;\n }\n\n get version(): { [key: string]: string } {\n return {\n ace: window.ace?.version || 'unknown',\n };\n }\n\n @NotifyAttribute()\n value?: string;\n\n @NotifyAttribute()\n mode?: string;\n\n @NotifyAttribute()\n theme?: string;\n\n @NotifyNumericAttribute()\n tabSize?: number;\n\n @NotifyBooleanAttribute()\n readonly?: boolean;\n\n @NotifyBooleanAttribute()\n softTabs?: boolean;\n\n @NotifyBooleanAttribute()\n wrap?: boolean;\n\n @NotifyAttribute()\n valueUpdateMode?: ValueUpdateMode;\n\n @NotifyBooleanAttribute()\n hideActiveLineHighlight?: boolean;\n\n @NotifyBooleanAttribute()\n hideGutter?: boolean;\n\n @NotifyBooleanAttribute()\n hideGutterLineHighlight?: boolean;\n\n @NotifyBooleanAttribute()\n hidePrintMargin?: boolean;\n\n @NotifyAttribute()\n basePath?: string;\n\n static get observedAttributes(): string[] {\n return AceEditorBase._observedAttributes;\n }\n\n /**\n * Registers an attribute to be observed.\n *\n * @param name Attribute name to observe.\n * @internal\n */\n addObservedAttribute(name: string): void {\n AceEditorBase._observedAttributes.push(name);\n }\n\n private dispatch<T>(type: string, detail: T): void {\n this.dispatchEvent(\n new CustomEvent(type, {\n bubbles: true,\n composed: true,\n cancelable: false,\n detail,\n }),\n );\n }\n\n private initializeEditor = debounce(() => {\n if (this.basePath) {\n window.ace.config.set('basePath', this.basePath);\n }\n\n const editor = this._editor || window.ace.edit(this);\n\n this.appendStyles();\n\n editor.session.setMode(this.mode || 'ace/mode/xml');\n editor.setTheme(this.theme || 'ace/theme/oscd');\n\n const text = editor.getValue() || '';\n if (text !== this.value) {\n editor.setValue(\n this.value || '',\n getValueUpdateNumber(this.valueUpdateMode),\n );\n }\n\n editor.getSession().setTabSize(this.tabSize || 2);\n editor.getSession().setUseSoftTabs(!!this.softTabs);\n\n editor.renderer.setShowGutter(!this.hideGutter);\n editor.renderer.setShowPrintMargin(!this.hidePrintMargin);\n editor.setHighlightActiveLine(!this.hideActiveLineHighlight);\n editor.setHighlightGutterLine(!this.hideGutterLineHighlight);\n\n editor.setReadOnly(!!this.readonly);\n if (this.readonly) {\n editor.setHighlightActiveLine(!this.readonly);\n editor.setHighlightGutterLine(!this.readonly);\n }\n\n editor.getSession().setUseWrapMode(!!this.wrap);\n\n editor.off('change', this.handleChange);\n editor.on('change', this.handleChange);\n editor.off('blur', this.handleBlur);\n editor.on('blur', this.handleBlur);\n\n this.resize();\n\n this._editor = editor;\n });\n\n private appendStyles() {\n const rootNode = this.getRootNode() as Document | ShadowRoot | undefined;\n const aceStyleId = `ace_editor.css`;\n const customStyleId = `ace-custom-element-style`;\n\n // initialize styles if rendering on the client:\n if (rootNode) {\n if (!rootNode.getElementById?.(customStyleId)) {\n const style = document.createElement('style');\n style.id = customStyleId;\n style.type = 'text/css';\n style.innerHTML = `\n ace-editor {\n display: block;\n width: 100%;\n height: 250px;\n }\n `;\n\n if (rootNode instanceof Document && rootNode.head) {\n rootNode.head.appendChild(style);\n } else {\n rootNode.appendChild(style);\n }\n }\n\n if (!rootNode.getElementById?.(aceStyleId)) {\n const editorStyle = document.getElementById(aceStyleId);\n if (editorStyle) {\n if (rootNode instanceof Document && rootNode.head) {\n rootNode.head.appendChild(editorStyle.cloneNode(true));\n } else {\n rootNode.appendChild(editorStyle.cloneNode(true));\n }\n }\n }\n }\n }\n\n connectedCallback(): void {\n this.initializeEditor().then(() => {\n this.dispatch('ready', {\n editor: this.editor,\n });\n });\n }\n\n disconnectedCallback(): void {\n if (!this._editor) {\n return;\n }\n\n this._editor.off('change', this.handleChange);\n this._editor.off('blur', this.handleBlur);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n attributeChangedCallback(name: string): void {\n this.initializeEditor();\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n notifyPropertyChanged(name: string): void {\n this.initializeEditor();\n }\n\n resize(): void {\n this._editor?.resize();\n }\n\n private handleChange = debounce(() => {\n const text = this._editor?.getValue() || '';\n if (text !== this.value) {\n if (text) {\n this.setAttribute('value', text);\n } else {\n this.removeAttribute('value');\n }\n\n this.dispatch('change', text);\n }\n });\n\n private handleBlur = () => {\n this.dispatchEvent(new FocusEvent('blur'));\n };\n}\n\nexport default AceEditorBase;\n"]}
1
+ {"version":3,"file":"AceEditorBase.js","sourceRoot":"","sources":["../../../../ace-editor/internal/ace-editor-base/AceEditorBase.ts"],"names":[],"mappings":"AAAA,2CAA2C;;AAE3C,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AASzC,IAAK,eAIJ;AAJD,WAAK,eAAe;IAClB,kCAAe,CAAA;IACf,8BAAW,CAAA;IACX,oCAAiB,CAAA;AACnB,CAAC,EAJI,eAAe,KAAf,eAAe,QAInB;AAED,SAAS,oBAAoB,CAAC,IAAsB;IAClD,IAAI,IAAI,KAAK,eAAe,CAAC,KAAK,EAAE,CAAC;QACnC,OAAO,CAAC,C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,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED,6DAA6D;IAC7D,wBAAwB,CAAC,IAAY;QACnC,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;IAED,6DAA6D;IAC7D,qBAAqB,CAAC,IAAY;QAChC,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IACzB,CAAC;;AAhMc,iCAAmB,GAAa,EAAE,AAAf,CAAgB;AAclD;IADC,eAAe,EAAE;4CACH;AAGf;IADC,eAAe,EAAE;2CACJ;AAGd;IADC,eAAe,EAAE;4CACH;AAGf;IADC,sBAAsB,EAAE;8CACR;AAGjB;IADC,sBAAsB,EAAE;+CACN;AAGnB;IADC,sBAAsB,EAAE;+CACN;AAGnB;IADC,sBAAsB,EAAE;2CACV;AAGf;IADC,eAAe,EAAE;sDACgB;AAGlC;IADC,sBAAsB,EAAE;8DACS;AAGlC;IADC,sBAAsB,EAAE;iDACJ;AAGrB;IADC,sBAAsB,EAAE;8DACS;AAGlC;IADC,sBAAsB,EAAE;sDACC;AAG1B;IADC,eAAe,EAAE;+CACA;AAkKpB,eAAe,aAAa,CAAC","sourcesContent":["/* eslint-disable class-methods-use-this */\n\nimport {\n NotifyAttribute,\n NotifyBooleanAttribute,\n NotifyNumericAttribute,\n} from './property-decorators.js';\n\nimport { Ace } from 'ace-builds';\nimport { debounce } from './debounce.js';\nimport type * as AceGlobal from 'ace-builds';\n\ndeclare global {\n interface Window {\n ace: typeof AceGlobal;\n }\n}\n\nenum ValueUpdateMode {\n start = 'start',\n end = 'end',\n select = 'select',\n}\n\nfunction getValueUpdateNumber(mode?: ValueUpdateMode): number {\n if (mode === ValueUpdateMode.start) {\n return -1;\n }\n if (mode === ValueUpdateMode.end) {\n return 1;\n }\n return 0;\n}\n\n/**\n * Custom element Ace code editor\n */\nclass AceEditorBase extends HTMLElement {\n private static _observedAttributes: string[] = [];\n\n private _editor?: Ace.Editor;\n get editor(): Ace.Editor | undefined {\n return this._editor;\n }\n\n get version(): { [key: string]: string } {\n return {\n ace: window.ace?.version || 'unknown',\n };\n }\n\n @NotifyAttribute()\n value?: string;\n\n @NotifyAttribute()\n mode?: string;\n\n @NotifyAttribute()\n theme?: string;\n\n @NotifyNumericAttribute()\n tabSize?: number;\n\n @NotifyBooleanAttribute()\n readonly?: boolean;\n\n @NotifyBooleanAttribute()\n softTabs?: boolean;\n\n @NotifyBooleanAttribute()\n wrap?: boolean;\n\n @NotifyAttribute()\n valueUpdateMode?: ValueUpdateMode;\n\n @NotifyBooleanAttribute()\n hideActiveLineHighlight?: boolean;\n\n @NotifyBooleanAttribute()\n hideGutter?: boolean;\n\n @NotifyBooleanAttribute()\n hideGutterLineHighlight?: boolean;\n\n @NotifyBooleanAttribute()\n hidePrintMargin?: boolean;\n\n @NotifyAttribute()\n basePath?: string;\n\n static get observedAttributes(): string[] {\n return AceEditorBase._observedAttributes;\n }\n\n /**\n * Registers an attribute to be observed.\n *\n * @param name Attribute name to observe.\n * @internal\n */\n addObservedAttribute(name: string): void {\n AceEditorBase._observedAttributes.push(name);\n }\n\n private dispatch<T>(type: string, detail: T): void {\n this.dispatchEvent(\n new CustomEvent(type, {\n bubbles: true,\n composed: true,\n cancelable: false,\n detail,\n }),\n );\n }\n\n private initializeEditor = debounce(() => {\n if (this.basePath) {\n window.ace.config.set('basePath', this.basePath);\n }\n\n const editor = this._editor || window.ace.edit(this);\n\n this.appendStyles();\n\n editor.session.setMode(this.mode || 'ace/mode/xml');\n editor.setTheme(this.theme || 'ace/theme/oscd');\n\n const text = editor.getValue() || '';\n if (text !== this.value) {\n editor.setValue(\n this.value || '',\n getValueUpdateNumber(this.valueUpdateMode),\n );\n }\n\n editor.getSession().setTabSize(this.tabSize || 2);\n editor.getSession().setUseSoftTabs(!!this.softTabs);\n\n editor.renderer.setShowGutter(!this.hideGutter);\n editor.renderer.setShowPrintMargin(!this.hidePrintMargin);\n editor.setHighlightActiveLine(!this.hideActiveLineHighlight);\n editor.setHighlightGutterLine(!this.hideGutterLineHighlight);\n\n editor.setReadOnly(!!this.readonly);\n if (this.readonly) {\n editor.setHighlightActiveLine(!this.readonly);\n editor.setHighlightGutterLine(!this.readonly);\n }\n\n editor.getSession().setUseWrapMode(!!this.wrap);\n\n editor.off('change', this.handleChange);\n editor.on('change', this.handleChange);\n editor.off('blur', this.handleBlur);\n editor.on('blur', this.handleBlur);\n\n this.resize();\n\n this._editor = editor;\n });\n\n private appendStyles() {\n const rootNode = this.getRootNode() as Document | ShadowRoot | undefined;\n const aceStyleId = `ace_editor.css`;\n const customStyleId = `ace-custom-element-style`;\n\n // initialize styles if rendering on the client:\n if (rootNode) {\n if (!rootNode.getElementById?.(customStyleId)) {\n const style = document.createElement('style');\n style.id = customStyleId;\n style.type = 'text/css';\n style.innerHTML = `\n ace-editor {\n display: block;\n width: 100%;\n height: 100%;\n min-height: 250px;\n }\n `;\n\n if (rootNode instanceof Document && rootNode.head) {\n rootNode.head.appendChild(style);\n } else {\n rootNode.appendChild(style);\n }\n }\n\n if (!rootNode.getElementById?.(aceStyleId)) {\n const editorStyle = document.getElementById(aceStyleId);\n if (editorStyle) {\n if (rootNode instanceof Document && rootNode.head) {\n rootNode.head.appendChild(editorStyle.cloneNode(true));\n } else {\n rootNode.appendChild(editorStyle.cloneNode(true));\n }\n }\n }\n }\n }\n\n connectedCallback(): void {\n this.initializeEditor().then(() => {\n this.dispatch('ready', {\n editor: this.editor,\n });\n });\n }\n\n disconnectedCallback(): void {\n if (!this._editor) {\n return;\n }\n\n this._editor.off('change', this.handleChange);\n this._editor.off('blur', this.handleBlur);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n attributeChangedCallback(name: string): void {\n this.initializeEditor();\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n notifyPropertyChanged(name: string): void {\n this.initializeEditor();\n }\n\n resize(): void {\n this._editor?.resize();\n }\n\n private handleChange = debounce(() => {\n const text = this._editor?.getValue() || '';\n if (text !== this.value) {\n if (text) {\n this.setAttribute('value', text);\n } else {\n this.removeAttribute('value');\n }\n\n this.dispatch('change', text);\n }\n });\n\n private handleBlur = () => {\n this.dispatchEvent(new FocusEvent('blur'));\n };\n}\n\nexport default AceEditorBase;\n"]}