@omicronenergy/oscd-scl-dialogs 0.0.8 → 0.0.10

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.
@@ -0,0 +1,62 @@
1
+ import 'ace-builds/src-noconflict/ace';
2
+ import { Ace } from 'ace-builds';
3
+ import type * as AceGlobal from 'ace-builds';
4
+ declare global {
5
+ interface Window {
6
+ ace: typeof AceGlobal;
7
+ }
8
+ }
9
+ declare enum ValueUpdateMode {
10
+ start = "start",
11
+ end = "end",
12
+ select = "select"
13
+ }
14
+ /**
15
+ * Custom element Ace code editor
16
+ */
17
+ declare class AceEditor extends HTMLElement {
18
+ private static _observedAttributes;
19
+ private _editor?;
20
+ get editor(): Ace.Editor | undefined;
21
+ get version(): {
22
+ [key: string]: string;
23
+ };
24
+ value?: string;
25
+ mode?: string;
26
+ theme?: string;
27
+ tabSize?: number;
28
+ readonly?: boolean;
29
+ softTabs?: boolean;
30
+ wrap?: boolean;
31
+ valueUpdateMode?: ValueUpdateMode;
32
+ hideActiveLineHighlight?: boolean;
33
+ hideGutter?: boolean;
34
+ hideGutterLineHighlight?: boolean;
35
+ hidePrintMargin?: boolean;
36
+ basePath?: string;
37
+ static get observedAttributes(): string[];
38
+ /**
39
+ * Registers an attribute to be observed.
40
+ *
41
+ * @param name Attribute name to observe.
42
+ * @internal
43
+ */
44
+ addObservedAttribute(name: string): void;
45
+ private dispatch;
46
+ private initializeEditor;
47
+ private appendStyles;
48
+ connectedCallback(): void;
49
+ disconnectedCallback(): void;
50
+ attributeChangedCallback(name: string): void;
51
+ notifyPropertyChanged(name: string): void;
52
+ resize(): void;
53
+ private handleChange;
54
+ private handleBlur;
55
+ }
56
+ interface AceEditor {
57
+ addEventListener(type: 'change', listener: (event: CustomEvent<string>) => void): void;
58
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
59
+ removeEventListener(type: 'change', listener: (event: CustomEvent<string>) => void): void;
60
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
61
+ }
62
+ export default AceEditor;
@@ -0,0 +1,202 @@
1
+ import { __decorate } from "tslib";
2
+ /* eslint-disable class-methods-use-this */
3
+ /* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
4
+ import 'ace-builds/src-noconflict/ace';
5
+ import { NotifyAttribute, NotifyBooleanAttribute, NotifyNumericAttribute, } from './property-decorators.js';
6
+ import { debounce } from './debounce.js';
7
+ var ValueUpdateMode;
8
+ (function (ValueUpdateMode) {
9
+ ValueUpdateMode["start"] = "start";
10
+ ValueUpdateMode["end"] = "end";
11
+ ValueUpdateMode["select"] = "select";
12
+ })(ValueUpdateMode || (ValueUpdateMode = {}));
13
+ function getValueUpdateNumber(mode) {
14
+ if (mode === ValueUpdateMode.start)
15
+ return -1;
16
+ if (mode === ValueUpdateMode.end)
17
+ return 1;
18
+ return 0;
19
+ }
20
+ /**
21
+ * Custom element Ace code editor
22
+ */
23
+ class AceEditor extends HTMLElement {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.initializeEditor = debounce(() => {
27
+ const basePath = this.basePath || import.meta.url.replace(/[^/]+$/, 'ace/');
28
+ window.ace.config.set('basePath', basePath);
29
+ const editor = this._editor || window.ace.edit(this);
30
+ this.appendStyles();
31
+ editor.session.setMode(this.mode || 'ace/mode/javascript');
32
+ editor.setTheme(this.theme || 'ace/theme/eclipse');
33
+ const text = editor.getValue() || '';
34
+ if (text !== this.value) {
35
+ editor.setValue(this.value || '', getValueUpdateNumber(this.valueUpdateMode));
36
+ }
37
+ editor.getSession().setTabSize(this.tabSize || 2);
38
+ editor.getSession().setUseSoftTabs(!!this.softTabs);
39
+ editor.renderer.setShowGutter(!this.hideGutter);
40
+ editor.renderer.setShowPrintMargin(!this.hidePrintMargin);
41
+ editor.setHighlightActiveLine(!this.hideActiveLineHighlight);
42
+ editor.setHighlightGutterLine(!this.hideGutterLineHighlight);
43
+ editor.setReadOnly(!!this.readonly);
44
+ if (this.readonly) {
45
+ editor.setHighlightActiveLine(!this.readonly);
46
+ editor.setHighlightGutterLine(!this.readonly);
47
+ }
48
+ editor.getSession().setUseWrapMode(!!this.wrap);
49
+ editor.off('change', this.handleChange);
50
+ editor.on('change', this.handleChange);
51
+ editor.off('blur', this.handleBlur);
52
+ editor.on('blur', this.handleBlur);
53
+ this.resize();
54
+ this._editor = editor;
55
+ });
56
+ this.handleChange = debounce(() => {
57
+ const text = this._editor?.getValue() || '';
58
+ if (text !== this.value) {
59
+ if (text) {
60
+ this.setAttribute('value', text);
61
+ }
62
+ else {
63
+ this.removeAttribute('value');
64
+ }
65
+ this.dispatch('change', text);
66
+ }
67
+ });
68
+ this.handleBlur = () => {
69
+ this.dispatchEvent(new FocusEvent('blur'));
70
+ };
71
+ }
72
+ get editor() {
73
+ return this._editor;
74
+ }
75
+ get version() {
76
+ return {
77
+ ace: window.ace?.version || 'unknown',
78
+ };
79
+ }
80
+ static get observedAttributes() {
81
+ return AceEditor._observedAttributes;
82
+ }
83
+ /**
84
+ * Registers an attribute to be observed.
85
+ *
86
+ * @param name Attribute name to observe.
87
+ * @internal
88
+ */
89
+ addObservedAttribute(name) {
90
+ AceEditor._observedAttributes.push(name);
91
+ }
92
+ dispatch(type, detail) {
93
+ this.dispatchEvent(new CustomEvent(type, {
94
+ bubbles: true,
95
+ cancelable: false,
96
+ detail,
97
+ }));
98
+ }
99
+ appendStyles() {
100
+ const rootNode = this.getRootNode();
101
+ const aceStyleId = `ace_editor.css`;
102
+ const customStyleId = `ace-custom-element-style`;
103
+ // initialize styles if rendering on the client:
104
+ if (rootNode) {
105
+ if (!rootNode.getElementById?.(customStyleId)) {
106
+ const style = document.createElement('style');
107
+ style.id = customStyleId;
108
+ style.type = 'text/css';
109
+ style.innerHTML = `
110
+ ace-editor {
111
+ display: block;
112
+ width: 100%;
113
+ height: 250px;
114
+ }
115
+ `;
116
+ if (rootNode instanceof Document && rootNode.head) {
117
+ rootNode.head.appendChild(style);
118
+ }
119
+ else {
120
+ rootNode.appendChild(style);
121
+ }
122
+ }
123
+ if (!rootNode.getElementById?.(aceStyleId)) {
124
+ const editorStyle = document.getElementById(aceStyleId);
125
+ if (editorStyle) {
126
+ if (rootNode instanceof Document && rootNode.head) {
127
+ rootNode.head.appendChild(editorStyle.cloneNode(true));
128
+ }
129
+ else {
130
+ rootNode.appendChild(editorStyle.cloneNode(true));
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }
136
+ connectedCallback() {
137
+ this.initializeEditor().then(() => {
138
+ this.dispatch('ready', {
139
+ editor: this.editor,
140
+ });
141
+ });
142
+ }
143
+ disconnectedCallback() {
144
+ if (!this._editor)
145
+ return;
146
+ this._editor.off('change', this.handleChange);
147
+ this._editor.off('blur', this.handleBlur);
148
+ }
149
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
150
+ attributeChangedCallback(name) {
151
+ this.initializeEditor();
152
+ }
153
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
154
+ notifyPropertyChanged(name) {
155
+ this.initializeEditor();
156
+ }
157
+ resize() {
158
+ this._editor?.resize();
159
+ }
160
+ }
161
+ AceEditor._observedAttributes = [];
162
+ __decorate([
163
+ NotifyAttribute()
164
+ ], AceEditor.prototype, "value", void 0);
165
+ __decorate([
166
+ NotifyAttribute()
167
+ ], AceEditor.prototype, "mode", void 0);
168
+ __decorate([
169
+ NotifyAttribute()
170
+ ], AceEditor.prototype, "theme", void 0);
171
+ __decorate([
172
+ NotifyNumericAttribute()
173
+ ], AceEditor.prototype, "tabSize", void 0);
174
+ __decorate([
175
+ NotifyBooleanAttribute()
176
+ ], AceEditor.prototype, "readonly", void 0);
177
+ __decorate([
178
+ NotifyBooleanAttribute()
179
+ ], AceEditor.prototype, "softTabs", void 0);
180
+ __decorate([
181
+ NotifyBooleanAttribute()
182
+ ], AceEditor.prototype, "wrap", void 0);
183
+ __decorate([
184
+ NotifyAttribute()
185
+ ], AceEditor.prototype, "valueUpdateMode", void 0);
186
+ __decorate([
187
+ NotifyBooleanAttribute()
188
+ ], AceEditor.prototype, "hideActiveLineHighlight", void 0);
189
+ __decorate([
190
+ NotifyBooleanAttribute()
191
+ ], AceEditor.prototype, "hideGutter", void 0);
192
+ __decorate([
193
+ NotifyBooleanAttribute()
194
+ ], AceEditor.prototype, "hideGutterLineHighlight", void 0);
195
+ __decorate([
196
+ NotifyBooleanAttribute()
197
+ ], AceEditor.prototype, "hidePrintMargin", void 0);
198
+ __decorate([
199
+ NotifyAttribute()
200
+ ], AceEditor.prototype, "basePath", void 0);
201
+ export default AceEditor;
202
+ //# sourceMappingURL=AceEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AceEditor.js","sourceRoot":"","sources":["../../ace-editor/AceEditor.ts"],"names":[],"mappings":";AAAA,2CAA2C;AAC3C,qEAAqE;AACrE,OAAO,+BAA+B,CAAC;AAEvC,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;QAAE,OAAO,CAAC,CAAC,CAAC;IAC9C,IAAI,IAAI,KAAK,eAAe,CAAC,GAAG;QAAE,OAAO,CAAC,CAAC;IAC3C,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;GAEG;AACH,MAAM,SAAU,SAAQ,WAAW;IAAnC;;QA6EU,qBAAgB,GAAG,QAAQ,CAAC,GAAG,EAAE;YACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,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OAAO,EAAE,MAAM,EAAE,CAAC;IACzB,CAAC;;AA3Lc,6BAAmB,GAAa,EAAE,AAAf,CAAgB;AAclD;IADC,eAAe,EAAE;wCACH;AAGf;IADC,eAAe,EAAE;uCACJ;AAGd;IADC,eAAe,EAAE;wCACH;AAGf;IADC,sBAAsB,EAAE;0CACR;AAGjB;IADC,sBAAsB,EAAE;2CACN;AAGnB;IADC,sBAAsB,EAAE;2CACN;AAGnB;IADC,sBAAsB,EAAE;uCACV;AAGf;IADC,eAAe,EAAE;kDACgB;AAGlC;IADC,sBAAsB,EAAE;0DACS;AAGlC;IADC,sBAAsB,EAAE;6CACJ;AAGrB;IADC,sBAAsB,EAAE;0DACS;AAGlC;IADC,sBAAsB,EAAE;kDACC;AAG1B;IADC,eAAe,EAAE;2CACA;AAmLpB,eAAe,SAAS,CAAC","sourcesContent":["/* eslint-disable class-methods-use-this */\n/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport 'ace-builds/src-noconflict/ace';\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) return -1;\n if (mode === ValueUpdateMode.end) return 1;\n return 0;\n}\n\n/**\n * Custom element Ace code editor\n */\nclass AceEditor 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 AceEditor._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 AceEditor._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 cancelable: false,\n detail,\n }),\n );\n }\n\n private initializeEditor = debounce(() => {\n const basePath = this.basePath || import.meta.url.replace(/[^/]+$/, 'ace/');\n window.ace.config.set('basePath', basePath);\n\n const editor = this._editor || window.ace.edit(this);\n\n this.appendStyles();\n\n editor.session.setMode(this.mode || 'ace/mode/javascript');\n editor.setTheme(this.theme || 'ace/theme/eclipse');\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) return;\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\ninterface AceEditor {\n addEventListener(\n type: 'change',\n listener: (event: CustomEvent<string>) => void,\n ): void;\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void;\n\n removeEventListener(\n type: 'change',\n listener: (event: CustomEvent<string>) => void,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n}\n\nexport default AceEditor;\n"]}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright 2020 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Returns a new function that delays invocations to the original function
18
+ * within a specified wait period. The last invocation within this time period
19
+ * gets invoked. All earlier invocations are ignore.
20
+ *
21
+ * @param func The function to invoke.
22
+ * @param wait The time in milliseconds to wait for idle invocations.
23
+ */
24
+ export declare function debounce<T>(func: (...params: any[]) => T, wait?: number): () => Promise<T>;
@@ -0,0 +1,41 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /**
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Returns a new function that delays invocations to the original function
19
+ * within a specified wait period. The last invocation within this time period
20
+ * gets invoked. All earlier invocations are ignore.
21
+ *
22
+ * @param func The function to invoke.
23
+ * @param wait The time in milliseconds to wait for idle invocations.
24
+ */
25
+ export function debounce(func, wait = 0) {
26
+ let timeout;
27
+ return function (...args) {
28
+ window.clearTimeout(timeout);
29
+ const later = function () {
30
+ timeout = undefined;
31
+ return func(...args);
32
+ };
33
+ return new Promise(resolve => {
34
+ timeout = window.setTimeout(() => {
35
+ const result = later();
36
+ resolve(result);
37
+ }, wait);
38
+ });
39
+ };
40
+ }
41
+ //# sourceMappingURL=debounce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.js","sourceRoot":"","sources":["../../ace-editor/debounce.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CACtB,IAA6B,EAC7B,IAAI,GAAG,CAAC;IAER,IAAI,OAA2B,CAAC;IAEhC,OAAO,UAAU,GAAG,IAAW;QAC7B,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAE7B,MAAM,KAAK,GAAG;YACZ,OAAO,GAAG,SAAS,CAAC;YACpB,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC;QAEF,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;YAC3B,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;gBAC/B,MAAM,MAAM,GAAG,KAAK,EAAE,CAAC;gBACvB,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC,EAAE,IAAI,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Returns a new function that delays invocations to the original function\n * within a specified wait period. The last invocation within this time period\n * gets invoked. All earlier invocations are ignore.\n *\n * @param func The function to invoke.\n * @param wait The time in milliseconds to wait for idle invocations.\n */\nexport function debounce<T>(\n func: (...params: any[]) => T,\n wait = 0,\n): () => Promise<T> {\n let timeout: number | undefined;\n\n return function (...args: any[]): Promise<any> {\n window.clearTimeout(timeout);\n\n const later = function (): any {\n timeout = undefined;\n return func(...args);\n };\n\n return new Promise(resolve => {\n timeout = window.setTimeout(() => {\n const result = later();\n resolve(result);\n }, wait);\n });\n };\n}\n"]}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Copyright 2020 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Describes notification target for the `Notify` decorators.
18
+ */
19
+ interface NotifyTarget {
20
+ notifyPropertyChanged: (name: string) => void;
21
+ addObservedAttribute?: (name: string) => void;
22
+ [key: string]: any;
23
+ }
24
+ /**
25
+ * Defines that the target property should be exposed as an attribute, and
26
+ * that changes to the attribute should trigger a `notifyPropertyChanged`
27
+ * callback.
28
+ *
29
+ * @param attribute Override the attribute name to use. If ommitted, the
30
+ * property name is used (coverted from camelCase, to kebab-case).
31
+ */
32
+ export declare function NotifyAttribute(attribute?: string): (target: NotifyTarget & HTMLElement, key: string) => void;
33
+ /**
34
+ * Defines that the target property should be exposed as boolean attribute, and
35
+ * that changes to the attribute should trigger a `notifyPropertyChanged`
36
+ * callback.
37
+ *
38
+ * @param attribute Override the attribute name to use. If ommitted, the
39
+ * property name is used (coverted from camelCase, to snake-case).
40
+ */
41
+ export declare function NotifyBooleanAttribute(attribute?: string): (target: NotifyTarget & HTMLElement, key: string) => void;
42
+ /**
43
+ * Defines that the target property should be exposed as numeric attribute, and
44
+ * that changes to the attribute should trigger a `notifyPropertyChanged`
45
+ * callback.
46
+ *
47
+ * @param attribute Override the attribute name to use. If ommitted, the
48
+ * property name is used (coverted from camelCase, to snake-case).
49
+ */
50
+ export declare function NotifyNumericAttribute(attribute?: string): (target: NotifyTarget & HTMLElement, key: string) => void;
51
+ /**
52
+ * Defines that the target property should trigger a `notifyPropertyChanged`
53
+ * callback when the property changes.
54
+ *
55
+ * @param attribute Expose the property as an attribute. Note that when
56
+ * attribute is specified, this method has the same behavior as
57
+ * `NotifyAttribute`.
58
+ */
59
+ export declare function Notify(attribute?: string): (target: NotifyTarget & HTMLElement, key: string) => void;
60
+ /**
61
+ * Creates an alias for the given property with a getter and a setter.
62
+ *
63
+ * @param alias Name of the alias.
64
+ */
65
+ export declare function Alias(alias: string): (target: NotifyTarget, key: string) => void;
66
+ export {};
@@ -0,0 +1,171 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /**
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Converts a camelCase property name to a kebab-case attribute name.
19
+ */
20
+ function getAttributeName(propertyName) {
21
+ return propertyName
22
+ .replace(/[A-Z]+/g, sub => `-${sub}`)
23
+ .replace(/^-/, '')
24
+ .toLowerCase();
25
+ }
26
+ /**
27
+ * Defines that the target property should be exposed as an attribute, and
28
+ * that changes to the attribute should trigger a `notifyPropertyChanged`
29
+ * callback.
30
+ *
31
+ * @param attribute Override the attribute name to use. If ommitted, the
32
+ * property name is used (coverted from camelCase, to kebab-case).
33
+ */
34
+ export function NotifyAttribute(attribute) {
35
+ return function (target, key) {
36
+ const attr = attribute || getAttributeName(key);
37
+ if (target.addObservedAttribute) {
38
+ target.addObservedAttribute(attr);
39
+ }
40
+ Object.defineProperty(target, key, {
41
+ get() {
42
+ return this.getAttribute(attr);
43
+ },
44
+ set(value) {
45
+ if (value === null || value === undefined) {
46
+ this.removeAttribute(attr);
47
+ }
48
+ else {
49
+ this.setAttribute(attr, value);
50
+ }
51
+ this.notifyPropertyChanged(key);
52
+ },
53
+ enumerable: true,
54
+ configurable: true,
55
+ });
56
+ };
57
+ }
58
+ /**
59
+ * Defines that the target property should be exposed as boolean attribute, and
60
+ * that changes to the attribute should trigger a `notifyPropertyChanged`
61
+ * callback.
62
+ *
63
+ * @param attribute Override the attribute name to use. If ommitted, the
64
+ * property name is used (coverted from camelCase, to snake-case).
65
+ */
66
+ export function NotifyBooleanAttribute(attribute) {
67
+ return function (target, key) {
68
+ const attr = attribute || getAttributeName(key);
69
+ if (target.addObservedAttribute) {
70
+ target.addObservedAttribute(attr);
71
+ }
72
+ Object.defineProperty(target, key, {
73
+ get() {
74
+ return this.hasAttribute(attr);
75
+ },
76
+ set(value) {
77
+ if (value) {
78
+ this.setAttribute(attr, '');
79
+ }
80
+ else {
81
+ this.removeAttribute(attr);
82
+ }
83
+ this.notifyPropertyChanged(key);
84
+ },
85
+ enumerable: true,
86
+ configurable: true,
87
+ });
88
+ };
89
+ }
90
+ /**
91
+ * Defines that the target property should be exposed as numeric attribute, and
92
+ * that changes to the attribute should trigger a `notifyPropertyChanged`
93
+ * callback.
94
+ *
95
+ * @param attribute Override the attribute name to use. If ommitted, the
96
+ * property name is used (coverted from camelCase, to snake-case).
97
+ */
98
+ export function NotifyNumericAttribute(attribute) {
99
+ return function (target, key) {
100
+ const attr = attribute || getAttributeName(key);
101
+ if (target.addObservedAttribute) {
102
+ target.addObservedAttribute(attr);
103
+ }
104
+ Object.defineProperty(target, key, {
105
+ get() {
106
+ const value = Number(this.getAttribute(attr));
107
+ if (isNaN(value)) {
108
+ return undefined;
109
+ }
110
+ return value;
111
+ },
112
+ set(value) {
113
+ if (value === null || value === undefined) {
114
+ this.removeAttribute(attr);
115
+ }
116
+ else {
117
+ this.setAttribute(attr, value);
118
+ }
119
+ this.notifyPropertyChanged(key);
120
+ },
121
+ enumerable: true,
122
+ configurable: true,
123
+ });
124
+ };
125
+ }
126
+ /**
127
+ * Defines that the target property should trigger a `notifyPropertyChanged`
128
+ * callback when the property changes.
129
+ *
130
+ * @param attribute Expose the property as an attribute. Note that when
131
+ * attribute is specified, this method has the same behavior as
132
+ * `NotifyAttribute`.
133
+ */
134
+ export function Notify(attribute) {
135
+ if (attribute) {
136
+ return NotifyAttribute(attribute);
137
+ }
138
+ return function (target, key) {
139
+ Object.defineProperty(target, key, {
140
+ get() {
141
+ return this[`$__${key}`];
142
+ },
143
+ set(value) {
144
+ this[`$__${key}`] = value;
145
+ this.notifyPropertyChanged(key);
146
+ },
147
+ enumerable: true,
148
+ configurable: true,
149
+ });
150
+ };
151
+ }
152
+ /**
153
+ * Creates an alias for the given property with a getter and a setter.
154
+ *
155
+ * @param alias Name of the alias.
156
+ */
157
+ export function Alias(alias) {
158
+ return function (target, key) {
159
+ Object.defineProperty(target, alias, {
160
+ get() {
161
+ return this[key];
162
+ },
163
+ set(value) {
164
+ this[key] = value;
165
+ },
166
+ enumerable: true,
167
+ configurable: false,
168
+ });
169
+ };
170
+ }
171
+ //# sourceMappingURL=property-decorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property-decorators.js","sourceRoot":"","sources":["../../ace-editor/property-decorators.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD;;;;;;;;;;;;;;GAcG;AAWH;;GAEG;AACH,SAAS,gBAAgB,CAAC,YAAoB;IAC5C,OAAO,YAAY;SAChB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC;SACpC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;SACjB,WAAW,EAAE,CAAC;AACnB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,SAAkB;IAChD,OAAO,UAAU,MAAkC,EAAE,GAAW;QAC9D,MAAM,IAAI,GAAG,SAAS,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAEhD,IAAI,MAAM,CAAC,oBAAoB,EAAE,CAAC;YAChC,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;YACjC,GAAG;gBACD,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACjC,CAAC;YACD,GAAG,CAAmC,KAAU;gBAC9C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBAC1C,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;gBAC7B,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;gBACjC,CAAC;gBACD,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;YACD,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC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,GAAG,CAAC,GAAG,KAAK,CAAC;YACpB,CAAC;YACD,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Describes notification target for the `Notify` decorators.\n */\ninterface NotifyTarget {\n notifyPropertyChanged: (name: string) => void;\n addObservedAttribute?: (name: string) => void;\n [key: string]: any;\n}\n\n/**\n * Converts a camelCase property name to a kebab-case attribute name.\n */\nfunction getAttributeName(propertyName: string): string {\n return propertyName\n .replace(/[A-Z]+/g, sub => `-${sub}`)\n .replace(/^-/, '')\n .toLowerCase();\n}\n\n/**\n * Defines that the target property should be exposed as an attribute, and\n * that changes to the attribute should trigger a `notifyPropertyChanged`\n * callback.\n *\n * @param attribute Override the attribute name to use. If ommitted, the\n * property name is used (coverted from camelCase, to kebab-case).\n */\nexport function NotifyAttribute(attribute?: string) {\n return function (target: NotifyTarget & HTMLElement, key: string): void {\n const attr = attribute || getAttributeName(key);\n\n if (target.addObservedAttribute) {\n target.addObservedAttribute(attr);\n }\n\n Object.defineProperty(target, key, {\n get(this: NotifyTarget & HTMLElement) {\n return this.getAttribute(attr);\n },\n set(this: NotifyTarget & HTMLElement, value: any) {\n if (value === null || value === undefined) {\n this.removeAttribute(attr);\n } else {\n this.setAttribute(attr, value);\n }\n this.notifyPropertyChanged(key);\n },\n enumerable: true,\n configurable: true,\n });\n };\n}\n\n/**\n * Defines that the target property should be exposed as boolean attribute, and\n * that changes to the attribute should trigger a `notifyPropertyChanged`\n * callback.\n *\n * @param attribute Override the attribute name to use. If ommitted, the\n * property name is used (coverted from camelCase, to snake-case).\n */\nexport function NotifyBooleanAttribute(attribute?: string) {\n return function (target: NotifyTarget & HTMLElement, key: string): void {\n const attr = attribute || getAttributeName(key);\n\n if (target.addObservedAttribute) {\n target.addObservedAttribute(attr);\n }\n\n Object.defineProperty(target, key, {\n get(this: NotifyTarget & HTMLElement) {\n return this.hasAttribute(attr);\n },\n set(this: NotifyTarget & HTMLElement, value: any) {\n if (value) {\n this.setAttribute(attr, '');\n } else {\n this.removeAttribute(attr);\n }\n this.notifyPropertyChanged(key);\n },\n enumerable: true,\n configurable: true,\n });\n };\n}\n\n/**\n * Defines that the target property should be exposed as numeric attribute, and\n * that changes to the attribute should trigger a `notifyPropertyChanged`\n * callback.\n *\n * @param attribute Override the attribute name to use. If ommitted, the\n * property name is used (coverted from camelCase, to snake-case).\n */\nexport function NotifyNumericAttribute(attribute?: string) {\n return function (target: NotifyTarget & HTMLElement, key: string): void {\n const attr = attribute || getAttributeName(key);\n\n if (target.addObservedAttribute) {\n target.addObservedAttribute(attr);\n }\n\n Object.defineProperty(target, key, {\n get(this: NotifyTarget & HTMLElement) {\n const value = Number(this.getAttribute(attr));\n if (isNaN(value)) {\n return undefined;\n }\n return value;\n },\n set(this: NotifyTarget & HTMLElement, value: any) {\n if (value === null || value === undefined) {\n this.removeAttribute(attr);\n } else {\n this.setAttribute(attr, value);\n }\n this.notifyPropertyChanged(key);\n },\n enumerable: true,\n configurable: true,\n });\n };\n}\n\n/**\n * Defines that the target property should trigger a `notifyPropertyChanged`\n * callback when the property changes.\n *\n * @param attribute Expose the property as an attribute. Note that when\n * attribute is specified, this method has the same behavior as\n * `NotifyAttribute`.\n */\nexport function Notify(\n attribute?: string,\n): (target: NotifyTarget & HTMLElement, key: string) => void {\n if (attribute) {\n return NotifyAttribute(attribute);\n }\n\n return function (target: NotifyTarget, key: string): void {\n Object.defineProperty(target, key, {\n get(this: NotifyTarget) {\n return this[`$__${key}`];\n },\n set(this: NotifyTarget, value: any) {\n this[`$__${key}`] = value;\n this.notifyPropertyChanged(key);\n },\n enumerable: true,\n configurable: true,\n });\n };\n}\n\n/**\n * Creates an alias for the given property with a getter and a setter.\n *\n * @param alias Name of the alias.\n */\nexport function Alias(alias: string) {\n return function (target: NotifyTarget, key: string): void {\n Object.defineProperty(target, alias, {\n get(this: NotifyTarget) {\n return this[key];\n },\n set(this: NotifyTarget, value: any) {\n this[key] = value;\n },\n enumerable: true,\n configurable: false,\n });\n };\n}\n"]}
@@ -100,14 +100,16 @@ export function updateAction(element) {
100
100
  const ldName = ldNameAllowed
101
101
  ? getValue(inputs.find(i => i.label === 'ldName'))
102
102
  : null;
103
- if (ldName === element.getAttribute('ldName') &&
104
- desc === element.getAttribute('desc')) {
105
- return [];
106
- }
103
+ const attributes = {
104
+ ...(ldNameAllowed && ldName !== element.getAttribute('ldName')
105
+ ? { ldName }
106
+ : {}),
107
+ ...(desc !== element.getAttribute('desc') ? { desc } : {}),
108
+ };
107
109
  return [
108
110
  {
109
111
  element,
110
- attributes: { ldName, desc },
112
+ attributes,
111
113
  },
112
114
  ];
113
115
  };