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

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.
@@ -42,8 +42,8 @@ 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: string, element: Element, root: HTMLElement): Promise<CSSStyleSheet>;
46
- parseCssBinding(value: string, element: Element, root: HTMLElement): string;
45
+ parseCssBindings(sheet: string, element: Element, relativeSignalPath: string, root: HTMLElement): Promise<[stylesheet: CSSStyleSheet, unsub: (() => void)[]]>;
46
+ parseCssBinding(value: string, element: Element, relativeSignalPath: string, root: HTMLElement): [name: string, unsub: (() => void)[]];
47
47
  applyBinding(element: Element, binding: namedBinding, relativeSignalPath: string, root: HTMLElement): () => void;
48
48
  private addTwoWayBinding;
49
49
  private static parseValueWithType;
@@ -392,25 +392,32 @@ export class BindingsHelper {
392
392
  return retVal;
393
393
  }
394
394
  static #cssBindingsVarId = 0;
395
- async parseCssBindings(sheet, element, root) {
395
+ async parseCssBindings(sheet, element, relativeSignalPath, root) {
396
396
  const parser = (await import("@adobe/css-tools"));
397
397
  const ast = parser.parse(sheet);
398
+ let unsub;
398
399
  for (let r of ast.stylesheet.rules) {
399
400
  if (r.type === parser.CssTypes.rule) {
400
401
  for (const d of r.declarations) {
401
402
  if (d.type === parser.CssTypes.declaration) {
402
403
  if (d.value.includes(bindingPrefixInsideCss)) {
403
- const newValue = this.parseCssBinding(d.value, element, root);
404
- d.value = newValue;
404
+ const newValue = this.parseCssBinding(d.value, element, relativeSignalPath, root);
405
+ d.value = newValue[0];
406
+ if (unsub) {
407
+ unsub.push(...newValue[1]);
408
+ }
409
+ else {
410
+ unsub = newValue[1];
411
+ }
405
412
  }
406
413
  }
407
414
  }
408
415
  }
409
416
  }
410
417
  const newStyle = parser.stringify(ast, { indent: '', compress: true });
411
- return cssFromString(newStyle);
418
+ return [cssFromString(newStyle), unsub];
412
419
  }
413
- parseCssBinding(value, element, root) {
420
+ parseCssBinding(value, element, relativeSignalPath, root) {
414
421
  value = value.trim();
415
422
  let res = '';
416
423
  let tmp = '';
@@ -418,6 +425,7 @@ export class BindingsHelper {
418
425
  let binding = '';
419
426
  let escape = false;
420
427
  let quote = null;
428
+ let unsub = [];
421
429
  for (let n = 0; n < value.length; n++) {
422
430
  const c = value[n];
423
431
  if (inBind) {
@@ -434,9 +442,10 @@ export class BindingsHelper {
434
442
  if (binding.startsWith('{')) {
435
443
  bnd = JSON.parse(binding);
436
444
  }
437
- this.applyBinding(element, bnd, '', root);
445
+ unsub.push(this.applyBinding(element, bnd, relativeSignalPath, root));
438
446
  res += 'var(' + varName + ')';
439
447
  inBind = false;
448
+ binding = '';
440
449
  }
441
450
  else
442
451
  binding += c;
@@ -466,7 +475,7 @@ export class BindingsHelper {
466
475
  tmp += c;
467
476
  }
468
477
  }
469
- return res + tmp;
478
+ return [res + tmp, unsub];
470
479
  }
471
480
  applyBinding(element, binding, relativeSignalPath, root) {
472
481
  let unsubscribeList = [];
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.29",
4
+ "version": "0.1.31",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",