@node-projects/web-component-designer-visualization-addons 0.1.120 → 0.1.121
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.
|
@@ -30,6 +30,7 @@ export declare function parseBindingString(id: string): {
|
|
|
30
30
|
export declare class BindingsHelper {
|
|
31
31
|
#private;
|
|
32
32
|
_visualizationHandler: VisualizationHandler;
|
|
33
|
+
namedConverterCallback: (converter: string, value: any, element: Element, binding: namedBinding) => any;
|
|
33
34
|
constructor(visualizationHandler: VisualizationHandler);
|
|
34
35
|
getChangedEventName(element: Element, propertyName: string): string;
|
|
35
36
|
parseBinding(element: Element, name: string, value: string, bindingTarget: BindingTarget, prefix: string): namedBinding;
|
|
@@ -64,6 +64,11 @@ class IndirectSignal {
|
|
|
64
64
|
root.addEventListener(evtName, (evtCallback));
|
|
65
65
|
this.cleanupCalls.push(() => root.removeEventListener(evtName, evtCallback));
|
|
66
66
|
continue;
|
|
67
|
+
//} else if (nm[0] === '?' && nm[1] === '$') {
|
|
68
|
+
// const attrNm = nm.substring(2);
|
|
69
|
+
// let val = root.getAttribute(attrNm);
|
|
70
|
+
// this.handleValueChanged(val, i);
|
|
71
|
+
// continue;
|
|
67
72
|
}
|
|
68
73
|
else if (nm[0] === '#' && nm[1] === '#') {
|
|
69
74
|
const propNm = nm.substring(2);
|
|
@@ -73,6 +78,11 @@ class IndirectSignal {
|
|
|
73
78
|
element.addEventListener(evtName, (evtCallback));
|
|
74
79
|
this.cleanupCalls.push(() => element.removeEventListener(evtName, evtCallback));
|
|
75
80
|
continue;
|
|
81
|
+
//} else if (nm[0] === '#' && nm[1] === '$') {
|
|
82
|
+
// const attrNm = nm.substring(2);
|
|
83
|
+
// let val = element.getAttribute(attrNm);
|
|
84
|
+
// this.handleValueChanged(val, i);
|
|
85
|
+
// continue;
|
|
76
86
|
}
|
|
77
87
|
else if (nm[0] === '?') {
|
|
78
88
|
//TODO: react to changes of signal name in prop
|
|
@@ -136,6 +146,7 @@ class IndirectSignal {
|
|
|
136
146
|
}
|
|
137
147
|
export class BindingsHelper {
|
|
138
148
|
_visualizationHandler;
|
|
149
|
+
namedConverterCallback;
|
|
139
150
|
constructor(visualizationHandler) {
|
|
140
151
|
this._visualizationHandler = visualizationHandler;
|
|
141
152
|
}
|
|
@@ -830,50 +841,55 @@ export class BindingsHelper {
|
|
|
830
841
|
valuesObject[signalVarNames.length - 1] = v;
|
|
831
842
|
}
|
|
832
843
|
if (binding[1].converter) {
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
v = new Function(signalVarNames, 'return `' + binding[1].converter[stringValue] + '`')(...valuesObject);
|
|
844
|
+
if (binding[1].converter) {
|
|
845
|
+
v = this.namedConverterCallback(binding[1].converter, v, element, binding);
|
|
836
846
|
}
|
|
837
847
|
else {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
break;
|
|
848
|
+
const stringValue = (v != null ? v.toString() : v);
|
|
849
|
+
if (stringValue in binding[1].converter) {
|
|
850
|
+
v = new Function(signalVarNames, 'return `' + binding[1].converter[stringValue] + '`')(...valuesObject);
|
|
851
|
+
}
|
|
852
|
+
else {
|
|
853
|
+
//@ts-ignore
|
|
854
|
+
const nr = parseFloat(v);
|
|
855
|
+
for (let c in binding[1].converter) {
|
|
856
|
+
if (c.length > 2 && c[0] === '>' && c[1] === '=') {
|
|
857
|
+
const wr = parseFloat(c.substring(2));
|
|
858
|
+
if (nr >= wr) {
|
|
859
|
+
v = new Function(signalVarNames, 'return `' + binding[1].converter[c] + '`')(...valuesObject);
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
853
862
|
}
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
863
|
+
else if (c.length > 2 && c[0] === '<' && c[1] === '=') {
|
|
864
|
+
const wr = parseFloat(c.substring(2));
|
|
865
|
+
if (nr <= wr) {
|
|
866
|
+
v = new Function(signalVarNames, 'return `' + binding[1].converter[c] + '`')(...valuesObject);
|
|
867
|
+
break;
|
|
868
|
+
}
|
|
860
869
|
}
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
870
|
+
else if (c.length > 1 && c[0] === '>') {
|
|
871
|
+
const wr = parseFloat(c.substring(1));
|
|
872
|
+
if (nr > wr) {
|
|
873
|
+
v = new Function(signalVarNames, 'return `' + binding[1].converter[c] + '`')(...valuesObject);
|
|
874
|
+
break;
|
|
875
|
+
}
|
|
867
876
|
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
if (sp.length > 1) {
|
|
872
|
-
if ((sp[0] === '' || nr >= parseFloat(sp[0])) && (sp[1] === '' || parseFloat(sp[1]) >= nr)) {
|
|
877
|
+
else if (c.length > 1 && c[0] === '<') {
|
|
878
|
+
const wr = parseFloat(c.substring(1));
|
|
879
|
+
if (nr < wr) {
|
|
873
880
|
v = new Function(signalVarNames, 'return `' + binding[1].converter[c] + '`')(...valuesObject);
|
|
874
881
|
break;
|
|
875
882
|
}
|
|
876
883
|
}
|
|
884
|
+
else {
|
|
885
|
+
const sp = c.split('-');
|
|
886
|
+
if (sp.length > 1) {
|
|
887
|
+
if ((sp[0] === '' || nr >= parseFloat(sp[0])) && (sp[1] === '' || parseFloat(sp[1]) >= nr)) {
|
|
888
|
+
v = new Function(signalVarNames, 'return `' + binding[1].converter[c] + '`')(...valuesObject);
|
|
889
|
+
break;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
}
|
|
877
893
|
}
|
|
878
894
|
}
|
|
879
895
|
}
|
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.121",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "jochen.kuehner@gmx.de",
|