@quandis/qbo4.ui 4.0.1-CI-20240403-131518

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 (94) hide show
  1. package/package.json +52 -0
  2. package/readme.md +456 -0
  3. package/src/qbo/Program.d.ts +18 -0
  4. package/src/qbo/Program.js +18 -0
  5. package/src/qbo/Program.ts +19 -0
  6. package/src/qbo/qbo-api.d.ts +27 -0
  7. package/src/qbo/qbo-api.js +96 -0
  8. package/src/qbo/qbo-api.ts +106 -0
  9. package/src/qbo/qbo-badge.d.ts +32 -0
  10. package/src/qbo/qbo-badge.js +93 -0
  11. package/src/qbo/qbo-badge.js.map +1 -0
  12. package/src/qbo/qbo-badge.ts +80 -0
  13. package/src/qbo/qbo-breadcrumb.d.ts +23 -0
  14. package/src/qbo/qbo-breadcrumb.js +132 -0
  15. package/src/qbo/qbo-breadcrumb.ts +96 -0
  16. package/src/qbo/qbo-datalist.d.ts +22 -0
  17. package/src/qbo/qbo-datalist.js +126 -0
  18. package/src/qbo/qbo-datalist.ts +104 -0
  19. package/src/qbo/qbo-docviewer.d.ts +15 -0
  20. package/src/qbo/qbo-docviewer.js +55 -0
  21. package/src/qbo/qbo-docviewer.ts +39 -0
  22. package/src/qbo/qbo-fetch.d.ts +29 -0
  23. package/src/qbo/qbo-fetch.js +134 -0
  24. package/src/qbo/qbo-fetch.ts +127 -0
  25. package/src/qbo/qbo-json.d.ts +8 -0
  26. package/src/qbo/qbo-json.js +85 -0
  27. package/src/qbo/qbo-json.ts +92 -0
  28. package/src/qbo/qbo-link.d.ts +15 -0
  29. package/src/qbo/qbo-link.js +48 -0
  30. package/src/qbo/qbo-link.js.map +1 -0
  31. package/src/qbo/qbo-link.ts +34 -0
  32. package/src/qbo/qbo-logging.d.ts +13 -0
  33. package/src/qbo/qbo-logging.js +92 -0
  34. package/src/qbo/qbo-logging.ts +72 -0
  35. package/src/qbo/qbo-mainmenu.d.ts +41 -0
  36. package/src/qbo/qbo-mainmenu.js +307 -0
  37. package/src/qbo/qbo-mainmenu.ts +263 -0
  38. package/src/qbo/qbo-markdown.d.ts +9 -0
  39. package/src/qbo/qbo-markdown.js +33 -0
  40. package/src/qbo/qbo-markdown.js.map +1 -0
  41. package/src/qbo/qbo-markdown.ts +22 -0
  42. package/src/qbo/qbo-microphone.d.ts +31 -0
  43. package/src/qbo/qbo-microphone.js +149 -0
  44. package/src/qbo/qbo-microphone.js.map +1 -0
  45. package/src/qbo/qbo-microphone.ts +137 -0
  46. package/src/qbo/qbo-popover.d.ts +8 -0
  47. package/src/qbo/qbo-popover.js +41 -0
  48. package/src/qbo/qbo-popover.ts +26 -0
  49. package/src/qbo/qbo-popup-listener.d.ts +25 -0
  50. package/src/qbo/qbo-popup-listener.js +145 -0
  51. package/src/qbo/qbo-popup-listener.ts +129 -0
  52. package/src/qbo/qbo-popup.d.ts +19 -0
  53. package/src/qbo/qbo-popup.js +95 -0
  54. package/src/qbo/qbo-popup.ts +84 -0
  55. package/src/qbo/qbo-select.d.ts +22 -0
  56. package/src/qbo/qbo-select.js +87 -0
  57. package/src/qbo/qbo-select.ts +65 -0
  58. package/src/qbo/qbo-sidebar.d.ts +10 -0
  59. package/src/qbo/qbo-sidebar.js +65 -0
  60. package/src/qbo/qbo-sidebar.ts +41 -0
  61. package/src/qbo/qbo-table.d.ts +23 -0
  62. package/src/qbo/qbo-table.js +94 -0
  63. package/src/qbo/qbo-table.js.map +1 -0
  64. package/src/qbo/qbo-table.ts +80 -0
  65. package/src/qbo/qbo-validate.d.ts +20 -0
  66. package/src/qbo/qbo-validate.js +92 -0
  67. package/src/qbo/qbo-validate.js.map +1 -0
  68. package/src/qbo/qbo-validate.ts +77 -0
  69. package/src/qbo/qbo-validators.d.ts +37 -0
  70. package/src/qbo/qbo-validators.js +72 -0
  71. package/src/qbo/qbo-validators.ts +66 -0
  72. package/src/qbo/styles.d.ts +3 -0
  73. package/src/qbo/styles.js +27 -0
  74. package/src/qbo/styles.ts +30 -0
  75. package/src/qbo-code/qbo-code.d.ts +12 -0
  76. package/src/qbo-code/qbo-code.js +54 -0
  77. package/src/qbo-code/qbo-code.ts +40 -0
  78. package/src/qbo-flowchart/qbo-flowchart.d.ts +45 -0
  79. package/src/qbo-flowchart/qbo-flowchart.js +309 -0
  80. package/src/qbo-flowchart/qbo-flowchart.js.map +1 -0
  81. package/src/qbo-flowchart/qbo-flowchart.ts +320 -0
  82. package/src/qbo-flowchart/readme.md +2 -0
  83. package/wwwroot/js/qbo4.ui-code.js +37965 -0
  84. package/wwwroot/js/qbo4.ui-code.min.js +3 -0
  85. package/wwwroot/js/qbo4.ui-code.min.js.LICENSE.txt +32 -0
  86. package/wwwroot/js/qbo4.ui-code.min.js.map +1 -0
  87. package/wwwroot/js/qbo4.ui-flowchart.js +44909 -0
  88. package/wwwroot/js/qbo4.ui-flowchart.min.js +9 -0
  89. package/wwwroot/js/qbo4.ui-flowchart.min.js.LICENSE.txt +43 -0
  90. package/wwwroot/js/qbo4.ui-flowchart.min.js.map +1 -0
  91. package/wwwroot/js/qbo4.ui.js +18840 -0
  92. package/wwwroot/js/qbo4.ui.min.js +108 -0
  93. package/wwwroot/js/qbo4.ui.min.js.LICENSE.txt +53 -0
  94. package/wwwroot/js/qbo4.ui.min.js.map +1 -0
@@ -0,0 +1,320 @@
1
+ import 'reflect-metadata';
2
+ // import 'jointjs/dist/joint.css';
3
+ import { html, css, PropertyValues, LitElement } from 'lit';
4
+ import { customElement, property } from 'lit/decorators.js';
5
+ import { dia, elementTools, linkTools, shapes } from '@joint/core';
6
+ import { TemplateContentDirective } from 'lit/directives/template-content.js';
7
+
8
+
9
+ interface TemplateOptions {
10
+ label: string,
11
+ position: number,
12
+ height: number,
13
+ width: number,
14
+ spacing: number,
15
+ color?: string | null,
16
+ bgcolor?: string | null,
17
+ element?: string | null
18
+ }
19
+
20
+ /**
21
+ * Renders JointJs flowchart.
22
+ */
23
+ @customElement('qbo-flowchart')
24
+ export class QboFlowchart extends LitElement {
25
+
26
+ @property({ type: Boolean })
27
+ renderInHost = true;
28
+
29
+ @property({ type: Object })
30
+ paper: dia.Paper | null = null;
31
+
32
+ @property({ type: Object })
33
+ graph: dia.Graph;
34
+
35
+ @property({ type: Object })
36
+ namespace: any = shapes;
37
+
38
+ @property({ type: String })
39
+ height: string = '600px';
40
+
41
+ @property({ type: String })
42
+ width: string = '100%';
43
+
44
+ @property({ type: Number })
45
+ portRadius: Number = 3;
46
+
47
+ @property({ type: String })
48
+ router: String | any = 'manhattan';
49
+
50
+ @property({ type: Number })
51
+ templateHeight: number = 30;
52
+
53
+ @property({ type: Number })
54
+ templateWidth: number = 80;
55
+
56
+ @property({ type: Number })
57
+ templateSpacing: number = 20;
58
+
59
+ @property({ type: Number })
60
+ gridSize: number = 10;
61
+
62
+ @property({ type: String })
63
+ gridColor: string = 'lightgrey';
64
+
65
+ draggedElement: any | null = null;
66
+
67
+ static styles = css`
68
+ .available-magnet {
69
+ fill: green;
70
+ }
71
+ .available-cell rect {
72
+ stroke-dasharray: 5, 2;
73
+ }`;
74
+
75
+
76
+ createRenderRoot() {
77
+ return this.renderInHost ? this : super.createRenderRoot();
78
+ }
79
+
80
+ constructor() {
81
+ super();
82
+ this.graph = this.createGraph();
83
+ }
84
+
85
+ firstUpdated(changedProperties: PropertyValues) {
86
+ super.firstUpdated(changedProperties);
87
+
88
+ this.paper = this.createPaper(this.renderRoot.querySelector('div'));
89
+
90
+ document.addEventListener('keydown', (event) => {
91
+ if (event.altKey && event.key === '+') {
92
+ event.preventDefault();
93
+ this.paper!.scale(this.paper!.scale().sx + 0.1, this.paper!.scale().sy + 0.1);
94
+ }
95
+ });
96
+
97
+ document.addEventListener('keydown', (event) => {
98
+ if (event.altKey && event.key === '-') {
99
+ event.preventDefault();
100
+ this.paper!.scale(this.paper!.scale().sx - 0.1, this.paper!.scale().sy - 0.1);
101
+ }
102
+ });
103
+
104
+ document.addEventListener('keydown', (event) => {
105
+ if (event.altKey && event.key === '0') {
106
+ event.preventDefault();
107
+ this.paper!.scale();
108
+ }
109
+ });
110
+
111
+
112
+ const templates: Object[] = [
113
+ { label: "Task", bgcolor: "#ADD8E6", color: "black" },
114
+ { label: "Document", bgcolor: "#90EE90", color: "black" },
115
+ { label: "Message", bgcolor: "#F08080", color: "black" },
116
+ { label: "Score", bgcolor: "#E6E6FA", color: "black" },
117
+ { label: "Ledger", bgcolor: "#FFA07A", color: "black" },
118
+ { label: "Workflow", bgcolor: "#F5FFFA", color: "black" },
119
+ { label: "Process", bgcolor: "#FFEBCD", color: "black" },
120
+ { label: "If/Then", bgcolor: "#F0F8FF", element: "Ellipse", color: "black" },
121
+ { label: "Poll", bgcolor: "#FFDAB9", element: "Ellipse", color: "black" },
122
+ { label: "Advanced", bgcolor: "#F0FFF0", color: "black" },
123
+
124
+ ];
125
+
126
+ const defaultOptions: TemplateOptions = {
127
+ label: "New",
128
+ position: 0,
129
+ height: this.templateHeight,
130
+ width: this.templateWidth,
131
+ spacing: this.templateSpacing,
132
+ color: 'white',
133
+ bgcolor: 'blue',
134
+ element: 'Rectangle'
135
+ }
136
+
137
+ templates.forEach((template: Object, index: number) => {
138
+ // this.createTemplate({}template, ((index + 1) * this.templateSpacing) + (index * this.templateHeight));
139
+ const position = ((index + 1) * this.templateSpacing) + (index * this.templateHeight);
140
+ const options: TemplateOptions = Object.assign(defaultOptions, { position: position }, template);
141
+ this.createTemplate(options);
142
+ });
143
+ }
144
+
145
+ createGraph() {
146
+ const graph = new dia.Graph({}, { cellNamespace: this.namespace });
147
+ return graph;
148
+ }
149
+
150
+ createPaper(target: HTMLElement | null) {
151
+ const component = this;
152
+ const paper = new dia.Paper({
153
+ el: target,
154
+ model: this.graph,
155
+ width: component.width,
156
+ height: component.height,
157
+ gridSize: component.gridSize,
158
+ drawGrid: true,
159
+ cellViewNamespace: this.namespace,
160
+ background: {
161
+ color: component.gridColor
162
+ },
163
+ defaultLink: () => new shapes.standard.Link({
164
+ router: {
165
+ name: component.router, args: { step: 5 }
166
+ }
167
+ }),
168
+ interactive: {
169
+ linkMove: true
170
+ // arrowheadMove: true,
171
+ },
172
+ linkPinning: false,
173
+ markAvailable: true,
174
+ snapLinks: { radius: 20 },
175
+ validateConnection: function (cellViewS, magnetS, cellViewT, magnetT, end, linkView) {
176
+ if (cellViewS === cellViewT) return false;
177
+ return magnetT !== null; // && magnetT.getAttribute('port-group') !== 'restart';
178
+ }
179
+ });
180
+
181
+ // Register events
182
+ paper.on('link:mouseenter', (linkView) => {
183
+ this.showLinkTools(linkView);
184
+ });
185
+
186
+ paper.on('link:mouseleave', (linkView) => {
187
+ linkView.removeTools();
188
+ });
189
+
190
+ paper.on('element:mouseenter', elementView => elementView.showTools());
191
+ paper.on('element:mouseleave', elementView => elementView.hideTools());
192
+
193
+ paper.on('selection:change', function (selectedModels, options) {
194
+ // Reset styles for all elements
195
+ component.graph.getCells().forEach(function (cell) {
196
+ cell.attr('body/stroke', 'none');
197
+ });
198
+
199
+ // Apply a distinct style to selected models
200
+ selectedModels.forEach(function (cell) {
201
+ cell.attr('body/stroke', 'red');
202
+ cell.attr('body/stroke-width', 2);
203
+ });
204
+ });
205
+ return paper;
206
+ }
207
+
208
+ createStep(cellView) {
209
+ const component = this;
210
+ cellView.on('element:pointerdown', function (evt) {
211
+ // Clone the element
212
+ component.draggedElement = cellView.model.clone();
213
+ // clonedRect.position(cellView.model)
214
+ // Set the fill color of the selected element to gray
215
+ cellView.model.attr('body/fill', 'gray');
216
+
217
+ // Add the cloned element to the paper
218
+ // clonedRect.position(evt.clientX, evt.clientY);
219
+ component.graph.addCell(component.draggedElement);
220
+ });
221
+
222
+ cellView.on('element:pointerup', function () {
223
+ cellView.model.attr('body/fill', component.draggedElement.attr('body/fill'));
224
+ // Swap positions
225
+ var originalPosition = cellView.model.position();
226
+ var clonedPosition = component.draggedElement.position();
227
+ cellView.model.position(clonedPosition.x, clonedPosition.y);
228
+ component.draggedElement.position(originalPosition.x, originalPosition.y);
229
+ component.draggedElement.addPorts([{ 'group': 'left' }, { 'group': 'top' }, { 'group': 'right' }, { 'group': 'bottom' }]);
230
+
231
+ var view = component.draggedElement.findView(component.paper);
232
+ view.addTools(new dia.ToolsView({
233
+ tools: [new elementTools.Remove()]
234
+ }));
235
+
236
+
237
+ });
238
+ }
239
+
240
+ shapeFactory: Record<string, (options: Object) => dia.Element> = {
241
+ 'Rectangle': (options: Object) => {
242
+ return new shapes.standard.Rectangle(options);
243
+ },
244
+ 'Polygon': (options: Object) => {
245
+ options['transform'] = { rotate: 45 };
246
+ return new shapes.standard.Rectangle(options);
247
+ },
248
+ 'Ellipse': (options: Object) => {
249
+ return new shapes.standard.Ellipse(options);
250
+ },
251
+ 'Circle': (options: Object) => {
252
+ return new shapes.standard.Circle(options);
253
+ }
254
+ };
255
+
256
+ createTemplate(options: TemplateOptions) {
257
+ // const left = this.renderRoot!.querySelector('div')!.clientWidth;
258
+ const left = this.paper!['el'].clientWidth - options.spacing - options.width;
259
+ const template = this.shapeFactory[options.element ?? 'Rectangle']({
260
+ position: { x: left, y: options.position },
261
+ size: { width: options.width, height: options.height },
262
+ attrs: {
263
+ body: {
264
+ fill: options.bgcolor ?? 'blue',
265
+ },
266
+ label: {
267
+ text: options.label,
268
+ fill: options.color ?? 'white',
269
+ }
270
+ },
271
+ ports: {
272
+ groups: {
273
+ 'left': this.createPort('left'),
274
+ 'top': this.createPort('top'),
275
+ 'right': this.createPort('right'),
276
+ 'bottom': this.createPort('bottom')
277
+ }
278
+ }
279
+ });
280
+ this.graph.addCell(template);
281
+ this.createStep(this.paper!.findViewByModel(template));
282
+
283
+ return template;
284
+ }
285
+
286
+ createPort(position: String, radius: Number = this.portRadius, tagName: String = 'circle', fill: String = 'orange', stroke: String = 'blue'): Object {
287
+ return {
288
+ position: { name: position },
289
+ attrs: {
290
+ portBody: {
291
+ magnet: true,
292
+ r: radius,
293
+ fill: fill,
294
+ stroke: stroke
295
+ }
296
+ },
297
+ markup: [{
298
+ tagName: tagName,
299
+ selector: 'portBody'
300
+ }]
301
+ };
302
+ }
303
+
304
+ showLinkTools(linkView) {
305
+ var tools = new dia.ToolsView({
306
+ tools: [
307
+ new linkTools.SourceArrowhead(),
308
+ new linkTools.TargetArrowhead(),
309
+ new linkTools.Remove()
310
+ ]
311
+ });
312
+ linkView.addTools(tools);
313
+ }
314
+
315
+
316
+ render() {
317
+ return html`<slot><div></div></slot>`;
318
+ }
319
+ }
320
+
@@ -0,0 +1,2 @@
1
+ The qbo-flowchart web component is based on JointJS, and provides a flowchart editor.
2
+