@omegagrid/dashboard 0.6.118 → 0.6.120
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/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -2
- package/dist/constants.js.map +1 -1
- package/dist/model/dashboardItemModel.d.ts +3 -1
- package/dist/model/dashboardItemModel.d.ts.map +1 -1
- package/dist/model/dashboardItemModel.js +2 -1
- package/dist/model/dashboardItemModel.js.map +1 -1
- package/dist/model/dashboardModel.d.ts.map +1 -1
- package/dist/model/dashboardModel.js +31 -30
- package/dist/model/dashboardModel.js.map +1 -1
- package/dist/types.d.ts +14 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/ui/dashboard.d.ts +4 -4
- package/dist/ui/dashboard.d.ts.map +1 -1
- package/dist/ui/dashboard.js +24 -18
- package/dist/ui/dashboard.js.map +1 -1
- package/dist/ui/dashboardItem.d.ts.map +1 -1
- package/dist/ui/dashboardItem.js +5 -1
- package/dist/ui/dashboardItem.js.map +1 -1
- package/package.json +3 -3
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAW3C,wBAGC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { constants as coreConstants } from '@omegagrid/core';
|
|
2
2
|
const DEFAULT_OPTIONS = {
|
|
3
|
-
|
|
3
|
+
columns: 12,
|
|
4
4
|
gap: 10,
|
|
5
|
-
orientation: 'vertical'
|
|
5
|
+
orientation: 'vertical',
|
|
6
|
+
overlay: {
|
|
7
|
+
opacity: 0.9
|
|
8
|
+
}
|
|
6
9
|
};
|
|
7
10
|
export default {
|
|
8
11
|
DEFAULT_OPTIONS,
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG7D,MAAM,eAAe,GAAqB;IACzC,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG7D,MAAM,eAAe,GAAqB;IACzC,OAAO,EAAE,EAAE;IACX,GAAG,EAAE,EAAE;IACP,WAAW,EAAE,UAAU;IACvB,OAAO,EAAE;QACR,OAAO,EAAE,GAAG;KACZ;CACD,CAAA;AAED,eAAe;IACd,eAAe;IACf,GAAG,aAAa;CAChB,CAAA","sourcesContent":["import { constants as coreConstants } from '@omegagrid/core';\nimport { DashboardOptions } from './types';\n\nconst DEFAULT_OPTIONS: DashboardOptions = {\n\tcolumns: 12,\n\tgap: 10,\n\torientation: 'vertical',\n\toverlay: {\n\t\topacity: 0.9\n\t}\n}\n\nexport default {\n\tDEFAULT_OPTIONS,\n\t...coreConstants\n}"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ComponentId } from "@omegagrid/core";
|
|
2
2
|
import { DashboardItemSource } from "../types";
|
|
3
|
+
import { DashboardModel } from "./dashboardModel";
|
|
3
4
|
export declare class DashboardItemModel {
|
|
5
|
+
readonly model: DashboardModel;
|
|
4
6
|
private _index;
|
|
5
7
|
get index(): number;
|
|
6
8
|
set index(value: number);
|
|
@@ -11,7 +13,7 @@ export declare class DashboardItemModel {
|
|
|
11
13
|
w: number;
|
|
12
14
|
h: number;
|
|
13
15
|
title: string;
|
|
14
|
-
constructor(index: number, source?: DashboardItemSource);
|
|
16
|
+
constructor(model: DashboardModel, index: number, source?: DashboardItemSource);
|
|
15
17
|
pupulate(source: DashboardItemSource): void;
|
|
16
18
|
getSourceData(): DashboardItemSource;
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboardItemModel.d.ts","sourceRoot":"","sources":["../../src/model/dashboardItemModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"dashboardItemModel.d.ts","sourceRoot":"","sources":["../../src/model/dashboardItemModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,qBAAa,kBAAkB;IAgB7B,QAAQ,CAAC,KAAK,EAAE,cAAc;IAd/B,OAAO,CAAC,MAAM,CAAS;IACvB,IAAI,KAAK,IACQ,MAAM,CADW;IAClC,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAAyB;IAEhD,OAAO,CAAC,GAAG,CAAc;IACzB,IAAI,EAAE,gBAAsB;IAE5B,CAAC,SAAK;IACN,CAAC,SAAK;IACN,CAAC,SAAK;IACN,CAAC,SAAK;IACN,KAAK,EAAE,MAAM,CAAC;gBAGJ,KAAK,EAAE,cAAc,EAC9B,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,mBAAmB;IAM7B,QAAQ,CAAC,MAAM,EAAE,mBAAmB;IASpC,aAAa,IAAI,mBAAmB;CAWpC"}
|
|
@@ -2,7 +2,8 @@ export class DashboardItemModel {
|
|
|
2
2
|
get index() { return this._index; }
|
|
3
3
|
set index(value) { this._index = value; }
|
|
4
4
|
get id() { return this._id; }
|
|
5
|
-
constructor(index, source) {
|
|
5
|
+
constructor(model, index, source) {
|
|
6
|
+
this.model = model;
|
|
6
7
|
this.x = 0;
|
|
7
8
|
this.y = 0;
|
|
8
9
|
this.w = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboardItemModel.js","sourceRoot":"","sources":["../../src/model/dashboardItemModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dashboardItemModel.js","sourceRoot":"","sources":["../../src/model/dashboardItemModel.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,kBAAkB;IAG9B,IAAI,KAAK,KAAK,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IAClC,IAAI,KAAK,CAAC,KAAa,IAAI,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA,CAAC,CAAC;IAGhD,IAAI,EAAE,KAAK,OAAO,IAAI,CAAC,GAAG,CAAA,CAAC,CAAC;IAQ5B,YACU,KAAqB,EAC9B,KAAa,EACb,MAA4B;QAFnB,UAAK,GAAL,KAAK,CAAgB;QAP/B,MAAC,GAAG,CAAC,CAAC;QACN,MAAC,GAAG,CAAC,CAAC;QACN,MAAC,GAAG,CAAC,CAAC;QACN,MAAC,GAAG,CAAC,CAAC;QAQL,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,MAAM;YAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ,CAAC,MAA2B;QACnC,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC;QACrB,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;QAClB,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;QAClB,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;IACnD,CAAC;IAED,aAAa;QACZ,OAAO;YACN,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,CAAC,EAAE,IAAI,CAAC,CAAC;YACT,CAAC,EAAE,IAAI,CAAC,CAAC;YACT,CAAC,EAAE,IAAI,CAAC,CAAC;YACT,CAAC,EAAE,IAAI,CAAC,CAAC;SACT,CAAC;IACH,CAAC;CAED","sourcesContent":["import { ComponentId } from \"@omegagrid/core\";\nimport { DashboardItemSource } from \"../types\";\nimport { DashboardModel } from \"./dashboardModel\";\n\nexport class DashboardItemModel {\n\n\tprivate _index: number;\n\tget index() { return this._index }\n\tset index(value: number) { this._index = value }\n\n\tprivate _id: ComponentId;\n\tget id() { return this._id }\n\n\tx = 0;\n\ty = 0;\n\tw = 1;\n\th = 1;\n\ttitle: string;\n\n\tconstructor(\n\t\treadonly model: DashboardModel, \n\t\tindex: number, \n\t\tsource?: DashboardItemSource\n\t) {\n\t\tthis._index = index;\n\t\tif (source) this.pupulate(source);\n\t}\n\n\tpupulate(source: DashboardItemSource) {\n\t\tthis._id = source.id;\n\t\tthis.x = source.x;\n\t\tthis.y = source.y;\n\t\tthis.w = source.w || 1;\n\t\tthis.h = source.h || 1;\n\t\tthis.title = source.title || `#${this.index + 1}`;\n\t}\n\n\tgetSourceData(): DashboardItemSource {\n\t\treturn {\n\t\t\tid: this.id,\n\t\t\ttitle: this.title,\n\t\t\tx: this.x,\n\t\t\ty: this.y,\n\t\t\tw: this.w,\n\t\t\th: this.h\n\t\t};\n\t}\n\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboardModel.d.ts","sourceRoot":"","sources":["../../src/model/dashboardModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAS,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qBAAa,cAAc;IAE1B,OAAO,CAAC,QAAQ,CAAmB;IACnC,IAAI,OAAO,qBAA2B;IAEtC,OAAO,CAAC,MAAM,CAA4B;IAC1C,IAAI,KAAK,yBAAyB;gBAEtB,MAAM,CAAC,EAAE,eAAe;IAIpC,QAAQ,CAAC,MAAM,EAAE,eAAe;IAKhC,OAAO,CAAC,KAAK,CAAO;IACpB,IAAI,IAAI,SAQP;IAED,aAAa,IAAI,eAAe;IAOhC,eAAe,CAAC,SAAS,EAAE,IAAI,EAAE;IAcjC,kBAAkB,CAAC,UAAU,EAAE,kBAAkB,EAAE,IAAI,EAAE,IAAI;
|
|
1
|
+
{"version":3,"file":"dashboardModel.d.ts","sourceRoot":"","sources":["../../src/model/dashboardModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAS,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qBAAa,cAAc;IAE1B,OAAO,CAAC,QAAQ,CAAmB;IACnC,IAAI,OAAO,qBAA2B;IAEtC,OAAO,CAAC,MAAM,CAA4B;IAC1C,IAAI,KAAK,yBAAyB;gBAEtB,MAAM,CAAC,EAAE,eAAe;IAIpC,QAAQ,CAAC,MAAM,EAAE,eAAe;IAKhC,OAAO,CAAC,KAAK,CAAO;IACpB,IAAI,IAAI,SAQP;IAED,aAAa,IAAI,eAAe;IAOhC,eAAe,CAAC,SAAS,EAAE,IAAI,EAAE;IAcjC,kBAAkB,CAAC,UAAU,EAAE,kBAAkB,EAAE,IAAI,EAAE,IAAI;IA0H7D;;;OAGG;IACH,sBAAsB,IAAI,IAAI;IAmG9B;;;OAGG;IACH,aAAa,IAAI,OAAO;CAYxB"}
|
|
@@ -10,7 +10,7 @@ export class DashboardModel {
|
|
|
10
10
|
this.populate(source);
|
|
11
11
|
}
|
|
12
12
|
populate(source) {
|
|
13
|
-
this._items = source.items.map((item, i) => new DashboardItemModel(i, item));
|
|
13
|
+
this._items = source.items.map((item, i) => new DashboardItemModel(this, i, item));
|
|
14
14
|
this._options = utils.mergeDeep(constants.DEFAULT_OPTIONS, source.options);
|
|
15
15
|
}
|
|
16
16
|
get size() {
|
|
@@ -44,7 +44,8 @@ export class DashboardModel {
|
|
|
44
44
|
}
|
|
45
45
|
calculatePositions(movingItem, rect) {
|
|
46
46
|
const newPositions = new Array(this._items.length);
|
|
47
|
-
const
|
|
47
|
+
const columns = this._options.columns || Infinity;
|
|
48
|
+
const rows = this._options.rows || Infinity;
|
|
48
49
|
const orientation = this._options.orientation;
|
|
49
50
|
// Set the position for the moving item with boundary constraints
|
|
50
51
|
const movingIndex = this._items.indexOf(movingItem);
|
|
@@ -52,8 +53,8 @@ export class DashboardModel {
|
|
|
52
53
|
newPositions[movingIndex] = {
|
|
53
54
|
x: Math.max(0, rect.x),
|
|
54
55
|
y: Math.max(0, rect.y),
|
|
55
|
-
w: orientation == 'vertical' ? Math.min(rect.w,
|
|
56
|
-
h: orientation == 'horizontal' ? Math.min(rect.h,
|
|
56
|
+
w: orientation == 'vertical' ? Math.min(rect.w, columns - Math.max(0, rect.x)) : rect.w,
|
|
57
|
+
h: orientation == 'horizontal' ? Math.min(rect.h, rows - Math.max(0, rect.y)) : rect.h
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
// First pass: identify collisions and set initial positions
|
|
@@ -87,8 +88,8 @@ export class DashboardModel {
|
|
|
87
88
|
else if (moveUp <= moveRight && moveUp <= moveLeft && itemRect.y - otherRect.h >= 0) {
|
|
88
89
|
otherRect.y = Math.max(0, itemRect.y - otherRect.h);
|
|
89
90
|
}
|
|
90
|
-
else if (moveRight <= moveLeft && itemRect.x + itemRect.w + otherRect.w <=
|
|
91
|
-
otherRect.x = Math.min(
|
|
91
|
+
else if (moveRight <= moveLeft && itemRect.x + itemRect.w + otherRect.w <= columns) {
|
|
92
|
+
otherRect.x = Math.min(columns - otherRect.w, itemRect.x + itemRect.w);
|
|
92
93
|
}
|
|
93
94
|
else if (itemRect.x - otherRect.w >= 0) {
|
|
94
95
|
otherRect.x = Math.max(0, itemRect.x - otherRect.w);
|
|
@@ -98,8 +99,8 @@ export class DashboardModel {
|
|
|
98
99
|
otherRect.y = Math.max(0, itemRect.y + itemRect.h);
|
|
99
100
|
}
|
|
100
101
|
// Ensure width doesn't exceed container
|
|
101
|
-
if (otherRect.x + otherRect.w >
|
|
102
|
-
otherRect.w = Math.max(1,
|
|
102
|
+
if (otherRect.x + otherRect.w > columns) {
|
|
103
|
+
otherRect.w = Math.max(1, columns - otherRect.x);
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
else {
|
|
@@ -110,8 +111,8 @@ export class DashboardModel {
|
|
|
110
111
|
else if (moveLeft <= moveUp && moveLeft <= moveDown && itemRect.x - otherRect.w >= 0) {
|
|
111
112
|
otherRect.x = Math.max(0, itemRect.x - otherRect.w);
|
|
112
113
|
}
|
|
113
|
-
else if (moveDown <= moveUp && itemRect.y + itemRect.h + otherRect.h <=
|
|
114
|
-
otherRect.y = Math.min(
|
|
114
|
+
else if (moveDown <= moveUp && itemRect.y + itemRect.h + otherRect.h <= rows) {
|
|
115
|
+
otherRect.y = Math.min(rows - otherRect.h, itemRect.y + itemRect.h);
|
|
115
116
|
}
|
|
116
117
|
else if (itemRect.y - otherRect.h >= 0) {
|
|
117
118
|
otherRect.y = Math.max(0, itemRect.y - otherRect.h);
|
|
@@ -121,8 +122,8 @@ export class DashboardModel {
|
|
|
121
122
|
otherRect.x = Math.max(0, itemRect.x + itemRect.w);
|
|
122
123
|
}
|
|
123
124
|
// Ensure height doesn't exceed container
|
|
124
|
-
if (otherRect.y + otherRect.h >
|
|
125
|
-
otherRect.h = Math.max(1,
|
|
125
|
+
if (otherRect.y + otherRect.h > rows) {
|
|
126
|
+
otherRect.h = Math.max(1, rows - otherRect.y);
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
// Mark this item as processed in the current recursive call
|
|
@@ -143,13 +144,13 @@ export class DashboardModel {
|
|
|
143
144
|
newPositions[i].y = Math.max(0, newPositions[i].y);
|
|
144
145
|
// Apply container constraints based on orientation
|
|
145
146
|
if (orientation === 'vertical') {
|
|
146
|
-
if (newPositions[i].x + newPositions[i].w >
|
|
147
|
-
newPositions[i].w = Math.max(1,
|
|
147
|
+
if (newPositions[i].x + newPositions[i].w > columns) {
|
|
148
|
+
newPositions[i].w = Math.max(1, columns - newPositions[i].x);
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
else {
|
|
151
|
-
if (newPositions[i].y + newPositions[i].h >
|
|
152
|
-
newPositions[i].h = Math.max(1,
|
|
152
|
+
if (newPositions[i].y + newPositions[i].h > rows) {
|
|
153
|
+
newPositions[i].h = Math.max(1, rows - newPositions[i].y);
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
156
|
}
|
|
@@ -161,11 +162,11 @@ export class DashboardModel {
|
|
|
161
162
|
* Applies collision fixes directly to the dashboard items
|
|
162
163
|
*/
|
|
163
164
|
detectAndFixCollisions() {
|
|
164
|
-
const
|
|
165
|
+
const columns = this._options.columns || Infinity;
|
|
166
|
+
const rows = this._options.rows || Infinity;
|
|
165
167
|
const orientation = this._options.orientation;
|
|
166
168
|
const processedItems = new Set();
|
|
167
169
|
const resolveCollisions = (itemIndex) => {
|
|
168
|
-
console.log(itemIndex);
|
|
169
170
|
if (processedItems.has(itemIndex))
|
|
170
171
|
return;
|
|
171
172
|
const itemRect = this._items[itemIndex];
|
|
@@ -190,8 +191,8 @@ export class DashboardModel {
|
|
|
190
191
|
else if (moveUp <= moveRight && moveUp <= moveLeft && itemRect.y - otherRect.h >= 0) {
|
|
191
192
|
otherRect.y = Math.max(0, itemRect.y - otherRect.h);
|
|
192
193
|
}
|
|
193
|
-
else if (moveRight <= moveLeft && itemRect.x + itemRect.w + otherRect.w <=
|
|
194
|
-
otherRect.x = Math.min(
|
|
194
|
+
else if (moveRight <= moveLeft && itemRect.x + itemRect.w + otherRect.w <= columns) {
|
|
195
|
+
otherRect.x = Math.min(columns - otherRect.w, itemRect.x + itemRect.w);
|
|
195
196
|
}
|
|
196
197
|
else if (itemRect.x - otherRect.w >= 0) {
|
|
197
198
|
otherRect.x = Math.max(0, itemRect.x - otherRect.w);
|
|
@@ -200,8 +201,8 @@ export class DashboardModel {
|
|
|
200
201
|
otherRect.y = Math.max(0, itemRect.y + itemRect.h);
|
|
201
202
|
}
|
|
202
203
|
// Ensure width doesn't exceed container
|
|
203
|
-
if (otherRect.x + otherRect.w >
|
|
204
|
-
otherRect.w = Math.max(1,
|
|
204
|
+
if (otherRect.x + otherRect.w > columns) {
|
|
205
|
+
otherRect.w = Math.max(1, columns - otherRect.x);
|
|
205
206
|
}
|
|
206
207
|
}
|
|
207
208
|
else {
|
|
@@ -212,8 +213,8 @@ export class DashboardModel {
|
|
|
212
213
|
else if (moveLeft <= moveUp && moveLeft <= moveDown && itemRect.x - otherRect.w >= 0) {
|
|
213
214
|
otherRect.x = Math.max(0, itemRect.x - otherRect.w);
|
|
214
215
|
}
|
|
215
|
-
else if (moveDown <= moveUp && itemRect.y + itemRect.h + otherRect.h <=
|
|
216
|
-
otherRect.y = Math.min(
|
|
216
|
+
else if (moveDown <= moveUp && itemRect.y + itemRect.h + otherRect.h <= rows) {
|
|
217
|
+
otherRect.y = Math.min(rows - otherRect.h, itemRect.y + itemRect.h);
|
|
217
218
|
}
|
|
218
219
|
else if (itemRect.y - otherRect.h >= 0) {
|
|
219
220
|
otherRect.y = Math.max(0, itemRect.y - otherRect.h);
|
|
@@ -222,8 +223,8 @@ export class DashboardModel {
|
|
|
222
223
|
otherRect.x = Math.max(0, itemRect.x + itemRect.w);
|
|
223
224
|
}
|
|
224
225
|
// Ensure height doesn't exceed container
|
|
225
|
-
if (otherRect.y + otherRect.h >
|
|
226
|
-
otherRect.h = Math.max(1,
|
|
226
|
+
if (otherRect.y + otherRect.h > rows) {
|
|
227
|
+
otherRect.h = Math.max(1, rows - otherRect.y);
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
230
|
// Recursively resolve new collisions
|
|
@@ -245,13 +246,13 @@ export class DashboardModel {
|
|
|
245
246
|
item.y = Math.max(0, item.y);
|
|
246
247
|
// Apply container constraints based on orientation
|
|
247
248
|
if (orientation === 'vertical') {
|
|
248
|
-
if (item.x + item.w >
|
|
249
|
-
item.w = Math.max(1,
|
|
249
|
+
if (item.x + item.w > columns) {
|
|
250
|
+
item.w = Math.max(1, columns - item.x);
|
|
250
251
|
}
|
|
251
252
|
}
|
|
252
253
|
else {
|
|
253
|
-
if (item.y + item.h >
|
|
254
|
-
item.h = Math.max(1,
|
|
254
|
+
if (item.y + item.h > rows) {
|
|
255
|
+
item.h = Math.max(1, rows - item.y);
|
|
255
256
|
}
|
|
256
257
|
}
|
|
257
258
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboardModel.js","sourceRoot":"","sources":["../../src/model/dashboardModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,OAAO,cAAc;IAG1B,IAAI,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAA,CAAC,CAAC;IAGtC,IAAI,KAAK,KAAK,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IAElC,YAAY,MAAwB;QAH5B,WAAM,GAAyB,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I,CAAC;gBACb,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC;CAED","sourcesContent":["import { Rect, Size, utils } from \"@omegagrid/core\";\nimport constants from \"../constants\";\nimport { DashboardOptions, DashboardSource } from \"../types\";\nimport { DashboardItemModel } from \"./dashboardItemModel\";\n\nexport class DashboardModel {\n\n\tprivate _options: DashboardOptions;\n\tget options() { return this._options }\n\n\tprivate _items: DashboardItemModel[] = [];\n\tget items() { return this._items }\n\n\tconstructor(source?: DashboardSource) {\n\t\tif (source) this.populate(source);\n\t}\n\n\tpopulate(source: DashboardSource) {\n\t\tthis._items = source.items.map((item, i) => new DashboardItemModel(i, item));\n\t\tthis._options = utils.mergeDeep(constants.DEFAULT_OPTIONS, source.options);\n\t}\n\n\tprivate _size: Size;\n\tget size() {\n\t\tif (this._size) return this._size;\n\t\tthis._size = {w: 0, h: 0};\n\t\tthis._items.forEach(item => {\n\t\t\tthis._size.w = Math.max(this._size.w, item.x + item.w);\n\t\t\tthis._size.h = Math.max(this._size.h, item.y + item.h);\n\t\t});\n\t\treturn this._size;\n\t}\n\n\tgetSourceData(): DashboardSource {\n\t\treturn {\n\t\t\titems: this._items.map(item => item.getSourceData()),\n\t\t\toptions: this._options\n\t\t};\n\t}\n\n\tupdatePositions(positions: Rect[]) {\n\t\tthis._size = {w: 0, h: 0};\n\t\tthis._items.forEach((item, i) => {\n\t\t\tif (positions[i]) {\n\t\t\t\titem.x = positions[i].x;\n\t\t\t\titem.y = positions[i].y;\n\t\t\t\titem.w = positions[i].w;\n\t\t\t\titem.h = positions[i].h;\n\t\t\t}\n\t\t\tthis._size.w = Math.max(this._size.w, item.x + item.w);\n\t\t\tthis._size.h = Math.max(this._size.h, item.y + item.h);\n\t\t});\n\t}\n\n\tcalculatePositions(movingItem: DashboardItemModel, rect: Rect) {\n\t\tconst newPositions: Rect[] = new Array(this._items.length);\n\t\tconst containerSize = this._options.size || Infinity;\n\t\tconst orientation = this._options.orientation;\n\n\t\t// Set the position for the moving item with boundary constraints\n\t\tconst movingIndex = this._items.indexOf(movingItem);\n\t\tif (movingIndex !== -1) {\n\t\t\tnewPositions[movingIndex] = { \n\t\t\t\tx: Math.max(0, rect.x), \n\t\t\t\ty: Math.max(0, rect.y), \n\t\t\t\tw: orientation == 'vertical' ? Math.min(rect.w, containerSize - Math.max(0, rect.x)) : rect.w,\n\t\t\t\th: orientation == 'horizontal' ? Math.min(rect.h, containerSize - Math.max(0, rect.y)) : rect.h\n\t\t\t};\n\t\t}\n\t\t\n\t\t// First pass: identify collisions and set initial positions\n\t\tthis._items.forEach((item, i) => {\n\t\t\tif (i !== movingIndex) {\n\t\t\t\tnewPositions[i] = { x: item.x, y: item.y, w: item.w, h: item.h };\n\t\t\t}\n\t\t});\n\t\t\n\t\t// Resolve collisions recursively\n\t\tconst processedItems = new Set<number>();\n\t\tprocessedItems.add(movingIndex);\n\t\t\n\t\tconst resolveCollisions = (itemIndex: number) => {\n\t\t\tconst itemRect = newPositions[itemIndex];\n\t\t\t\n\t\t\tfor (let i = 0; i < this._items.length; i++) {\n\t\t\t\t// Skip if it's the same item or already processed in this recursive call\n\t\t\t\tif (i === itemIndex || processedItems.has(i)) continue;\n\t\t\t\t\n\t\t\t\tconst otherRect = newPositions[i];\n\t\t\t\tconst intersection = utils.rectIntersect(itemRect, otherRect);\n\t\t\t\t\n\t\t\t\tif (intersection) {\n\t\t\t\t\t// Calculate distances to move in each direction\n\t\t\t\t\tconst moveDown = itemRect.y + itemRect.h - otherRect.y;\n\t\t\t\t\tconst moveRight = itemRect.x + itemRect.w - otherRect.x;\n\t\t\t\t\tconst moveUp = otherRect.y + otherRect.h - itemRect.y;\n\t\t\t\t\tconst moveLeft = otherRect.x + otherRect.w - itemRect.x;\n\t\t\t\t\t\n\t\t\t\t\tif (orientation === 'vertical') {\n\t\t\t\t\t\t// In vertical orientation, prioritize downward movement\n\t\t\t\t\t\tif (moveDown <= moveUp && moveDown <= moveRight && moveDown <= moveLeft) {\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y + itemRect.h);\n\t\t\t\t\t\t} else if (moveUp <= moveRight && moveUp <= moveLeft && itemRect.y - otherRect.h >= 0) {\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y - otherRect.h);\n\t\t\t\t\t\t} else if (moveRight <= moveLeft && itemRect.x + itemRect.w + otherRect.w <= containerSize) {\n\t\t\t\t\t\t\totherRect.x = Math.min(containerSize - otherRect.w, itemRect.x + itemRect.w);\n\t\t\t\t\t\t} else if (itemRect.x - otherRect.w >= 0) {\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x - otherRect.w);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Default to moving down if other directions would cause boundary violations\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y + itemRect.h);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Ensure width doesn't exceed container\n\t\t\t\t\t\tif (otherRect.x + otherRect.w > containerSize) {\n\t\t\t\t\t\t\totherRect.w = Math.max(1, containerSize - otherRect.x);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// In horizontal orientation, prioritize rightward movement\n\t\t\t\t\t\tif (moveRight <= moveUp && moveRight <= moveDown && moveRight <= moveLeft) {\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x + itemRect.w);\n\t\t\t\t\t\t} else if (moveLeft <= moveUp && moveLeft <= moveDown && itemRect.x - otherRect.w >= 0) {\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x - otherRect.w);\n\t\t\t\t\t\t} else if (moveDown <= moveUp && itemRect.y + itemRect.h + otherRect.h <= containerSize) {\n\t\t\t\t\t\t\totherRect.y = Math.min(containerSize - otherRect.h, itemRect.y + itemRect.h);\n\t\t\t\t\t\t} else if (itemRect.y - otherRect.h >= 0) {\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y - otherRect.h);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Default to moving right if other directions would cause boundary violations\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x + itemRect.w);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Ensure height doesn't exceed container\n\t\t\t\t\t\tif (otherRect.y + otherRect.h > containerSize) {\n\t\t\t\t\t\t\totherRect.h = Math.max(1, containerSize - otherRect.y);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t// Mark this item as processed in the current recursive call\n\t\t\t\t\tprocessedItems.add(i);\n\t\t\t\t\t\n\t\t\t\t\t// Recursively resolve any new collisions this movement might have caused\n\t\t\t\t\tresolveCollisions(i);\n\t\t\t\t\t\n\t\t\t\t\t// Remove from processed set after recursion to allow for future collision checks\n\t\t\t\t\tprocessedItems.delete(i);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\t\n\t\t// Start resolving collisions from the moving item\n\t\tresolveCollisions(movingIndex);\n\t\t\n\t\t// Final pass to ensure all items are within bounds\n\t\tfor (let i = 0; i < newPositions.length; i++) {\n\t\t\tif (newPositions[i]) {\n\t\t\t\tnewPositions[i].x = Math.max(0, newPositions[i].x);\n\t\t\t\tnewPositions[i].y = Math.max(0, newPositions[i].y);\n\t\t\t\t\n\t\t\t\t// Apply container constraints based on orientation\n\t\t\t\tif (orientation === 'vertical') {\n\t\t\t\t\tif (newPositions[i].x + newPositions[i].w > containerSize) {\n\t\t\t\t\t\tnewPositions[i].w = Math.max(1, containerSize - newPositions[i].x);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (newPositions[i].y + newPositions[i].h > containerSize) {\n\t\t\t\t\t\tnewPositions[i].h = Math.max(1, containerSize - newPositions[i].y);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn newPositions;\n\t}\n\n\t/**\n\t * Detects and fixes collisions between dashboard items\n\t * Applies collision fixes directly to the dashboard items\n\t */\n\tdetectAndFixCollisions(): void {\n\t\tconst containerSize = this._options.size || Infinity;\n\t\tconst orientation = this._options.orientation;\n\t\tconst processedItems = new Set<number>();\n\n\t\tconst resolveCollisions = (itemIndex: number) => {\n\t\t\tconsole.log(itemIndex);\n\n\t\t\tif (processedItems.has(itemIndex)) return;\n\t\t\t\n\t\t\tconst itemRect = this._items[itemIndex];\n\t\t\tif (!itemRect) return;\n\n\t\t\tfor (let i = 0; i < this._items.length; i++) {\n\t\t\t\tif (i === itemIndex) continue;\n\n\t\t\t\tconst otherRect = this._items[i];\n\t\t\t\tconst intersection = utils.rectIntersect(itemRect, otherRect);\n\n\t\t\t\tif (intersection) {\n\t\t\t\t\t// Calculate distances to move in each direction\n\t\t\t\t\tconst moveDown = itemRect.y + itemRect.h - otherRect.y;\n\t\t\t\t\tconst moveRight = itemRect.x + itemRect.w - otherRect.x;\n\t\t\t\t\tconst moveUp = otherRect.y + otherRect.h - itemRect.y;\n\t\t\t\t\tconst moveLeft = otherRect.x + otherRect.w - itemRect.x;\n\n\t\t\t\t\t// Choose movement direction based on orientation and smallest displacement\n\t\t\t\t\tif (orientation === 'vertical') {\n\t\t\t\t\t\tif (moveDown <= moveUp && moveDown <= moveRight && moveDown <= moveLeft) {\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y + itemRect.h);\n\t\t\t\t\t\t} else if (moveUp <= moveRight && moveUp <= moveLeft && itemRect.y - otherRect.h >= 0) {\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y - otherRect.h);\n\t\t\t\t\t\t} else if (moveRight <= moveLeft && itemRect.x + itemRect.w + otherRect.w <= containerSize) {\n\t\t\t\t\t\t\totherRect.x = Math.min(containerSize - otherRect.w, itemRect.x + itemRect.w);\n\t\t\t\t\t\t} else if (itemRect.x - otherRect.w >= 0) {\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x - otherRect.w);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y + itemRect.h);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Ensure width doesn't exceed container\n\t\t\t\t\t\tif (otherRect.x + otherRect.w > containerSize) {\n\t\t\t\t\t\t\totherRect.w = Math.max(1, containerSize - otherRect.x);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Horizontal orientation\n\t\t\t\t\t\tif (moveRight <= moveUp && moveRight <= moveDown && moveRight <= moveLeft) {\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x + itemRect.w);\n\t\t\t\t\t\t} else if (moveLeft <= moveUp && moveLeft <= moveDown && itemRect.x - otherRect.w >= 0) {\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x - otherRect.w);\n\t\t\t\t\t\t} else if (moveDown <= moveUp && itemRect.y + itemRect.h + otherRect.h <= containerSize) {\n\t\t\t\t\t\t\totherRect.y = Math.min(containerSize - otherRect.h, itemRect.y + itemRect.h);\n\t\t\t\t\t\t} else if (itemRect.y - otherRect.h >= 0) {\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y - otherRect.h);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x + itemRect.w);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Ensure height doesn't exceed container\n\t\t\t\t\t\tif (otherRect.y + otherRect.h > containerSize) {\n\t\t\t\t\t\t\totherRect.h = Math.max(1, containerSize - otherRect.y);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Recursively resolve new collisions\n\t\t\t\t\tresolveCollisions(i);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\t// Process all items to resolve collisions\n\t\tfor (let i = 0; i < this._items.length; i++) {\n\t\t\tif (!processedItems.has(i)) {\n\t\t\t\tresolveCollisions(i);\n\t\t\t\tprocessedItems.add(i);\n\t\t\t}\n\t\t}\n\n\t\t// Final pass to ensure all items are within bounds\n\t\tfor (let i = 0; i < this._items.length; i++) {\n\t\t\tconst item = this._items[i];\n\t\t\titem.x = Math.max(0, item.x);\n\t\t\titem.y = Math.max(0, item.y);\n\n\t\t\t// Apply container constraints based on orientation\n\t\t\tif (orientation === 'vertical') {\n\t\t\t\tif (item.x + item.w > containerSize) {\n\t\t\t\t\titem.w = Math.max(1, containerSize - item.x);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (item.y + item.h > containerSize) {\n\t\t\t\t\titem.h = Math.max(1, containerSize - item.y);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Clear cached size since positions have changed\n\t\tthis._size = null;\n\t}\n\n\t/**\n\t * Detects if there are any collisions between dashboard items\n\t * @returns True if collisions are detected, false otherwise\n\t */\n\thasCollisions(): boolean {\n\t\tfor (let i = 0; i < this._items.length; i++) {\n\t\t\tfor (let j = i + 1; j < this._items.length; j++) {\n\t\t\t\tif (utils.rectIntersect(this._items[i], this._items[j])) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n\n}"]}
|
|
1
|
+
{"version":3,"file":"dashboardModel.js","sourceRoot":"","sources":["../../src/model/dashboardModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,OAAO,cAAc;IAG1B,IAAI,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAA,CAAC,CAAC;IAGtC,IAAI,KAAK,KAAK,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IAElC,YAAY,MAAwB;QAH5B,WAAM,GAAyB,EAAE,CAAC;QAIzC,IAAI,MAAM;YAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ,CAAC,M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ACb,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC;CAED","sourcesContent":["import { Rect, Size, utils } from \"@omegagrid/core\";\nimport constants from \"../constants\";\nimport { DashboardOptions, DashboardSource } from \"../types\";\nimport { DashboardItemModel } from \"./dashboardItemModel\";\n\nexport class DashboardModel {\n\n\tprivate _options: DashboardOptions;\n\tget options() { return this._options }\n\n\tprivate _items: DashboardItemModel[] = [];\n\tget items() { return this._items }\n\n\tconstructor(source?: DashboardSource) {\n\t\tif (source) this.populate(source);\n\t}\n\n\tpopulate(source: DashboardSource) {\n\t\tthis._items = source.items.map((item, i) => new DashboardItemModel(this, i, item));\n\t\tthis._options = utils.mergeDeep(constants.DEFAULT_OPTIONS, source.options);\n\t}\n\n\tprivate _size: Size;\n\tget size() {\n\t\tif (this._size) return this._size;\n\t\tthis._size = {w: 0, h: 0};\n\t\tthis._items.forEach(item => {\n\t\t\tthis._size.w = Math.max(this._size.w, item.x + item.w);\n\t\t\tthis._size.h = Math.max(this._size.h, item.y + item.h);\n\t\t});\n\t\treturn this._size;\n\t}\n\n\tgetSourceData(): DashboardSource {\n\t\treturn {\n\t\t\titems: this._items.map(item => item.getSourceData()),\n\t\t\toptions: this._options\n\t\t};\n\t}\n\n\tupdatePositions(positions: Rect[]) {\n\t\tthis._size = {w: 0, h: 0};\n\t\tthis._items.forEach((item, i) => {\n\t\t\tif (positions[i]) {\n\t\t\t\titem.x = positions[i].x;\n\t\t\t\titem.y = positions[i].y;\n\t\t\t\titem.w = positions[i].w;\n\t\t\t\titem.h = positions[i].h;\n\t\t\t}\n\t\t\tthis._size.w = Math.max(this._size.w, item.x + item.w);\n\t\t\tthis._size.h = Math.max(this._size.h, item.y + item.h);\n\t\t});\n\t}\n\n\tcalculatePositions(movingItem: DashboardItemModel, rect: Rect) {\n\t\tconst newPositions: Rect[] = new Array(this._items.length);\n\t\tconst columns = this._options.columns || Infinity;\n\t\tconst rows = this._options.rows || Infinity;\n\t\tconst orientation = this._options.orientation;\n\n\t\t// Set the position for the moving item with boundary constraints\n\t\tconst movingIndex = this._items.indexOf(movingItem);\n\t\tif (movingIndex !== -1) {\n\t\t\tnewPositions[movingIndex] = { \n\t\t\t\tx: Math.max(0, rect.x), \n\t\t\t\ty: Math.max(0, rect.y), \n\t\t\t\tw: orientation == 'vertical' ? Math.min(rect.w, columns - Math.max(0, rect.x)) : rect.w,\n\t\t\t\th: orientation == 'horizontal' ? Math.min(rect.h, rows - Math.max(0, rect.y)) : rect.h\n\t\t\t};\n\t\t}\n\t\t\n\t\t// First pass: identify collisions and set initial positions\n\t\tthis._items.forEach((item, i) => {\n\t\t\tif (i !== movingIndex) {\n\t\t\t\tnewPositions[i] = { x: item.x, y: item.y, w: item.w, h: item.h };\n\t\t\t}\n\t\t});\n\t\t\n\t\t// Resolve collisions recursively\n\t\tconst processedItems = new Set<number>();\n\t\tprocessedItems.add(movingIndex);\n\t\t\n\t\tconst resolveCollisions = (itemIndex: number) => {\n\t\t\tconst itemRect = newPositions[itemIndex];\n\t\t\t\n\t\t\tfor (let i = 0; i < this._items.length; i++) {\n\t\t\t\t// Skip if it's the same item or already processed in this recursive call\n\t\t\t\tif (i === itemIndex || processedItems.has(i)) continue;\n\t\t\t\t\n\t\t\t\tconst otherRect = newPositions[i];\n\t\t\t\tconst intersection = utils.rectIntersect(itemRect, otherRect);\n\t\t\t\t\n\t\t\t\tif (intersection) {\n\t\t\t\t\t// Calculate distances to move in each direction\n\t\t\t\t\tconst moveDown = itemRect.y + itemRect.h - otherRect.y;\n\t\t\t\t\tconst moveRight = itemRect.x + itemRect.w - otherRect.x;\n\t\t\t\t\tconst moveUp = otherRect.y + otherRect.h - itemRect.y;\n\t\t\t\t\tconst moveLeft = otherRect.x + otherRect.w - itemRect.x;\n\t\t\t\t\t\n\t\t\t\t\tif (orientation === 'vertical') {\n\t\t\t\t\t\t// In vertical orientation, prioritize downward movement\n\t\t\t\t\t\tif (moveDown <= moveUp && moveDown <= moveRight && moveDown <= moveLeft) {\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y + itemRect.h);\n\t\t\t\t\t\t} else if (moveUp <= moveRight && moveUp <= moveLeft && itemRect.y - otherRect.h >= 0) {\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y - otherRect.h);\n\t\t\t\t\t\t} else if (moveRight <= moveLeft && itemRect.x + itemRect.w + otherRect.w <= columns) {\n\t\t\t\t\t\t\totherRect.x = Math.min(columns - otherRect.w, itemRect.x + itemRect.w);\n\t\t\t\t\t\t} else if (itemRect.x - otherRect.w >= 0) {\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x - otherRect.w);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Default to moving down if other directions would cause boundary violations\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y + itemRect.h);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Ensure width doesn't exceed container\n\t\t\t\t\t\tif (otherRect.x + otherRect.w > columns) {\n\t\t\t\t\t\t\totherRect.w = Math.max(1, columns - otherRect.x);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// In horizontal orientation, prioritize rightward movement\n\t\t\t\t\t\tif (moveRight <= moveUp && moveRight <= moveDown && moveRight <= moveLeft) {\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x + itemRect.w);\n\t\t\t\t\t\t} else if (moveLeft <= moveUp && moveLeft <= moveDown && itemRect.x - otherRect.w >= 0) {\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x - otherRect.w);\n\t\t\t\t\t\t} else if (moveDown <= moveUp && itemRect.y + itemRect.h + otherRect.h <= rows) {\n\t\t\t\t\t\t\totherRect.y = Math.min(rows - otherRect.h, itemRect.y + itemRect.h);\n\t\t\t\t\t\t} else if (itemRect.y - otherRect.h >= 0) {\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y - otherRect.h);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Default to moving right if other directions would cause boundary violations\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x + itemRect.w);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Ensure height doesn't exceed container\n\t\t\t\t\t\tif (otherRect.y + otherRect.h > rows) {\n\t\t\t\t\t\t\totherRect.h = Math.max(1, rows - otherRect.y);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t// Mark this item as processed in the current recursive call\n\t\t\t\t\tprocessedItems.add(i);\n\t\t\t\t\t\n\t\t\t\t\t// Recursively resolve any new collisions this movement might have caused\n\t\t\t\t\tresolveCollisions(i);\n\t\t\t\t\t\n\t\t\t\t\t// Remove from processed set after recursion to allow for future collision checks\n\t\t\t\t\tprocessedItems.delete(i);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\t\n\t\t// Start resolving collisions from the moving item\n\t\tresolveCollisions(movingIndex);\n\t\t\n\t\t// Final pass to ensure all items are within bounds\n\t\tfor (let i = 0; i < newPositions.length; i++) {\n\t\t\tif (newPositions[i]) {\n\t\t\t\tnewPositions[i].x = Math.max(0, newPositions[i].x);\n\t\t\t\tnewPositions[i].y = Math.max(0, newPositions[i].y);\n\t\t\t\t\n\t\t\t\t// Apply container constraints based on orientation\n\t\t\t\tif (orientation === 'vertical') {\n\t\t\t\t\tif (newPositions[i].x + newPositions[i].w > columns) {\n\t\t\t\t\t\tnewPositions[i].w = Math.max(1, columns - newPositions[i].x);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (newPositions[i].y + newPositions[i].h > rows) {\n\t\t\t\t\t\tnewPositions[i].h = Math.max(1, rows - newPositions[i].y);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn newPositions;\n\t}\n\n\t/**\n\t * Detects and fixes collisions between dashboard items\n\t * Applies collision fixes directly to the dashboard items\n\t */\n\tdetectAndFixCollisions(): void {\n\t\tconst columns = this._options.columns || Infinity;\n\t\tconst rows = this._options.rows || Infinity;\n\t\tconst orientation = this._options.orientation;\n\t\tconst processedItems = new Set<number>();\n\n\t\tconst resolveCollisions = (itemIndex: number) => {\n\t\t\tif (processedItems.has(itemIndex)) return;\n\t\t\t\n\t\t\tconst itemRect = this._items[itemIndex];\n\t\t\tif (!itemRect) return;\n\n\t\t\tfor (let i = 0; i < this._items.length; i++) {\n\t\t\t\tif (i === itemIndex) continue;\n\n\t\t\t\tconst otherRect = this._items[i];\n\t\t\t\tconst intersection = utils.rectIntersect(itemRect, otherRect);\n\n\t\t\t\tif (intersection) {\n\t\t\t\t\t// Calculate distances to move in each direction\n\t\t\t\t\tconst moveDown = itemRect.y + itemRect.h - otherRect.y;\n\t\t\t\t\tconst moveRight = itemRect.x + itemRect.w - otherRect.x;\n\t\t\t\t\tconst moveUp = otherRect.y + otherRect.h - itemRect.y;\n\t\t\t\t\tconst moveLeft = otherRect.x + otherRect.w - itemRect.x;\n\n\t\t\t\t\t// Choose movement direction based on orientation and smallest displacement\n\t\t\t\t\tif (orientation === 'vertical') {\n\t\t\t\t\t\tif (moveDown <= moveUp && moveDown <= moveRight && moveDown <= moveLeft) {\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y + itemRect.h);\n\t\t\t\t\t\t} else if (moveUp <= moveRight && moveUp <= moveLeft && itemRect.y - otherRect.h >= 0) {\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y - otherRect.h);\n\t\t\t\t\t\t} else if (moveRight <= moveLeft && itemRect.x + itemRect.w + otherRect.w <= columns) {\n\t\t\t\t\t\t\totherRect.x = Math.min(columns - otherRect.w, itemRect.x + itemRect.w);\n\t\t\t\t\t\t} else if (itemRect.x - otherRect.w >= 0) {\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x - otherRect.w);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y + itemRect.h);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Ensure width doesn't exceed container\n\t\t\t\t\t\tif (otherRect.x + otherRect.w > columns) {\n\t\t\t\t\t\t\totherRect.w = Math.max(1, columns - otherRect.x);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Horizontal orientation\n\t\t\t\t\t\tif (moveRight <= moveUp && moveRight <= moveDown && moveRight <= moveLeft) {\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x + itemRect.w);\n\t\t\t\t\t\t} else if (moveLeft <= moveUp && moveLeft <= moveDown && itemRect.x - otherRect.w >= 0) {\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x - otherRect.w);\n\t\t\t\t\t\t} else if (moveDown <= moveUp && itemRect.y + itemRect.h + otherRect.h <= rows) {\n\t\t\t\t\t\t\totherRect.y = Math.min(rows - otherRect.h, itemRect.y + itemRect.h);\n\t\t\t\t\t\t} else if (itemRect.y - otherRect.h >= 0) {\n\t\t\t\t\t\t\totherRect.y = Math.max(0, itemRect.y - otherRect.h);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\totherRect.x = Math.max(0, itemRect.x + itemRect.w);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Ensure height doesn't exceed container\n\t\t\t\t\t\tif (otherRect.y + otherRect.h > rows) {\n\t\t\t\t\t\t\totherRect.h = Math.max(1, rows - otherRect.y);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Recursively resolve new collisions\n\t\t\t\t\tresolveCollisions(i);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\t// Process all items to resolve collisions\n\t\tfor (let i = 0; i < this._items.length; i++) {\n\t\t\tif (!processedItems.has(i)) {\n\t\t\t\tresolveCollisions(i);\n\t\t\t\tprocessedItems.add(i);\n\t\t\t}\n\t\t}\n\n\t\t// Final pass to ensure all items are within bounds\n\t\tfor (let i = 0; i < this._items.length; i++) {\n\t\t\tconst item = this._items[i];\n\t\t\titem.x = Math.max(0, item.x);\n\t\t\titem.y = Math.max(0, item.y);\n\n\t\t\t// Apply container constraints based on orientation\n\t\t\tif (orientation === 'vertical') {\n\t\t\t\tif (item.x + item.w > columns) {\n\t\t\t\t\titem.w = Math.max(1, columns - item.x);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (item.y + item.h > rows) {\n\t\t\t\t\titem.h = Math.max(1, rows - item.y);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Clear cached size since positions have changed\n\t\tthis._size = null;\n\t}\n\n\t/**\n\t * Detects if there are any collisions between dashboard items\n\t * @returns True if collisions are detected, false otherwise\n\t */\n\thasCollisions(): boolean {\n\t\tfor (let i = 0; i < this._items.length; i++) {\n\t\t\tfor (let j = i + 1; j < this._items.length; j++) {\n\t\t\t\tif (utils.rectIntersect(this._items[i], this._items[j])) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n\n}"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -14,12 +14,22 @@ export type DashboardItemSource = {
|
|
|
14
14
|
title?: string;
|
|
15
15
|
};
|
|
16
16
|
export type DashboardOptions = {
|
|
17
|
-
/** number of columns
|
|
18
|
-
|
|
17
|
+
/** number of columns */
|
|
18
|
+
columns?: number;
|
|
19
|
+
/** fixed column width */
|
|
20
|
+
columnWidth?: number;
|
|
21
|
+
/** number of rows */
|
|
22
|
+
rows?: number;
|
|
23
|
+
/** fixed row height */
|
|
24
|
+
rowHeight?: number;
|
|
19
25
|
/** The gap between items */
|
|
20
|
-
gap
|
|
26
|
+
gap?: number;
|
|
21
27
|
/** Orientation of dashboard */
|
|
22
|
-
orientation?: 'horizontal' | 'vertical';
|
|
28
|
+
orientation?: 'horizontal' | 'vertical' | null;
|
|
29
|
+
overlay?: {
|
|
30
|
+
/** opacity of overlay in design mode */
|
|
31
|
+
opacity?: number;
|
|
32
|
+
};
|
|
23
33
|
};
|
|
24
34
|
export type DashboardSource = {
|
|
25
35
|
/** Dashboard items */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,MAAM,mBAAmB,GAAG;IACjC,0BAA0B;IAC1B,EAAE,EAAE,WAAW,CAAC;IAEhB,cAAc;IACd,CAAC,EAAE,MAAM,CAAC;IAEV,cAAc;IACd,CAAC,EAAE,MAAM,CAAC;IAEV,YAAY;IACZ,CAAC,CAAC,EAAE,MAAM,CAAC;IAEX,aAAa;IACb,CAAC,CAAC,EAAE,MAAM,CAAC;IAEX,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC9B,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,MAAM,mBAAmB,GAAG;IACjC,0BAA0B;IAC1B,EAAE,EAAE,WAAW,CAAC;IAEhB,cAAc;IACd,CAAC,EAAE,MAAM,CAAC;IAEV,cAAc;IACd,CAAC,EAAE,MAAM,CAAC;IAEV,YAAY;IACZ,CAAC,CAAC,EAAE,MAAM,CAAC;IAEX,aAAa;IACb,CAAC,CAAC,EAAE,MAAM,CAAC;IAEX,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC9B,wBAAwB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,qBAAqB;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,4BAA4B;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,+BAA+B;IAC/B,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,IAAI,CAAC;IAE/C,OAAO,CAAC,EAAE;QACT,wCAAwC;QACxC,OAAO,CAAC,EAAE,MAAM,CAAC;KACjB,CAAA;CACD,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC7B,sBAAsB;IACtB,KAAK,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAE9B,wBAAwB;IACxB,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC3B,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ComponentId } from \"@omegagrid/core\";\n\nexport type DashboardItemSource = {\n\t/** id of the component */\n\tid: ComponentId;\n\n\t/** x coord */\n\tx: number;\n\n\t/** y coord */\n\ty: number;\n\t\n\t/** width */\n\tw?: number;\n\n\t/** height */\n\th?: number;\n\n\t/** title shown in design mode */\n\ttitle?: string;\n}\n\nexport type DashboardOptions = {\n\t/** number of columns
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ComponentId } from \"@omegagrid/core\";\n\nexport type DashboardItemSource = {\n\t/** id of the component */\n\tid: ComponentId;\n\n\t/** x coord */\n\tx: number;\n\n\t/** y coord */\n\ty: number;\n\t\n\t/** width */\n\tw?: number;\n\n\t/** height */\n\th?: number;\n\n\t/** title shown in design mode */\n\ttitle?: string;\n}\n\nexport type DashboardOptions = {\n\t/** number of columns */\n\tcolumns?: number;\n\n\t/** fixed column width */\n\tcolumnWidth?: number;\n\n\t/** number of rows */\n\trows?: number;\n\n\t/** fixed row height */\n\trowHeight?: number;\n\n\t/** The gap between items */\n\tgap?: number;\n\n\t/** Orientation of dashboard */\n\torientation?: 'horizontal' | 'vertical' | null;\n\n\toverlay?: {\n\t\t/** opacity of overlay in design mode */\n\t\topacity?: number;\n\t}\n}\n\nexport type DashboardSource = {\n\t/** Dashboard items */\n\titems?: DashboardItemSource[];\n\n\t/** Dashboard options */\n\toptions?: DashboardOptions;\n}"]}
|
package/dist/ui/dashboard.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentFactory, ComponentStore, Layout, OmegaComponent, Rect, Container } from '@omegagrid/core';
|
|
1
|
+
import { ComponentFactory, ComponentStore, Layout, OmegaComponent, Rect, Container, Size } from '@omegagrid/core';
|
|
2
2
|
import { DashboardItemModel, DashboardModel } from '../model';
|
|
3
3
|
import { DashboardSource } from '../types';
|
|
4
4
|
import { DashboardItem } from './dashboardItem';
|
|
@@ -19,13 +19,13 @@ export declare class Dashboard extends OmegaComponent implements Layout {
|
|
|
19
19
|
private _currentItem;
|
|
20
20
|
private _previewPositions;
|
|
21
21
|
readonly components: ComponentStore<HTMLElement & Layout>;
|
|
22
|
-
get pixelSize(): number;
|
|
23
22
|
private _baseSize;
|
|
24
|
-
get baseSize():
|
|
23
|
+
get baseSize(): Size;
|
|
25
24
|
startMove(item: DashboardItem): void;
|
|
26
25
|
stopMove(): void;
|
|
27
26
|
get scrollOffset(): number;
|
|
28
|
-
|
|
27
|
+
offsetToXCoord(offset: number): number;
|
|
28
|
+
offsetToYCoord(offset: number): number;
|
|
29
29
|
updatePreviewPositions(): void;
|
|
30
30
|
previewLayout(rect: Rect): void;
|
|
31
31
|
_onItemMove: (e: DashboardEvent) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../src/ui/dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAO,IAAI,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;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cAAc,UAQ/B;IAED,aAAa,MAAO,cAAc,UAQjC;;IAYD,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAI,IAAI;IAWxC,eAAe,CAAC,IAAI,EAAE,IAAI;IAK1B,eAAe;IAIf,aAAa,CAAC,MAAM,EAAE,eAAe;IAMrC,eAAe,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI;IAM5C,aAAa;IAMb,MAAM;IAUN,OAAO;IAIP,MAAM,kDAaC;CAEP"}
|
package/dist/ui/dashboard.js
CHANGED
|
@@ -17,15 +17,18 @@ export class DashboardEvent extends Event {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
let Dashboard = class Dashboard extends OmegaComponent {
|
|
20
|
-
get pixelSize() {
|
|
21
|
-
return this.model.options.orientation === 'horizontal'
|
|
22
|
-
? this.container.clientHeight
|
|
23
|
-
: this.container.clientWidth;
|
|
24
|
-
}
|
|
25
20
|
get baseSize() {
|
|
26
21
|
if (this._baseSize)
|
|
27
22
|
return this._baseSize;
|
|
28
|
-
|
|
23
|
+
const { columns, columnWidth, rows, rowHeight, gap } = this.model.options;
|
|
24
|
+
this._baseSize = {
|
|
25
|
+
w: columnWidth || (columns ? (this.container.clientWidth - ((columns + 1) * gap)) / columns : null),
|
|
26
|
+
h: rowHeight || (rows ? (this.container.clientHeight - ((rows + 1) * gap)) / rows : null),
|
|
27
|
+
};
|
|
28
|
+
if (this._baseSize.w == null)
|
|
29
|
+
this._baseSize.w = this._baseSize.h;
|
|
30
|
+
if (this._baseSize.h == null)
|
|
31
|
+
this._baseSize.h = this._baseSize.w;
|
|
29
32
|
return this._baseSize;
|
|
30
33
|
}
|
|
31
34
|
startMove(item) {
|
|
@@ -45,8 +48,11 @@ let Dashboard = class Dashboard extends OmegaComponent {
|
|
|
45
48
|
get scrollOffset() {
|
|
46
49
|
return this.container?.verticalSlider?.value || 0;
|
|
47
50
|
}
|
|
48
|
-
|
|
49
|
-
return Math.max(0, Math.floor(offset / (this.baseSize + this.model.options.gap)));
|
|
51
|
+
offsetToXCoord(offset) {
|
|
52
|
+
return Math.max(0, Math.floor(offset / (this.baseSize.w + this.model.options.gap)));
|
|
53
|
+
}
|
|
54
|
+
offsetToYCoord(offset) {
|
|
55
|
+
return Math.max(0, Math.floor(offset / (this.baseSize.h + this.model.options.gap)));
|
|
50
56
|
}
|
|
51
57
|
updatePreviewPositions() {
|
|
52
58
|
if (!this._previewPositions)
|
|
@@ -71,8 +77,8 @@ let Dashboard = class Dashboard extends OmegaComponent {
|
|
|
71
77
|
if (!e.item.moving)
|
|
72
78
|
return;
|
|
73
79
|
const topOffset = this.scrollOffset;
|
|
74
|
-
const x = this.
|
|
75
|
-
const y = this.
|
|
80
|
+
const x = this.offsetToXCoord(e.item.offsetLeft);
|
|
81
|
+
const y = this.offsetToYCoord(e.item.offsetTop + topOffset);
|
|
76
82
|
const rect = { x, y, w: e.item.model.w, h: e.item.model.h };
|
|
77
83
|
this.showPlaceholder(rect);
|
|
78
84
|
this.previewLayout(rect);
|
|
@@ -81,8 +87,8 @@ let Dashboard = class Dashboard extends OmegaComponent {
|
|
|
81
87
|
if (!e.item.resizing)
|
|
82
88
|
return;
|
|
83
89
|
const topOffset = this.scrollOffset;
|
|
84
|
-
const w = this.
|
|
85
|
-
const h = this.
|
|
90
|
+
const w = this.offsetToXCoord(e.item.offsetLeft + e.item.offsetWidth) - e.item.model.x + 1;
|
|
91
|
+
const h = this.offsetToYCoord(e.item.offsetTop + e.item.offsetHeight + topOffset) - e.item.model.y + 1;
|
|
86
92
|
const rect = { x: e.item.model.x, y: e.item.model.y, w, h };
|
|
87
93
|
this.showPlaceholder(rect);
|
|
88
94
|
this.previewLayout(rect);
|
|
@@ -112,10 +118,10 @@ let Dashboard = class Dashboard extends OmegaComponent {
|
|
|
112
118
|
const baseSize = this.baseSize;
|
|
113
119
|
const gap = this.model.options.gap;
|
|
114
120
|
return {
|
|
115
|
-
x: item.x * (baseSize + gap) + gap,
|
|
116
|
-
y: item.y * (baseSize + gap) + gap,
|
|
117
|
-
w: item.w * (baseSize + gap) - gap,
|
|
118
|
-
h: item.h * (baseSize + gap) - gap,
|
|
121
|
+
x: item.x * (baseSize.w + gap) + gap,
|
|
122
|
+
y: item.y * (baseSize.h + gap) + gap,
|
|
123
|
+
w: item.w * (baseSize.w + gap) - gap,
|
|
124
|
+
h: item.h * (baseSize.h + gap) - gap,
|
|
119
125
|
};
|
|
120
126
|
}
|
|
121
127
|
showPlaceholder(rect) {
|
|
@@ -147,8 +153,8 @@ let Dashboard = class Dashboard extends OmegaComponent {
|
|
|
147
153
|
return;
|
|
148
154
|
this.items?.forEach((item) => this.setItemPosition(item, item.model));
|
|
149
155
|
dom.setSize(this.content, {
|
|
150
|
-
w: this.model.size.w * (this.baseSize + this.model.options.gap) + this.model.options.gap,
|
|
151
|
-
h: this.model.size.h * (this.baseSize + this.model.options.gap) + this.model.options.gap
|
|
156
|
+
w: this.model.size.w * (this.baseSize.w + this.model.options.gap) + this.model.options.gap,
|
|
157
|
+
h: this.model.size.h * (this.baseSize.h + this.model.options.gap) + this.model.options.gap
|
|
152
158
|
});
|
|
153
159
|
}
|
|
154
160
|
updated() {
|
package/dist/ui/dashboard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.js","sourceRoot":"","sources":["../../src/ui/dashboard.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAoB,cAAc,EAAU,cAAc,EAAE,GAAG,EAAmB,MAAM,iBAAiB,CAAC;AACjH,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAsB,cAAc,EAAE,MAAM,UAAU,C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K,CAAC,OAAO,CAAC,GAAG;SACxF,CAAC,CAAC;IACJ,CAAC;IAED,OAAO;QACN,IAAI,CAAC,MAAM,EAAE,CAAC;IACf,CAAC;;AAjKM,gBAAM,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,AAAjC,CAAkC;AAG/C;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;wCACH;AAGtB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;6CACtB;AAGnB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;kDACS;AAGlC;IADC,QAAQ,CAAC,mBAAmB,CAAC;wCACd;AAGhB;IADC,KAAK,CAAC,cAAc,CAAC;4CACD;AAGrB;IADC,KAAK,CAAC,kBAAkB,CAAC;0CACF;AAGxB;IADC,KAAK,CAAC,mBAAmB,CAAC;8CACC;AAvBhB,SAAS;IADrB,aAAa,CAAC,cAAc,CAAC;GACjB,SAAS,CAoLrB","sourcesContent":["import { ComponentFactory, ComponentStore, Layout, OmegaComponent, dom, Rect, Container } from '@omegagrid/core';\nimport { html } from 'lit';\nimport { customElement, property, query, queryAll } from 'lit/decorators.js';\nimport { map } from 'lit/directives/map.js';\nimport { style } from './dashboard.style';\nimport { DashboardItemModel, DashboardModel } from '../model';\nimport { DashboardSource } from '../types';\nimport { DashboardItem } from './dashboardItem';\n\nexport class DashboardEvent extends Event {\n\n\treadonly item: DashboardItem;\n\treadonly model: DashboardItemModel;\n\n\tconstructor(type: string, args: Partial<DashboardEvent>) {\n\t\tsuper(`dashboard.${type}`, {bubbles: true, composed: true});\n\t\tObject.assign(this, args);\n\t}\n}\n\n@customElement('og-dashboard')\nexport class Dashboard extends OmegaComponent implements Layout {\n\n\tstatic styles = [OmegaComponent.styles, style];\n\n\t@property({type: Object})\n\tmodel: DashboardModel;\n\n\t@property({type: Boolean, reflect: true})\n\tdesignMode = false;\n\n\t@property({type: Object})\n\tcreateComponent: ComponentFactory;\n\n\t@queryAll('og-dashboard-item')\n\titems: NodeList;\n\n\t@query('og-container')\n\tcontainer: Container;\n\n\t@query('[slot=\"content\"]')\n\tcontent: HTMLDivElement;\n\n\t@query('.item-placeholder')\n\tplaceholder: HTMLDivElement;\n\n\tprivate _currentItem: DashboardItem;\n\tprivate _previewPositions: Rect[];\n\n\treadonly components = new ComponentStore<HTMLElement & Layout>(\n\t\tid => this.createComponent ? this.createComponent(id) as HTMLElement & Layout : null\n\t);\n\n\tget pixelSize() {\n\t\treturn this.model.options.orientation === 'horizontal'\n\t\t\t? this.container.clientHeight\n\t\t\t: this.container.clientWidth;\n\t}\n\n\tprivate _baseSize: number;\n\tget baseSize() {\n\t\tif (this._baseSize) return this._baseSize;\n\t\tthis._baseSize = (this.pixelSize - ((this.model.options.size + 1) * this.model.options.gap)) / this.model.options.size;\n\t\treturn this._baseSize;\n\t}\n\n\tstartMove(item: DashboardItem) {\n\t\tthis._currentItem = item;\n\t\tthis._currentItem.classList.toggle('active', true);\n\t\tthis.classList.toggle('moving', true);\n\t}\n\n\tstopMove() {\n\t\tif (!this._currentItem) return;\n\t\tthis._currentItem.classList.toggle('active', false);\n\t\tthis._currentItem = null;\n\t\tthis.classList.toggle('moving', false);\n\t\tthis.hidePlaceholder();\n\t\tthis.updatePreviewPositions();\n\t}\n\n\tget scrollOffset() {\n\t\treturn this.container?.verticalSlider?.value || 0;\n\t}\n\n\toffsetToCoord(offset: number) {\n\t\treturn Math.max(0, Math.floor(offset / (this.baseSize + this.model.options.gap)));\n\t}\n\n\tupdatePreviewPositions() {\n\t\tif (!this._previewPositions) return;\n\t\tthis.model.updatePositions(this._previewPositions);\n\t\tthis._previewPositions = null;\n\t\tthis.layout();\n\t}\n\n\tpreviewLayout(rect: Rect) {\n\t\tthis._previewPositions = this.model.calculatePositions(this._currentItem.model, rect);\n\t\tthis._previewPositions.forEach((rect, i) => {\n\t\t\tconst item = this.items[i] as DashboardItem;\n\t\t\tif (item && item != this._currentItem) this.setItemPosition(item, rect);\n\t\t});\n\t}\n\n\t_onItemMove = (e: DashboardEvent) => {\n\t\tif (!e.item.moving) return;\n\t\tconst topOffset = this.scrollOffset;\n\t\tconst x = this.offsetToCoord(e.item.offsetLeft);\n\t\tconst y = this.offsetToCoord(e.item.offsetTop + topOffset);\n\t\tconst rect: Rect = {x, y, w: e.item.model.w, h: e.item.model.h};\n\t\tthis.showPlaceholder(rect);\n\t\tthis.previewLayout(rect);\n\t}\n\n\t_onItemResize = (e: DashboardEvent) => {\n\t\tif (!e.item.resizing) return;\n\t\tconst topOffset = this.scrollOffset;\n\t\tconst w = this.offsetToCoord(e.item.offsetLeft + e.item.offsetWidth) - e.item.model.x + 1;\n\t\tconst h = this.offsetToCoord(e.item.offsetTop + e.item.offsetHeight + topOffset) - e.item.model.y + 1;\n\t\tconst rect: Rect = {x: e.item.model.x, y: e.item.model.y, w, h};\n\t\tthis.showPlaceholder(rect);\n\t\tthis.previewLayout(rect);\n\t}\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addEventListener('dashboard.movestart', (e: DashboardEvent) => this.startMove(e.item));\n\t\tthis.addEventListener('dashboard.resizestart', (e: DashboardEvent) => this.startMove(e.item));\n\t\tthis.addEventListener('dashboard.movestop', () => this.stopMove());\n\t\tthis.addEventListener('dashboard.resizestop', () => this.stopMove());\n\t\tthis.addEventListener('dashboard.move', this._onItemMove);\n\t\tthis.addEventListener('dashboard.resize', this._onItemResize);\n\t}\n\n\tcalculateItemLocation(item: Rect) : Rect {\n\t\tconst baseSize = this.baseSize;\n\t\tconst gap = this.model.options.gap;\n\t\treturn {\n\t\t\tx: item.x * (baseSize + gap) + gap,\n\t\t\ty: item.y * (baseSize + gap) + gap,\n\t\t\tw: item.w * (baseSize + gap) - gap,\n\t\t\th: item.h * (baseSize + gap) - gap,\n\t\t};\n\t}\n\n\tshowPlaceholder(rect: Rect) {\n\t\tdom.showElement(this.placeholder);\n\t\tthis.setItemPosition(this.placeholder, rect);\n\t}\n\n\thidePlaceholder() {\n\t\tdom.hideElement(this.placeholder);\n\t}\n\n\tsetSourceData(source: DashboardSource) {\n\t\tthis.components.clear();\n\t\tthis.model = new DashboardModel(source);\n\t\tthis.model.detectAndFixCollisions();\n\t}\n\n\tsetItemPosition(elm: HTMLElement, rect: Rect) {\n\t\tconst {x, y, w, h} = this.calculateItemLocation(rect);\n\t\tdom.setSize(elm, { w, h});\n\t\tdom.setPosition(elm, {l: x, t: y});\n\t}\n\n\tfixCollisions() {\n\t\tif (!this.model) return;\n\t\tthis.model.detectAndFixCollisions();\n\t\tthis.layout();\n\t}\n\n\tlayout() {\n\t\tthis._baseSize = null;\n\t\tif (!this.model) return;\n\t\tthis.items?.forEach((item: DashboardItem) => this.setItemPosition(item, item.model));\n\t\tdom.setSize(this.content, {\n\t\t\tw: this.model.size.w * (this.baseSize + this.model.options.gap) + this.model.options.gap,\n\t\t\th: this.model.size.h * (this.baseSize + this.model.options.gap) + this.model.options.gap\n\t\t});\n\t}\n\n\tupdated() {\n\t\tthis.layout();\n\t}\n\t\n\trender = () => this.model ? html`\n\t\t<og-container>\n\t\t\t<div slot=\"content\">\n\t\t\t\t${this.designMode ? html`<div class=\"item-placeholder\"></div>` : null}\n\t\t\t\t${map(this.model.items, item => html`\n\t\t\t\t\t<og-dashboard-item\n\t\t\t\t\t\t?designMode=\"${this.designMode}\"\n\t\t\t\t\t\t.model=\"${item}\" \n\t\t\t\t\t\t.components=\"${this.components}\">\n\t\t\t\t\t</og-dashboard-item>\n\t\t\t\t`)}\n\t\t\t</div>\n\t\t</og-container>\n\t` : '';\n\n}"]}
|
|
1
|
+
{"version":3,"file":"dashboard.js","sourceRoot":"","sources":["../../src/ui/dashboard.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAoB,cAAc,EAAU,cAAc,EAAE,GAAG,EAAyB,MAAM,iBAAiB,CAAC;AACvH,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;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AC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;6CACtB;AAGnB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;kDACS;AAGlC;IADC,QAAQ,CAAC,mBAAmB,CAAC;wCACd;AAGhB;IADC,KAAK,CAAC,cAAc,CAAC;4CACD;AAGrB;IADC,KAAK,CAAC,kBAAkB,CAAC;0CACF;AAGxB;IADC,KAAK,CAAC,mBAAmB,CAAC;8CACC;AAvBhB,SAAS;IADrB,aAAa,CAAC,cAAc,CAAC;GACjB,SAAS,CA0LrB","sourcesContent":["import { ComponentFactory, ComponentStore, Layout, OmegaComponent, dom, Rect, Container, Size } from '@omegagrid/core';\nimport { html } from 'lit';\nimport { customElement, property, query, queryAll } from 'lit/decorators.js';\nimport { map } from 'lit/directives/map.js';\nimport { style } from './dashboard.style';\nimport { DashboardItemModel, DashboardModel } from '../model';\nimport { DashboardSource } from '../types';\nimport { DashboardItem } from './dashboardItem';\n\nexport class DashboardEvent extends Event {\n\n\treadonly item: DashboardItem;\n\treadonly model: DashboardItemModel;\n\n\tconstructor(type: string, args: Partial<DashboardEvent>) {\n\t\tsuper(`dashboard.${type}`, {bubbles: true, composed: true});\n\t\tObject.assign(this, args);\n\t}\n}\n\n@customElement('og-dashboard')\nexport class Dashboard extends OmegaComponent implements Layout {\n\n\tstatic styles = [OmegaComponent.styles, style];\n\n\t@property({type: Object})\n\tmodel: DashboardModel;\n\n\t@property({type: Boolean, reflect: true})\n\tdesignMode = false;\n\n\t@property({type: Object})\n\tcreateComponent: ComponentFactory;\n\n\t@queryAll('og-dashboard-item')\n\titems: NodeList;\n\n\t@query('og-container')\n\tcontainer: Container;\n\n\t@query('[slot=\"content\"]')\n\tcontent: HTMLDivElement;\n\n\t@query('.item-placeholder')\n\tplaceholder: HTMLDivElement;\n\n\tprivate _currentItem: DashboardItem;\n\tprivate _previewPositions: Rect[];\n\n\treadonly components = new ComponentStore<HTMLElement & Layout>(\n\t\tid => this.createComponent ? this.createComponent(id) as HTMLElement & Layout : null\n\t);\n\n\tprivate _baseSize: Size;\n\tget baseSize() {\n\t\tif (this._baseSize) return this._baseSize;\n\t\tconst { columns, columnWidth, rows, rowHeight, gap } = this.model.options;\n\n\t\tthis._baseSize = {\n\t\t\tw: columnWidth || (columns ? (this.container.clientWidth - ((columns + 1) * gap)) / columns : null),\n\t\t\th: rowHeight || (rows ? (this.container.clientHeight - ((rows + 1) * gap)) / rows : null),\n\t\t};\n\n\t\tif (this._baseSize.w == null) this._baseSize.w = this._baseSize.h;\n\t\tif (this._baseSize.h == null) this._baseSize.h = this._baseSize.w;\n\t\treturn this._baseSize;\n\t}\n\n\tstartMove(item: DashboardItem) {\n\t\tthis._currentItem = item;\n\t\tthis._currentItem.classList.toggle('active', true);\n\t\tthis.classList.toggle('moving', true);\n\t}\n\n\tstopMove() {\n\t\tif (!this._currentItem) return;\n\t\tthis._currentItem.classList.toggle('active', false);\n\t\tthis._currentItem = null;\n\t\tthis.classList.toggle('moving', false);\n\t\tthis.hidePlaceholder();\n\t\tthis.updatePreviewPositions();\n\t}\n\n\tget scrollOffset() {\n\t\treturn this.container?.verticalSlider?.value || 0;\n\t}\n\n\toffsetToXCoord(offset: number) {\n\t\treturn Math.max(0, Math.floor(offset / (this.baseSize.w + this.model.options.gap)));\n\t}\n\n\toffsetToYCoord(offset: number) {\n\t\treturn Math.max(0, Math.floor(offset / (this.baseSize.h + this.model.options.gap)));\n\t}\n\n\tupdatePreviewPositions() {\n\t\tif (!this._previewPositions) return;\n\t\tthis.model.updatePositions(this._previewPositions);\n\t\tthis._previewPositions = null;\n\t\tthis.layout();\n\t}\n\n\tpreviewLayout(rect: Rect) {\n\t\tthis._previewPositions = this.model.calculatePositions(this._currentItem.model, rect);\n\t\tthis._previewPositions.forEach((rect, i) => {\n\t\t\tconst item = this.items[i] as DashboardItem;\n\t\t\tif (item && item != this._currentItem) this.setItemPosition(item, rect);\n\t\t});\n\t}\n\n\t_onItemMove = (e: DashboardEvent) => {\n\t\tif (!e.item.moving) return;\n\t\tconst topOffset = this.scrollOffset;\n\t\tconst x = this.offsetToXCoord(e.item.offsetLeft);\n\t\tconst y = this.offsetToYCoord(e.item.offsetTop + topOffset);\n\t\tconst rect: Rect = {x, y, w: e.item.model.w, h: e.item.model.h};\n\t\tthis.showPlaceholder(rect);\n\t\tthis.previewLayout(rect);\n\t}\n\n\t_onItemResize = (e: DashboardEvent) => {\n\t\tif (!e.item.resizing) return;\n\t\tconst topOffset = this.scrollOffset;\n\t\tconst w = this.offsetToXCoord(e.item.offsetLeft + e.item.offsetWidth) - e.item.model.x + 1;\n\t\tconst h = this.offsetToYCoord(e.item.offsetTop + e.item.offsetHeight + topOffset) - e.item.model.y + 1;\n\t\tconst rect: Rect = {x: e.item.model.x, y: e.item.model.y, w, h};\n\t\tthis.showPlaceholder(rect);\n\t\tthis.previewLayout(rect);\n\t}\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addEventListener('dashboard.movestart', (e: DashboardEvent) => this.startMove(e.item));\n\t\tthis.addEventListener('dashboard.resizestart', (e: DashboardEvent) => this.startMove(e.item));\n\t\tthis.addEventListener('dashboard.movestop', () => this.stopMove());\n\t\tthis.addEventListener('dashboard.resizestop', () => this.stopMove());\n\t\tthis.addEventListener('dashboard.move', this._onItemMove);\n\t\tthis.addEventListener('dashboard.resize', this._onItemResize);\n\t}\n\n\tcalculateItemLocation(item: Rect) : Rect {\n\t\tconst baseSize = this.baseSize;\n\t\tconst gap = this.model.options.gap;\n\t\treturn {\n\t\t\tx: item.x * (baseSize.w + gap) + gap,\n\t\t\ty: item.y * (baseSize.h + gap) + gap,\n\t\t\tw: item.w * (baseSize.w + gap) - gap,\n\t\t\th: item.h * (baseSize.h + gap) - gap,\n\t\t};\n\t}\n\n\tshowPlaceholder(rect: Rect) {\n\t\tdom.showElement(this.placeholder);\n\t\tthis.setItemPosition(this.placeholder, rect);\n\t}\n\n\thidePlaceholder() {\n\t\tdom.hideElement(this.placeholder);\n\t}\n\n\tsetSourceData(source: DashboardSource) {\n\t\tthis.components.clear();\n\t\tthis.model = new DashboardModel(source);\n\t\tthis.model.detectAndFixCollisions();\n\t}\n\n\tsetItemPosition(elm: HTMLElement, rect: Rect) {\n\t\tconst {x, y, w, h} = this.calculateItemLocation(rect);\n\t\tdom.setSize(elm, { w, h});\n\t\tdom.setPosition(elm, {l: x, t: y});\n\t}\n\n\tfixCollisions() {\n\t\tif (!this.model) return;\n\t\tthis.model.detectAndFixCollisions();\n\t\tthis.layout();\n\t}\n\n\tlayout() {\n\t\tthis._baseSize = null;\n\t\tif (!this.model) return;\n\t\tthis.items?.forEach((item: DashboardItem) => this.setItemPosition(item, item.model));\n\t\tdom.setSize(this.content, {\n\t\t\tw: this.model.size.w * (this.baseSize.w + this.model.options.gap) + this.model.options.gap,\n\t\t\th: this.model.size.h * (this.baseSize.h + this.model.options.gap) + this.model.options.gap\n\t\t});\n\t}\n\n\tupdated() {\n\t\tthis.layout();\n\t}\n\t\n\trender = () => this.model ? html`\n\t\t<og-container>\n\t\t\t<div slot=\"content\">\n\t\t\t\t${this.designMode ? html`<div class=\"item-placeholder\"></div>` : null}\n\t\t\t\t${map(this.model.items, item => html`\n\t\t\t\t\t<og-dashboard-item\n\t\t\t\t\t\t?designMode=\"${this.designMode}\"\n\t\t\t\t\t\t.model=\"${item}\" \n\t\t\t\t\t\t.components=\"${this.components}\">\n\t\t\t\t\t</og-dashboard-item>\n\t\t\t\t`)}\n\t\t\t</div>\n\t\t</og-container>\n\t` : '';\n\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboardItem.d.ts","sourceRoot":"","sources":["../../src/ui/dashboardItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAO,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAGvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9C,qBACa,aAAc,SAAQ,cAAe,YAAW,MAAM;IAElE,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"dashboardItem.d.ts","sourceRoot":"","sources":["../../src/ui/dashboardItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAO,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAGvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9C,qBACa,aAAc,SAAQ,cAAe,YAAW,MAAM;IAElE,MAAM,CAAC,MAAM,iCAgBV;IAGH,UAAU,EAAE,cAAc,CAAC,WAAW,GAAG,MAAM,CAAC,CAAC;IAGjD,KAAK,EAAE,kBAAkB,CAAC;IAG1B,UAAU,UAAS;IAGnB,SAAS,EAAE,cAAc,CAAC;IAG1B,OAAO,EAAE,OAAO,CAAC;IAEjB,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,YAAY,CAAqC;IACzD,OAAO,CAAC,aAAa,CAAqC;IAC1D,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,cAAc,CAAqC;IAC3D,OAAO,CAAC,eAAe,CAAiB;IAExC,IAAI,WAAW;aANa,MAAM;cAAQ,MAAM;MAMF;IAC9C,IAAI,MAAM,YAAyC;IACnD,IAAI,QAAQ,YAA4B;IAGxC,IAAI,SAAS,kCAIZ;;IAWD,iBAAiB;IAMjB,oBAAoB;IAMpB,WAAW;IAKX,UAAU,aAUR;IAEF,YAAY,MAAO,UAAU,UAc3B;IAEF,YAAY,MAAO,UAAU,UAO3B;IAEF,SAAS,aAEP;IAEI,MAAM;IAIZ,WAAW,CAAC,IAAI,GAAE,MAAa,EAAE,MAAM,GAAE,OAAe;IASxD,WAAW;IAKL,OAAO;IAgBb,MAAM,6CAGJ;CAEF"}
|
package/dist/ui/dashboardItem.js
CHANGED
|
@@ -95,8 +95,11 @@ let DashboardItem = class DashboardItem extends OmegaComponent {
|
|
|
95
95
|
showOverlay(text = null, loader = false) {
|
|
96
96
|
this.overlay.text = text;
|
|
97
97
|
this.overlay.defaultLoader = loader;
|
|
98
|
+
const opacity = this.model.model.options.overlay?.opacity ?? 1;
|
|
99
|
+
this.overlay.style.opacity = opacity.toString();
|
|
98
100
|
this.overlay.show(this);
|
|
99
|
-
|
|
101
|
+
if (opacity >= 1)
|
|
102
|
+
dom.hideElement(this.container);
|
|
100
103
|
}
|
|
101
104
|
hideOverlay() {
|
|
102
105
|
this.overlay.hide();
|
|
@@ -127,6 +130,7 @@ DashboardItem.styles = [OmegaComponent.styles, css `
|
|
|
127
130
|
position: absolute;
|
|
128
131
|
inset: 0;
|
|
129
132
|
z-index: 1101;
|
|
133
|
+
background-color: var(--og-accent-color);
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
.container {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboardItem.js","sourceRoot":"","sources":["../../src/ui/dashboardItem.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAkB,GAAG,EAAU,cAAc,EAAW,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGjD,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,cAAc;IAyChD,IAAI,WAAW,KAAK,OAAO,IAAI,CAAC,YAAY,CAAA,CAAC,CAAC;IAC9C,IAAI,MAAM,KAAK,OAAO,IAAI,CAAC,aAAa,KAAK,IAAI,CAAA,CAAC,CAAC;IACnD,IAAI,QAAQ,KAAK,OAAO,IAAI,CAAC,SAAS,CAAA,CAAC,CAAC;IAGxC,IAAI,SAAS;QACZ,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QAC7B,IAAI,CAA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AI,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,WAAW,EAAE,CAAC;QACpB,CAAC;IAEF,CAAC;;AAnJM,oBAAM,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,CAAA;;;;;;;;;;;;;;;EAe1C,CAAC,AAfW,CAeV;AAGH;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;iDACwB;AAGjD;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;4CACC;AAG1B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;iDACtB;AAGnB;IADC,KAAK,CAAC,YAAY,CAAC;gDACM;AAG1B;IADC,KAAK,CAAC,YAAY,CAAC;8CACH;AAhCL,aAAa;IADzB,aAAa,CAAC,mBAAmB,CAAC;GACtB,aAAa,CA4JzB","sourcesContent":["import { ComponentStore, dom, Layout, OmegaComponent, Overlay } from \"@omegagrid/core\";\nimport { css, html } from \"lit\";\nimport { customElement, property, query } from \"lit/decorators.js\";\nimport { DashboardItemModel } from \"../model\";\nimport { Dashboard, DashboardEvent } from \"./dashboard\";\n\n@customElement('og-dashboard-item')\nexport class DashboardItem extends OmegaComponent implements Layout {\n\n\tstatic styles = [OmegaComponent.styles, css`\n\t\t:host {\n\t\t\tposition: relative;\n\t\t\toverflow: hidden;\n\t\t}\n\n\t\tog-overlay {\n\t\t\tposition: absolute;\n\t\t\tinset: 0;\n\t\t\tz-index: 1101;\n\t\t}\n\n\t\t.container {\n\t\t\theight: 100%;\n\t\t}\n\t`];\n\n\t@property({type: Object})\n\tcomponents: ComponentStore<HTMLElement & Layout>;\n\n\t@property({type: Object})\n\tmodel: DashboardItemModel;\n\n\t@property({type: Boolean, reflect: true})\n\tdesignMode = false;\n\n\t@query('.container')\n\tcontainer: HTMLDivElement;\n\t\n\t@query('og-overlay')\n\toverlay: Overlay;\n\n\tprivate _parent: Dashboard;\n\tprivate _mouseOffset: {top: number, left: number} = null;\n\tprivate _movingOffset: {top: number, left: number} = null;\n\tprivate _resizing = false;\n\tprivate _elementOffset: {top: number, left: number} = null;\n\tprivate _resizeObserver: ResizeObserver;\n\n\tget mouseOffset() { return this._mouseOffset }\n\tget moving() { return this._movingOffset !== null }\n\tget resizing() { return this._resizing }\n\n\n\tget component() {\n\t\tif (!this.model) return null;\n\t\tif (!this.components) return null;\n\t\treturn this.components.get(this.model.id);\n\t}\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addEventListener('mousedown', this._onMouseDown);\n\t\tthis.addEventListener('mouseup', this._onMouseUp);\n\t\tthis._resizeObserver = new ResizeObserver(() => {\n\t\t\tthis.dispatchEvent(new DashboardEvent('resize', {item: this, model: this.model}));\n\t\t});\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis._resizeObserver.observe(this);\n\t\tthis._parent = dom.findParent<Dashboard>(this, elm => elm instanceof Dashboard);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.clearEvents();\n\t\tthis._parent = null;\n\t\tthis._resizeObserver.unobserve(this);\n\t}\n\n\tclearEvents() {\n\t\tthis._parent.removeEventListener('mouseup', this._onMouseUp);\n\t\tthis._parent.removeEventListener('mousemove', this._onMouseMove);\n\t}\n\n\t_onMouseUp = () => {\n\t\tif (this.resizing) {\n\t\t\tthis.dispatchEvent(new DashboardEvent('resizestop', {item: this, model: this.model}));\n\t\t} else if (this.moving) {\n\t\t\tthis.dispatchEvent(new DashboardEvent('movestop', {item: this, model: this.model}));\n\t\t}\n\n\t\tthis._movingOffset = null;\n\t\tthis._resizing = false;\n\t\tthis.clearEvents();\n\t};\n\n\t_onMouseDown = (e: MouseEvent) => {\n\t\tif (!this._parent.designMode) return;\n\t\tconst scrollOffset = this._parent.scrollOffset;\n\t\tthis._mouseOffset = {top: e.offsetY, left: e.offsetX};\n\t\tif (e.offsetX > this.offsetWidth - 20 && e.offsetY > this.offsetHeight - 20) {\n\t\t\tthis._resizing = true;\n\t\t\tthis.dispatchEvent(new DashboardEvent('resizestart', {item: this, model: this.model}));\n\t\t} else {\n\t\t\tthis._movingOffset = {left: e.clientX, top: e.clientY + scrollOffset}; \n\t\t\tthis._elementOffset = {left: this.offsetLeft, top: this.offsetTop + scrollOffset};\n\t\t\tthis._parent.addEventListener('mouseup', this._onMouseUp);\n\t\t\tthis._parent.addEventListener('mousemove', this._onMouseMove);\n\t\t\tthis.dispatchEvent(new DashboardEvent('movestart', {item: this, model: this.model}));\n\t\t}\n\t};\n\n\t_onMouseMove = (e: MouseEvent) => {\n\t\tconst scrollOffset = this._parent.scrollOffset;\n\t\tdom.setPosition(this, {\n\t\t\tl: this._elementOffset.left + e.clientX - this._movingOffset.left,\n\t\t\tt: this._elementOffset.top + e.clientY - this._movingOffset.top + scrollOffset, \n\t\t});\n\t\tthis.dispatchEvent(new DashboardEvent('move', {item: this, model: this.model}));\n\t};\n\n\t_onResize = () => {\n\t\tthis.dispatchEvent(new DashboardEvent('resize', {item: this, model: this.model}));\n\t};\n\n\tasync layout() {\n\t\t(await this.component)?.layout();\n\t}\n\n\tshowOverlay(text: string = null, loader: boolean = false) {\n\t\tthis.overlay.text = text;\n\t\tthis.overlay.defaultLoader = loader;\n\t\tthis.overlay.show(this);\n\t\tdom.hideElement(this.container);\n\t}\n\n\thideOverlay() {\n\t\tthis.overlay.hide();\n\t\tdom.showElement(this.container);\n\t}\n\n\tasync updated() {\n\t\tthis.showOverlay(this.designMode ? this.model.title : null);\n\t\tconst component = await this.component;\n\t\tif (component) {\n\t\t\tdom.empty(this.container);\n\t\t\tthis.container.appendChild(component);\n\t\t}\n\t\t\t\n\t\tif (this.designMode) {\n\t\t\tthis.showOverlay(this.model.title, false);\n\t\t} else {\n\t\t\tthis.hideOverlay();\n\t\t}\n\t\t\n\t}\n\n\trender = () => html`\n\t\t<div class=\"container\"></div>\n\t\t<og-overl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,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;iDACwB;AAGjD;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;4CACC;AAG1B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;iDACtB;AAGnB;IADC,KAAK,CAAC,YAAY,CAAC;gDACM;AAG1B;IADC,KAAK,CAAC,YAAY,CAAC;8CACH;AAjCL,aAAa;IADzB,aAAa,CAAC,mBAAmB,CAAC;GACtB,aAAa,CA+JzB","sourcesContent":["import { ComponentStore, dom, Layout, OmegaComponent, Overlay } from \"@omegagrid/core\";\nimport { css, html } from \"lit\";\nimport { customElement, property, query } from \"lit/decorators.js\";\nimport { DashboardItemModel } from \"../model\";\nimport { Dashboard, DashboardEvent } from \"./dashboard\";\n\n@customElement('og-dashboard-item')\nexport class DashboardItem extends OmegaComponent implements Layout {\n\n\tstatic styles = [OmegaComponent.styles, css`\n\t\t:host {\n\t\t\tposition: relative;\n\t\t\toverflow: hidden;\n\t\t}\n\n\t\tog-overlay {\n\t\t\tposition: absolute;\n\t\t\tinset: 0;\n\t\t\tz-index: 1101;\n\t\t\tbackground-color: var(--og-accent-color);\n\t\t}\n\n\t\t.container {\n\t\t\theight: 100%;\n\t\t}\n\t`];\n\n\t@property({type: Object})\n\tcomponents: ComponentStore<HTMLElement & Layout>;\n\n\t@property({type: Object})\n\tmodel: DashboardItemModel;\n\n\t@property({type: Boolean, reflect: true})\n\tdesignMode = false;\n\n\t@query('.container')\n\tcontainer: HTMLDivElement;\n\t\n\t@query('og-overlay')\n\toverlay: Overlay;\n\n\tprivate _parent: Dashboard;\n\tprivate _mouseOffset: {top: number, left: number} = null;\n\tprivate _movingOffset: {top: number, left: number} = null;\n\tprivate _resizing = false;\n\tprivate _elementOffset: {top: number, left: number} = null;\n\tprivate _resizeObserver: ResizeObserver;\n\n\tget mouseOffset() { return this._mouseOffset }\n\tget moving() { return this._movingOffset !== null }\n\tget resizing() { return this._resizing }\n\n\n\tget component() {\n\t\tif (!this.model) return null;\n\t\tif (!this.components) return null;\n\t\treturn this.components.get(this.model.id);\n\t}\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addEventListener('mousedown', this._onMouseDown);\n\t\tthis.addEventListener('mouseup', this._onMouseUp);\n\t\tthis._resizeObserver = new ResizeObserver(() => {\n\t\t\tthis.dispatchEvent(new DashboardEvent('resize', {item: this, model: this.model}));\n\t\t});\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis._resizeObserver.observe(this);\n\t\tthis._parent = dom.findParent<Dashboard>(this, elm => elm instanceof Dashboard);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.clearEvents();\n\t\tthis._parent = null;\n\t\tthis._resizeObserver.unobserve(this);\n\t}\n\n\tclearEvents() {\n\t\tthis._parent.removeEventListener('mouseup', this._onMouseUp);\n\t\tthis._parent.removeEventListener('mousemove', this._onMouseMove);\n\t}\n\n\t_onMouseUp = () => {\n\t\tif (this.resizing) {\n\t\t\tthis.dispatchEvent(new DashboardEvent('resizestop', {item: this, model: this.model}));\n\t\t} else if (this.moving) {\n\t\t\tthis.dispatchEvent(new DashboardEvent('movestop', {item: this, model: this.model}));\n\t\t}\n\n\t\tthis._movingOffset = null;\n\t\tthis._resizing = false;\n\t\tthis.clearEvents();\n\t};\n\n\t_onMouseDown = (e: MouseEvent) => {\n\t\tif (!this._parent.designMode) return;\n\t\tconst scrollOffset = this._parent.scrollOffset;\n\t\tthis._mouseOffset = {top: e.offsetY, left: e.offsetX};\n\t\tif (e.offsetX > this.offsetWidth - 20 && e.offsetY > this.offsetHeight - 20) {\n\t\t\tthis._resizing = true;\n\t\t\tthis.dispatchEvent(new DashboardEvent('resizestart', {item: this, model: this.model}));\n\t\t} else {\n\t\t\tthis._movingOffset = {left: e.clientX, top: e.clientY + scrollOffset}; \n\t\t\tthis._elementOffset = {left: this.offsetLeft, top: this.offsetTop + scrollOffset};\n\t\t\tthis._parent.addEventListener('mouseup', this._onMouseUp);\n\t\t\tthis._parent.addEventListener('mousemove', this._onMouseMove);\n\t\t\tthis.dispatchEvent(new DashboardEvent('movestart', {item: this, model: this.model}));\n\t\t}\n\t};\n\n\t_onMouseMove = (e: MouseEvent) => {\n\t\tconst scrollOffset = this._parent.scrollOffset;\n\t\tdom.setPosition(this, {\n\t\t\tl: this._elementOffset.left + e.clientX - this._movingOffset.left,\n\t\t\tt: this._elementOffset.top + e.clientY - this._movingOffset.top + scrollOffset, \n\t\t});\n\t\tthis.dispatchEvent(new DashboardEvent('move', {item: this, model: this.model}));\n\t};\n\n\t_onResize = () => {\n\t\tthis.dispatchEvent(new DashboardEvent('resize', {item: this, model: this.model}));\n\t};\n\n\tasync layout() {\n\t\t(await this.component)?.layout();\n\t}\n\n\tshowOverlay(text: string = null, loader: boolean = false) {\n\t\tthis.overlay.text = text;\n\t\tthis.overlay.defaultLoader = loader;\n\t\tconst opacity = this.model.model.options.overlay?.opacity ?? 1;\n\t\tthis.overlay.style.opacity = opacity.toString();\n\t\tthis.overlay.show(this);\n\t\tif (opacity >= 1) dom.hideElement(this.container);\n\t}\n\n\thideOverlay() {\n\t\tthis.overlay.hide();\n\t\tdom.showElement(this.container);\n\t}\n\n\tasync updated() {\n\t\tthis.showOverlay(this.designMode ? this.model.title : null);\n\t\tconst component = await this.component;\n\t\tif (component) {\n\t\t\tdom.empty(this.container);\n\t\t\tthis.container.appendChild(component);\n\t\t}\n\t\t\t\n\t\tif (this.designMode) {\n\t\t\tthis.showOverlay(this.model.title, false);\n\t\t} else {\n\t\t\tthis.hideOverlay();\n\t\t}\n\t\t\n\t}\n\n\trender = () => html`\n\t\t<div class=\"container\"></div>\n\t\t<og-overlay></og-overlay>\n\t`;\n\n}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omegagrid/dashboard",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.120",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Dashboard component",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@fortawesome/fontawesome-svg-core": "6.4.2",
|
|
31
|
-
"@omegagrid/core": "^0.6.
|
|
32
|
-
"@omegagrid/localize": "^0.6.
|
|
31
|
+
"@omegagrid/core": "^0.6.120",
|
|
32
|
+
"@omegagrid/localize": "^0.6.120",
|
|
33
33
|
"@riovir/wc-fontawesome": "^0.1.9",
|
|
34
34
|
"date-fns": "^3.2.0",
|
|
35
35
|
"lit": "^3.1.1",
|