@node-projects/web-component-designer 0.0.138 → 0.0.139

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.
@@ -19,7 +19,6 @@ export declare class DesignerTabControl extends BaseCustomWebComponentLazyAppend
19
19
  connectedCallback(): void;
20
20
  get selectedIndex(): number;
21
21
  set selectedIndex(value: number);
22
- disconnectedCallback(): void;
23
22
  refreshItems(): void;
24
23
  private _selectedIndexChanged;
25
24
  readonly onSelectedTabChanged: TypedEvent<DesignerTabControlIndexChangedEventArgs>;
@@ -97,8 +97,14 @@ export class DesignerTabControl extends BaseCustomWebComponentLazyAppend {
97
97
  `;
98
98
  constructor() {
99
99
  super();
100
- this._contentObserver = new MutationObserver(() => {
101
- this.refreshItems();
100
+ this._contentObserver = new MutationObserver((mut) => {
101
+ let refresh = false;
102
+ for (let m of mut) {
103
+ if (m.type != 'attributes' || m.attributeName == 'style')
104
+ refresh = true;
105
+ }
106
+ if (refresh)
107
+ this.refreshItems();
102
108
  });
103
109
  let outerDiv = document.createElement("div");
104
110
  outerDiv.className = 'outer';
@@ -138,16 +144,18 @@ export class DesignerTabControl extends BaseCustomWebComponentLazyAppend {
138
144
  DomHelper.removeAllChildnodes(this._headerDiv);
139
145
  let reloadOnce = true;
140
146
  for (let item of this.children) {
141
- let htmlItem = item;
142
- if (!this._elementMap.has(htmlItem) && reloadOnce) {
143
- this.refreshItems();
144
- reloadOnce = false;
145
- }
146
- const tabHeaderDiv = this._elementMap.get(htmlItem);
147
- this._moreContainer.appendChild(tabHeaderDiv);
148
- if (this._headerDiv.children.length == 0 || (w + (tabHeaderDiv.clientWidth / 2)) < this._headerDiv.clientWidth) {
149
- this._headerDiv.appendChild(tabHeaderDiv);
150
- w += tabHeaderDiv.clientWidth;
147
+ if (item.style.display != 'none') {
148
+ let htmlItem = item;
149
+ if (!this._elementMap.has(htmlItem) && reloadOnce) {
150
+ this.refreshItems();
151
+ reloadOnce = false;
152
+ }
153
+ const tabHeaderDiv = this._elementMap.get(htmlItem);
154
+ this._moreContainer.appendChild(tabHeaderDiv);
155
+ if (this._headerDiv.children.length == 0 || (w + (tabHeaderDiv.clientWidth / 2)) < this._headerDiv.clientWidth) {
156
+ this._headerDiv.appendChild(tabHeaderDiv);
157
+ w += tabHeaderDiv.clientWidth;
158
+ }
151
159
  }
152
160
  }
153
161
  }
@@ -155,7 +163,7 @@ export class DesignerTabControl extends BaseCustomWebComponentLazyAppend {
155
163
  if (this._firstConnect) {
156
164
  this.refreshItems();
157
165
  this._firstConnect = false;
158
- this._contentObserver.observe(this, { childList: true });
166
+ this._contentObserver.observe(this, { childList: true, subtree: true, attributes: true });
159
167
  let selectedIndexAttribute = this.getAttribute("selected-index");
160
168
  if (selectedIndexAttribute) {
161
169
  this.selectedIndex = parseInt(selectedIndexAttribute);
@@ -171,52 +179,52 @@ export class DesignerTabControl extends BaseCustomWebComponentLazyAppend {
171
179
  if (this.children.length && old != this._selectedIndex)
172
180
  this._selectedIndexChanged(old);
173
181
  }
174
- disconnectedCallback() {
175
- //this._contentObserver.disconnect();
176
- }
177
182
  refreshItems() {
178
183
  this._headerDiv.innerHTML = "";
179
184
  let i = 0;
180
185
  for (let item of this.children) {
181
- let htmlItem = item;
182
- let tabHeaderDiv = document.createElement("div");
183
- tabHeaderDiv.innerText = htmlItem.title;
184
- tabHeaderDiv.title = htmlItem.title;
185
- tabHeaderDiv.className = 'tab-header';
186
- let j = i;
187
- tabHeaderDiv.onpointerdown = () => {
188
- let old = this._selectedIndex;
189
- this._selectedIndex = j;
190
- if (this._headerDiv.children.length)
191
- this._selectedIndexChanged(old, true);
192
- this._moreContainer.style.visibility = 'hidden';
193
- };
194
- this._elementMap.set(htmlItem, tabHeaderDiv);
195
- this._headerDiv.appendChild(tabHeaderDiv);
196
- i++;
186
+ if (item.style.display != 'none') {
187
+ let htmlItem = item;
188
+ let tabHeaderDiv = document.createElement("div");
189
+ tabHeaderDiv.innerText = htmlItem.title;
190
+ tabHeaderDiv.title = htmlItem.title;
191
+ tabHeaderDiv.className = 'tab-header';
192
+ let j = i;
193
+ tabHeaderDiv.onpointerdown = () => {
194
+ let old = this._selectedIndex;
195
+ this._selectedIndex = j;
196
+ if (this._headerDiv.children.length)
197
+ this._selectedIndexChanged(old, true);
198
+ this._moreContainer.style.visibility = 'hidden';
199
+ };
200
+ this._elementMap.set(htmlItem, tabHeaderDiv);
201
+ this._headerDiv.appendChild(tabHeaderDiv);
202
+ i++;
203
+ }
197
204
  }
198
205
  this._showHideHeaderItems();
199
206
  this._selectedIndexChanged();
200
207
  }
201
208
  _selectedIndexChanged(oldIndex, viaClick = false) {
202
- for (let index = 0; index < this.children.length; index++) {
203
- const element = this.children[index];
204
- if (index == this._selectedIndex) {
205
- element.slot = "panels";
206
- const el = this.children[index];
207
- const headerEl = this._elementMap.get(el);
208
- if (headerEl) {
209
- headerEl.classList.add('selected');
210
- if (element.activated)
211
- element.activated();
209
+ let index = -1;
210
+ for (let element of this.children) {
211
+ if (element.style.display != 'none') {
212
+ index++;
213
+ if (index == this._selectedIndex) {
214
+ element.slot = "panels";
215
+ const headerEl = this._elementMap.get(element);
216
+ if (headerEl) {
217
+ headerEl.classList.add('selected');
218
+ if (element.activated)
219
+ element.activated();
220
+ }
212
221
  }
213
- }
214
- else {
215
- element.removeAttribute("slot");
216
- const el = this.children[index];
217
- const headerEl = this._elementMap.get(el);
218
- if (headerEl) {
219
- headerEl.classList.remove('selected');
222
+ else {
223
+ element.removeAttribute("slot");
224
+ const headerEl = this._elementMap.get(element);
225
+ if (headerEl) {
226
+ headerEl.classList.remove('selected');
227
+ }
220
228
  }
221
229
  }
222
230
  }
@@ -21,7 +21,8 @@ export class PropertyGroupsService {
21
21
  if (designItems == null || designItems.length == 0)
22
22
  return [];
23
23
  this._pgList[0].propertiesService = designItems[0].serviceContainer.getLastServiceWhere('propertyService', x => x.isHandledElement(designItems[0]));
24
- if (designItems[0] instanceof SVGElement)
24
+ this._svgPgList[0].propertiesService = designItems[0].serviceContainer.getLastServiceWhere('propertyService', x => x.isHandledElement(designItems[0]));
25
+ if (designItems[0].element instanceof SVGElement)
25
26
  return this._svgPgList;
26
27
  return this._pgList;
27
28
  }
@@ -24,11 +24,24 @@ export class AttributesPropertiesService {
24
24
  return null;
25
25
  }
26
26
  setValue(designItems, property, value) {
27
+ const cg = designItems[0].openGroup("properties changed");
28
+ for (let d of designItems) {
29
+ d.attributes.set(property.name, value);
30
+ d.element.setAttribute(property.name, value);
31
+ }
32
+ cg.commit();
27
33
  }
28
34
  getPropertyTarget(designItem, property) {
29
35
  return BindingTarget.attribute;
30
36
  }
31
37
  clearValue(designItems, property) {
38
+ for (let d of designItems) {
39
+ d.attributes.delete(property.name);
40
+ d.element.removeAttribute(property.name);
41
+ d.serviceContainer.forSomeServicesTillResult('bindingService', (s) => {
42
+ return s.clearBinding(d, property.name, this.getPropertyTarget(d, property));
43
+ });
44
+ }
32
45
  }
33
46
  isSet(designItems, property) {
34
47
  let all = true;
@@ -3,7 +3,7 @@ import { BindingTarget } from "../../../item/BindingTarget";
3
3
  import { PropertyType } from "../PropertyType";
4
4
  export class CommonPropertiesService {
5
5
  listNeedsRefresh(designItem) {
6
- return false;
6
+ return true;
7
7
  }
8
8
  //@ts-ignore
9
9
  commonProperties = [
@@ -195,7 +195,9 @@ export class CssPropertiesService {
195
195
  if (this.name == 'styles') {
196
196
  if (!designItem)
197
197
  return [];
198
- return Array.from(designItem.styles.keys(), x => ({ name: x, type: 'string', service: this, propertyType: PropertyType.cssValue }));
198
+ let arr = Array.from(designItem.styles.keys(), x => ({ name: x, type: 'string', service: this, propertyType: PropertyType.cssValue }));
199
+ arr.push({ name: '', type: 'addNew', service: this, propertyType: PropertyType.complex });
200
+ return arr;
199
201
  }
200
202
  return this[this.name];
201
203
  }
@@ -124,11 +124,16 @@ export class PropertyGridPropertyList extends BaseCustomWebComponentLazyAppend {
124
124
  this.openContextMenu(event, p);
125
125
  };
126
126
  if (p.type == 'addNew') {
127
+ let input = editor.element;
128
+ input.disabled = true;
127
129
  let label = document.createElement("input");
128
130
  label.value = p.name;
129
131
  label.onkeyup = e => {
130
- if (e.key == 'Enter') {
131
- designItem.setAttribute(label.value, "");
132
+ if (e.key == 'Enter' && label.value) {
133
+ p.name = label.value;
134
+ label.disabled = true;
135
+ input.disabled = false;
136
+ input.focus();
132
137
  }
133
138
  };
134
139
  this._div.appendChild(label);
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.138",
4
+ "version": "0.0.139",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",