@node-projects/web-component-designer 0.0.272 → 0.0.274

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.
Files changed (28) hide show
  1. package/dist/elements/controls/MetricsEditor.d.ts +4 -0
  2. package/dist/elements/controls/MetricsEditor.js +31 -5
  3. package/dist/elements/helper/GridHelper.d.ts +5 -1
  4. package/dist/elements/helper/GridHelper.js +19 -1
  5. package/dist/elements/helper/contextMenu/ContextMenu.d.ts +2 -2
  6. package/dist/elements/helper/contextMenu/ContextMenu.js +2 -2
  7. package/dist/elements/helper/contextMenu/IContextMenuItem.d.ts +4 -1
  8. package/dist/elements/helper/contextMenu/IContextMenuItem.js +1 -0
  9. package/dist/elements/item/DesignItem.d.ts +3 -0
  10. package/dist/elements/item/DesignItem.js +10 -1
  11. package/dist/elements/services/htmlWriterService/HtmlWriterService.js +7 -3
  12. package/dist/elements/services/placementService/GridPlacementService.js +28 -26
  13. package/dist/elements/services/propertiesService/ValueType.d.ts +2 -1
  14. package/dist/elements/services/propertiesService/ValueType.js +1 -0
  15. package/dist/elements/services/propertiesService/propertyEditors/SelectPropertyEditor.d.ts +3 -1
  16. package/dist/elements/services/propertiesService/propertyEditors/SelectPropertyEditor.js +22 -5
  17. package/dist/elements/services/propertiesService/propertyEditors/special/GridAssignedRowColumnPropertyEditor.js +7 -6
  18. package/dist/elements/services/propertiesService/propertyEditors/special/MetricsPropertyEditor.js +1 -1
  19. package/dist/elements/services/propertiesService/services/AbstractPolymerLikePropertiesService.js +4 -0
  20. package/dist/elements/services/propertiesService/services/AbstractPropertiesService.d.ts +3 -0
  21. package/dist/elements/services/propertiesService/services/AbstractPropertiesService.js +19 -3
  22. package/dist/elements/services/propertiesService/services/CommonPropertiesService.js +5 -0
  23. package/dist/elements/widgets/designerView/extensions/grid/DisplayGridExtension.js +3 -3
  24. package/dist/elements/widgets/designerView/extensions/grid/EditGridColumnRowSizesExtension.d.ts +2 -2
  25. package/dist/elements/widgets/designerView/extensions/grid/EditGridColumnRowSizesExtension.js +2 -2
  26. package/dist/elements/widgets/propertyGrid/PropertyGridPropertyList.js +21 -4
  27. package/dist/index.d.ts +1 -1
  28. package/package.json +2 -2
@@ -8,7 +8,11 @@ export declare class MetricsEditor extends BaseCustomWebComponentConstructorAppe
8
8
  static readonly template: HTMLTemplateElement;
9
9
  property: string;
10
10
  unsetValue: string;
11
+ private _borderDiv;
12
+ private _elementDiv;
13
+ constructor();
11
14
  ready(): void;
12
15
  onDoubleClick(event: PointerEvent): void;
13
16
  onKeyDown(event: KeyboardEvent): void;
17
+ refresh(element: Element): void;
14
18
  }
@@ -6,6 +6,7 @@ export class MetricsEditor extends BaseCustomWebComponentConstructorAppend {
6
6
  display: flex;
7
7
  margin: 10px;
8
8
  line-height: 12px;
9
+ min-width: 120px;
9
10
  }
10
11
 
11
12
  * {
@@ -49,6 +50,10 @@ div.ct {
49
50
  vertical-align: middle;
50
51
  }
51
52
 
53
+ div.ct.box {
54
+ border: dotted 2px black;
55
+ }
56
+
52
57
  div.ct > div.ct {
53
58
  left: 0;
54
59
  top: 0;
@@ -82,17 +87,25 @@ span {
82
87
  text-overflow: ellipsis;
83
88
  }`;
84
89
  static template = html `
85
- <div class="ct"><span title="position">position</span>
86
- <div data-style="position" @keydown="onKeyDown" @dblclick="onDoubleClick" class="top">-</div><br><div data-style="position" @keydown="onKeyDown" @dblclick="onDoubleClick" class="left">-</div><div class="ct"><span title="margin">margin</span>
87
- <div data-style="margin" @keydown="onKeyDown" @dblclick="onDoubleClick" class="top">-</div><br><div @keydown="onKeyDown" @dblclick="onDoubleClick" class="left">-</div><div class="ct"><span title="border">border</span>
88
- <div data-style="border" @keydown="onKeyDown" @dblclick="onDoubleClick" class="top">-</div><br><div @keydown="onKeyDown" @dblclick="onDoubleClick" class="left">-</div><div class="ct"><span title="padding">padding</span>
89
- <div data-style="padding" @keydown="onKeyDown" @dblclick="onDoubleClick" class="top">-</div><br><div @keydown="onKeyDown" @dblclick="onDoubleClick" class="left">-</div><div class="ct" style="font-size:6px"><div data-style="element" @keydown="onKeyDown" @dblclick="onDoubleClick" class="left">-</div>
90
+ <div id="position" class="ct"><span title="position">position</span>
91
+ <div data-style="position" @keydown="onKeyDown" @dblclick="onDoubleClick" class="top">-</div><br><div data-style="position" @keydown="onKeyDown" @dblclick="onDoubleClick" class="left">-</div><div id="margin" class="ct"><span title="margin">margin</span>
92
+ <div data-style="margin" @keydown="onKeyDown" @dblclick="onDoubleClick" class="top">-</div><br><div @keydown="onKeyDown" @dblclick="onDoubleClick" class="left">-</div><div id="border" class="ct"><span title="border">border</span>
93
+ <div data-style="border" @keydown="onKeyDown" @dblclick="onDoubleClick" class="top">-</div><br><div @keydown="onKeyDown" @dblclick="onDoubleClick" class="left">-</div><div id="padding" class="ct"><span title="padding">padding</span>
94
+ <div data-style="padding" @keydown="onKeyDown" @dblclick="onDoubleClick" class="top">-</div><br><div @keydown="onKeyDown" @dblclick="onDoubleClick" class="left">-</div><div id="element" class="ct" style="font-size:6px"><div data-style="element" @keydown="onKeyDown" @dblclick="onDoubleClick" class="left">-</div>
90
95
  &nbsp;x&nbsp;
91
96
  <div data-style="element" @keydown="onKeyDown" @dblclick="onDoubleClick" class="right">-</div>
92
97
  </div><div data-style="padding" @keydown="onKeyDown" @dblclick="onDoubleClick" class="right">-</div><br><div data-style="padding" @keydown="onKeyDown" @dblclick="onDoubleClick" class="bottom">-</div></div><div data-style="border" @keydown="onKeyDown" @dblclick="onDoubleClick" class="right">-</div><br><div data-style="border" @keydown="onKeyDown" @dblclick="onDoubleClick" class="bottom">-</div></div><div data-style="margin" @keydown="onKeyDown" @dblclick="onDoubleClick" class="right">-</div><br><div data-style="margin" @keydown="onKeyDown" @dblclick="onDoubleClick" class="bottom">-</div></div><div data-style="position" @keydown="onKeyDown" @dblclick="onDoubleClick" class="right">-</div><br><div data-style="position" @keydown="onKeyDown" @dblclick="onDoubleClick" class="bottom">-</div></div>
93
98
  `;
94
99
  property;
95
100
  unsetValue;
101
+ _borderDiv;
102
+ _elementDiv;
103
+ constructor() {
104
+ super();
105
+ this._restoreCachedInititalValues();
106
+ this._borderDiv = this._getDomElement('border');
107
+ this._elementDiv = this._getDomElement('element');
108
+ }
96
109
  ready() {
97
110
  this._parseAttributesToProperties();
98
111
  this._assignEvents();
@@ -121,5 +134,18 @@ span {
121
134
  this.dispatchEvent(valueChangedEvent);
122
135
  }
123
136
  }
137
+ refresh(element) {
138
+ this._elementDiv.classList.remove('box');
139
+ this._borderDiv.classList.remove('box');
140
+ if (element) {
141
+ let cp = getComputedStyle(element);
142
+ if (cp.boxSizing == 'content-box') {
143
+ this._elementDiv.classList.add('box');
144
+ }
145
+ else {
146
+ this._borderDiv.classList.add('box');
147
+ }
148
+ }
149
+ }
124
150
  }
125
151
  customElements.define('node-projects-metrics-editor', MetricsEditor);
@@ -1,5 +1,9 @@
1
1
  import { IDesignItem } from "../item/IDesignItem.js";
2
- export declare function CalculateGridInformation(designItem: IDesignItem): {
2
+ export declare function getElementGridInformation(element: HTMLElement): {
3
+ colSpan: number;
4
+ rowSpan: number;
5
+ };
6
+ export declare function calculateGridInformation(designItem: IDesignItem): {
3
7
  cells?: {
4
8
  x: number;
5
9
  y: number;
@@ -1,5 +1,23 @@
1
1
  import { getDesignerCanvasNormalizedTransformedCornerDOMPoints } from "./TransformHelper.js";
2
- export function CalculateGridInformation(designItem) {
2
+ export function getElementGridInformation(element) {
3
+ let cs = getComputedStyle(element);
4
+ let rowSpan = 1;
5
+ let colSpan = 1;
6
+ if (cs.gridRowEnd == 'auto')
7
+ rowSpan = 1;
8
+ else if (cs.gridRowEnd.startsWith('span'))
9
+ rowSpan = parseInt(cs.gridRowEnd.substring(4));
10
+ else
11
+ rowSpan = parseInt(cs.gridRowEnd) - parseInt(cs.gridRowStart);
12
+ if (cs.gridColumnEnd == 'auto')
13
+ colSpan = 1;
14
+ else if (cs.gridColumnEnd.startsWith('span'))
15
+ colSpan = parseInt(cs.gridColumnEnd.substring(4));
16
+ else
17
+ colSpan = parseInt(cs.gridColumnEnd) - parseInt(cs.gridColumnStart);
18
+ return { colSpan, rowSpan };
19
+ }
20
+ export function calculateGridInformation(designItem) {
3
21
  //todo:
4
22
  //same name should combine columns/rows
5
23
  let itemRect = designItem.instanceServiceContainer.designerCanvas.getNormalizedElementCoordinates(designItem.element);
@@ -1,4 +1,4 @@
1
- import { IContextMenuItem } from './IContextMenuItem.js';
1
+ import { IContextMenu, IContextMenuItem } from './IContextMenuItem.js';
2
2
  export interface IContextMenuOptions {
3
3
  defaultIcon?: string;
4
4
  subIcon?: string;
@@ -6,7 +6,7 @@ export interface IContextMenuOptions {
6
6
  shadowRoot?: ShadowRoot | Document;
7
7
  mode?: 'normal' | 'undo';
8
8
  }
9
- export declare class ContextMenu {
9
+ export declare class ContextMenu implements IContextMenu {
10
10
  private static _contextMenuCss;
11
11
  static count: number;
12
12
  menu: IContextMenuItem[];
@@ -183,12 +183,12 @@ export class ContextMenu {
183
183
  else {
184
184
  if (item.action)
185
185
  li.addEventListener('click', (e) => {
186
- item.action(e, item, this.context);
186
+ item.action(e, item, this.context, this);
187
187
  this.close();
188
188
  });
189
189
  if (this.options?.mode == 'undo') {
190
190
  li.addEventListener('mouseup', (e) => {
191
- item.action(e, item, this.context);
191
+ item.action(e, item, this.context, this);
192
192
  this.close();
193
193
  });
194
194
  }
@@ -1,3 +1,6 @@
1
+ export interface IContextMenu {
2
+ close: () => void;
3
+ }
1
4
  export interface IContextMenuItem {
2
5
  readonly id?: string;
3
6
  readonly title?: string;
@@ -5,5 +8,5 @@ export interface IContextMenuItem {
5
8
  readonly children?: IContextMenuItem[];
6
9
  readonly disabled?: boolean;
7
10
  readonly shortCut?: string;
8
- action?: (event: MouseEvent, item: IContextMenuItem, context?: any) => void;
11
+ action?: (event: MouseEvent, item: IContextMenuItem, context?: any, menu?: IContextMenu) => void;
9
12
  }
@@ -1,2 +1,3 @@
1
1
  ;
2
+ ;
2
3
  export {};
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { ServiceContainer } from '../services/ServiceContainer.js';
2
3
  import { IDesignItem } from './IDesignItem.js';
3
4
  import { InstanceServiceContainer } from '../services/InstanceServiceContainer.js';
@@ -80,6 +81,8 @@ export declare class DesignItem implements IDesignItem {
80
81
  getStyleFromSheetOrLocal(name: string, fallback?: string): string;
81
82
  getStyleFromSheetOrLocalOrComputed(name: string, fallback?: string): string;
82
83
  getComputedStyle(name: string, fallback?: string): string;
84
+ _stylesCache: IStyleRule[];
85
+ _cacheClearTimer: NodeJS.Timeout;
83
86
  getAllStyles(): IStyleRule[];
84
87
  setAttribute(name: string, value?: string | null): void;
85
88
  removeAttribute(name: string): void;
@@ -399,7 +399,12 @@ export class DesignItem {
399
399
  }
400
400
  return value ?? fallback;
401
401
  }
402
+ _stylesCache = null;
403
+ _cacheClearTimer;
402
404
  getAllStyles() {
405
+ let styles = this._stylesCache;
406
+ if (styles)
407
+ return styles;
403
408
  if (this.nodeType != NodeType.Element)
404
409
  return [];
405
410
  const localStyles = [...this._styles.entries()].map(x => ({ name: x[0], value: x[1], important: false, parent: null }));
@@ -412,7 +417,11 @@ export class DesignItem {
412
417
  }
413
418
  catch (err) { }
414
419
  }
415
- return [{ selector: null, declarations: localStyles, specificity: -1 }];
420
+ styles = [{ selector: null, declarations: localStyles, specificity: -1 }];
421
+ this._stylesCache = styles;
422
+ clearTimeout(this._cacheClearTimer);
423
+ this._cacheClearTimer = setTimeout(() => this._stylesCache = null, 30);
424
+ return styles;
416
425
  }
417
426
  setAttribute(name, value) {
418
427
  if (this.isRootItem)
@@ -30,6 +30,7 @@ export class HtmlWriterService extends AbstractHtmlWriterService {
30
30
  this.internalWrite(indentedTextWriter, d, updatePositions);
31
31
  }
32
32
  }
33
+ //todo special case for style/script nodes, keep whitespace
33
34
  internalWrite(indentedTextWriter, designItem, updatePositions) {
34
35
  let start = indentedTextWriter.position;
35
36
  let end = indentedTextWriter.position;
@@ -61,7 +62,8 @@ export class HtmlWriterService extends AbstractHtmlWriterService {
61
62
  const children = designItem.children();
62
63
  contentSingleTextNode = designItem.childCount === 1 && designItem.firstChild.nodeType === NodeType.TextNode;
63
64
  if (contentSingleTextNode) {
64
- this.writeTextNode(indentedTextWriter, designItem, false);
65
+ const notrim = designItem.name == 'script' || designItem.name == 'style' || designItem.name == 'pre';
66
+ this.writeTextNode(indentedTextWriter, designItem, false, !notrim);
65
67
  }
66
68
  else {
67
69
  if (designItem.element instanceof HTMLElement && !isInlineAfter(designItem.element) || (designItem.element instanceof SVGElement)) {
@@ -99,8 +101,10 @@ export class HtmlWriterService extends AbstractHtmlWriterService {
99
101
  designItem.instanceServiceContainer.designItemDocumentPositionService.setPosition(designItem, { start: start, length: end - start });
100
102
  }
101
103
  }
102
- writeTextNode(indentedTextWriter, designItem, indentAndNewline) {
103
- let content = DomConverter.normalizeContentValue(designItem.content).trim();
104
+ writeTextNode(indentedTextWriter, designItem, indentAndNewline, trim = true) {
105
+ let content = DomConverter.normalizeContentValue(designItem.content);
106
+ if (trim)
107
+ content = content.trim();
104
108
  if (content) {
105
109
  if (indentAndNewline)
106
110
  this._conditionalyWriteIndent(indentedTextWriter, designItem);
@@ -1,4 +1,4 @@
1
- import { CalculateGridInformation } from '../../helper/GridHelper.js';
1
+ import { calculateGridInformation, getElementGridInformation } from '../../helper/GridHelper.js';
2
2
  import { pointInRect } from '../../helper/Helper.js';
3
3
  import { DefaultPlacementService } from './DefaultPlacementService.js';
4
4
  export class GridPlacementService {
@@ -49,38 +49,39 @@ export class GridPlacementService {
49
49
  startPlace(event, placementView, container, startPoint, offsetInControl, newPoint, items) {
50
50
  }
51
51
  place(event, placementView, container, startPoint, offsetInControl, newPoint, items) {
52
- const gridInformation = CalculateGridInformation(container);
52
+ const gridInformation = calculateGridInformation(container);
53
53
  const pos = placementView.getNormalizedEventCoordinates(event);
54
- const posElement = placementView.getNormalizedElementCoordinates(items[0].element);
54
+ //pos.x -= offsetInControl.x;
55
+ //pos.y -= offsetInControl.y;
55
56
  let row = 0;
56
57
  let column = 0;
57
- if (!pointInRect(pos, posElement)) {
58
- row = 0;
59
- for (let cellRow of gridInformation.cells) {
60
- column = 0;
61
- for (let cell of cellRow) {
62
- if (pointInRect(pos, cell)) {
63
- if (cell.name) {
64
- items[0].element.style.gridColumn = '';
65
- items[0].element.style.gridRow = '';
66
- items[0].element.style.gridArea = cell.name;
67
- }
68
- else {
69
- items[0].element.style.gridArea = '';
70
- items[0].element.style.gridColumn = column + 1;
71
- items[0].element.style.gridRow = row + 1;
72
- }
58
+ for (let cellRow of gridInformation.cells) {
59
+ column = 0;
60
+ for (let cell of cellRow) {
61
+ if (pointInRect(pos, cell)) {
62
+ let info = getElementGridInformation(items[0].element);
63
+ if (cell.name) {
64
+ items[0].element.style.gridColumn = '';
65
+ items[0].element.style.gridRow = '';
66
+ items[0].element.style.gridArea = cell.name;
67
+ }
68
+ else {
69
+ items[0].element.style.gridArea = '';
70
+ items[0].element.style.gridColumn = (column + 1) + (info.colSpan > 1 ? ' / span ' + info.colSpan : '');
71
+ items[0].element.style.gridRow = (row + 1) + (info.rowSpan > 1 ? ' / span ' + info.rowSpan : '');
73
72
  }
74
- column++;
75
73
  }
76
- row++;
74
+ column++;
77
75
  }
76
+ row++;
78
77
  }
79
78
  placementView.extensionManager.refreshAllExtensions([container]);
80
79
  }
81
80
  finishPlace(event, placementView, container, startPoint, offsetInControl, newPoint, items) {
82
- const gridInformation = CalculateGridInformation(container);
81
+ const gridInformation = calculateGridInformation(container);
83
82
  const pos = placementView.getNormalizedEventCoordinates(event);
83
+ //pos.x -= offsetInControl.x;
84
+ //pos.y -= offsetInControl.y;
84
85
  let row = 0;
85
86
  let column = 0;
86
87
  row = 0;
@@ -88,6 +89,7 @@ export class GridPlacementService {
88
89
  column = 0;
89
90
  for (let cell of cellRow) {
90
91
  if (pointInRect(pos, cell)) {
92
+ let info = getElementGridInformation(items[0].element);
91
93
  //Grid Area is shorthand for grid row/column, to make undo work correctly we need to set befor and after clear
92
94
  if (cell.name) {
93
95
  items[0].setStyle('grid-area', cell.name);
@@ -96,11 +98,11 @@ export class GridPlacementService {
96
98
  items[0].setStyle('grid-area', cell.name);
97
99
  }
98
100
  else {
99
- items[0].setStyle('grid-column', column + 1);
100
- items[0].setStyle('grid-row', row + 1);
101
+ items[0].setStyle('grid-column', (column + 1) + (info.colSpan > 1 ? ' / span ' + info.colSpan : ''));
102
+ items[0].setStyle('grid-row', (row + 1) + (info.rowSpan > 1 ? ' / span ' + info.rowSpan : ''));
101
103
  items[0].removeStyle('grid-area');
102
- items[0].setStyle('grid-column', column + 1);
103
- items[0].setStyle('grid-row', row + 1);
104
+ items[0].setStyle('grid-column', (column + 1) + (info.colSpan > 1 ? ' / span ' + info.colSpan : ''));
105
+ items[0].setStyle('grid-row', (row + 1) + (info.rowSpan > 1 ? ' / span ' + info.rowSpan : ''));
104
106
  }
105
107
  }
106
108
  column++;
@@ -2,5 +2,6 @@ export declare enum ValueType {
2
2
  'none' = "none",
3
3
  'all' = "all",
4
4
  'some' = "some",
5
- 'bound' = "bound"
5
+ 'bound' = "bound",
6
+ 'fromStylesheet' = "fromStylesheet"
6
7
  }
@@ -4,4 +4,5 @@ export var ValueType;
4
4
  ValueType["all"] = "all";
5
5
  ValueType["some"] = "some";
6
6
  ValueType["bound"] = "bound";
7
+ ValueType["fromStylesheet"] = "fromStylesheet";
7
8
  })(ValueType || (ValueType = {}));
@@ -1,7 +1,9 @@
1
1
  import { IProperty } from '../IProperty.js';
2
2
  import { BasePropertyEditor } from './BasePropertyEditor.js';
3
3
  import { ValueType } from '../ValueType.js';
4
- export declare class SelectPropertyEditor extends BasePropertyEditor<HTMLSelectElement> {
4
+ export declare class SelectPropertyEditor extends BasePropertyEditor<HTMLDivElement> {
5
+ elementSelect: HTMLSelectElement;
6
+ elementInput: HTMLInputElement;
5
7
  constructor(property: IProperty);
6
8
  refreshValue(valueType: ValueType, value: any): void;
7
9
  }
@@ -1,14 +1,17 @@
1
1
  import { BasePropertyEditor } from './BasePropertyEditor.js';
2
2
  export class SelectPropertyEditor extends BasePropertyEditor {
3
+ elementSelect;
4
+ elementInput;
3
5
  constructor(property) {
4
6
  super(property);
5
- let element = document.createElement("select");
7
+ let element = document.createElement("div");
8
+ let elementSel = document.createElement("select");
6
9
  if (property.type == 'enum') {
7
10
  for (let v of property.enumValues) {
8
11
  let option = document.createElement("option");
9
12
  option.value = v[1];
10
13
  option.text = v[0];
11
- element.appendChild(option);
14
+ elementSel.appendChild(option);
12
15
  }
13
16
  }
14
17
  else {
@@ -16,13 +19,27 @@ export class SelectPropertyEditor extends BasePropertyEditor {
16
19
  let option = document.createElement("option");
17
20
  option.value = v;
18
21
  option.text = v;
19
- element.appendChild(option);
22
+ elementSel.appendChild(option);
20
23
  }
21
24
  }
22
- element.onchange = (e) => this._valueChanged(element.value);
25
+ elementSel.onchange = (e) => this._valueChanged(elementSel.value);
26
+ let elementInput = document.createElement("input");
27
+ elementInput.style.display = 'none';
28
+ elementInput.onchange = (e) => this._valueChanged(elementInput.value);
29
+ this.elementSelect = elementSel;
30
+ this.elementInput = elementInput;
31
+ element.appendChild(this.elementSelect);
32
+ element.appendChild(this.elementInput);
23
33
  this.element = element;
24
34
  }
25
35
  refreshValue(valueType, value) {
26
- this.element.value = value;
36
+ this.elementSelect.style.display = 'block';
37
+ this.elementInput.style.display = 'none';
38
+ this.elementSelect.value = value;
39
+ if (this.elementSelect.value != value && value) {
40
+ this.elementInput.value = value;
41
+ this.elementSelect.style.display = 'none';
42
+ this.elementInput.style.display = 'block';
43
+ }
27
44
  }
28
45
  }
@@ -1,4 +1,5 @@
1
1
  import { BasePropertyEditor } from '../BasePropertyEditor.js';
2
+ import { getElementGridInformation } from '../../../../helper/GridHelper.js';
2
3
  export class GridAssignedRowColumnPropertyEditor extends BasePropertyEditor {
3
4
  //Todo: multiple cell selection, grid area support, span support
4
5
  _root;
@@ -17,25 +18,25 @@ export class GridAssignedRowColumnPropertyEditor extends BasePropertyEditor {
17
18
  let container = this.designItems[0].element.parentElement;
18
19
  if (container) {
19
20
  let styleContainer = getComputedStyle(container);
21
+ let info = getElementGridInformation(this.designItems[0].element);
20
22
  let style = getComputedStyle(this.designItems[0].element);
21
23
  let cntCol = styleContainer.gridTemplateColumns.split(' ').length;
22
24
  let cntRow = styleContainer.gridTemplateRows.split(' ').length;
23
25
  this._root.style.gridTemplateColumns = 'repeat(' + cntCol + ', 1fr)';
24
26
  this._root.style.gridTemplateRows = 'repeat(' + cntRow + ', 1fr)';
25
27
  let rowStart = parseInt(style.gridRowStart);
26
- let rowEnd = style.gridRowEnd == 'auto' ? rowStart : parseInt(style.gridRowEnd);
27
- rowEnd = rowEnd <= rowStart ? rowStart + 1 : rowEnd;
28
+ let rowEnd = rowStart + info.rowSpan;
28
29
  let colStart = parseInt(style.gridColumnStart);
29
- let colEnd = style.gridColumnEnd == 'auto' ? colStart : parseInt(style.gridColumnEnd);
30
- colEnd = colEnd <= colStart ? colStart + 1 : colEnd;
30
+ let colEnd = colStart + info.colSpan;
31
31
  for (let p = 1; p <= cntRow; p++) {
32
32
  for (let n = 1; n <= cntCol; n++) {
33
33
  const b = document.createElement('button');
34
34
  b.style.minHeight = '10px';
35
35
  b.onclick = () => {
36
+ let info = getElementGridInformation(this.designItems[0].element);
36
37
  let grp = this.designItems[0].openGroup('Change grid row/column');
37
- this.designItems[0].setStyle("grid-row", p + ' / ' + (p + 1));
38
- this.designItems[0].setStyle("grid-column", n + ' / ' + (n + 1));
38
+ this.designItems[0].setStyle("grid-row", p + ' / ' + (p + info.rowSpan));
39
+ this.designItems[0].setStyle("grid-column", n + ' / ' + (n + info.colSpan));
39
40
  grp.commit();
40
41
  };
41
42
  if (p >= rowStart && p < rowEnd && n >= colStart && n < colEnd)
@@ -10,6 +10,6 @@ export class MetricsPropertyEditor extends BasePropertyEditor {
10
10
  this.element = selector;
11
11
  }
12
12
  refreshValue(valueType, value) {
13
- //this.element.valueLeft = value;
13
+ this.element.refresh(this.designItems?.[0]?.element);
14
14
  }
15
15
  }
@@ -42,6 +42,10 @@ export class AbstractPolymerLikePropertiesService extends AbstractPropertiesServ
42
42
  let property = { name: name, type: "enum", enumValues: PropertiesHelper.getTypescriptEnumEntries(type), service: this, propertyType: PropertyType.propertyAndAttribute };
43
43
  properties.push(property);
44
44
  }
45
+ else {
46
+ let property = { name: name, type: "string", service: this, propertyType: PropertyType.propertyAndAttribute };
47
+ properties.push(property);
48
+ }
45
49
  }
46
50
  return properties;
47
51
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { IPropertiesService, RefreshMode } from '../IPropertiesService.js';
2
3
  import { IProperty } from '../IProperty.js';
3
4
  import { IDesignItem } from '../../../item/IDesignItem.js';
@@ -6,6 +7,8 @@ import { BindingTarget } from '../../../item/BindingTarget.js';
6
7
  import { IBinding } from '../../../item/IBinding.js';
7
8
  import { IPropertyGroup } from '../IPropertyGroup.js';
8
9
  export declare abstract class AbstractPropertiesService implements IPropertiesService {
10
+ _stylesCache: Map<IDesignItem, Set<string>>;
11
+ _cacheClearTimer: NodeJS.Timeout;
9
12
  abstract getRefreshMode(designItem: IDesignItem): RefreshMode;
10
13
  abstract isHandledElement(designItem: IDesignItem): boolean;
11
14
  protected _notifyChangedProperty(designItem: IDesignItem, property: IProperty, value: any): void;
@@ -4,6 +4,8 @@ import { BindingTarget } from '../../../item/BindingTarget.js';
4
4
  import { PropertyType } from '../PropertyType.js';
5
5
  import { NodeType } from '../../../item/NodeType.js';
6
6
  export class AbstractPropertiesService {
7
+ _stylesCache = new Map;
8
+ _cacheClearTimer;
7
9
  _notifyChangedProperty(designItem, property, value) {
8
10
  }
9
11
  getProperty(designItem, name) {
@@ -90,7 +92,7 @@ export class AbstractPropertiesService {
90
92
  let attributeName = property.attributeName;
91
93
  if (!attributeName)
92
94
  attributeName = PropertiesHelper.camelToDashCase(property.name);
93
- designItems.forEach((x) => {
95
+ for (let x of designItems) {
94
96
  let has = false;
95
97
  if (property.propertyType == PropertyType.cssValue)
96
98
  has = x.hasStyle(property.name);
@@ -98,7 +100,10 @@ export class AbstractPropertiesService {
98
100
  has = x.hasAttribute(attributeName);
99
101
  all = all && has;
100
102
  some = some || has;
101
- });
103
+ if (!all && some)
104
+ break;
105
+ }
106
+ ;
102
107
  //todo: optimize perf, do not call bindings service for each property.
103
108
  const bindings = designItems[0].serviceContainer.forSomeServicesTillResult('bindingService', (s) => {
104
109
  return s.getBindings(designItems[0]);
@@ -111,6 +116,18 @@ export class AbstractPropertiesService {
111
116
  if (bindings && bindings.find(x => x.target == BindingTarget.property && x.targetName == property.name))
112
117
  return ValueType.bound;
113
118
  }
119
+ if (!all && property.propertyType == PropertyType.cssValue) {
120
+ let styles = this._stylesCache.get(designItems[0]);
121
+ if (!styles) {
122
+ styles = new Set(designItems[0].getAllStyles().filter(x => x.selector != null).flatMap(x => x.declarations).map(x => x.name));
123
+ this._stylesCache.set(designItems[0], styles);
124
+ clearTimeout(this._cacheClearTimer);
125
+ this._cacheClearTimer = setTimeout(() => this._stylesCache.clear(), 30);
126
+ }
127
+ let cssValue = styles.has(property.name);
128
+ if (cssValue)
129
+ return ValueType.fromStylesheet;
130
+ }
114
131
  }
115
132
  else
116
133
  return ValueType.none;
@@ -162,7 +179,6 @@ export class AbstractPropertiesService {
162
179
  return bindings.find(x => (x.target == BindingTarget.property || x.target == BindingTarget.attribute) && x.targetName == property.name);
163
180
  }
164
181
  }
165
- //todo: optimize perf, call window.getComputedStyle only once per item, and not per property
166
182
  getUnsetValue(designItems, property) {
167
183
  if (property.propertyType == PropertyType.cssValue) {
168
184
  if (designItems != null && designItems.length !== 0) {
@@ -24,6 +24,11 @@ export class CommonPropertiesService extends AbstractPropertiesService {
24
24
  type: "string",
25
25
  service: this,
26
26
  propertyType: PropertyType.propertyAndAttribute
27
+ }, {
28
+ name: "part",
29
+ type: "string",
30
+ service: this,
31
+ propertyType: PropertyType.propertyAndAttribute
27
32
  }, {
28
33
  name: "tabindex",
29
34
  type: "number",
@@ -1,4 +1,4 @@
1
- import { CalculateGridInformation } from "../../../../helper/GridHelper.js";
1
+ import { calculateGridInformation } from "../../../../helper/GridHelper.js";
2
2
  import { getElementCombinedTransform } from "../../../../helper/TransformHelper.js";
3
3
  import { AbstractExtension } from '../AbstractExtension.js';
4
4
  import { OverlayLayer } from "../OverlayLayer.js";
@@ -16,7 +16,7 @@ export class DisplayGridExtension extends AbstractExtension {
16
16
  this.refresh(event);
17
17
  }
18
18
  refresh(event) {
19
- this.gridInformation = CalculateGridInformation(this.extendedItem);
19
+ this.gridInformation = calculateGridInformation(this.extendedItem);
20
20
  let cells = this.gridInformation.cells;
21
21
  if (!this._group) {
22
22
  this._group = this._drawGroup(null, this._group, OverlayLayer.Background);
@@ -56,7 +56,7 @@ export class DisplayGridExtension extends AbstractExtension {
56
56
  }
57
57
  _initSVGArrays() {
58
58
  this._removeAllOverlays();
59
- this.gridInformation = CalculateGridInformation(this.extendedItem);
59
+ this.gridInformation = calculateGridInformation(this.extendedItem);
60
60
  this._cells = new Array(this.gridInformation.cells.length);
61
61
  this.gridInformation.cells.forEach((row, i) => this._cells[i] = new Array(row.length));
62
62
  this._texts = new Array(this.gridInformation.cells.length);
@@ -1,10 +1,10 @@
1
- import { CalculateGridInformation } from "../../../../helper/GridHelper.js";
1
+ import { calculateGridInformation } from "../../../../helper/GridHelper.js";
2
2
  import { IDesignItem } from '../../../../item/IDesignItem.js';
3
3
  import { IDesignerCanvas } from '../../IDesignerCanvas.js';
4
4
  import { AbstractExtension } from '../AbstractExtension.js';
5
5
  import { IExtensionManager } from '../IExtensionManger.js';
6
6
  export declare class EditGridColumnRowSizesExtension extends AbstractExtension {
7
- gridInformation: ReturnType<typeof CalculateGridInformation>;
7
+ gridInformation: ReturnType<typeof calculateGridInformation>;
8
8
  private _resizers;
9
9
  private _initalPos;
10
10
  private _initialSizes;
@@ -1,6 +1,6 @@
1
1
  import { EventNames } from "../../../../../enums/EventNames.js";
2
2
  import { convertCssUnit, convertCssUnitToPixel, getCssUnit } from "../../../../helper/CssUnitConverter.js";
3
- import { CalculateGridInformation } from "../../../../helper/GridHelper.js";
3
+ import { calculateGridInformation } from "../../../../helper/GridHelper.js";
4
4
  import { getElementCombinedTransform } from "../../../../helper/TransformHelper.js";
5
5
  import { AbstractExtension } from '../AbstractExtension.js';
6
6
  import { OverlayLayer } from "../OverlayLayer.js";
@@ -17,7 +17,7 @@ export class EditGridColumnRowSizesExtension extends AbstractExtension {
17
17
  this.refresh(event);
18
18
  }
19
19
  refresh(event) {
20
- this.gridInformation = CalculateGridInformation(this.extendedItem);
20
+ this.gridInformation = calculateGridInformation(this.extendedItem);
21
21
  this._group = this._drawGroup(null, this._group, OverlayLayer.Background);
22
22
  this._group.style.transform = getElementCombinedTransform(this.extendedItem.element).toString();
23
23
  this._group.style.transformOrigin = '0 0';
@@ -185,7 +185,7 @@ export class PropertyGridPropertyList extends BaseCustomWebComponentLazyAppend {
185
185
  let label = document.createElement("label");
186
186
  label.htmlFor = p.name;
187
187
  label.textContent = p.name;
188
- label.title = p.name;
188
+ label.title = p.name + ' (type: ' + p.type + (p.defaultValue ? ', default: ' + p.defaultValue : '') + ', propertytype: ' + p.propertyType + ')';
189
189
  label.ondragleave = (e) => this._onDragLeave(e, p, label);
190
190
  label.ondragover = (e) => this._onDragOver(e, p, label);
191
191
  label.ondrop = (e) => this._onDrop(e, p, label);
@@ -251,16 +251,29 @@ export class PropertyGridPropertyList extends BaseCustomWebComponentLazyAppend {
251
251
  PropertyGridPropertyList.openContextMenu(event, this._designItems, property);
252
252
  }
253
253
  static openContextMenu(event, designItems, property) {
254
- const ctxMenu = [
254
+ const ctxMenuItems = [
255
255
  {
256
256
  title: 'clear', action: (e) => {
257
257
  property.service.clearValue(designItems, property, 'value');
258
258
  designItems[0].instanceServiceContainer.designerCanvas.extensionManager.refreshAllExtensions(designItems);
259
259
  }
260
260
  },
261
+ {
262
+ title: 'edit as text', action: (e, _1, _2, menu) => {
263
+ menu.close();
264
+ setTimeout(() => {
265
+ const oldValue = property.service.getValue(designItems, property);
266
+ let value = prompt(`edit value of '${property.name}' as string:`, oldValue);
267
+ if (value && value != oldValue) {
268
+ property.service.setValue(designItems, property, value);
269
+ }
270
+ designItems[0].instanceServiceContainer.designerCanvas.extensionManager.refreshAllExtensions(designItems);
271
+ }, 10);
272
+ }
273
+ },
261
274
  ];
262
275
  if (designItems[0].serviceContainer.config.openBindingsEditor) {
263
- ctxMenu.push(...[
276
+ ctxMenuItems.push(...[
264
277
  { title: '-' },
265
278
  {
266
279
  title: 'edit binding', action: () => {
@@ -278,7 +291,7 @@ export class PropertyGridPropertyList extends BaseCustomWebComponentLazyAppend {
278
291
  ]);
279
292
  }
280
293
  ;
281
- ContextMenu.show(ctxMenu, event);
294
+ ContextMenu.show(ctxMenuItems, event);
282
295
  }
283
296
  designItemsChanged(designItems) {
284
297
  this._designItems = designItems;
@@ -306,6 +319,10 @@ export class PropertyGridPropertyList extends BaseCustomWebComponentLazyAppend {
306
319
  isSetElement.style.background = 'gray';
307
320
  else if (s == ValueType.bound)
308
321
  isSetElement.style.background = 'orange';
322
+ else if (s == ValueType.fromStylesheet) {
323
+ v = propertiesService.getUnsetValue(items, property);
324
+ isSetElement.style.background = 'yellow';
325
+ }
309
326
  editor?.refreshValueWithoutNotification(s, v);
310
327
  }
311
328
  else {
package/dist/index.d.ts CHANGED
@@ -15,7 +15,7 @@ export * from "./elements/helper/contextMenu/ContextMenu.js";
15
15
  export * from "./elements/helper/Helper.js";
16
16
  export * from "./elements/helper/SwitchContainerHelper.js";
17
17
  export * from "./elements/helper/NpmPackageLoader.js";
18
- export type { IContextMenuItem } from "./elements/helper/contextMenu/IContextMenuItem.js";
18
+ export type { IContextMenuItem, IContextMenu } from "./elements/helper/contextMenu/IContextMenuItem.js";
19
19
  export * from "./elements/item/DesignItem.js";
20
20
  export type { IDesignItem } from "./elements/item/IDesignItem.js";
21
21
  export type { IBinding } from "./elements/item/IBinding.js";
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.272",
4
+ "version": "0.0.274",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",
@@ -13,7 +13,7 @@
13
13
  "prepublishOnly": "npm run build"
14
14
  },
15
15
  "dependencies": {
16
- "@node-projects/base-custom-webcomponent": "^0.13.0"
16
+ "@node-projects/base-custom-webcomponent": "^0.15.0"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@adobe/css-tools": "4.3.1",