@node-projects/web-component-designer-visualization-addons 0.1.34 → 0.1.35
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.
|
@@ -14,6 +14,7 @@ export declare class ScriptSystem {
|
|
|
14
14
|
constructor(visualizationHandler: VisualizationHandler);
|
|
15
15
|
execute(scriptCommands: ScriptCommands[], outerContext: contextType): Promise<void>;
|
|
16
16
|
runScriptCommand<T extends ScriptCommands>(command: T, context: contextType): Promise<void>;
|
|
17
|
+
getTargetFromTargetSelector(context: contextType, targetSelectorTarget: 'currentScreen' | 'parentScreen' | 'currentElement' | 'parentElement', targetSelector: string): Iterable<Element>;
|
|
17
18
|
getValue<T>(value: string | number | boolean | IScriptMultiplexValue, outerContext: contextType): Promise<any>;
|
|
18
19
|
getStateOrFieldOrParameter(name: string, context: contextType): Promise<any>;
|
|
19
20
|
parseStringWithValues(text: string, context: contextType): Promise<string>;
|
|
@@ -98,16 +98,7 @@ export class ScriptSystem {
|
|
|
98
98
|
case 'SetElementProperty': {
|
|
99
99
|
const name = await this.getValue(command.name, context);
|
|
100
100
|
const value = await this.getValue(command.value, context);
|
|
101
|
-
let
|
|
102
|
-
if (command.targetSelectorTarget == 'currentElement')
|
|
103
|
-
host = context.element;
|
|
104
|
-
else if (command.targetSelectorTarget == 'parentElement')
|
|
105
|
-
host = context.element.parentElement;
|
|
106
|
-
else if (command.targetSelectorTarget == 'parentScreen')
|
|
107
|
-
host = host.getRootNode().host;
|
|
108
|
-
let elements = [host];
|
|
109
|
-
if (command.targetSelector)
|
|
110
|
-
elements = host.shadowRoot.querySelectorAll(command.targetSelector);
|
|
101
|
+
let elements = this.getTargetFromTargetSelector(context, command.targetSelectorTarget, command.targetSelector);
|
|
111
102
|
for (let e of elements) {
|
|
112
103
|
if (command.target == 'attribute') {
|
|
113
104
|
e.setAttribute(name, value);
|
|
@@ -123,6 +114,19 @@ export class ScriptSystem {
|
|
|
123
114
|
}
|
|
124
115
|
}
|
|
125
116
|
}
|
|
117
|
+
getTargetFromTargetSelector(context, targetSelectorTarget, targetSelector) {
|
|
118
|
+
let host = context.element.getRootNode().host;
|
|
119
|
+
if (targetSelector == 'currentElement')
|
|
120
|
+
host = context.element;
|
|
121
|
+
else if (targetSelector == 'parentElement')
|
|
122
|
+
host = context.element.parentElement;
|
|
123
|
+
else if (targetSelector == 'parentScreen')
|
|
124
|
+
host = host.getRootNode().host;
|
|
125
|
+
let elements = [host];
|
|
126
|
+
if (targetSelector)
|
|
127
|
+
elements = host.shadowRoot.querySelectorAll(targetSelector);
|
|
128
|
+
return elements;
|
|
129
|
+
}
|
|
126
130
|
async getValue(value, outerContext) {
|
|
127
131
|
if (typeof value === 'object') {
|
|
128
132
|
switch (value.source) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "web-component-designer addon for visualizations",
|
|
3
3
|
"name": "@node-projects/web-component-designer-visualization-addons",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.35",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "jochen.kuehner@gmx.de",
|