@node-projects/web-component-designer 0.0.182 → 0.0.184

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.
@@ -4,3 +4,5 @@ export declare function sleep(ms: any): Promise<unknown>;
4
4
  export declare function exportData(blob: Blob, fileName: string): Promise<void>;
5
5
  export declare function dataURItoBlob(dataURI: any): Blob;
6
6
  export declare function pointInRect(point: IPoint, rect: IRect): boolean;
7
+ export declare function removeTrailing(text: string, char: string): string;
8
+ export declare function removeLeading(text: string, char: string): string;
@@ -24,3 +24,13 @@ export function dataURItoBlob(dataURI) {
24
24
  export function pointInRect(point, rect) {
25
25
  return point.x >= rect.x && point.x <= rect.x + rect.width && point.y >= rect.y && point.y <= rect.y + rect.height;
26
26
  }
27
+ export function removeTrailing(text, char) {
28
+ if (text.endsWith('/'))
29
+ return text.substring(0, text.length - 1);
30
+ return text;
31
+ }
32
+ export function removeLeading(text, char) {
33
+ if (text.startsWith('/'))
34
+ return text.substring(1);
35
+ return text;
36
+ }
@@ -1,3 +1,4 @@
1
+ import { removeLeading, removeTrailing } from "../../helper/Helper.js";
1
2
  export class WebcomponentManifestElementsService {
2
3
  _name;
3
4
  get name() { return this._name; }
@@ -15,7 +16,7 @@ export class WebcomponentManifestElementsService {
15
16
  for (let m of manifest.modules) {
16
17
  for (let e of m.exports) {
17
18
  if (e.kind == 'custom-element-definition') {
18
- let elDef = { tag: e.name, import: this._importPrefix + (this._importPrefix.endsWith('/') ? '' : '/') + e.declaration.module, defaultWidth: "200px", defaultHeight: "200px", className: e.declaration.name };
19
+ let elDef = { tag: e.name, import: removeTrailing(this._importPrefix, '/') + '/' + removeLeading(e.declaration.module, '/'), defaultWidth: "200px", defaultHeight: "200px", className: e.declaration.name };
19
20
  this._elementList.push(elDef);
20
21
  }
21
22
  }
@@ -2,6 +2,7 @@ import { BindingTarget } from '../../item/BindingTarget.js';
2
2
  import { RefreshMode } from '../propertiesService/IPropertiesService.js';
3
3
  import { PropertyType } from '../propertiesService/PropertyType.js';
4
4
  import { AbstractPropertiesService } from '../propertiesService/services/AbstractPropertiesService.js';
5
+ import { removeLeading, removeTrailing } from '../../helper/Helper.js';
5
6
  export class WebcomponentManifestParserService extends AbstractPropertiesService {
6
7
  getRefreshMode(designItem) {
7
8
  return RefreshMode.none;
@@ -42,7 +43,7 @@ export class WebcomponentManifestParserService extends AbstractPropertiesService
42
43
  for (let m of this._packageData.modules) {
43
44
  for (let e of m.exports) {
44
45
  if (e.kind == 'custom-element-definition') {
45
- this._elementList.push({ tag: e.name, import: this._importPrefix + (this._importPrefix.endsWith('/') ? '' : '/') + e.declaration.module });
46
+ this._elementList.push({ tag: e.name, import: removeTrailing(this._importPrefix, '/') + '/' + removeLeading(e.declaration.module, '/') });
46
47
  let properties = [];
47
48
  let declaration = m.declarations.find(x => x.name == e.declaration.name);
48
49
  for (let d of declaration.members) {
@@ -50,7 +51,8 @@ export class WebcomponentManifestParserService extends AbstractPropertiesService
50
51
  let pType = PropertyType.property;
51
52
  if (declaration.attributes)
52
53
  pType = declaration.attributes.find(x => x.fieldName == d.name) != null ? PropertyType.propertyAndAttribute : PropertyType.property;
53
- properties.push({ name: d.name, service: this, propertyType: pType, type: this.manifestClassPropertyTypeToEditorPropertyType(d.type?.text) });
54
+ const p = this.manifestClassPropertyTypeToEditorPropertyType(d.type?.text);
55
+ properties.push({ name: d.name, service: this, propertyType: pType, type: p[0], values: p[1] });
54
56
  }
55
57
  }
56
58
  this._propertiesList[e.name] = properties;
@@ -66,11 +68,17 @@ export class WebcomponentManifestParserService extends AbstractPropertiesService
66
68
  manifestClassPropertyTypeToEditorPropertyType(type) {
67
69
  if (type) {
68
70
  if (type.toLowerCase() === 'boolean')
69
- return 'boolean';
71
+ return ['boolean'];
70
72
  if (type.toLowerCase() === 'number')
71
- return 'number';
73
+ return ['number'];
74
+ if (type.toLowerCase() === 'string')
75
+ return ['string'];
76
+ if (type.startsWith("'") && type.includes("|")) {
77
+ const values = type.split("|").map(x => x.trim()).map(x => x.substring(1, x.length - 1));
78
+ return ['list', values];
79
+ }
72
80
  }
73
- return type;
81
+ return [type];
74
82
  }
75
83
  async getElements() {
76
84
  if (this._packageData)
@@ -33,7 +33,8 @@ export class WebcomponentManifestPropertiesService extends AbstractPropertiesSer
33
33
  let pType = PropertyType.property;
34
34
  if (declaration.attributes)
35
35
  pType = declaration.attributes.find(x => x.fieldName == d.name) != null ? PropertyType.propertyAndAttribute : PropertyType.property;
36
- properties.push({ name: d.name, service: this, propertyType: pType, type: this.manifestClassPropertyTypeToEditorPropertyType(d.type?.text) });
36
+ const p = this.manifestClassPropertyTypeToEditorPropertyType(d.type?.text);
37
+ properties.push({ name: d.name, service: this, propertyType: pType, type: p[0], values: p[1] });
37
38
  }
38
39
  }
39
40
  this._propertiesList[e.name] = properties;
@@ -49,11 +50,17 @@ export class WebcomponentManifestPropertiesService extends AbstractPropertiesSer
49
50
  manifestClassPropertyTypeToEditorPropertyType(type) {
50
51
  if (type) {
51
52
  if (type.toLowerCase() === 'boolean')
52
- return 'boolean';
53
+ return ['boolean'];
53
54
  if (type.toLowerCase() === 'number')
54
- return 'number';
55
+ return ['number'];
56
+ if (type.toLowerCase() === 'string')
57
+ return ['string'];
58
+ if (type.startsWith("'") && type.includes("|")) {
59
+ const values = type.split("|").map(x => x.trim()).map(x => x.substring(1, x.length - 1));
60
+ return ['list', values];
61
+ }
55
62
  }
56
- return type;
63
+ return [type];
57
64
  }
58
65
  isHandledElement(designItem) {
59
66
  return this._propertiesList[designItem.name] != null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "A UI designer for Polymer apps",
3
3
  "name": "@node-projects/web-component-designer",
4
- "version": "0.0.182",
4
+ "version": "0.0.184",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",