@acorex/components 19.13.0-next.0 → 19.13.0-next.10
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.
- package/calendar/lib/calendar-range.component.d.ts +0 -4
- package/fesm2022/acorex-components-action-sheet.mjs +10 -10
- package/fesm2022/acorex-components-alert.mjs +7 -7
- package/fesm2022/acorex-components-audio-wave.mjs +7 -7
- package/fesm2022/acorex-components-autocomplete.mjs +7 -7
- package/fesm2022/acorex-components-avatar.mjs +10 -10
- package/fesm2022/acorex-components-badge.mjs +7 -7
- package/fesm2022/acorex-components-bottom-navigation.mjs +10 -10
- package/fesm2022/acorex-components-breadcrumbs.mjs +10 -10
- package/fesm2022/acorex-components-button-group.mjs +10 -10
- package/fesm2022/acorex-components-button.mjs +15 -15
- package/fesm2022/acorex-components-button.mjs.map +1 -1
- package/fesm2022/acorex-components-calendar.mjs +16 -17
- package/fesm2022/acorex-components-calendar.mjs.map +1 -1
- package/fesm2022/acorex-components-check-box.mjs +7 -7
- package/fesm2022/acorex-components-chips.mjs +7 -7
- package/fesm2022/acorex-components-circular-progress.mjs +7 -7
- package/fesm2022/acorex-components-collapse.mjs +10 -10
- package/fesm2022/acorex-components-color-box.mjs +7 -7
- package/fesm2022/acorex-components-color-palette.mjs +25 -25
- package/fesm2022/acorex-components-comment.mjs +28 -28
- package/fesm2022/acorex-components-common.mjs +91 -91
- package/fesm2022/acorex-components-conversation.mjs +49 -49
- package/fesm2022/acorex-components-cron-job.mjs +46 -46
- package/fesm2022/acorex-components-data-pager.mjs +31 -31
- package/fesm2022/acorex-components-data-table.mjs +37 -37
- package/fesm2022/acorex-components-datetime-box.mjs +7 -7
- package/fesm2022/acorex-components-datetime-input.mjs +7 -7
- package/fesm2022/acorex-components-datetime-picker.mjs +7 -7
- package/fesm2022/acorex-components-decorators.mjs +27 -27
- package/fesm2022/acorex-components-decorators.mjs.map +1 -1
- package/fesm2022/acorex-components-dialog.mjs +10 -10
- package/fesm2022/acorex-components-drawer.mjs +13 -13
- package/fesm2022/acorex-components-dropdown-button.mjs +7 -7
- package/fesm2022/acorex-components-dropdown.mjs +13 -13
- package/fesm2022/acorex-components-file-explorer.mjs +25 -25
- package/fesm2022/acorex-components-flow-chart.mjs +669 -0
- package/fesm2022/acorex-components-flow-chart.mjs.map +1 -0
- package/fesm2022/acorex-components-form.mjs +25 -23
- package/fesm2022/acorex-components-form.mjs.map +1 -1
- package/fesm2022/acorex-components-grid-layout-builder.mjs +10 -10
- package/fesm2022/acorex-components-image-editor.mjs +34 -34
- package/fesm2022/acorex-components-image.mjs +23 -11
- package/fesm2022/acorex-components-image.mjs.map +1 -1
- package/fesm2022/acorex-components-json-viewer.mjs +7 -7
- package/fesm2022/acorex-components-kbd.mjs +10 -10
- package/fesm2022/acorex-components-label.mjs +7 -7
- package/fesm2022/acorex-components-list.mjs +7 -7
- package/fesm2022/acorex-components-loading-dialog.mjs +10 -10
- package/fesm2022/acorex-components-loading.mjs +16 -16
- package/fesm2022/acorex-components-map.mjs +10 -10
- package/fesm2022/acorex-components-media-viewer.mjs +34 -34
- package/fesm2022/acorex-components-media-viewer.mjs.map +1 -1
- package/fesm2022/acorex-components-menu.mjs +16 -16
- package/fesm2022/{acorex-components-modal-acorex-components-modal-BzlZIwq8.mjs → acorex-components-modal-acorex-components-modal-B4nBGqa3.mjs} +21 -21
- package/fesm2022/acorex-components-modal-acorex-components-modal-B4nBGqa3.mjs.map +1 -0
- package/fesm2022/{acorex-components-modal-modal-content.component-zmFWBaiD.mjs → acorex-components-modal-modal-content.component-oWerCvDI.mjs} +10 -6
- package/fesm2022/acorex-components-modal-modal-content.component-oWerCvDI.mjs.map +1 -0
- package/fesm2022/acorex-components-modal.mjs +1 -1
- package/fesm2022/acorex-components-navbar.mjs +7 -7
- package/fesm2022/acorex-components-notification.mjs +10 -10
- package/fesm2022/acorex-components-number-box.mjs +7 -7
- package/fesm2022/acorex-components-otp.mjs +7 -7
- package/fesm2022/acorex-components-page.mjs +10 -10
- package/fesm2022/acorex-components-paint.mjs +25 -25
- package/fesm2022/acorex-components-password-box.mjs +10 -10
- package/fesm2022/acorex-components-pdf-reader.mjs +7 -7
- package/fesm2022/acorex-components-phone-box.mjs +7 -7
- package/fesm2022/acorex-components-picker.mjs +13 -13
- package/fesm2022/acorex-components-popover.mjs +7 -7
- package/fesm2022/acorex-components-popup.mjs +11 -11
- package/fesm2022/acorex-components-popup.mjs.map +1 -1
- package/fesm2022/acorex-components-progress-bar.mjs +7 -7
- package/fesm2022/acorex-components-qrcode.mjs +7 -7
- package/fesm2022/acorex-components-query-builder.mjs +7 -7
- package/fesm2022/acorex-components-radio.mjs +7 -7
- package/fesm2022/acorex-components-rail-navigation.mjs +13 -13
- package/fesm2022/acorex-components-range-slider.mjs +7 -7
- package/fesm2022/acorex-components-rate-picker.mjs +7 -7
- package/fesm2022/acorex-components-rest-api-generator.mjs +22 -22
- package/fesm2022/acorex-components-result.mjs +7 -7
- package/fesm2022/acorex-components-routing-progress.mjs +7 -7
- package/fesm2022/acorex-components-scheduler.mjs +585 -122
- package/fesm2022/acorex-components-scheduler.mjs.map +1 -1
- package/fesm2022/acorex-components-scss.mjs +4 -4
- package/fesm2022/acorex-components-search-box.mjs +7 -7
- package/fesm2022/acorex-components-select-box.mjs +7 -7
- package/fesm2022/acorex-components-selection-list.mjs +7 -7
- package/fesm2022/acorex-components-side-menu.mjs +13 -13
- package/fesm2022/acorex-components-skeleton.mjs +7 -7
- package/fesm2022/acorex-components-slider.mjs +7 -7
- package/fesm2022/acorex-components-sliding-item.mjs +13 -13
- package/fesm2022/acorex-components-step-wizard.mjs +13 -13
- package/fesm2022/acorex-components-switch.mjs +10 -10
- package/fesm2022/acorex-components-tabs.mjs +13 -13
- package/fesm2022/acorex-components-tag-box.mjs +7 -7
- package/fesm2022/acorex-components-tag.mjs +7 -7
- package/fesm2022/acorex-components-text-area.mjs +7 -7
- package/fesm2022/acorex-components-text-box.mjs +10 -10
- package/fesm2022/acorex-components-time-line.mjs +10 -10
- package/fesm2022/acorex-components-toast.mjs +10 -10
- package/fesm2022/acorex-components-toolbar.mjs +7 -7
- package/fesm2022/acorex-components-tooltip.mjs +10 -10
- package/fesm2022/acorex-components-tree-view.mjs +10 -10
- package/fesm2022/acorex-components-uploader.mjs +22 -22
- package/fesm2022/acorex-components-video-player.mjs +7 -7
- package/fesm2022/acorex-components-wysiwyg.mjs +31 -31
- package/flow-chart/README.md +3 -0
- package/flow-chart/index.d.ts +5 -0
- package/flow-chart/lib/flow-chart-creator/flow-chart-creator.component.d.ts +13 -0
- package/flow-chart/lib/flow-chart-renderer/flow-chart-renderer.component.d.ts +22 -0
- package/flow-chart/lib/flow-chart.component.d.ts +24 -0
- package/flow-chart/lib/flow-chart.module.d.ts +10 -0
- package/flow-chart/lib/flow-chart.service.d.ts +57 -0
- package/flow-chart/lib/flow-chart.type.d.ts +37 -0
- package/form/lib/form-field.component.d.ts +3 -2
- package/image/lib/image.component.d.ts +4 -1
- package/modal/lib/modal-content/modal-content.component.d.ts +5 -1
- package/modal/lib/modal-state.service.d.ts +1 -1
- package/modal/lib/modal.service.d.ts +1 -1
- package/package.json +5 -1
- package/scheduler/README.md +2 -2
- package/scheduler/index.d.ts +4 -0
- package/scheduler/lib/scheduler.class.d.ts +12 -6
- package/scheduler/lib/scheduler.component.d.ts +6 -12
- package/scheduler/lib/scheduler.module.d.ts +2 -1
- package/scheduler/lib/scheduler.service.d.ts +4 -0
- package/scheduler/lib/views/agenda/scheduler-agenda-view.component.d.ts +30 -0
- package/scheduler/lib/views/day/scheduler-day-view.component.d.ts +6 -4
- package/scheduler/lib/views/month/scheduler-month-view.component.d.ts +5 -3
- package/scheduler/lib/views/timeline-day/scheduler-timeline-day-view.component.d.ts +30 -0
- package/scheduler/lib/views/timeline-month/scheduler-timeline-month-view.component.d.ts +37 -0
- package/scheduler/lib/views/timeline-multi-day/scheduler-timeline-multi-day-view.component.d.ts +25 -0
- package/scheduler/lib/views/week/scheduler-week-view.component.d.ts +11 -7
- package/fesm2022/acorex-components-modal-acorex-components-modal-BzlZIwq8.mjs.map +0 -1
- package/fesm2022/acorex-components-modal-modal-content.component-zmFWBaiD.mjs.map +0 -1
@@ -0,0 +1,669 @@
|
|
1
|
+
import * as i2 from '@acorex/components/button';
|
2
|
+
import { AXButtonModule } from '@acorex/components/button';
|
3
|
+
import { NXComponent } from '@acorex/components/common';
|
4
|
+
import * as i1 from '@acorex/components/text-box';
|
5
|
+
import { AXTextBoxModule } from '@acorex/components/text-box';
|
6
|
+
import * as i3 from '@angular/common';
|
7
|
+
import { CommonModule } from '@angular/common';
|
8
|
+
import * as i0 from '@angular/core';
|
9
|
+
import { inject, NgZone, signal, effect, Injectable, ViewEncapsulation, ChangeDetectionStrategy, Component, viewChild, output, afterNextRender, input, computed, HostListener, NgModule } from '@angular/core';
|
10
|
+
import * as i4 from '@angular/forms';
|
11
|
+
import { FormsModule } from '@angular/forms';
|
12
|
+
import { Subject } from 'rxjs';
|
13
|
+
|
14
|
+
class AXFlowChartService {
|
15
|
+
constructor() {
|
16
|
+
this.zone = inject(NgZone);
|
17
|
+
this.initialFlowChartEdge = signal([]);
|
18
|
+
this.initialFlowChartNode = signal([]);
|
19
|
+
this.selectedNode = signal(null);
|
20
|
+
this.selectedEdge = signal(null);
|
21
|
+
this.svgService = signal(null);
|
22
|
+
this.canvasService = signal(null);
|
23
|
+
this.lineClick = new Subject();
|
24
|
+
this.lineDbClick = new Subject();
|
25
|
+
this.nodeClick = new Subject();
|
26
|
+
this.nodeDbClick = new Subject();
|
27
|
+
this.onEdgeUpdate = new Subject();
|
28
|
+
this.onNodeUpdate = new Subject();
|
29
|
+
this.nodesMap = new Map();
|
30
|
+
this.eventListeners = new Map();
|
31
|
+
this.anchorClickBuffer = null;
|
32
|
+
this.currentConnection = null;
|
33
|
+
this.draggingConnection = false;
|
34
|
+
this.tempLine = null;
|
35
|
+
this.#eff2 = effect(() => {
|
36
|
+
if (this.initialFlowChartEdge()) {
|
37
|
+
setTimeout(() => {
|
38
|
+
this.drawEdges(this.initialFlowChartEdge());
|
39
|
+
});
|
40
|
+
}
|
41
|
+
});
|
42
|
+
this.#eff3 = effect(() => {
|
43
|
+
if (this.initialFlowChartNode()) {
|
44
|
+
this.createNode(this.initialFlowChartNode());
|
45
|
+
}
|
46
|
+
});
|
47
|
+
}
|
48
|
+
#eff2;
|
49
|
+
#eff3;
|
50
|
+
addEventListener(element, event, handler) {
|
51
|
+
const elementId = element.dataset['id'] || 'global';
|
52
|
+
if (!this.eventListeners.has(elementId)) {
|
53
|
+
this.eventListeners.set(elementId, new Map());
|
54
|
+
}
|
55
|
+
const elementListeners = this.eventListeners.get(elementId);
|
56
|
+
if (elementListeners) {
|
57
|
+
const boundHandler = handler.bind(this);
|
58
|
+
elementListeners.set(event, boundHandler);
|
59
|
+
element.addEventListener(event, boundHandler);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
removeEventListeners(elementId) {
|
63
|
+
const elementListeners = this.eventListeners.get(elementId);
|
64
|
+
if (elementListeners) {
|
65
|
+
elementListeners.forEach((handler, event) => {
|
66
|
+
const element = this.nodesMap.get(elementId);
|
67
|
+
if (element) {
|
68
|
+
element.removeEventListener(event, handler);
|
69
|
+
}
|
70
|
+
});
|
71
|
+
this.eventListeners.delete(elementId);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
setupNodeEventListeners(el, node) {
|
75
|
+
this.addEventListener(el, 'click', (e) => {
|
76
|
+
this.nodeClick.next({ target: el, event: e });
|
77
|
+
this.selectedNode.set(node);
|
78
|
+
el.classList.add('selected');
|
79
|
+
this.nodesMap.forEach((existingNode) => {
|
80
|
+
if (existingNode !== el) {
|
81
|
+
existingNode.classList.remove('selected');
|
82
|
+
}
|
83
|
+
});
|
84
|
+
});
|
85
|
+
this.addEventListener(el, 'dblclick', (e) => {
|
86
|
+
this.nodeDbClick.next({ target: el, event: e });
|
87
|
+
});
|
88
|
+
this.addEventListener(el, 'mouseenter', () => {
|
89
|
+
el.classList.add('hover');
|
90
|
+
});
|
91
|
+
this.addEventListener(el, 'mouseleave', () => {
|
92
|
+
el.classList.remove('hover');
|
93
|
+
});
|
94
|
+
}
|
95
|
+
setupAnchorEventListeners(dot, el) {
|
96
|
+
// start drag to connect
|
97
|
+
this.addEventListener(dot, 'mousedown', (e) => {
|
98
|
+
const mouseEvent = e;
|
99
|
+
mouseEvent.stopPropagation();
|
100
|
+
mouseEvent.preventDefault();
|
101
|
+
const pos = this.getAnchorPoint(el, dot.dataset['anchor']);
|
102
|
+
this.currentConnection = {
|
103
|
+
source: {
|
104
|
+
id: dot.dataset['nodeId'],
|
105
|
+
anchor: dot.dataset['anchor'],
|
106
|
+
},
|
107
|
+
mouse: { x: mouseEvent.clientX, y: mouseEvent.clientY },
|
108
|
+
};
|
109
|
+
this.startTempLine(pos.x, pos.y);
|
110
|
+
this.draggingConnection = true;
|
111
|
+
});
|
112
|
+
this.addEventListener(dot, 'click', (e) => {
|
113
|
+
e.stopPropagation();
|
114
|
+
if (dot.classList.contains('selected')) {
|
115
|
+
dot.classList.remove('selected');
|
116
|
+
}
|
117
|
+
else {
|
118
|
+
dot.classList.add('selected');
|
119
|
+
}
|
120
|
+
const clicked = {
|
121
|
+
nodeId: dot.dataset['nodeId'],
|
122
|
+
anchor: dot.dataset['anchor'],
|
123
|
+
};
|
124
|
+
console.log(clicked);
|
125
|
+
if (!this.anchorClickBuffer) {
|
126
|
+
this.anchorClickBuffer = clicked;
|
127
|
+
}
|
128
|
+
else {
|
129
|
+
const source = this.anchorClickBuffer;
|
130
|
+
const target = clicked;
|
131
|
+
if (source.nodeId !== target.nodeId) {
|
132
|
+
this.pushAndCreateEdgeData({ id: source.nodeId, anchor: source.anchor }, { id: target.nodeId, anchor: target.anchor });
|
133
|
+
}
|
134
|
+
this.anchorClickBuffer = null;
|
135
|
+
}
|
136
|
+
});
|
137
|
+
this.addEventListener(dot, 'mouseenter', () => {
|
138
|
+
dot.classList.add('hover');
|
139
|
+
});
|
140
|
+
this.addEventListener(dot, 'mouseleave', () => {
|
141
|
+
dot.classList.remove('hover');
|
142
|
+
});
|
143
|
+
}
|
144
|
+
addAnchors(el, type) {
|
145
|
+
['top', 'bottom', 'left', 'right'].forEach((anchor) => {
|
146
|
+
const dot = document.createElement('div');
|
147
|
+
dot.className = 'ax-flow-chart-anchor';
|
148
|
+
dot.dataset['anchor'] = anchor;
|
149
|
+
dot.dataset['nodeId'] = el.dataset['id'];
|
150
|
+
this.positionAnchor(dot, anchor, type);
|
151
|
+
el.appendChild(dot);
|
152
|
+
this.setupAnchorEventListeners(dot, el);
|
153
|
+
});
|
154
|
+
}
|
155
|
+
makeDraggable(el) {
|
156
|
+
let offsetX = 0, offsetY = 0, isDragging = false;
|
157
|
+
this.addEventListener(el, 'mousedown', (e) => {
|
158
|
+
const mouseEvent = e;
|
159
|
+
if (mouseEvent.target.classList.contains('ax-flow-chart-anchor'))
|
160
|
+
return;
|
161
|
+
isDragging = true;
|
162
|
+
offsetX = mouseEvent.clientX - el.offsetLeft;
|
163
|
+
offsetY = mouseEvent.clientY - el.offsetTop;
|
164
|
+
mouseEvent.preventDefault();
|
165
|
+
});
|
166
|
+
const mousemoveHandler = (e) => {
|
167
|
+
if (isDragging) {
|
168
|
+
el.style.left = e.clientX - offsetX + 'px';
|
169
|
+
el.style.top = e.clientY - offsetY + 'px';
|
170
|
+
this.drawEdges(this.initialFlowChartEdge());
|
171
|
+
this.initialFlowChartNode.update((value) => {
|
172
|
+
const node = value.find((node) => node.id === el.dataset['id']);
|
173
|
+
if (node) {
|
174
|
+
node.x = e.clientX - offsetX;
|
175
|
+
node.y = e.clientY - offsetY;
|
176
|
+
}
|
177
|
+
return value;
|
178
|
+
});
|
179
|
+
}
|
180
|
+
const elementId = e.target.id;
|
181
|
+
if (elementId === 'ax-flow-chart-renderer-connections' || elementId === 'ax-flow-chart-renderer-canvas') {
|
182
|
+
if (this.draggingConnection && this.tempLine) {
|
183
|
+
this.tempLine.setAttribute('x2', e.offsetX.toString());
|
184
|
+
this.tempLine.setAttribute('y2', e.offsetY.toString());
|
185
|
+
}
|
186
|
+
}
|
187
|
+
};
|
188
|
+
const mouseupHandler = (e) => {
|
189
|
+
isDragging = false;
|
190
|
+
if (this.draggingConnection) {
|
191
|
+
const target = e.target.closest('.ax-flow-chart-anchor');
|
192
|
+
if (target && target.dataset['nodeId'] !== this.currentConnection?.source?.id) {
|
193
|
+
this.currentConnection = {
|
194
|
+
...this.currentConnection,
|
195
|
+
target: {
|
196
|
+
id: target.dataset['nodeId'],
|
197
|
+
anchor: target.dataset['anchor'],
|
198
|
+
},
|
199
|
+
};
|
200
|
+
this.finishConnection();
|
201
|
+
}
|
202
|
+
this.clearTempLine();
|
203
|
+
this.draggingConnection = false;
|
204
|
+
}
|
205
|
+
};
|
206
|
+
// Add global event listeners
|
207
|
+
this.zone.runOutsideAngular(() => {
|
208
|
+
document.addEventListener('mousemove', mousemoveHandler);
|
209
|
+
document.addEventListener('mouseup', mouseupHandler);
|
210
|
+
});
|
211
|
+
// Store global listeners
|
212
|
+
const globalListeners = this.eventListeners.get('global');
|
213
|
+
if (globalListeners) {
|
214
|
+
globalListeners.set('mousemove', mousemoveHandler);
|
215
|
+
globalListeners.set('mouseup', mouseupHandler);
|
216
|
+
}
|
217
|
+
}
|
218
|
+
positionAnchor(dot, anchor, type) {
|
219
|
+
if (type !== 'diamond') {
|
220
|
+
switch (anchor) {
|
221
|
+
case 'top':
|
222
|
+
dot.style.top = '0%';
|
223
|
+
dot.style.left = '50%';
|
224
|
+
break;
|
225
|
+
case 'bottom':
|
226
|
+
dot.style.top = '100%';
|
227
|
+
dot.style.left = '50%';
|
228
|
+
break;
|
229
|
+
case 'left':
|
230
|
+
dot.style.top = '50%';
|
231
|
+
dot.style.left = '0%';
|
232
|
+
break;
|
233
|
+
case 'right':
|
234
|
+
dot.style.top = '50%';
|
235
|
+
dot.style.left = '100%';
|
236
|
+
break;
|
237
|
+
}
|
238
|
+
}
|
239
|
+
else {
|
240
|
+
switch (anchor) {
|
241
|
+
case 'top':
|
242
|
+
dot.style.top = '0%';
|
243
|
+
dot.style.left = '0%';
|
244
|
+
break;
|
245
|
+
case 'bottom':
|
246
|
+
dot.style.top = '100%';
|
247
|
+
dot.style.left = '100%';
|
248
|
+
break;
|
249
|
+
case 'left':
|
250
|
+
dot.style.top = '100%';
|
251
|
+
dot.style.left = '0%';
|
252
|
+
break;
|
253
|
+
case 'right':
|
254
|
+
dot.style.top = '0%';
|
255
|
+
dot.style.left = '100%';
|
256
|
+
break;
|
257
|
+
}
|
258
|
+
}
|
259
|
+
}
|
260
|
+
getAnchorPoint(el, anchor) {
|
261
|
+
const rect = el.getBoundingClientRect();
|
262
|
+
const centerX = el.offsetLeft + rect.width / 2;
|
263
|
+
const centerY = el.offsetTop + rect.height / 2;
|
264
|
+
switch (anchor) {
|
265
|
+
case 'top':
|
266
|
+
return { x: centerX, y: el.offsetTop };
|
267
|
+
case 'bottom':
|
268
|
+
return { x: centerX, y: el.offsetTop + rect.height };
|
269
|
+
case 'left':
|
270
|
+
return { x: el.offsetLeft, y: centerY };
|
271
|
+
case 'right':
|
272
|
+
return { x: el.offsetLeft + rect.width, y: centerY };
|
273
|
+
default:
|
274
|
+
return { x: centerX, y: centerY };
|
275
|
+
}
|
276
|
+
}
|
277
|
+
startTempLine(x, y) {
|
278
|
+
const svgElement = this.svgService()?.nativeElement;
|
279
|
+
if (!svgElement)
|
280
|
+
return;
|
281
|
+
this.tempLine = document.createElementNS('http://www.w3.org/2000/svg', 'line');
|
282
|
+
this.tempLine.setAttribute('x1', x.toString());
|
283
|
+
this.tempLine.setAttribute('y1', y.toString());
|
284
|
+
this.tempLine.setAttribute('x2', x.toString());
|
285
|
+
this.tempLine.setAttribute('y2', y.toString());
|
286
|
+
this.tempLine.setAttribute('stroke', 'rgba(var(--ax-sys-color-on-lightest-surface),0.5)');
|
287
|
+
this.tempLine.setAttribute('stroke-width', '2');
|
288
|
+
this.tempLine.setAttribute('stroke-dasharray', '4');
|
289
|
+
svgElement.appendChild(this.tempLine);
|
290
|
+
}
|
291
|
+
clearTempLine() {
|
292
|
+
if (this.tempLine && this.tempLine.parentElement) {
|
293
|
+
this.svgService()?.nativeElement.removeChild(this.tempLine);
|
294
|
+
this.tempLine = null;
|
295
|
+
}
|
296
|
+
}
|
297
|
+
pushAndCreateEdgeData(source, target) {
|
298
|
+
const newEdge = {
|
299
|
+
id: `edge-${Math.random().toString()}`,
|
300
|
+
source,
|
301
|
+
target,
|
302
|
+
};
|
303
|
+
this.onEdgeUpdate.next(newEdge);
|
304
|
+
this.initialFlowChartEdge.update((value) => [...value, newEdge]);
|
305
|
+
this.drawEdges();
|
306
|
+
}
|
307
|
+
drawEdges(edges) {
|
308
|
+
const svg = this.svgService()?.nativeElement;
|
309
|
+
if (!svg)
|
310
|
+
return;
|
311
|
+
// Clear existing edges
|
312
|
+
svg.innerHTML = '';
|
313
|
+
// Use provided edges or get from signal
|
314
|
+
const edgesToDraw = edges || this.initialFlowChartEdge();
|
315
|
+
edgesToDraw.forEach((edge) => {
|
316
|
+
const sourceNode = this.nodesMap.get(edge.source.id);
|
317
|
+
const targetNode = this.nodesMap.get(edge.target.id);
|
318
|
+
if (sourceNode) {
|
319
|
+
const sourceAnchor = sourceNode.querySelector(`[data-anchor="${edge.source.anchor}"]`);
|
320
|
+
if (sourceAnchor)
|
321
|
+
sourceAnchor.classList.add('selected');
|
322
|
+
}
|
323
|
+
if (targetNode) {
|
324
|
+
const targetAnchor = targetNode.querySelector(`[data-anchor="${edge.target.anchor}"]`);
|
325
|
+
if (targetAnchor)
|
326
|
+
targetAnchor.classList.add('selected');
|
327
|
+
}
|
328
|
+
if (sourceNode && targetNode) {
|
329
|
+
const sourcePoint = this.getAnchorPoint(sourceNode, edge.source.anchor);
|
330
|
+
const targetPoint = this.getAnchorPoint(targetNode, edge.target.anchor);
|
331
|
+
const line = this.createLine(sourcePoint, targetPoint, edge);
|
332
|
+
line.classList.add('ax-flow-chart-line');
|
333
|
+
// Add click event listener for line selection
|
334
|
+
this.addEventListener(line, 'click', (e) => {
|
335
|
+
e.stopPropagation();
|
336
|
+
this.lineClick.next({ target: edge, event: e });
|
337
|
+
this.selectedEdge.set(edge);
|
338
|
+
this.selectedNode.set(null);
|
339
|
+
// Remove selection from all other lines
|
340
|
+
document.querySelectorAll('.ax-flow-chart-line').forEach((l) => {
|
341
|
+
if (l !== line)
|
342
|
+
l.classList.remove('selected');
|
343
|
+
});
|
344
|
+
// Add selection to clicked line
|
345
|
+
line.classList.add('selected');
|
346
|
+
// Remove selection from all nodes
|
347
|
+
this.nodesMap.forEach((node) => node.classList.remove('selected'));
|
348
|
+
});
|
349
|
+
svg.appendChild(line);
|
350
|
+
}
|
351
|
+
});
|
352
|
+
}
|
353
|
+
createLine(from, to, edge) {
|
354
|
+
const line = document.createElementNS('http://www.w3.org/2000/svg', 'line');
|
355
|
+
line.setAttribute('x1', from.x.toString());
|
356
|
+
line.setAttribute('y1', from.y.toString());
|
357
|
+
line.setAttribute('x2', to.x.toString());
|
358
|
+
line.setAttribute('y2', to.y.toString());
|
359
|
+
line.setAttribute('stroke', 'rgba(var(--ax-sys-color-on-surface))');
|
360
|
+
line.setAttribute('stroke-width', '3');
|
361
|
+
line.classList.add('ax-flow-chart-line');
|
362
|
+
line.addEventListener('click', (e) => {
|
363
|
+
this.lineClick.next({ target: edge, event: e });
|
364
|
+
this.selectedEdge.set(edge);
|
365
|
+
});
|
366
|
+
line.addEventListener('dblclick', (e) => {
|
367
|
+
this.lineDbClick.next({ target: edge, event: e });
|
368
|
+
});
|
369
|
+
return line;
|
370
|
+
}
|
371
|
+
finishConnection() {
|
372
|
+
if (this.currentConnection?.source && this.currentConnection?.target) {
|
373
|
+
this.pushAndCreateEdgeData(this.currentConnection.source, this.currentConnection.target);
|
374
|
+
}
|
375
|
+
this.currentConnection = null;
|
376
|
+
}
|
377
|
+
removeEdge(edge) {
|
378
|
+
this.initialFlowChartEdge.update((value) => value.filter((e) => e.id !== edge.id));
|
379
|
+
// Remove selected class from connected anchors
|
380
|
+
const sourceNode = this.nodesMap.get(edge.source.id);
|
381
|
+
const targetNode = this.nodesMap.get(edge.target.id);
|
382
|
+
if (sourceNode) {
|
383
|
+
const sourceAnchor = sourceNode.querySelector(`[data-anchor="${edge.source.anchor}"]`);
|
384
|
+
if (sourceAnchor)
|
385
|
+
sourceAnchor.classList.remove('selected');
|
386
|
+
}
|
387
|
+
if (targetNode) {
|
388
|
+
const targetAnchor = targetNode.querySelector(`[data-anchor="${edge.target.anchor}"]`);
|
389
|
+
if (targetAnchor)
|
390
|
+
targetAnchor.classList.remove('selected');
|
391
|
+
}
|
392
|
+
}
|
393
|
+
createNode(nodes) {
|
394
|
+
document.querySelectorAll('.ax-flow-chart-node')?.forEach((node) => node.remove());
|
395
|
+
nodes.forEach((node) => {
|
396
|
+
const el = document.createElement('div');
|
397
|
+
const p = document.createElement('p');
|
398
|
+
p.innerText = node.label;
|
399
|
+
el.appendChild(p);
|
400
|
+
el.className = 'ax-flow-chart-node';
|
401
|
+
el.classList.add(`ax-${node.type}`);
|
402
|
+
el.style.left = node.x + 'px';
|
403
|
+
el.style.top = node.y + 'px';
|
404
|
+
el.dataset['id'] = node.id;
|
405
|
+
this.addAnchors(el, node.type);
|
406
|
+
this.makeDraggable(el);
|
407
|
+
this.setupNodeEventListeners(el, node);
|
408
|
+
this.canvasService().nativeElement.appendChild(el);
|
409
|
+
this.nodesMap.set(node.id, el);
|
410
|
+
});
|
411
|
+
}
|
412
|
+
removeNode(nodeId) {
|
413
|
+
this.initialFlowChartNode.update((value) => value.filter((e) => e.id !== nodeId));
|
414
|
+
this.initialFlowChartEdge().forEach((edge) => {
|
415
|
+
if (edge.source.id === nodeId || edge.target.id === nodeId) {
|
416
|
+
this.removeEdge(edge);
|
417
|
+
}
|
418
|
+
});
|
419
|
+
document.querySelector(`[data-id="${nodeId}"]`)?.remove();
|
420
|
+
this.anchorClickBuffer = null;
|
421
|
+
}
|
422
|
+
cleanup() {
|
423
|
+
this.nodesMap.forEach((_, id) => this.removeEventListeners(id));
|
424
|
+
this.nodesMap.clear();
|
425
|
+
this.eventListeners.clear();
|
426
|
+
}
|
427
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.9", ngImport: i0, type: AXFlowChartService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
428
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.9", ngImport: i0, type: AXFlowChartService }); }
|
429
|
+
}
|
430
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.9", ngImport: i0, type: AXFlowChartService, decorators: [{
|
431
|
+
type: Injectable
|
432
|
+
}] });
|
433
|
+
|
434
|
+
class AXFlowChartCreatorComponent extends NXComponent {
|
435
|
+
constructor() {
|
436
|
+
super(...arguments);
|
437
|
+
this.service = inject(AXFlowChartService);
|
438
|
+
this.selectedShape = signal('rectangle');
|
439
|
+
this.label = 'Label';
|
440
|
+
}
|
441
|
+
selectShapeHandler(shape) {
|
442
|
+
this.selectedShape.set(shape);
|
443
|
+
}
|
444
|
+
createShapeHandler() {
|
445
|
+
const newNode = {
|
446
|
+
id: Math.random().toString(),
|
447
|
+
type: this.selectedShape(),
|
448
|
+
label: this.label,
|
449
|
+
x: 0,
|
450
|
+
y: 0,
|
451
|
+
};
|
452
|
+
this.service.initialFlowChartNode.update((value) => [...value, newNode]);
|
453
|
+
this.service.onNodeUpdate.next(newNode);
|
454
|
+
}
|
455
|
+
printChart() {
|
456
|
+
const printWindow = window.open('', '_blank');
|
457
|
+
if (!printWindow)
|
458
|
+
return;
|
459
|
+
const canvas = this.service.canvasService()?.nativeElement;
|
460
|
+
if (!canvas)
|
461
|
+
return;
|
462
|
+
// Get all styles from the document and component
|
463
|
+
const styles = Array.from(document.styleSheets)
|
464
|
+
.map((sheet) => {
|
465
|
+
try {
|
466
|
+
return Array.from(sheet.cssRules)
|
467
|
+
.map((rule) => rule.cssText)
|
468
|
+
.join('\n');
|
469
|
+
}
|
470
|
+
catch (e) {
|
471
|
+
return '';
|
472
|
+
}
|
473
|
+
})
|
474
|
+
.join('\n');
|
475
|
+
// Add print-specific styles for anchors
|
476
|
+
const printStyles = `
|
477
|
+
${styles}
|
478
|
+
.ax-flow-chart-anchor {
|
479
|
+
opacity: 1 !important;
|
480
|
+
}
|
481
|
+
`;
|
482
|
+
// Create the print content with proper styling
|
483
|
+
const printContent = `
|
484
|
+
<!DOCTYPE html>
|
485
|
+
<html>
|
486
|
+
<head>
|
487
|
+
<title>Flow Chart Print</title>
|
488
|
+
<style>
|
489
|
+
${printStyles}
|
490
|
+
</style>
|
491
|
+
</head>
|
492
|
+
<body>
|
493
|
+
<ax-flow-chart-renderer>
|
494
|
+
${canvas.outerHTML}
|
495
|
+
</ax-flow-chart-renderer>
|
496
|
+
</body>
|
497
|
+
</html>
|
498
|
+
`;
|
499
|
+
printWindow.document.write(printContent);
|
500
|
+
printWindow.document.close();
|
501
|
+
}
|
502
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.9", ngImport: i0, type: AXFlowChartCreatorComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
503
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.9", type: AXFlowChartCreatorComponent, isStandalone: true, selector: "ax-flow-chart-creator", usesInheritance: true, ngImport: i0, template: "<div class=\"ax-shape-container\">\n <div\n [ngClass]=\"{ 'ax-shape-selected': selectedShape() === 'rectangle' }\"\n (click)=\"selectShapeHandler('rectangle')\"\n class=\"ax-rectangle\"\n ></div>\n <div\n [ngClass]=\"{ 'ax-shape-selected': selectedShape() === 'circle' }\"\n (click)=\"selectShapeHandler('circle')\"\n class=\"ax-circle\"\n ></div>\n <div\n [ngClass]=\"{ 'ax-shape-selected': selectedShape() === 'diamond' }\"\n (click)=\"selectShapeHandler('diamond')\"\n class=\"ax-diamond\"\n ></div>\n</div>\n<ax-text-box class=\"ax-sm\" [(ngModel)]=\"label\" placeholder=\"Label\"> </ax-text-box>\n\n<ax-button class=\"ax-sm\" (onClick)=\"createShapeHandler()\" color=\"primary\" text=\"Create\"></ax-button>\n<ax-button color=\"primary\" text=\"Print\" class=\"ax-sm\" (click)=\"printChart()\"></ax-button>\n", styles: ["ax-flow-chart-creator{display:flex;gap:1rem;align-items:center;padding:1rem}ax-flow-chart-creator .ax-shape-container{display:flex;gap:1rem}ax-flow-chart-creator .ax-shape-container .ax-shape-selected{border:2px solid rgba(var(--ax-sys-color-danger-darker-surface))!important}ax-flow-chart-creator .ax-shape-container .ax-rectangle,ax-flow-chart-creator .ax-shape-container .ax-circle,ax-flow-chart-creator .ax-shape-container .ax-diamond{border:2px solid rgba(var(--ax-sys-color-border-surface));display:flex;justify-content:center;align-items:center;width:30px;height:30px;cursor:pointer}ax-flow-chart-creator .ax-shape-container .ax-circle{border-radius:1000vmax;aspect-ratio:1}ax-flow-chart-creator .ax-shape-container .ax-diamond{transform:rotate(45deg) scale(.75);aspect-ratio:1}\n"], dependencies: [{ kind: "ngmodule", type: AXTextBoxModule }, { kind: "component", type: i1.AXTextBoxComponent, selector: "ax-text-box", inputs: ["disabled", "tabIndex", "readonly", "value", "state", "name", "id", "placeholder", "maxLength", "allowNull", "type", "autoComplete", "look", "mask-options", "class"], outputs: ["onBlur", "onFocus", "valueChange", "stateChange", "onValueChanged", "readonlyChange", "disabledChange", "onKeyDown", "onKeyUp", "onKeyPress"] }, { kind: "ngmodule", type: AXButtonModule }, { kind: "component", type: i2.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "iconOnly", "type", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "loadingTextChange"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
504
|
+
}
|
505
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.9", ngImport: i0, type: AXFlowChartCreatorComponent, decorators: [{
|
506
|
+
type: Component,
|
507
|
+
args: [{ selector: 'ax-flow-chart-creator', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [AXTextBoxModule, AXButtonModule, CommonModule, FormsModule], template: "<div class=\"ax-shape-container\">\n <div\n [ngClass]=\"{ 'ax-shape-selected': selectedShape() === 'rectangle' }\"\n (click)=\"selectShapeHandler('rectangle')\"\n class=\"ax-rectangle\"\n ></div>\n <div\n [ngClass]=\"{ 'ax-shape-selected': selectedShape() === 'circle' }\"\n (click)=\"selectShapeHandler('circle')\"\n class=\"ax-circle\"\n ></div>\n <div\n [ngClass]=\"{ 'ax-shape-selected': selectedShape() === 'diamond' }\"\n (click)=\"selectShapeHandler('diamond')\"\n class=\"ax-diamond\"\n ></div>\n</div>\n<ax-text-box class=\"ax-sm\" [(ngModel)]=\"label\" placeholder=\"Label\"> </ax-text-box>\n\n<ax-button class=\"ax-sm\" (onClick)=\"createShapeHandler()\" color=\"primary\" text=\"Create\"></ax-button>\n<ax-button color=\"primary\" text=\"Print\" class=\"ax-sm\" (click)=\"printChart()\"></ax-button>\n", styles: ["ax-flow-chart-creator{display:flex;gap:1rem;align-items:center;padding:1rem}ax-flow-chart-creator .ax-shape-container{display:flex;gap:1rem}ax-flow-chart-creator .ax-shape-container .ax-shape-selected{border:2px solid rgba(var(--ax-sys-color-danger-darker-surface))!important}ax-flow-chart-creator .ax-shape-container .ax-rectangle,ax-flow-chart-creator .ax-shape-container .ax-circle,ax-flow-chart-creator .ax-shape-container .ax-diamond{border:2px solid rgba(var(--ax-sys-color-border-surface));display:flex;justify-content:center;align-items:center;width:30px;height:30px;cursor:pointer}ax-flow-chart-creator .ax-shape-container .ax-circle{border-radius:1000vmax;aspect-ratio:1}ax-flow-chart-creator .ax-shape-container .ax-diamond{transform:rotate(45deg) scale(.75);aspect-ratio:1}\n"] }]
|
508
|
+
}] });
|
509
|
+
|
510
|
+
class AXFlowChartRendererComponent extends NXComponent {
|
511
|
+
constructor() {
|
512
|
+
super(...arguments);
|
513
|
+
this.canvas = viewChild('canvas');
|
514
|
+
this.svg = viewChild('connections');
|
515
|
+
this.service = inject(AXFlowChartService);
|
516
|
+
this.onLineClick = output();
|
517
|
+
this.onLineDbClick = output();
|
518
|
+
this.onNodeClick = output();
|
519
|
+
this.onNodeDbClick = output();
|
520
|
+
this.onEdgeUpdate = output();
|
521
|
+
this.onNodeUpdate = output();
|
522
|
+
this.#init = afterNextRender(() => {
|
523
|
+
this.setupEventListeners();
|
524
|
+
});
|
525
|
+
this.#eff = effect(() => {
|
526
|
+
if (this.canvas() && this.svg()) {
|
527
|
+
this.initializeServices();
|
528
|
+
}
|
529
|
+
});
|
530
|
+
}
|
531
|
+
#init;
|
532
|
+
#eff;
|
533
|
+
setupEventListeners() {
|
534
|
+
this.service.lineClick.subscribe((value) => {
|
535
|
+
this.onLineClick.emit(value);
|
536
|
+
});
|
537
|
+
this.service.lineDbClick.subscribe((value) => {
|
538
|
+
this.onLineDbClick.emit(value);
|
539
|
+
});
|
540
|
+
this.service.nodeClick.subscribe((value) => {
|
541
|
+
this.onNodeClick.emit(value);
|
542
|
+
});
|
543
|
+
this.service.nodeDbClick.subscribe((value) => {
|
544
|
+
this.onNodeDbClick.emit(value);
|
545
|
+
});
|
546
|
+
this.service.onEdgeUpdate.subscribe((newEdge) => {
|
547
|
+
this.onEdgeUpdate.emit(newEdge);
|
548
|
+
});
|
549
|
+
this.service.onNodeUpdate.subscribe((newNode) => {
|
550
|
+
this.onNodeUpdate.emit(newNode);
|
551
|
+
});
|
552
|
+
}
|
553
|
+
initializeServices() {
|
554
|
+
this.service.canvasService.set(this.canvas());
|
555
|
+
this.service.svgService.set(this.svg());
|
556
|
+
// Add click handlers for parent elements
|
557
|
+
const canvas = this.canvas()?.nativeElement;
|
558
|
+
const svg = this.svg()?.nativeElement;
|
559
|
+
if (canvas) {
|
560
|
+
canvas.addEventListener('click', (e) => {
|
561
|
+
if (e.target === canvas) {
|
562
|
+
this.service.selectedNode.set(null);
|
563
|
+
this.service.selectedEdge.set(null);
|
564
|
+
document.querySelectorAll('.ax-flow-chart-node').forEach((node) => node.classList.remove('selected'));
|
565
|
+
document.querySelectorAll('.ax-flow-chart-line').forEach((line) => line.classList.remove('selected'));
|
566
|
+
}
|
567
|
+
});
|
568
|
+
}
|
569
|
+
if (svg) {
|
570
|
+
svg.addEventListener('click', (e) => {
|
571
|
+
if (e.target === svg) {
|
572
|
+
this.service.selectedNode.set(null);
|
573
|
+
this.service.selectedEdge.set(null);
|
574
|
+
document.querySelectorAll('.ax-flow-chart-node').forEach((node) => node.classList.remove('selected'));
|
575
|
+
document.querySelectorAll('.ax-flow-chart-line').forEach((line) => line.classList.remove('selected'));
|
576
|
+
}
|
577
|
+
});
|
578
|
+
}
|
579
|
+
}
|
580
|
+
ngOnDestroy() {
|
581
|
+
this.cleanup();
|
582
|
+
}
|
583
|
+
cleanup() {
|
584
|
+
this.service.cleanup();
|
585
|
+
this.service.lineClick.unsubscribe();
|
586
|
+
this.service.lineDbClick.unsubscribe();
|
587
|
+
this.service.nodeClick.unsubscribe();
|
588
|
+
this.service.nodeDbClick.unsubscribe();
|
589
|
+
this.service.onEdgeUpdate.unsubscribe();
|
590
|
+
}
|
591
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.9", ngImport: i0, type: AXFlowChartRendererComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
592
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.9", type: AXFlowChartRendererComponent, isStandalone: true, selector: "ax-flow-chart-renderer", outputs: { onLineClick: "onLineClick", onLineDbClick: "onLineDbClick", onNodeClick: "onNodeClick", onNodeDbClick: "onNodeDbClick", onEdgeUpdate: "onEdgeUpdate", onNodeUpdate: "onNodeUpdate" }, viewQueries: [{ propertyName: "canvas", first: true, predicate: ["canvas"], descendants: true, isSignal: true }, { propertyName: "svg", first: true, predicate: ["connections"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div id=\"ax-flow-chart-renderer-canvas\" #canvas>\n <svg class=\"ax-flow-chart-renderer-svg\" id=\"ax-flow-chart-renderer-connections\" #connections></svg>\n</div>\n", styles: ["ax-flow-chart-renderer{overflow:hidden;width:var(--ax-comp-flow-chart-width, 100%);height:var(--ax-comp-flow-chart-height, 30rem);-webkit-print-color-adjust:exact;print-color-adjust:exact}ax-flow-chart-renderer #ax-flow-chart-renderer-canvas{position:relative;width:100%;height:100%}ax-flow-chart-renderer .ax-flow-chart-node{position:absolute;padding:1rem;background-color:rgba(var(--ax-sys-color-surface));color:rgba(var(--ax-sys-color-on-surface));border:2px solid rgba(var(--ax-sys-color-border-surface));cursor:move;-webkit-user-select:none;user-select:none}ax-flow-chart-renderer .ax-flow-chart-node.selected{border:2px solid rgba(var(--ax-sys-color-danger-darker-surface))}ax-flow-chart-renderer .ax-flow-chart-node .ax-flow-chart-anchor{opacity:0;transition:opacity .5s ease}ax-flow-chart-renderer .ax-flow-chart-node:hover .ax-flow-chart-anchor,ax-flow-chart-renderer .ax-flow-chart-node.selected .ax-flow-chart-anchor{opacity:1}ax-flow-chart-renderer .ax-flow-chart-anchor{position:absolute;width:10px;height:10px;background-color:rgba(var(--ax-sys-color-on-lightest-surface));border-radius:50%;cursor:crosshair;transform:translate(-50%,-50%)}ax-flow-chart-renderer .ax-flow-chart-anchor.selected{background-color:rgba(var(--ax-sys-color-primary-surface))}ax-flow-chart-renderer .ax-flow-chart-anchor.hover{transition:.3s all ease;scale:1.3;background-color:rgba(var(--ax-sys-color-danger-darkest-surface))}ax-flow-chart-renderer .ax-flow-chart-anchor:before{content:\"\";position:absolute;top:-7px;left:-7px;right:-7px;bottom:-7px}ax-flow-chart-renderer .ax-flow-chart-renderer-svg{position:absolute;top:0;left:0;overflow:visible}ax-flow-chart-renderer .ax-flow-chart-line:hover{transition:.3s all ease;stroke:rgba(var(--ax-sys-color-danger-darker-surface));cursor:pointer}ax-flow-chart-renderer .ax-flow-chart-line.selected{stroke:rgba(var(--ax-sys-color-primary-surface))}ax-flow-chart-renderer .ax-rectangle,ax-flow-chart-renderer .ax-circle,ax-flow-chart-renderer .ax-diamond{border:2px solid rgba(var(--ax-sys-color-border-surface));display:flex;justify-content:center;align-items:center;width:auto;height:auto}ax-flow-chart-renderer .ax-circle{border-radius:1000vmax;aspect-ratio:1}ax-flow-chart-renderer .ax-diamond{transform:rotate(45deg) scale(.75);aspect-ratio:1}ax-flow-chart-renderer .ax-diamond p{transform:rotate(-45deg) scale(1.25)}ax-flow-chart-renderer .ax-diamond .ax-flow-chart-anchor{width:14px;height:14px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
593
|
+
}
|
594
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.9", ngImport: i0, type: AXFlowChartRendererComponent, decorators: [{
|
595
|
+
type: Component,
|
596
|
+
args: [{ selector: 'ax-flow-chart-renderer', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<div id=\"ax-flow-chart-renderer-canvas\" #canvas>\n <svg class=\"ax-flow-chart-renderer-svg\" id=\"ax-flow-chart-renderer-connections\" #connections></svg>\n</div>\n", styles: ["ax-flow-chart-renderer{overflow:hidden;width:var(--ax-comp-flow-chart-width, 100%);height:var(--ax-comp-flow-chart-height, 30rem);-webkit-print-color-adjust:exact;print-color-adjust:exact}ax-flow-chart-renderer #ax-flow-chart-renderer-canvas{position:relative;width:100%;height:100%}ax-flow-chart-renderer .ax-flow-chart-node{position:absolute;padding:1rem;background-color:rgba(var(--ax-sys-color-surface));color:rgba(var(--ax-sys-color-on-surface));border:2px solid rgba(var(--ax-sys-color-border-surface));cursor:move;-webkit-user-select:none;user-select:none}ax-flow-chart-renderer .ax-flow-chart-node.selected{border:2px solid rgba(var(--ax-sys-color-danger-darker-surface))}ax-flow-chart-renderer .ax-flow-chart-node .ax-flow-chart-anchor{opacity:0;transition:opacity .5s ease}ax-flow-chart-renderer .ax-flow-chart-node:hover .ax-flow-chart-anchor,ax-flow-chart-renderer .ax-flow-chart-node.selected .ax-flow-chart-anchor{opacity:1}ax-flow-chart-renderer .ax-flow-chart-anchor{position:absolute;width:10px;height:10px;background-color:rgba(var(--ax-sys-color-on-lightest-surface));border-radius:50%;cursor:crosshair;transform:translate(-50%,-50%)}ax-flow-chart-renderer .ax-flow-chart-anchor.selected{background-color:rgba(var(--ax-sys-color-primary-surface))}ax-flow-chart-renderer .ax-flow-chart-anchor.hover{transition:.3s all ease;scale:1.3;background-color:rgba(var(--ax-sys-color-danger-darkest-surface))}ax-flow-chart-renderer .ax-flow-chart-anchor:before{content:\"\";position:absolute;top:-7px;left:-7px;right:-7px;bottom:-7px}ax-flow-chart-renderer .ax-flow-chart-renderer-svg{position:absolute;top:0;left:0;overflow:visible}ax-flow-chart-renderer .ax-flow-chart-line:hover{transition:.3s all ease;stroke:rgba(var(--ax-sys-color-danger-darker-surface));cursor:pointer}ax-flow-chart-renderer .ax-flow-chart-line.selected{stroke:rgba(var(--ax-sys-color-primary-surface))}ax-flow-chart-renderer .ax-rectangle,ax-flow-chart-renderer .ax-circle,ax-flow-chart-renderer .ax-diamond{border:2px solid rgba(var(--ax-sys-color-border-surface));display:flex;justify-content:center;align-items:center;width:auto;height:auto}ax-flow-chart-renderer .ax-circle{border-radius:1000vmax;aspect-ratio:1}ax-flow-chart-renderer .ax-diamond{transform:rotate(45deg) scale(.75);aspect-ratio:1}ax-flow-chart-renderer .ax-diamond p{transform:rotate(-45deg) scale(1.25)}ax-flow-chart-renderer .ax-diamond .ax-flow-chart-anchor{width:14px;height:14px}\n"] }]
|
597
|
+
}] });
|
598
|
+
|
599
|
+
class AXFlowChartComponent extends NXComponent {
|
600
|
+
constructor() {
|
601
|
+
super(...arguments);
|
602
|
+
this.flowChartService = inject(AXFlowChartService);
|
603
|
+
this.initialFlowChartNode = input.required();
|
604
|
+
this.initialFlowChartEdge = input.required();
|
605
|
+
this.selectedNode = computed(() => this.flowChartService.selectedNode());
|
606
|
+
this.selectedEdge = computed(() => this.flowChartService.selectedEdge());
|
607
|
+
this.#init = afterNextRender(() => {
|
608
|
+
this.flowChartService.initialFlowChartNode.set(this.initialFlowChartNode());
|
609
|
+
this.flowChartService.initialFlowChartEdge.set(this.initialFlowChartEdge());
|
610
|
+
});
|
611
|
+
}
|
612
|
+
#init;
|
613
|
+
handleKeyboardEvent(event) {
|
614
|
+
if (event.key === 'Delete') {
|
615
|
+
const selectedNode = this.selectedNode();
|
616
|
+
const selectedEdge = this.selectedEdge();
|
617
|
+
if (selectedNode) {
|
618
|
+
this.removeNode(selectedNode.id);
|
619
|
+
}
|
620
|
+
else if (selectedEdge) {
|
621
|
+
this.removeEdge(selectedEdge);
|
622
|
+
}
|
623
|
+
}
|
624
|
+
}
|
625
|
+
drawEdges(edges) {
|
626
|
+
this.flowChartService.drawEdges(edges);
|
627
|
+
}
|
628
|
+
removeEdge(edge) {
|
629
|
+
this.flowChartService.removeEdge(edge);
|
630
|
+
}
|
631
|
+
createNode(nodes) {
|
632
|
+
this.flowChartService.createNode(nodes);
|
633
|
+
}
|
634
|
+
removeNode(nodeId) {
|
635
|
+
this.flowChartService.removeNode(nodeId);
|
636
|
+
}
|
637
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.9", ngImport: i0, type: AXFlowChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
638
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.9", type: AXFlowChartComponent, isStandalone: true, selector: "ax-flow-chart", inputs: { initialFlowChartNode: { classPropertyName: "initialFlowChartNode", publicName: "initialFlowChartNode", isSignal: true, isRequired: true, transformFunction: null }, initialFlowChartEdge: { classPropertyName: "initialFlowChartEdge", publicName: "initialFlowChartEdge", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "document:keydown": "handleKeyboardEvent($event)" } }, providers: [AXFlowChartService], usesInheritance: true, ngImport: i0, template: "<ng-content select=\"ax-header\"></ng-content>\n<ng-content select=\"ax-flow-chart-renderer\"></ng-content>\n<ng-content select=\"ax-footer\"></ng-content>\n", styles: ["ax-flow-chart{display:flex;flex-direction:column;width:100%;height:100%;border:1px solid rgba(var(--ax-sys-color-border-lightest-surface));border-radius:var(--ax-sys-border-radius)}ax-flow-chart ax-header{border-bottom:1px solid rgba(var(--ax-sys-color-border-lightest-surface))}ax-flow-chart ax-footer{border-top:1px solid rgba(var(--ax-sys-color-border-lightest-surface))}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
639
|
+
}
|
640
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.9", ngImport: i0, type: AXFlowChartComponent, decorators: [{
|
641
|
+
type: Component,
|
642
|
+
args: [{ selector: 'ax-flow-chart', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [AXFlowChartService], template: "<ng-content select=\"ax-header\"></ng-content>\n<ng-content select=\"ax-flow-chart-renderer\"></ng-content>\n<ng-content select=\"ax-footer\"></ng-content>\n", styles: ["ax-flow-chart{display:flex;flex-direction:column;width:100%;height:100%;border:1px solid rgba(var(--ax-sys-color-border-lightest-surface));border-radius:var(--ax-sys-border-radius)}ax-flow-chart ax-header{border-bottom:1px solid rgba(var(--ax-sys-color-border-lightest-surface))}ax-flow-chart ax-footer{border-top:1px solid rgba(var(--ax-sys-color-border-lightest-surface))}\n"] }]
|
643
|
+
}], propDecorators: { handleKeyboardEvent: [{
|
644
|
+
type: HostListener,
|
645
|
+
args: ['document:keydown', ['$event']]
|
646
|
+
}] } });
|
647
|
+
|
648
|
+
const COMPONENT = [AXFlowChartRendererComponent, AXFlowChartCreatorComponent, AXFlowChartComponent];
|
649
|
+
const MODULES = [CommonModule];
|
650
|
+
class AXFlowChartModule {
|
651
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.9", ngImport: i0, type: AXFlowChartModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
652
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.9", ngImport: i0, type: AXFlowChartModule, imports: [CommonModule, AXFlowChartRendererComponent, AXFlowChartCreatorComponent, AXFlowChartComponent], exports: [AXFlowChartRendererComponent, AXFlowChartCreatorComponent, AXFlowChartComponent] }); }
|
653
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.9", ngImport: i0, type: AXFlowChartModule, imports: [MODULES, AXFlowChartCreatorComponent] }); }
|
654
|
+
}
|
655
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.9", ngImport: i0, type: AXFlowChartModule, decorators: [{
|
656
|
+
type: NgModule,
|
657
|
+
args: [{
|
658
|
+
imports: [...MODULES, ...COMPONENT],
|
659
|
+
exports: [...COMPONENT],
|
660
|
+
providers: [],
|
661
|
+
}]
|
662
|
+
}] });
|
663
|
+
|
664
|
+
/**
|
665
|
+
* Generated bundle index. Do not edit.
|
666
|
+
*/
|
667
|
+
|
668
|
+
export { AXFlowChartComponent, AXFlowChartCreatorComponent, AXFlowChartModule, AXFlowChartRendererComponent };
|
669
|
+
//# sourceMappingURL=acorex-components-flow-chart.mjs.map
|