@node-projects/web-component-designer-visualization-addons 0.1.0
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.
- package/README.md +19 -0
- package/dist/blockly/BlocklyJavascriptHelper.d.ts +2 -0
- package/dist/blockly/BlocklyJavascriptHelper.js +35 -0
- package/dist/blockly/BlocklyScriptEditor.d.ts +16 -0
- package/dist/blockly/BlocklyScriptEditor.js +106 -0
- package/dist/blockly/BlocklyToolbox.d.ts +1117 -0
- package/dist/blockly/BlocklyToolbox.js +980 -0
- package/dist/blockly/components/Console.d.ts +0 -0
- package/dist/blockly/components/Console.js +26 -0
- package/dist/blockly/components/Debugger.d.ts +0 -0
- package/dist/blockly/components/Debugger.js +15 -0
- package/dist/blockly/components/GetState.d.ts +0 -0
- package/dist/blockly/components/GetState.js +21 -0
- package/dist/blockly/components/GetSubProperty.d.ts +0 -0
- package/dist/blockly/components/GetSubProperty.js +27 -0
- package/dist/blockly/components/OpenScreen.d.ts +0 -0
- package/dist/blockly/components/OpenScreen.js +31 -0
- package/dist/blockly/components/QuerySelector.d.ts +0 -0
- package/dist/blockly/components/QuerySelector.js +30 -0
- package/dist/blockly/components/QuerySelectorAll.d.ts +0 -0
- package/dist/blockly/components/QuerySelectorAll.js +30 -0
- package/dist/blockly/components/Return.d.ts +0 -0
- package/dist/blockly/components/Return.js +21 -0
- package/dist/blockly/components/SetElement.d.ts +0 -0
- package/dist/blockly/components/SetElement.js +44 -0
- package/dist/blockly/components/SetState.d.ts +0 -0
- package/dist/blockly/components/SetState.js +26 -0
- package/dist/blockly/components/StartEvent.d.ts +0 -0
- package/dist/blockly/components/StartEvent.js +23 -0
- package/dist/blockly/components/components.d.ts +11 -0
- package/dist/blockly/components/components.js +11 -0
- package/dist/blockly/components/fields/FieldObjectId.d.ts +1 -0
- package/dist/blockly/components/fields/FieldObjectId.js +6 -0
- package/dist/components/BindingsEditor.d.ts +49 -0
- package/dist/components/BindingsEditor.js +298 -0
- package/dist/components/BindingsEditorHistoric.d.ts +14 -0
- package/dist/components/BindingsEditorHistoric.js +97 -0
- package/dist/components/PropertyGridExt.d.ts +0 -0
- package/dist/components/PropertyGridExt.js +1 -0
- package/dist/components/ScriptEditor.d.ts +28 -0
- package/dist/components/ScriptEditor.js +254 -0
- package/dist/components/VisualizationPropertyGrid.d.ts +12 -0
- package/dist/components/VisualizationPropertyGrid.js +104 -0
- package/dist/helpers/BindingsHelper.d.ts +47 -0
- package/dist/helpers/BindingsHelper.js +642 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +22 -0
- package/dist/interfaces/IScriptMultiplexValue.d.ts +15 -0
- package/dist/interfaces/IScriptMultiplexValue.js +15 -0
- package/dist/interfaces/VisualisationElementScript.d.ts +5 -0
- package/dist/interfaces/VisualisationElementScript.js +1 -0
- package/dist/interfaces/VisualizationBinding.d.ts +20 -0
- package/dist/interfaces/VisualizationBinding.js +4 -0
- package/dist/interfaces/VisualizationHandler.d.ts +24 -0
- package/dist/interfaces/VisualizationHandler.js +2 -0
- package/dist/interfaces/VisualizationShell.d.ts +13 -0
- package/dist/interfaces/VisualizationShell.js +1 -0
- package/dist/interfaces/VisualizationUiHandler.d.ts +5 -0
- package/dist/interfaces/VisualizationUiHandler.js +2 -0
- package/dist/scripting/Script.d.ts +6 -0
- package/dist/scripting/Script.js +5 -0
- package/dist/scripting/ScriptCommands.d.ts +192 -0
- package/dist/scripting/ScriptCommands.js +1 -0
- package/dist/scripting/ScriptSystem.d.ts +23 -0
- package/dist/scripting/ScriptSystem.js +224 -0
- package/dist/services/BindableObjectDragDropService.d.ts +16 -0
- package/dist/services/BindableObjectDragDropService.js +145 -0
- package/dist/services/BindingsService.d.ts +11 -0
- package/dist/services/BindingsService.js +46 -0
- package/dist/services/PropertyGridDragDropService.d.ts +7 -0
- package/dist/services/PropertyGridDragDropService.js +10 -0
- package/dist/services/ScriptRefactorService.d.ts +9 -0
- package/dist/services/ScriptRefactorService.js +79 -0
- package/dist/services/SignalPropertyEditor.d.ts +7 -0
- package/dist/services/SignalPropertyEditor.js +43 -0
- package/dist/setupVisuService.d.ts +0 -0
- package/dist/setupVisuService.js +1 -0
- package/package.json +29 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { OverlayLayer, DesignItem, InsertAction, BindingTarget, PropertyType } from "@node-projects/web-component-designer";
|
|
2
|
+
export class BindableObjectDragDropService {
|
|
3
|
+
constructor(bindingsHelper, visualizationHandler) {
|
|
4
|
+
this._bindingsHelper = bindingsHelper;
|
|
5
|
+
this._visualizationHandler = visualizationHandler;
|
|
6
|
+
}
|
|
7
|
+
_bindingsHelper;
|
|
8
|
+
_visualizationHandler;
|
|
9
|
+
rectMap = new Map();
|
|
10
|
+
rect;
|
|
11
|
+
dragEnter(designerCanvas, event, element) {
|
|
12
|
+
const designItem = DesignItem.GetDesignItem(element);
|
|
13
|
+
if (designItem && !designItem.isRootItem) {
|
|
14
|
+
let itemRect = designerCanvas.getNormalizedElementCoordinates(element);
|
|
15
|
+
this.rect = designerCanvas.overlayLayer.drawRect('IobrokerWebuiBindableObjectDragDropService', itemRect.x, itemRect.y, itemRect.width, itemRect.height, '', null, OverlayLayer.Background);
|
|
16
|
+
this.rect.style.fill = '#ff0000';
|
|
17
|
+
this.rect.style.opacity = '0.3';
|
|
18
|
+
this.rectMap.set(element, this.rect);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
dragLeave(designerCanvas, event, element) {
|
|
22
|
+
const designItem = DesignItem.GetDesignItem(element);
|
|
23
|
+
if (designItem && !designItem.isRootItem) {
|
|
24
|
+
const rect = this.rectMap.get(element);
|
|
25
|
+
designerCanvas.overlayLayer.removeOverlay(rect);
|
|
26
|
+
this.rectMap.delete(element);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
dragOver(designerView, event, element) {
|
|
30
|
+
return 'copy';
|
|
31
|
+
}
|
|
32
|
+
async drop(designerCanvas, event, bindableObject, element) {
|
|
33
|
+
for (let r of this.rectMap.values()) {
|
|
34
|
+
designerCanvas.overlayLayer.removeOverlay(r);
|
|
35
|
+
}
|
|
36
|
+
this.rectMap.clear();
|
|
37
|
+
const designItem = DesignItem.GetDesignItem(element);
|
|
38
|
+
const obj = await this._visualizationHandler.getObject(bindableObject.fullName);
|
|
39
|
+
const info = this._visualizationHandler.getSignalInformation(obj);
|
|
40
|
+
if (designItem && !designItem.isRootItem) {
|
|
41
|
+
// Add binding to drop target...
|
|
42
|
+
if (element instanceof HTMLInputElement) {
|
|
43
|
+
const binding = { signal: bindableObject.fullName, target: BindingTarget.property };
|
|
44
|
+
const serializedBinding = this._bindingsHelper.serializeBinding(element, element.type == 'checkbox' ? 'checked' : 'value', binding);
|
|
45
|
+
designItem.setAttribute(serializedBinding[0], serializedBinding[1]);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const binding = { signal: bindableObject.fullName, target: BindingTarget.content };
|
|
49
|
+
const serializedBinding = this._bindingsHelper.serializeBinding(element, null, binding);
|
|
50
|
+
designItem.setAttribute(serializedBinding[0], serializedBinding[1]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const position = designerCanvas.getNormalizedEventCoordinates(event);
|
|
55
|
+
let di;
|
|
56
|
+
let grp;
|
|
57
|
+
let state = await this._visualizationHandler.getState(bindableObject.fullName);
|
|
58
|
+
//TODO: only icon&image if val is a url with extension
|
|
59
|
+
if (info.role === 'url' && typeof state?.value === 'string') {
|
|
60
|
+
if (state.value.endsWith('jpg') || state.value.endsWith('jpeg') || state.value.endsWith('png') || state.value.endsWith('gif') || state.value.endsWith('svg')) {
|
|
61
|
+
const img = document.createElement('img');
|
|
62
|
+
di = DesignItem.createDesignItemFromInstance(img, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
63
|
+
grp = di.openGroup("Insert");
|
|
64
|
+
const binding = { signal: bindableObject.fullName, target: BindingTarget.property };
|
|
65
|
+
let serializedBinding = this._bindingsHelper.serializeBinding(img, 'src', binding);
|
|
66
|
+
di.setAttribute(serializedBinding[0], serializedBinding[1]);
|
|
67
|
+
di.element.src = state.value;
|
|
68
|
+
}
|
|
69
|
+
else if (state.value.endsWith('mp4')) {
|
|
70
|
+
const video = document.createElement('video');
|
|
71
|
+
di = DesignItem.createDesignItemFromInstance(video, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
72
|
+
grp = di.openGroup("Insert");
|
|
73
|
+
const binding = { signal: bindableObject.fullName, target: BindingTarget.property };
|
|
74
|
+
let serializedBinding = this._bindingsHelper.serializeBinding(video, 'src', binding);
|
|
75
|
+
di.setAttribute(serializedBinding[0], serializedBinding[1]);
|
|
76
|
+
di.element.src = state.value;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const video = document.createElement('iframe');
|
|
80
|
+
di = DesignItem.createDesignItemFromInstance(video, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
81
|
+
grp = di.openGroup("Insert");
|
|
82
|
+
const binding = { signal: bindableObject.fullName, target: BindingTarget.property };
|
|
83
|
+
let serializedBinding = this._bindingsHelper.serializeBinding(video, 'src', binding);
|
|
84
|
+
di.setAttribute(serializedBinding[0], serializedBinding[1]);
|
|
85
|
+
di.element.src = state.value;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (!di) {
|
|
89
|
+
const input = document.createElement('input');
|
|
90
|
+
di = DesignItem.createDesignItemFromInstance(input, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
91
|
+
grp = di.openGroup("Insert");
|
|
92
|
+
let twoWay = info.writeable !== false;
|
|
93
|
+
const binding = { signal: bindableObject.fullName, target: BindingTarget.property, twoWay: twoWay };
|
|
94
|
+
let serializedBinding = this._bindingsHelper.serializeBinding(input, 'value', binding);
|
|
95
|
+
if (info.type === 'boolean') {
|
|
96
|
+
serializedBinding = this._bindingsHelper.serializeBinding(input, 'checked', binding);
|
|
97
|
+
di.setAttribute("type", "checkbox");
|
|
98
|
+
}
|
|
99
|
+
else if (info.role == 'date') {
|
|
100
|
+
binding.twoWay = twoWay;
|
|
101
|
+
serializedBinding = this._bindingsHelper.serializeBinding(input, 'value-as-number', binding);
|
|
102
|
+
di.setAttribute("type", "date");
|
|
103
|
+
di.setAttribute("readonly", "");
|
|
104
|
+
}
|
|
105
|
+
else if (info.role == 'datetime') {
|
|
106
|
+
binding.twoWay = twoWay;
|
|
107
|
+
serializedBinding = this._bindingsHelper.serializeBinding(input, 'value-as-number', binding);
|
|
108
|
+
di.setAttribute("type", "datetime-local");
|
|
109
|
+
di.setAttribute("readonly", "");
|
|
110
|
+
}
|
|
111
|
+
di.setAttribute(serializedBinding[0], serializedBinding[1]);
|
|
112
|
+
}
|
|
113
|
+
di.setStyle('position', 'absolute');
|
|
114
|
+
di.setStyle('left', position.x + 'px');
|
|
115
|
+
di.setStyle('top', position.y + 'px');
|
|
116
|
+
designerCanvas.instanceServiceContainer.undoService.execute(new InsertAction(designerCanvas.rootDesignItem, designerCanvas.rootDesignItem.childCount, di));
|
|
117
|
+
grp.commit();
|
|
118
|
+
requestAnimationFrame(() => designerCanvas.instanceServiceContainer.selectionService.setSelectedElements([di]));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
dragOverOnProperty(event, property, designItems) {
|
|
122
|
+
return 'copy';
|
|
123
|
+
}
|
|
124
|
+
dropOnProperty(event, property, bindableObject, designItems) {
|
|
125
|
+
if (property.type == 'signal') {
|
|
126
|
+
property.service.setValue(designItems, property, bindableObject.fullName);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const binding = { signal: bindableObject.fullName, target: BindingTarget.property };
|
|
130
|
+
if (property.propertyType == PropertyType.attribute)
|
|
131
|
+
binding.target = BindingTarget.attribute;
|
|
132
|
+
if (property.propertyType == PropertyType.cssValue)
|
|
133
|
+
binding.target = BindingTarget.css;
|
|
134
|
+
binding.signal = bindableObject.fullName;
|
|
135
|
+
binding.twoWay = property.propertyType == PropertyType.property || property.propertyType == PropertyType.propertyAndAttribute;
|
|
136
|
+
//if (designItems[0].element instanceof BaseCustomControl)
|
|
137
|
+
// binding.twoWay = false;
|
|
138
|
+
const group = designItems[0].openGroup('drop binding');
|
|
139
|
+
for (let d of designItems) {
|
|
140
|
+
const serializedBinding = this._bindingsHelper.serializeBinding(d.element, property.name, binding);
|
|
141
|
+
d.setAttribute(serializedBinding[0], serializedBinding[1]);
|
|
142
|
+
}
|
|
143
|
+
group.commit();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BindingTarget, IBinding, IBindingService, IDesignItem } from "@node-projects/web-component-designer";
|
|
2
|
+
import { BindingsHelper } from "../helpers/BindingsHelper.js";
|
|
3
|
+
export declare class BindingsService implements IBindingService {
|
|
4
|
+
constructor(bindingsHelper: BindingsHelper);
|
|
5
|
+
private _bindingsHelper;
|
|
6
|
+
getBindings(designItem: IDesignItem): (IBinding & {
|
|
7
|
+
converter: Record<string, any>;
|
|
8
|
+
})[];
|
|
9
|
+
setBinding(designItem: IDesignItem, binding: IBinding): boolean;
|
|
10
|
+
clearBinding(designItem: IDesignItem, propertyName: string, propertyTarget: BindingTarget): boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { BindingMode, PropertiesHelper } from "@node-projects/web-component-designer";
|
|
2
|
+
export class BindingsService {
|
|
3
|
+
constructor(bindingsHelper) {
|
|
4
|
+
this._bindingsHelper = bindingsHelper;
|
|
5
|
+
}
|
|
6
|
+
_bindingsHelper;
|
|
7
|
+
getBindings(designItem) {
|
|
8
|
+
const iobBindings = Array.from(this._bindingsHelper.getBindings(designItem.element));
|
|
9
|
+
return iobBindings.map(x => ({
|
|
10
|
+
targetName: x[1].target == 'css' ? PropertiesHelper.camelToDashCase(x[0]) : x[0],
|
|
11
|
+
target: x[1].target,
|
|
12
|
+
mode: x[1].twoWay ? BindingMode.twoWay : BindingMode.oneWay,
|
|
13
|
+
invert: x[1].inverted,
|
|
14
|
+
bindableObjectNames: x[1].signal.split(';'),
|
|
15
|
+
expression: x[1].expression,
|
|
16
|
+
expressionTwoWay: x[1].expressionTwoWay,
|
|
17
|
+
converter: x[1].converter,
|
|
18
|
+
type: x[1].type,
|
|
19
|
+
changedEvents: x[1].events,
|
|
20
|
+
historic: x[1].historic
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
setBinding(designItem, binding) {
|
|
24
|
+
let bnd = { signal: binding.bindableObjectNames.join(';'), target: binding.target };
|
|
25
|
+
bnd.inverted = binding.invert;
|
|
26
|
+
bnd.twoWay = binding.mode == BindingMode.twoWay;
|
|
27
|
+
bnd.expression = binding.expression;
|
|
28
|
+
bnd.expressionTwoWay = binding.expressionTwoWay;
|
|
29
|
+
//@ts-ignore
|
|
30
|
+
bnd.historic = binding.historic;
|
|
31
|
+
bnd.type = binding.type;
|
|
32
|
+
bnd.converter = binding.converters;
|
|
33
|
+
bnd.target = binding.target;
|
|
34
|
+
bnd.events = binding.changedEvents;
|
|
35
|
+
let serializedBnd = this._bindingsHelper.serializeBinding(designItem.element, binding.targetName, bnd);
|
|
36
|
+
let group = designItem.openGroup('edit_binding');
|
|
37
|
+
designItem.setAttribute(serializedBnd[0], serializedBnd[1]);
|
|
38
|
+
group.commit();
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
clearBinding(designItem, propertyName, propertyTarget) {
|
|
42
|
+
const name = this._bindingsHelper.getBindingAttributeName(designItem.element, propertyName, propertyTarget);
|
|
43
|
+
designItem.removeAttribute(name);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IProperty, IDesignItem, IPropertyGridDragDropService } from "@node-projects/web-component-designer";
|
|
2
|
+
export declare class PropertyGridDragDropService implements IPropertyGridDragDropService {
|
|
3
|
+
rectMap: Map<Element, SVGRectElement>;
|
|
4
|
+
rect: SVGRectElement;
|
|
5
|
+
dragOverOnProperty?(event: DragEvent, property: IProperty, designItems: IDesignItem[]): 'none' | 'copy' | 'link' | 'move';
|
|
6
|
+
dropOnProperty?(event: DragEvent, property: IProperty, dropObject: any, designItems: IDesignItem[]): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export class PropertyGridDragDropService {
|
|
2
|
+
rectMap = new Map();
|
|
3
|
+
rect;
|
|
4
|
+
dragOverOnProperty(event, property, designItems) {
|
|
5
|
+
return 'copy';
|
|
6
|
+
}
|
|
7
|
+
dropOnProperty(event, property, dropObject, designItems) {
|
|
8
|
+
property.service.setValue(designItems, property, dropObject.text);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IDesignItem, IRefactorService, IRefactoring } from "@node-projects/web-component-designer";
|
|
2
|
+
export declare class ScriptRefactorService implements IRefactorService {
|
|
3
|
+
getRefactorings(designItems: IDesignItem[]): (IRefactoring & {
|
|
4
|
+
refactor: (newValue: any) => void;
|
|
5
|
+
})[];
|
|
6
|
+
refactor(refactoring: (IRefactoring & {
|
|
7
|
+
refactor: (newValue: any) => void;
|
|
8
|
+
}), oldValue: string, newValue: string): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { BindingTarget } from "@node-projects/web-component-designer";
|
|
2
|
+
export class ScriptRefactorService {
|
|
3
|
+
getRefactorings(designItems) {
|
|
4
|
+
let refactorings = [];
|
|
5
|
+
for (let d of designItems) {
|
|
6
|
+
for (let a of d.attributes()) {
|
|
7
|
+
if (a[0][0] == '@') {
|
|
8
|
+
let sc = a[1];
|
|
9
|
+
if (sc[0] == '{') {
|
|
10
|
+
let script = JSON.parse(sc);
|
|
11
|
+
if ('commands' in script) {
|
|
12
|
+
for (let c of script.commands) {
|
|
13
|
+
for (let p in c) {
|
|
14
|
+
let cp = c[p];
|
|
15
|
+
if (typeof cp === 'object') {
|
|
16
|
+
let mp = cp;
|
|
17
|
+
if (mp.source == 'signal') {
|
|
18
|
+
refactorings.push({ name: mp.name, itemType: 'bindableObject', target: BindingTarget.event, targetName: a[0], service: this, designItem: d, type: 'script', sourceObject: script, display: c.type + '/' + p, refactor: newValue => mp.name = newValue });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
switch (c.type) {
|
|
23
|
+
case 'SetSignalValue':
|
|
24
|
+
if (c.signal)
|
|
25
|
+
refactorings.push({ name: c.signal, itemType: 'bindableObject', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
|
|
26
|
+
break;
|
|
27
|
+
case 'ToggleSignalValue':
|
|
28
|
+
if (c.signal)
|
|
29
|
+
refactorings.push({ name: c.signal, itemType: 'bindableObject', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
|
|
30
|
+
break;
|
|
31
|
+
case 'IncrementSignalValue':
|
|
32
|
+
if (c.signal)
|
|
33
|
+
refactorings.push({ name: c.signal, itemType: 'bindableObject', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
|
|
34
|
+
break;
|
|
35
|
+
case 'DecrementSignalValue':
|
|
36
|
+
if (c.signal)
|
|
37
|
+
refactorings.push({ name: c.signal, itemType: 'bindableObject', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
|
|
38
|
+
break;
|
|
39
|
+
case 'SetBitInSignal':
|
|
40
|
+
if (c.signal)
|
|
41
|
+
refactorings.push({ name: c.signal, itemType: 'bindableObject', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
|
|
42
|
+
break;
|
|
43
|
+
case 'ClearBitInSignal':
|
|
44
|
+
if (c.signal)
|
|
45
|
+
refactorings.push({ name: c.signal, itemType: 'bindableObject', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
|
|
46
|
+
break;
|
|
47
|
+
case 'ToggleBitInSignal':
|
|
48
|
+
if (c.signal)
|
|
49
|
+
refactorings.push({ name: c.signal, itemType: 'bindableObject', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
|
|
50
|
+
break;
|
|
51
|
+
case 'OpenScreen':
|
|
52
|
+
if (c.screen)
|
|
53
|
+
refactorings.push({ name: c.screen, itemType: 'screenName', target: BindingTarget.event, targetName: a[0], display: c.type + '/screen', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.screen = newValue });
|
|
54
|
+
break;
|
|
55
|
+
case 'OpenDialog':
|
|
56
|
+
if (c.screen)
|
|
57
|
+
refactorings.push({ name: c.screen, itemType: 'screenName', target: BindingTarget.event, targetName: a[0], display: c.type + '/screen', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.screen = newValue });
|
|
58
|
+
break;
|
|
59
|
+
case 'CalculateSignalValue':
|
|
60
|
+
if (c.targetSignal)
|
|
61
|
+
refactorings.push({ name: c.targetSignal, itemType: 'bindableObject', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.targetSignal = newValue });
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if ('blocks' in script) {
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return refactorings;
|
|
73
|
+
}
|
|
74
|
+
refactor(refactoring, oldValue, newValue) {
|
|
75
|
+
refactoring.refactor(newValue);
|
|
76
|
+
let scriptString = JSON.stringify(refactoring.sourceObject);
|
|
77
|
+
refactoring.designItem.setAttribute(refactoring.targetName, scriptString);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BasePropertyEditor, IProperty, ValueType } from "@node-projects/web-component-designer";
|
|
2
|
+
import { VisualizationShell } from "../interfaces/VisualizationShell.js";
|
|
3
|
+
export declare class SignalPropertyEditor extends BasePropertyEditor<HTMLElement> {
|
|
4
|
+
_ip: HTMLInputElement;
|
|
5
|
+
constructor(property: IProperty, shell: VisualizationShell);
|
|
6
|
+
refreshValue(valueType: ValueType, value: any): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BasePropertyEditor } from "@node-projects/web-component-designer";
|
|
2
|
+
import { BindableObjectsBrowser } from "@node-projects/web-component-designer-widgets-wunderbaum";
|
|
3
|
+
export class SignalPropertyEditor extends BasePropertyEditor {
|
|
4
|
+
_ip;
|
|
5
|
+
constructor(property, shell) {
|
|
6
|
+
super(property);
|
|
7
|
+
let cnt = document.createElement('div');
|
|
8
|
+
cnt.style.display = 'flex';
|
|
9
|
+
this._ip = document.createElement('input');
|
|
10
|
+
this._ip.onchange = (e) => this._valueChanged(this._ip.value);
|
|
11
|
+
this._ip.onfocus = (e) => {
|
|
12
|
+
this._ip.selectionStart = 0;
|
|
13
|
+
this._ip.selectionEnd = this._ip.value?.length;
|
|
14
|
+
};
|
|
15
|
+
cnt.appendChild(this._ip);
|
|
16
|
+
let btn = document.createElement('button');
|
|
17
|
+
btn.textContent = '...';
|
|
18
|
+
btn.onclick = async () => {
|
|
19
|
+
let b = new BindableObjectsBrowser();
|
|
20
|
+
b.initialize(this.designItems[0].serviceContainer);
|
|
21
|
+
b.title = 'select signal...';
|
|
22
|
+
const abortController = new AbortController();
|
|
23
|
+
b.objectDoubleclicked.on(() => {
|
|
24
|
+
abortController.abort();
|
|
25
|
+
this._ip.value = b.selectedObject.fullName;
|
|
26
|
+
this._valueChanged(this._ip.value);
|
|
27
|
+
});
|
|
28
|
+
let res = await shell.openConfirmation(b, { x: 100, y: 100, width: 400, height: 300, abortSignal: abortController.signal });
|
|
29
|
+
if (res) {
|
|
30
|
+
this._ip.value = b.selectedObject.fullName;
|
|
31
|
+
this._valueChanged(this._ip.value);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
cnt.appendChild(btn);
|
|
35
|
+
this.element = cnt;
|
|
36
|
+
}
|
|
37
|
+
refreshValue(valueType, value) {
|
|
38
|
+
if (value == null)
|
|
39
|
+
this._ip.value = "";
|
|
40
|
+
else
|
|
41
|
+
this._ip.value = value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "web-component-designer addon for visualizations",
|
|
3
|
+
"name": "@node-projects/web-component-designer-visualization-addons",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"author": "jochen.kuehner@gmx.de",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"tsc": "tsc",
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"prepublishOnly": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@node-projects/base-custom-webcomponent": ">=0.19.0",
|
|
16
|
+
"@node-projects/web-component-designer": ">=0.1.1",
|
|
17
|
+
"@node-projects/web-component-designer-widgets-wunderbaum": ">=0.1.12",
|
|
18
|
+
"@node-projects/web-component-designer-codeview-monaco": ">=0.1.18",
|
|
19
|
+
"@node-projects/propertygrid.webcomponent": ">=1.0.2",
|
|
20
|
+
"@node-projects/splitview.webcomponent": ">=1.0.1",
|
|
21
|
+
"@blockly/zoom-to-fit": "^5.0.11",
|
|
22
|
+
"blockly": "^10.4.2",
|
|
23
|
+
"long": "^5.2.3"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/node-projects/web-component-designer.git"
|
|
28
|
+
}
|
|
29
|
+
}
|