@node-projects/web-component-designer-visualization-addons 0.1.34 → 0.1.36
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.
|
@@ -15,6 +15,8 @@ Blockly.Blocks['query_selector_all'] = {
|
|
|
15
15
|
this.setColour(230);
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
|
+
//TODO helper for current & parent screen queryselector
|
|
19
|
+
//TODO also a query selector for screen directly
|
|
18
20
|
//@ts-ignore
|
|
19
21
|
Blockly.JavaScript.forBlock['query_selector_all'] = function (block, generator) {
|
|
20
22
|
var dropdown_source = block.getFieldValue('SOURCE');
|
|
@@ -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);
|
|
@@ -118,11 +109,35 @@ export class ScriptSystem {
|
|
|
118
109
|
else if (command.target == 'css') {
|
|
119
110
|
e.style[name] = value;
|
|
120
111
|
}
|
|
112
|
+
else if (command.target == 'class') {
|
|
113
|
+
if (command.mode === 'toggle') {
|
|
114
|
+
e.classList.toggle(value);
|
|
115
|
+
}
|
|
116
|
+
else if (command.mode === 'remove') {
|
|
117
|
+
e.classList.remove(value);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
e.classList.add(value);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
121
123
|
}
|
|
122
124
|
break;
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
}
|
|
128
|
+
getTargetFromTargetSelector(context, targetSelectorTarget, targetSelector) {
|
|
129
|
+
let host = context.element.getRootNode().host;
|
|
130
|
+
if (targetSelector == 'currentElement')
|
|
131
|
+
host = context.element;
|
|
132
|
+
else if (targetSelector == 'parentElement')
|
|
133
|
+
host = context.element.parentElement;
|
|
134
|
+
else if (targetSelector == 'parentScreen')
|
|
135
|
+
host = host.getRootNode().host;
|
|
136
|
+
let elements = [host];
|
|
137
|
+
if (targetSelector)
|
|
138
|
+
elements = host.shadowRoot.querySelectorAll(targetSelector);
|
|
139
|
+
return elements;
|
|
140
|
+
}
|
|
126
141
|
async getValue(value, outerContext) {
|
|
127
142
|
if (typeof value === 'object') {
|
|
128
143
|
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.36",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "jochen.kuehner@gmx.de",
|