@node-projects/web-component-designer 0.1.334 → 0.1.335

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 (34) hide show
  1. package/dist/elements/item/DesignItem.d.ts +1 -1
  2. package/dist/elements/services/DefaultServiceBootstrap.js +2 -0
  3. package/dist/elements/services/DefaultServiceBootstrap.js.map +1 -1
  4. package/dist/elements/services/ServiceContainer.d.ts +3 -0
  5. package/dist/elements/services/ServiceContainer.js +3 -0
  6. package/dist/elements/services/ServiceContainer.js.map +1 -1
  7. package/dist/elements/services/miniatureViewService/IMinatureViewService copy.d.ts +2 -0
  8. package/dist/elements/services/miniatureViewService/IMinatureViewService copy.js +2 -0
  9. package/dist/elements/services/miniatureViewService/IMinatureViewService copy.js.map +1 -0
  10. package/dist/elements/services/miniatureViewService/IMinatureViewService.d.ts +4 -0
  11. package/dist/elements/services/miniatureViewService/IMinatureViewService.js +2 -0
  12. package/dist/elements/services/miniatureViewService/IMinatureViewService.js.map +1 -0
  13. package/dist/elements/services/miniatureViewService/IMiniatureViewService.d.ts +4 -0
  14. package/dist/elements/services/miniatureViewService/IMiniatureViewService.js +2 -0
  15. package/dist/elements/services/miniatureViewService/IMiniatureViewService.js.map +1 -0
  16. package/dist/elements/services/miniatureViewService/MinatureViewService.d.ts +5 -0
  17. package/dist/elements/services/miniatureViewService/MinatureViewService.js +10 -0
  18. package/dist/elements/services/miniatureViewService/MinatureViewService.js.map +1 -0
  19. package/dist/elements/services/miniatureViewService/MiniatureViewService.d.ts +5 -0
  20. package/dist/elements/services/miniatureViewService/MiniatureViewService.js +10 -0
  21. package/dist/elements/services/miniatureViewService/MiniatureViewService.js.map +1 -0
  22. package/dist/elements/widgets/designerView/DomConverter.d.ts +1 -1
  23. package/dist/elements/widgets/miniatureView/miniature-view.d.ts +33 -0
  24. package/dist/elements/widgets/miniatureView/miniature-view.js +178 -0
  25. package/dist/elements/widgets/miniatureView/miniature-view.js.map +1 -0
  26. package/dist/elements/widgets/miniatureView/miniatureView.d.ts +34 -0
  27. package/dist/elements/widgets/miniatureView/miniatureView.js +171 -0
  28. package/dist/elements/widgets/miniatureView/miniatureView.js.map +1 -0
  29. package/dist/index-min.js +127 -85
  30. package/dist/index-min.js.map +4 -4
  31. package/dist/index.d.ts +3 -0
  32. package/dist/index.js +2 -0
  33. package/dist/index.js.map +1 -1
  34. package/package.json +1 -1
@@ -0,0 +1,171 @@
1
+ import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
2
+ export class MiniatureView extends BaseCustomWebComponentConstructorAppend {
3
+ static style = css `
4
+ :host {
5
+ overflow:hidden;
6
+ display: block;
7
+ width: 100%;
8
+ height: 100%;
9
+ position: relative;
10
+ }
11
+ #outerDiv {
12
+ width: 100%;
13
+ height: 100%;
14
+ }
15
+ #innerDiv {
16
+ transform-origin: top left;
17
+ height: 100%;
18
+ width: 100%;
19
+ image-rendering: pixelated;
20
+ }
21
+ #above {
22
+ position: absolute;
23
+ top: 0;
24
+ left: 0;
25
+ width: 100%;
26
+ height: 100%;
27
+ pointer-events: auto;
28
+ background: transparent;
29
+ cursor: pointer;
30
+ }
31
+ #viewRect {
32
+ position: absolute;
33
+ top: 0;
34
+ left: 0;
35
+ width: 100%;
36
+ height: 100%;
37
+ border: 1px solid black;
38
+ pointer-events: none;
39
+ }`;
40
+ static template = html `
41
+ <div id="outerDiv">
42
+ <div id="innerDiv"></div>
43
+ </div>
44
+ <div id="above">
45
+ <div id="viewRect"></div>
46
+ </div>`;
47
+ _innerDiv;
48
+ _outerDiv;
49
+ _above;
50
+ _instanceServiceContainer;
51
+ _contentChangedHandler;
52
+ _maxX = 0;
53
+ _maxY = 0;
54
+ _resizeObserver;
55
+ _innerShadow;
56
+ _zoomFactorChangedHandler;
57
+ _viewRect;
58
+ _minatureScaleX = 1;
59
+ _minatureScaleY = 1;
60
+ _reRenderFlag = false;
61
+ _isDragging = false;
62
+ _boundMouseMove;
63
+ _boundMouseUp;
64
+ constructor() {
65
+ super();
66
+ this._restoreCachedInititalValues();
67
+ this._outerDiv = this._getDomElement('outerDiv');
68
+ this._innerDiv = this._getDomElement('innerDiv');
69
+ this._viewRect = this._getDomElement('viewRect');
70
+ this._above = this._getDomElement('above');
71
+ this._innerShadow = this._innerDiv.attachShadow({ mode: 'open' });
72
+ this._boundMouseMove = this._onMouseMove.bind(this);
73
+ this._boundMouseUp = this._onMouseUp.bind(this);
74
+ this._above.addEventListener('mousedown', (e) => this._onMouseDown(e));
75
+ this._resizeObserver = new ResizeObserver(() => {
76
+ this._reSize();
77
+ });
78
+ }
79
+ ready() {
80
+ this._resizeObserver.observe(this);
81
+ }
82
+ _reSize() {
83
+ const outerRect = this._outerDiv.getBoundingClientRect();
84
+ this._minatureScaleX = outerRect.width / this._maxX;
85
+ this._minatureScaleY = outerRect.height / this._maxY;
86
+ this._innerDiv.style.scale = this._minatureScaleX + ' ' + this._minatureScaleY;
87
+ }
88
+ async _reRender() {
89
+ if (this._instanceServiceContainer) {
90
+ const designerCanvas = this._instanceServiceContainer?.designerCanvas;
91
+ this._innerShadow.adoptedStyleSheets = [...designerCanvas.rootDesignItem.element.shadowRoot.adoptedStyleSheets];
92
+ const pixelSize = designerCanvas.designerPixelSize;
93
+ this._maxX = pixelSize.width;
94
+ this._maxY = pixelSize.height;
95
+ const miniatureViewContent = await this._instanceServiceContainer.designerCanvas.serviceContainer.miniatureViewService.provideMiniatureView(designerCanvas);
96
+ this._innerShadow.replaceChildren(miniatureViewContent);
97
+ this._reSize();
98
+ this._reDrawRect();
99
+ this._reRenderFlag = false;
100
+ }
101
+ }
102
+ _reDrawRect() {
103
+ const designerCanvas = this._instanceServiceContainer?.designerCanvas;
104
+ const offset = designerCanvas.canvasOffset;
105
+ const zoom = designerCanvas.zoomFactor;
106
+ this._viewRect.style.left = (-offset.x / this._maxX * 100) + '%';
107
+ this._viewRect.style.top = (-offset.y / this._maxY * 100) + '%';
108
+ this._viewRect.style.width = (designerCanvas.clientWidth / zoom / this._maxX * 100) + '%';
109
+ this._viewRect.style.height = (designerCanvas.clientHeight / zoom / this._maxY * 100) + '%';
110
+ }
111
+ _onMouseDown(e) {
112
+ if (!this._instanceServiceContainer)
113
+ return;
114
+ this._isDragging = true;
115
+ this._moveCanvasToMousePosition(e);
116
+ window.addEventListener('mousemove', this._boundMouseMove);
117
+ window.addEventListener('mouseup', this._boundMouseUp);
118
+ e.preventDefault();
119
+ }
120
+ _onMouseMove(e) {
121
+ if (!this._isDragging)
122
+ return;
123
+ this._moveCanvasToMousePosition(e);
124
+ e.preventDefault();
125
+ }
126
+ _onMouseUp(e) {
127
+ this._isDragging = false;
128
+ window.removeEventListener('mousemove', this._boundMouseMove);
129
+ window.removeEventListener('mouseup', this._boundMouseUp);
130
+ }
131
+ _moveCanvasToMousePosition(e) {
132
+ const designerCanvas = this._instanceServiceContainer.designerCanvas;
133
+ const zoom = designerCanvas.zoomFactor;
134
+ const aboveRect = this._above.getBoundingClientRect();
135
+ const mouseX = e.clientX - aboveRect.left;
136
+ const mouseY = e.clientY - aboveRect.top;
137
+ const contentX = (mouseX / aboveRect.width) * this._maxX;
138
+ const contentY = (mouseY / aboveRect.height) * this._maxY;
139
+ const halfViewW = designerCanvas.clientWidth / zoom / 2;
140
+ const halfViewH = designerCanvas.clientHeight / zoom / 2;
141
+ designerCanvas.canvasOffset = {
142
+ x: -(contentX - halfViewW),
143
+ y: -(contentY - halfViewH)
144
+ };
145
+ }
146
+ set instanceServiceContainer(value) {
147
+ this._contentChangedHandler?.dispose();
148
+ this._zoomFactorChangedHandler?.dispose();
149
+ this._instanceServiceContainer = value;
150
+ if (this._instanceServiceContainer) {
151
+ this._zoomFactorChangedHandler = this._instanceServiceContainer.designerCanvas.onZoomFactorChanged.on(() => {
152
+ this._reDrawRect();
153
+ });
154
+ this._contentChangedHandler = this._instanceServiceContainer.contentService.onContentChanged.on(e => {
155
+ if (this._reRenderFlag === false) {
156
+ this._reRenderFlag = true;
157
+ setTimeout(() => this._reRender(), 50);
158
+ }
159
+ });
160
+ if (this._reRenderFlag === false) {
161
+ this._reRenderFlag = true;
162
+ setTimeout(() => this._reRender(), 50);
163
+ }
164
+ }
165
+ else {
166
+ this._innerShadow.innerHTML = "";
167
+ }
168
+ }
169
+ }
170
+ customElements.define('node-projects-web-component-designer-miniature-view', MiniatureView);
171
+ //# sourceMappingURL=miniatureView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"miniatureView.js","sourceRoot":"","sources":["../../../../src/elements/widgets/miniatureView/miniatureView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uCAAuC,EAAE,GAAG,EAAE,IAAI,EAAc,MAAM,yCAAyC,CAAC;AAKzH,MAAM,OAAO,aAAc,SAAQ,uCAAuC;IAExE,MAAM,CAAmB,KAAK,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAoC5B,CAAC;IAET,MAAM,CAAmB,QAAQ,GAAG,IAAI,CAAA;;;;;;eAM3B,CAAC;IAEN,SAAS,CAAiB;IAC1B,SAAS,CAAiB;IAC1B,MAAM,CAAiB;IACvB,yBAAyB,CAA2B;IACpD,sBAAsB,CAAa;IACnC,KAAK,GAAG,CAAC,CAAC;IACV,KAAK,GAAG,CAAC,CAAC;IACV,eAAe,CAAiB;IAChC,YAAY,CAAa;IACzB,yBAAyB,CAAa;IACtC,SAAS,CAAiB;IAC1B,eAAe,GAAG,CAAC,CAAC;IACpB,eAAe,GAAG,CAAC,CAAC;IACpB,aAAa,GAAG,KAAK,CAAC;IACtB,WAAW,GAAG,KAAK,CAAC;IACpB,eAAe,CAA0B;IACzC,aAAa,CAA0B;IAE/C;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,4BAA4B,EAAE,CAAC;QAEpC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,cAAc,CAAiB,UAAU,CAAC,CAAC;QACjE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,cAAc,CAAiB,UAA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