@node-projects/web-component-designer-visualization-addons 0.1.28 → 0.1.29

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 CHANGED
@@ -15,5 +15,6 @@ It is used for example by the iobroker.webui.
15
15
 
16
16
  - long
17
17
  - blockly
18
+ - @adobe/css-tools ( only if you use Bindingshelper.parseCssBindings() )
18
19
 
19
20
  ## Usage
@@ -42,7 +42,7 @@ export declare class BindingsHelper {
42
42
  getBindingAttributeName(element: Element, propertyName: string, propertyTarget: BindingTarget): string;
43
43
  getBindings(element: Element): Generator<namedBinding, void, unknown>;
44
44
  applyAllBindings(rootElement: ParentNode, relativeSignalPath: string, root: HTMLElement): (() => void)[];
45
- parseCssBindings(sheet: CSSStyleSheet, element: Element, root: HTMLElement): void;
45
+ parseCssBindings(sheet: string, element: Element, root: HTMLElement): Promise<CSSStyleSheet>;
46
46
  parseCssBinding(value: string, element: Element, root: HTMLElement): string;
47
47
  applyBinding(element: Element, binding: namedBinding, relativeSignalPath: string, root: HTMLElement): () => void;
48
48
  private addTwoWayBinding;
@@ -1,4 +1,4 @@
1
- import { TypedEvent } from "@node-projects/base-custom-webcomponent";
1
+ import { TypedEvent, cssFromString } from "@node-projects/base-custom-webcomponent";
2
2
  import { BindingTarget } from "@node-projects/web-component-designer/dist/elements/item/BindingTarget.js";
3
3
  import { PropertiesHelper } from "@node-projects/web-component-designer/dist/elements/services/propertiesService/services/PropertiesHelper.js";
4
4
  //;,[ are not allowed in bindings, so they could be used for a short form...
@@ -392,18 +392,23 @@ export class BindingsHelper {
392
392
  return retVal;
393
393
  }
394
394
  static #cssBindingsVarId = 0;
395
- parseCssBindings(sheet, element, root) {
396
- for (let r of sheet.cssRules) {
397
- if (r instanceof CSSStyleRule) {
398
- for (const s of r.style) {
399
- const v = r.style.getPropertyValue(s);
400
- if (v.includes(bindingPrefixInsideCss)) {
401
- const newValue = this.parseCssBinding(v, element, root);
402
- r.style.setProperty(s, newValue);
395
+ async parseCssBindings(sheet, element, root) {
396
+ const parser = (await import("@adobe/css-tools"));
397
+ const ast = parser.parse(sheet);
398
+ for (let r of ast.stylesheet.rules) {
399
+ if (r.type === parser.CssTypes.rule) {
400
+ for (const d of r.declarations) {
401
+ if (d.type === parser.CssTypes.declaration) {
402
+ if (d.value.includes(bindingPrefixInsideCss)) {
403
+ const newValue = this.parseCssBinding(d.value, element, root);
404
+ d.value = newValue;
405
+ }
403
406
  }
404
407
  }
405
408
  }
406
409
  }
410
+ const newStyle = parser.stringify(ast, { indent: '', compress: true });
411
+ return cssFromString(newStyle);
407
412
  }
408
413
  parseCssBinding(value, element, root) {
409
414
  value = value.trim();
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.28",
4
+ "version": "0.1.29",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",
@@ -13,15 +13,16 @@
13
13
  "prepublishOnly": "npm run build"
14
14
  },
15
15
  "dependencies": {
16
+ "@adobe/css-tools": "^4.3.3",
17
+ "@blockly/zoom-to-fit": "^5.0.11",
16
18
  "@node-projects/base-custom-webcomponent": ">=0.19.0",
17
- "@node-projects/web-component-designer": ">=0.1.1",
18
- "@node-projects/web-component-designer-widgets-wunderbaum": ">=0.1.12",
19
- "@node-projects/web-component-designer-codeview-monaco": ">=0.1.18",
20
19
  "@node-projects/propertygrid.webcomponent": ">=1.0.2",
21
20
  "@node-projects/splitview.webcomponent": ">=1.0.1",
22
- "@blockly/zoom-to-fit": "^5.0.11",
21
+ "@node-projects/web-component-designer": ">=0.1.1",
22
+ "@node-projects/web-component-designer-codeview-monaco": ">=0.1.18",
23
+ "@node-projects/web-component-designer-widgets-wunderbaum": ">=0.1.12",
23
24
  "blockly": "^10.4.2",
24
- "long": "^5.2.3"
25
+ "long": "^5.2.3"
25
26
  },
26
27
  "repository": {
27
28
  "type": "git",