@node-projects/web-component-designer-widgets-wunderbaum 0.1.17 → 0.1.19

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,6 +4,9 @@ i.wb-icon > span.wb-badge {
4
4
  font-size: 70%;
5
5
  background-color: #486471;
6
6
  }
7
+ div.wunderbaum {
8
+ --wb-active-color-grayscale: #dddddd;
9
+ }
7
10
  div.wunderbaum span.wb-node i.wb-icon {
8
11
  background-size: 12px 12px;
9
12
  background-position-x: 5px;
@@ -19,7 +19,9 @@ export declare class TreeViewExtended extends BaseCustomWebComponentConstructorA
19
19
  _switchHideAtRunTimeState(img: HTMLImageElement, designItem: IDesignItem): void;
20
20
  showDesignItemContextMenu(designItem: IDesignItem, event: MouseEvent): ContextMenu;
21
21
  ready(): Promise<void>;
22
- createTree(rootItem: IDesignItem): void;
22
+ _recomputeRunning: any;
23
+ _recomputeRequestedAgain: any;
24
+ createTree(rootItem: IDesignItem): Promise<void>;
23
25
  set instanceServiceContainer(value: InstanceServiceContainer);
24
26
  selectionChanged(event: ISelectionChangedEvent): void;
25
27
  private _recomputeTree;
@@ -1,5 +1,5 @@
1
1
  import { css, html, BaseCustomWebComponentConstructorAppend, cssFromString } from '@node-projects/base-custom-webcomponent';
2
- import { NodeType, assetsPath, ContextMenu, switchContainer, DomConverter } from '@node-projects/web-component-designer';
2
+ import { NodeType, assetsPath, ContextMenu, switchContainer, DomConverter, ForceCssContextMenu } from '@node-projects/web-component-designer';
3
3
  import { Wunderbaum } from 'wunderbaum';
4
4
  import { defaultOptions, defaultStyle } from '../WunderbaumOptions.js';
5
5
  //@ts-ignore
@@ -45,6 +45,15 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
45
45
  div.wunderbaum span.wb-node span.wb-title {
46
46
  text-overflow: unset;
47
47
  width: unset !important;
48
+ }
49
+ div.forced {
50
+ border-radius: 50%;
51
+ width: 10px;
52
+ height: 10px;
53
+ background: orange;
54
+ top: 5px;
55
+ left: 5px;
56
+ position: relative;
48
57
  }`;
49
58
  static template = html `
50
59
  <div style="height: 100%;">
@@ -220,33 +229,60 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
220
229
  sp.style.width = "42px";
221
230
  e.nodeElem.appendChild(sp);
222
231
  if (item && item.nodeType === NodeType.Element && item !== item.instanceServiceContainer.contentService.rootDesignItem) {
223
- let d = document.createElement("div");
232
+ const d = document.createElement("div");
224
233
  d.className = "cmd";
225
- let imgL = document.createElement('img');
234
+ const imgL = document.createElement('img');
226
235
  this._showLockAtDesignTimeState(imgL, item);
227
236
  imgL.onclick = () => this._switchLockAtDesignTimeState(imgL, item);
228
237
  imgL.title = 'lock';
229
238
  d.appendChild(imgL);
230
- let img = document.createElement('img');
239
+ const img = document.createElement('img');
231
240
  this._showHideAtDesignTimeState(img, item);
232
241
  img.onclick = () => this._switchHideAtDesignTimeState(img, item);
233
242
  img.title = 'hide in designer';
234
243
  d.appendChild(img);
235
- let imgH = document.createElement('img');
244
+ const imgH = document.createElement('img');
236
245
  this._showHideAtRunTimeState(imgH, item);
237
246
  imgH.onclick = () => this._switchHideAtRunTimeState(imgH, item);
238
247
  imgH.title = 'hide at runtime';
239
248
  d.appendChild(imgH);
240
249
  rowElem.appendChild(d);
250
+ if (item.hasForcedCss) {
251
+ const f = document.createElement("div");
252
+ f.className = "forced";
253
+ f.title = "has forced style";
254
+ rowElem.appendChild(f);
255
+ f.addEventListener('click', (event) => {
256
+ const items = new ForceCssContextMenu().provideContextMenuItems(event, item.instanceServiceContainer.designerCanvas, item);
257
+ let ctxMenu = new ContextMenu(items, null);
258
+ ctxMenu.display(event);
259
+ });
260
+ }
241
261
  }
242
262
  }
243
263
  e.nodeElem.querySelector("span.wb-title").innerHTML = e.node.title;
244
264
  },
245
265
  });
246
266
  }
247
- createTree(rootItem) {
267
+ _recomputeRunning;
268
+ _recomputeRequestedAgain;
269
+ async createTree(rootItem) {
248
270
  if (this._tree) {
249
- this._recomputeTree(rootItem);
271
+ if (!this._recomputeRunning) {
272
+ this._recomputeRunning = true;
273
+ setTimeout(async () => {
274
+ this._recomputeRequestedAgain = false;
275
+ await this._recomputeTree(rootItem);
276
+ this._recomputeRunning = false;
277
+ if (this._recomputeRequestedAgain) {
278
+ this._recomputeRequestedAgain = false;
279
+ this.createTree(rootItem);
280
+ }
281
+ }, 20);
282
+ }
283
+ else {
284
+ this._recomputeRequestedAgain = true;
285
+ }
250
286
  }
251
287
  }
252
288
  set instanceServiceContainer(value) {
@@ -264,11 +300,11 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
264
300
  selectionChanged(event) {
265
301
  this._highlight(event.selectedElements);
266
302
  }
267
- _recomputeTree(rootItem) {
303
+ async _recomputeTree(rootItem) {
268
304
  try {
269
305
  this._tree.root.removeChildren();
270
306
  this._getChildren(rootItem, null);
271
- this._tree.expandAll();
307
+ await this._tree.expandAll();
272
308
  this._filterNodes();
273
309
  }
274
310
  catch (err) {
@@ -295,6 +331,9 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
295
331
  this._tree.visit((node) => {
296
332
  const flag = activeElements && activeElements.includes(node.data.ref);
297
333
  node.setSelected(flag);
334
+ node.setActive(flag);
335
+ if (flag)
336
+ node.setFocus(true);
298
337
  if (flag && !scrolled) {
299
338
  scrolled = true;
300
339
  node.scrollIntoView();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "web-component-designer addon: Widgets using wunderbaum",
3
3
  "name": "@node-projects/web-component-designer-widgets-wunderbaum",
4
- "version": "0.1.17",
4
+ "version": "0.1.19",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@node-projects/base-custom-webcomponent": ">=0.19.0",
16
- "@node-projects/web-component-designer": ">=0.1.150",
16
+ "@node-projects/web-component-designer": ">=0.1.159",
17
17
  "wunderbaum": ">=0.6.0"
18
18
  },
19
19
  "repository": {