@node-projects/web-component-designer 0.1.23 → 0.1.25

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.
@@ -17,7 +17,6 @@ export declare class WebcomponentManifestParserService extends AbstractPropertie
17
17
  private _importPrefix;
18
18
  constructor(name: string, fileOrObject: string | object, importPrefix?: string);
19
19
  private _parseManifest;
20
- private manifestClassPropertyTypeToEditorPropertyType;
21
20
  getElements(): Promise<IElementDefinition[]>;
22
21
  isHandledElement(designItem: IDesignItem): boolean;
23
22
  getProperties(designItem: IDesignItem): IProperty[];
@@ -3,6 +3,7 @@ import { RefreshMode } from '../propertiesService/IPropertiesService.js';
3
3
  import { PropertyType } from '../propertiesService/PropertyType.js';
4
4
  import { AbstractPropertiesService } from '../propertiesService/services/AbstractPropertiesService.js';
5
5
  import { removeLeading, removeTrailing } from '../../helper/Helper.js';
6
+ import { WebcomponentManifestPropertiesService } from '../propertiesService/services/WebcomponentManifestPropertiesService.js';
6
7
  export class WebcomponentManifestParserService extends AbstractPropertiesService {
7
8
  getRefreshMode(designItem) {
8
9
  return RefreshMode.none;
@@ -59,7 +60,7 @@ export class WebcomponentManifestParserService extends AbstractPropertiesService
59
60
  let pType = PropertyType.property;
60
61
  if (declaration.attributes)
61
62
  pType = declaration.attributes.find(x => x.fieldName == d.name) != null ? PropertyType.propertyAndAttribute : PropertyType.property;
62
- const p = this.manifestClassPropertyTypeToEditorPropertyType(d.type?.text);
63
+ const p = WebcomponentManifestPropertiesService.manifestClassPropertyTypeToEditorPropertyType(d.type?.text, d.type?.editor);
63
64
  properties.push({ name: d.name, service: this, propertyType: pType, type: p[0], values: p[1], description: d.description });
64
65
  }
65
66
  }
@@ -73,21 +74,6 @@ export class WebcomponentManifestParserService extends AbstractPropertiesService
73
74
  }
74
75
  }
75
76
  }
76
- manifestClassPropertyTypeToEditorPropertyType(type) {
77
- if (type) {
78
- if (type.toLowerCase() === 'boolean')
79
- return ['boolean'];
80
- if (type.toLowerCase() === 'number')
81
- return ['number'];
82
- if (type.toLowerCase() === 'string')
83
- return ['string'];
84
- if (type.startsWith("'") && type.includes("|")) {
85
- const values = type.split("|").map(x => x.trim()).map(x => x.substring(1, x.length - 1));
86
- return ['list', values];
87
- }
88
- }
89
- return [type];
90
- }
91
77
  async getElements() {
92
78
  if (this._packageData)
93
79
  return Promise.resolve(this._elementList);
@@ -3,6 +3,6 @@ export declare enum PropertyType {
3
3
  attribute = "attribute",
4
4
  propertyAndAttribute = "propertyAndAttribute",
5
5
  cssValue = "cssvalue",
6
- complex = "complex",
6
+ complex = "complex",// editor is special and could write multiple properties
7
7
  add = "add"
8
8
  }
@@ -38,13 +38,13 @@ export class AbstractPropertiesService {
38
38
  if (property.propertyType == PropertyType.property || property.propertyType == PropertyType.propertyAndAttribute)
39
39
  d.element[property.name] = value;
40
40
  }
41
- else if (property.type == 'boolean' && !value) {
41
+ else if (property.type == 'boolean' && (value === false || value == null)) {
42
42
  if (property.propertyType == PropertyType.attribute || property.propertyType == PropertyType.propertyAndAttribute)
43
43
  d.removeAttribute(attributeName);
44
44
  if (property.propertyType == PropertyType.property || property.propertyType == PropertyType.propertyAndAttribute)
45
45
  d.element[property.name] = false;
46
46
  }
47
- else if (property.type == 'boolean' && value) {
47
+ else if (property.type == 'boolean' && value === true) {
48
48
  if (property.propertyType == PropertyType.attribute || property.propertyType == PropertyType.propertyAndAttribute)
49
49
  d.setAttribute(attributeName, "");
50
50
  if (property.propertyType == PropertyType.property || property.propertyType == PropertyType.propertyAndAttribute)
@@ -155,8 +155,15 @@ export class AbstractPropertiesService {
155
155
  let attributeName = property.attributeName;
156
156
  if (!attributeName)
157
157
  attributeName = PropertiesHelper.camelToDashCase(property.name);
158
- if (property.type == 'boolean')
159
- return designItems[0].hasAttribute(attributeName);
158
+ if (property.type == 'boolean') {
159
+ if (designItems[0].hasAttribute(attributeName)) {
160
+ const val = designItems[0].getAttribute(attributeName);
161
+ if (val == "")
162
+ return true;
163
+ return val;
164
+ }
165
+ return false;
166
+ }
160
167
  let lastValue = designItems[0].getAttribute(attributeName);
161
168
  /*
162
169
  for (const x of designItems) {
@@ -11,7 +11,7 @@ export declare class WebcomponentManifestPropertiesService extends AbstractPrope
11
11
  private _propertiesList;
12
12
  constructor(name: string, manifest: any);
13
13
  private _parseManifest;
14
- private manifestClassPropertyTypeToEditorPropertyType;
14
+ static manifestClassPropertyTypeToEditorPropertyType(type: string, editor: string): [type: string, values?: string[]];
15
15
  isHandledElement(designItem: IDesignItem): boolean;
16
16
  getProperties(designItem: IDesignItem): IProperty[] | IPropertyGroup[];
17
17
  getProperty(designItem: IDesignItem, name: string): IProperty;
@@ -33,7 +33,7 @@ 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
- const p = this.manifestClassPropertyTypeToEditorPropertyType(d.type?.text);
36
+ const p = WebcomponentManifestPropertiesService.manifestClassPropertyTypeToEditorPropertyType(d.type?.text, d.type?.editor);
37
37
  if (d.name)
38
38
  properties.push({ name: d.name, service: this, propertyType: pType, type: p[0], values: p[1], description: d.description });
39
39
  }
@@ -48,7 +48,11 @@ export class WebcomponentManifestPropertiesService extends AbstractPropertiesSer
48
48
  }
49
49
  }
50
50
  }
51
- manifestClassPropertyTypeToEditorPropertyType(type) {
51
+ static manifestClassPropertyTypeToEditorPropertyType(type, editor) {
52
+ if (editor) {
53
+ if (editor.toLowerCase() === 'color')
54
+ return ['color'];
55
+ }
52
56
  if (type) {
53
57
  if (type.toLowerCase() === 'boolean')
54
58
  return ['boolean'];
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.1.23",
4
+ "version": "0.1.25",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",