@node-projects/web-component-designer-visualization-addons 0.1.128 → 0.1.130

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.
@@ -8,7 +8,7 @@ export class BindingsEditor extends BaseCustomWebComponentConstructorAppend {
8
8
  <div style="grid-column: 1/3">
9
9
  <div style="display: flex; flex-direction: column;">
10
10
  <div class="row">
11
- <span style="cursor: pointer;" title="to use multiple objects, seprate them with semicolon (;).&#010;Access signal objects in properties via ?propertyName, access the propertyValue via ??propertyName.&#010;Access signal objects in properties of the target via #propertyName, access a propertyValue of the target via ##propertyName.&#010;Bind to signal configurations via $objectId.&#010;You could also use signals inside of a Signal Name via {name}">objects</span>
11
+ <span style="cursor: pointer;" title="to use multiple objects, seprate them with semicolon (;).&#010;Access signal objects in properties via ?propertyName, access the propertyValue via ??propertyName.&#010;Access signal objects in properties of the target via #propertyName, access a propertyValue of the target via ##propertyName.&#010;Bind to signal configurations via $objectId.&#010;Bind to special values via §name (if supported by your framework).&#010;You could also use signals inside of a Signal Name via {name}">objects</span>
12
12
  </div>
13
13
  <div id="groupObjectName" style="display:flex;align-items: flex-end;">
14
14
  <input id="objectName" class="row" value="{{?this.objectNames::change}}" style="flex-grow: 1;">
@@ -4,11 +4,11 @@ import { BindingTarget } from "@node-projects/web-component-designer/dist/elemen
4
4
  export type SpecialValueHandler = {
5
5
  valueProvider: (propertyName: string, context: {
6
6
  element: Element;
7
- binding: namedBinding;
7
+ binding?: namedBinding;
8
8
  relativeSignalPath: string;
9
9
  root: HTMLElement;
10
10
  [key: string]: any;
11
- }) => any;
11
+ }) => Promise<any> | any;
12
12
  valueChangedCallbacks: Map<string, (() => void)[]>;
13
13
  };
14
14
  export declare const bindingPrefixProperty = "bind-prop:";
@@ -57,7 +57,7 @@ class IndirectSignal {
57
57
  visualizationHandler;
58
58
  element;
59
59
  relativeSignalPath;
60
- constructor(bindingsHelper, visualizationHandler, id, valueChangedCb, element, relativeSignalPath, root) {
60
+ constructor(bindingsHelper, visualizationHandler, id, valueChangedCb, element, relativeSignalPath, root, specialValueHandler) {
61
61
  this.visualizationHandler = visualizationHandler;
62
62
  this.valueChangedCb = valueChangedCb;
63
63
  this.element = element;
@@ -96,6 +96,28 @@ class IndirectSignal {
96
96
  }
97
97
  continue;
98
98
  }
99
+ else if (nm[0] === '§') {
100
+ const mS = nm.substring(1);
101
+ const value = specialValueHandler.valueProvider(mS, { element, relativeSignalPath, root });
102
+ if (value instanceof Promise)
103
+ value.then(v => this.handleValueChanged(v, i));
104
+ else
105
+ this.handleValueChanged(value, i);
106
+ if (!specialValueHandler.valueChangedCallbacks)
107
+ specialValueHandler.valueChangedCallbacks = new Map();
108
+ let changeList = specialValueHandler.valueChangedCallbacks.get(mS);
109
+ if (changeList == null) {
110
+ changeList = [];
111
+ specialValueHandler.valueChangedCallbacks.set(mS, changeList);
112
+ }
113
+ changeList.push(() => {
114
+ const value = specialValueHandler.valueProvider(mS, { element, relativeSignalPath, root });
115
+ if (value instanceof Promise)
116
+ value.then(v => this.handleValueChanged(v, i));
117
+ else
118
+ this.handleValueChanged(value, i);
119
+ });
120
+ }
99
121
  else if (nm[0] === '?') {
100
122
  //TODO: react to changes of signal name in prop
101
123
  if (!nm.includes('.')) {
@@ -731,7 +753,10 @@ export class BindingsHelper {
731
753
  else if (s[0] === '§') {
732
754
  const mS = s.substring(1);
733
755
  const value = specialValueHandler.valueProvider(mS, { element, binding, relativeSignalPath, root });
734
- this.handleValueChanged(element, binding, value, valuesObject, i, signalVars, true, relativeSignalPath);
756
+ if (value instanceof Promise)
757
+ value.then(v => this.handleValueChanged(element, binding, v, valuesObject, i, signalVars, true, relativeSignalPath));
758
+ else
759
+ this.handleValueChanged(element, binding, value, valuesObject, i, signalVars, true, relativeSignalPath);
735
760
  if (!specialValueHandler.valueChangedCallbacks)
736
761
  specialValueHandler.valueChangedCallbacks = new Map();
737
762
  let changeList = specialValueHandler.valueChangedCallbacks.get(mS);
@@ -741,12 +766,15 @@ export class BindingsHelper {
741
766
  }
742
767
  changeList.push(() => {
743
768
  const value = specialValueHandler.valueProvider(mS, { element, binding, relativeSignalPath, root });
744
- this.handleValueChanged(element, binding, value, valuesObject, i, signalVars, true, relativeSignalPath);
769
+ if (value instanceof Promise)
770
+ value.then(v => this.handleValueChanged(element, binding, v, valuesObject, i, signalVars, true, relativeSignalPath));
771
+ else
772
+ this.handleValueChanged(element, binding, value, valuesObject, i, signalVars, true, relativeSignalPath);
745
773
  });
746
774
  }
747
775
  else {
748
776
  if (s.includes('{')) {
749
- let indirectSignal = new IndirectSignal(this, this._visualizationHandler, s, (value) => this.handleValueChanged(element, binding, value.val, valuesObject, i, signalVars, false, relativeSignalPath), element, relativeSignalPath, root);
777
+ let indirectSignal = new IndirectSignal(this, this._visualizationHandler, s, (value) => this.handleValueChanged(element, binding, value.val, valuesObject, i, signalVars, false, relativeSignalPath), element, relativeSignalPath, root, specialValueHandler);
750
778
  if (!cleanupCalls)
751
779
  cleanupCalls = [];
752
780
  cleanupCalls.push(() => indirectSignal.dispose());
package/dist/index.d.ts CHANGED
@@ -9,11 +9,11 @@ export * from './components/VisualizationPropertyGrid.js';
9
9
  export * from './components/ParameterEditor.js';
10
10
  export * from './components/EventAssignment.js';
11
11
  export * from './helpers/BindingsHelper.js';
12
- export * from './interfaces/IScriptMultiplexValue.js';
13
- export * from './interfaces/VisualisationElementScript.js';
14
- export * from './interfaces/VisualizationBinding.js';
15
- export * from './interfaces/VisualizationHandler.js';
16
- export * from './interfaces/VisualizationShell.js';
12
+ export type * from './interfaces/IScriptMultiplexValue.js';
13
+ export type * from './interfaces/VisualisationElementScript.js';
14
+ export type * from './interfaces/VisualizationBinding.js';
15
+ export type * from './interfaces/VisualizationHandler.js';
16
+ export type * from './interfaces/VisualizationShell.js';
17
17
  export * from './scripting/Script.js';
18
18
  export * from './scripting/ScriptCommands.js';
19
19
  export * from './scripting/ScriptSystem.js';
package/dist/index.js CHANGED
@@ -9,11 +9,6 @@ export * from './components/VisualizationPropertyGrid.js';
9
9
  export * from './components/ParameterEditor.js';
10
10
  export * from './components/EventAssignment.js';
11
11
  export * from './helpers/BindingsHelper.js';
12
- export * from './interfaces/IScriptMultiplexValue.js';
13
- export * from './interfaces/VisualisationElementScript.js';
14
- export * from './interfaces/VisualizationBinding.js';
15
- export * from './interfaces/VisualizationHandler.js';
16
- export * from './interfaces/VisualizationShell.js';
17
12
  export * from './scripting/Script.js';
18
13
  export * from './scripting/ScriptCommands.js';
19
14
  export * from './scripting/ScriptSystem.js';
@@ -1,7 +1,8 @@
1
- export declare class IScriptMultiplexValue {
1
+ export interface IScriptMultiplexValue {
2
2
  /**
3
3
  * signal - read the value from a Signal
4
4
  * property - read the value from a property of the customControl (not usable in screens)
5
+ * signalInProperty - read the value from a Signal (wich name is in the Property)
5
6
  * event - read the value of a property of the event object
6
7
  * parameter - a parameter you hand over
7
8
  * context - a value of the context
@@ -10,7 +11,7 @@ export declare class IScriptMultiplexValue {
10
11
  * expression - js expression, 'ctx' is context object
11
12
  * elementProperty - a property defined on the element raising the event
12
13
  */
13
- source: 'signal' | 'property' | 'event' | 'parameter' | 'complexString' | 'complexSignal' | 'expression' | 'context' | 'elementProperty';
14
+ source: 'signal' | 'property' | 'signalInProperty' | 'event' | 'parameter' | 'complexString' | 'complexSignal' | 'expression' | 'context' | 'elementProperty';
14
15
  /**
15
16
  * Name of the signal, the property of the component or the parameter of the script
16
17
  * or for example in a event : srcElement.value to get the value of a input wich raises the event
@@ -1,20 +1 @@
1
- export class IScriptMultiplexValue {
2
- /**
3
- * signal - read the value from a Signal
4
- * property - read the value from a property of the customControl (not usable in screens)
5
- * event - read the value of a property of the event object
6
- * parameter - a parameter you hand over
7
- * context - a value of the context
8
- * complexString - a string with signals (contained in {})
9
- * complexSignal - read the value from a signal wich name is build here (it can contain other signals in {})
10
- * expression - js expression, 'ctx' is context object
11
- * elementProperty - a property defined on the element raising the event
12
- */
13
- source;
14
- /**
15
- * Name of the signal, the property of the component or the parameter of the script
16
- * or for example in a event : srcElement.value to get the value of a input wich raises the event
17
- * @TJS-format signal
18
- */
19
- name;
20
- }
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  export declare type ScriptCommands = RunnableScriptCommands | Comment | Condition | Exit | Label | Goto;
2
- export declare type RunnableScriptCommands = OpenScreen | OpenUrl | OpenDialog | CloseDialog | ToggleSignalValue | SetSignalValue | IncrementSignalValue | DecrementSignalValue | SetBitInSignal | ClearBitInSignal | ToggleBitInSignal | Console | CalculateSignalValue | Javascript | SetElementProperty | Delay | SwitchLanguage | Login | Logout | SubscribeSignal | UnsubscribeSignal | WriteSignalsInGroup | ClearSignalsInGroup | RunScript | CopySignalValuesFromFolder | ShowMessageBox | ExportSignalValuesAsJson | ImportSignalValuesFromJson;
2
+ export declare type RunnableScriptCommands = OpenScreen | OpenUrl | OpenDialog | CloseDialog | ToggleSignalValue | ToggleSignalValueFromList | SetSignalValue | IncrementSignalValue | DecrementSignalValue | SetBitInSignal | ClearBitInSignal | ToggleBitInSignal | Console | CalculateSignalValue | Javascript | SetElementProperty | Delay | SwitchLanguage | Login | Logout | SubscribeSignal | UnsubscribeSignal | WriteSignalsInGroup | ClearSignalsInGroup | RunScript | CopySignalValuesFromFolder | ShowMessageBox | ExportSignalValuesAsJson | ImportSignalValuesFromJson;
3
3
  /**
4
4
  * signal - a signal (the default)
5
5
  * property - a property defined in the current screen/control
@@ -114,6 +114,17 @@ export interface ToggleSignalValue {
114
114
  target: signalTarget;
115
115
  additionalData?: string;
116
116
  }
117
+ export interface ToggleSignalValueFromList {
118
+ type: 'ToggleSignalValueThroughList';
119
+ valueList: (string | number | boolean)[];
120
+ /**
121
+ * Name of the signal
122
+ * @TJS-format signal
123
+ */
124
+ signal: string;
125
+ target: signalTarget;
126
+ additionalData?: string;
127
+ }
117
128
  export interface IncrementSignalValue {
118
129
  type: 'IncrementSignalValue';
119
130
  /**
@@ -364,7 +375,7 @@ export interface Condition {
364
375
  */
365
376
  value1: any;
366
377
  value2?: any;
367
- comparisonType: '==null' | '!=null' | '==true' | '==false' | '==' | '!=' | '>' | '<' | '>=' | '<=';
378
+ comparisonType: '==null' | '!=null' | '==true' | '==false' | '==' | '!=' | '>' | '<' | '>=' | '<=' | '&&' | '||';
368
379
  /**
369
380
  * Name of the label to jumpe to when condition is true
370
381
  */
@@ -57,6 +57,12 @@ export class ScriptSystem {
57
57
  case '<=':
58
58
  res = value1 <= value2;
59
59
  break;
60
+ case '&&':
61
+ res = value1 && value2;
62
+ break;
63
+ case '||':
64
+ res = value1 || value2;
65
+ break;
60
66
  }
61
67
  if (res) {
62
68
  await this.runExternalScript(await this.getValue(c.trueScriptName, outerContext), await this.getValue(c.trueScriptType, outerContext));
@@ -139,6 +145,18 @@ export class ScriptSystem {
139
145
  await this._visualizationHandler.setState(this.getSignalName(signal, context), !state);
140
146
  break;
141
147
  }
148
+ case 'ToggleSignalValueThroughList': {
149
+ const valueList = await this.getValue(command.valueList, context);
150
+ const signal = await this.getValue(command.signal, context);
151
+ const target = await this.getValue(command.target, context);
152
+ let state = await this.getValueFromTarget(target, signal, context);
153
+ let nextIdx = valueList.indexOf(state) + 1;
154
+ if (nextIdx >= valueList.length)
155
+ nextIdx = 0;
156
+ const newState = valueList[nextIdx];
157
+ await this._visualizationHandler.setState(this.getSignalName(signal, context), newState);
158
+ break;
159
+ }
142
160
  case 'SetSignalValue': {
143
161
  const signal = await this.getValue(command.signal, context);
144
162
  const target = await this.getValue(command.target, context);
@@ -358,6 +376,11 @@ export class ScriptSystem {
358
376
  let sng = await this._visualizationHandler.getState(this.getSignalName(value.name, outerContext));
359
377
  return sng.val;
360
378
  }
379
+ case 'signalInProperty': {
380
+ const sngName = deepValue(outerContext.root, value.name);
381
+ let sng = await this._visualizationHandler.getState(this.getSignalName(sngName, outerContext));
382
+ return sng.val;
383
+ }
361
384
  case 'event': {
362
385
  let obj = outerContext.event;
363
386
  if (value.name)
@@ -402,11 +425,11 @@ export class ScriptSystem {
402
425
  var ctx = context;
403
426
  return eval('ctx.' + name.substring(1));
404
427
  }
405
- else if (name[0] === '?' && name[1] === '??') {
428
+ else if (name[0] === '?' && name[1] === '?') {
406
429
  return context.root[name.substring(2)];
407
430
  }
408
431
  else if (name[0] === '?') {
409
- return await this._visualizationHandler.getState(this.getSignalName(context.root[name.substring(2)], context));
432
+ return await this._visualizationHandler.getState(this.getSignalName(context.root[name.substring(1)], context));
410
433
  }
411
434
  return await this._visualizationHandler.getState(this.getSignalName(name, context));
412
435
  }
@@ -1,5 +1,5 @@
1
1
  import { ScriptCommands, SetElementProperty } from "./ScriptCommands";
2
2
  export declare class ScriptUpgrades {
3
- static upgradeScriptCommand(scriptCommand: ScriptCommands): SetElementProperty | import("./ScriptCommands").OpenScreen | import("./ScriptCommands").OpenUrl | import("./ScriptCommands").OpenDialog | import("./ScriptCommands").CloseDialog | import("./ScriptCommands").ToggleSignalValue | import("./ScriptCommands").SetSignalValue | import("./ScriptCommands").IncrementSignalValue | import("./ScriptCommands").DecrementSignalValue | import("./ScriptCommands").SetBitInSignal | import("./ScriptCommands").ClearBitInSignal | import("./ScriptCommands").ToggleBitInSignal | import("./ScriptCommands").Console | import("./ScriptCommands").CalculateSignalValue | import("./ScriptCommands").Javascript | import("./ScriptCommands").Delay | import("./ScriptCommands").SwitchLanguage | import("./ScriptCommands").Login | import("./ScriptCommands").Logout | import("./ScriptCommands").SubscribeSignal | import("./ScriptCommands").UnsubscribeSignal | import("./ScriptCommands").WriteSignalsInGroup | import("./ScriptCommands").ClearSignalsInGroup | import("./ScriptCommands").RunScript | import("./ScriptCommands").CopySignalValuesFromFolder | import("./ScriptCommands").ShowMessageBox | import("./ScriptCommands").ExportSignalValuesAsJson | import("./ScriptCommands").ImportSignalValuesFromJson | import("./ScriptCommands").Comment | import("./ScriptCommands").Condition | import("./ScriptCommands").Exit | import("./ScriptCommands").Label | import("./ScriptCommands").Goto;
3
+ static upgradeScriptCommand(scriptCommand: ScriptCommands): SetElementProperty | import("./ScriptCommands").OpenScreen | import("./ScriptCommands").OpenUrl | import("./ScriptCommands").OpenDialog | import("./ScriptCommands").CloseDialog | import("./ScriptCommands").ToggleSignalValue | import("./ScriptCommands").ToggleSignalValueFromList | import("./ScriptCommands").SetSignalValue | import("./ScriptCommands").IncrementSignalValue | import("./ScriptCommands").DecrementSignalValue | import("./ScriptCommands").SetBitInSignal | import("./ScriptCommands").ClearBitInSignal | import("./ScriptCommands").ToggleBitInSignal | import("./ScriptCommands").Console | import("./ScriptCommands").CalculateSignalValue | import("./ScriptCommands").Javascript | import("./ScriptCommands").Delay | import("./ScriptCommands").SwitchLanguage | import("./ScriptCommands").Login | import("./ScriptCommands").Logout | import("./ScriptCommands").SubscribeSignal | import("./ScriptCommands").UnsubscribeSignal | import("./ScriptCommands").WriteSignalsInGroup | import("./ScriptCommands").ClearSignalsInGroup | import("./ScriptCommands").RunScript | import("./ScriptCommands").CopySignalValuesFromFolder | import("./ScriptCommands").ShowMessageBox | import("./ScriptCommands").ExportSignalValuesAsJson | import("./ScriptCommands").ImportSignalValuesFromJson | import("./ScriptCommands").Comment | import("./ScriptCommands").Condition | import("./ScriptCommands").Exit | import("./ScriptCommands").Label | import("./ScriptCommands").Goto;
4
4
  static upgradeSetElementProperty(scriptCommand: SetElementProperty): SetElementProperty;
5
5
  }
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.128",
4
+ "version": "0.1.130",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",