@omegagrid/dashboard 0.10.2 → 0.10.5

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 (41) hide show
  1. package/dist/constants.d.ts +49 -0
  2. package/dist/constants.d.ts.map +1 -0
  3. package/dist/constants.js +14 -0
  4. package/dist/constants.js.map +1 -0
  5. package/dist/index.d.ts +5 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +5 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/model/dashboardItemModel.d.ts +20 -0
  10. package/dist/model/dashboardItemModel.d.ts.map +1 -0
  11. package/dist/model/dashboardItemModel.js +34 -0
  12. package/dist/model/dashboardItemModel.js.map +1 -0
  13. package/dist/model/dashboardModel.d.ts +27 -0
  14. package/dist/model/dashboardModel.d.ts.map +1 -0
  15. package/dist/model/dashboardModel.js +277 -0
  16. package/dist/model/dashboardModel.js.map +1 -0
  17. package/dist/model/index.d.ts +3 -0
  18. package/dist/model/index.d.ts.map +1 -0
  19. package/dist/model/index.js +3 -0
  20. package/dist/model/index.js.map +1 -0
  21. package/dist/types.d.ts +40 -0
  22. package/dist/types.d.ts.map +1 -0
  23. package/dist/types.js +2 -0
  24. package/dist/types.js.map +1 -0
  25. package/dist/ui/dashboard.d.ts +56 -0
  26. package/dist/ui/dashboard.d.ts.map +1 -0
  27. package/dist/ui/dashboard.js +405 -0
  28. package/dist/ui/dashboard.js.map +1 -0
  29. package/dist/ui/dashboard.style.d.ts +2 -0
  30. package/dist/ui/dashboard.style.d.ts.map +1 -0
  31. package/dist/ui/dashboard.style.js +60 -0
  32. package/dist/ui/dashboard.style.js.map +1 -0
  33. package/dist/ui/dashboardItem.d.ts +44 -0
  34. package/dist/ui/dashboardItem.d.ts.map +1 -0
  35. package/dist/ui/dashboardItem.js +195 -0
  36. package/dist/ui/dashboardItem.js.map +1 -0
  37. package/dist/ui/index.d.ts +3 -0
  38. package/dist/ui/index.d.ts.map +1 -0
  39. package/dist/ui/index.js +3 -0
  40. package/dist/ui/index.js.map +1 -0
  41. package/package.json +3 -3
@@ -0,0 +1,49 @@
1
+ import { DashboardOptions } from './types';
2
+ declare const _default: {
3
+ PREFIX: string;
4
+ DEFAULT_ACCENT_COLOR: string;
5
+ DEFAULT_ACCENT_COLOR_2: import("color")<string | number | import("color")<string | number | import("color")<string | number | import("color")<string | number | import("color")<string | number | import("color")<string | number | import("color")<string | number | import("color")<string | number | import("color")<string | number | import("color")<string | number | import("color")<string | number | import("color")<string | number | any | ArrayLike<number> | {
6
+ [key: string]: any;
7
+ }> | ArrayLike<number> | {
8
+ [key: string]: any;
9
+ }> | ArrayLike<number> | {
10
+ [key: string]: any;
11
+ }> | ArrayLike<number> | {
12
+ [key: string]: any;
13
+ }> | ArrayLike<number> | {
14
+ [key: string]: any;
15
+ }> | ArrayLike<number> | {
16
+ [key: string]: any;
17
+ }> | ArrayLike<number> | {
18
+ [key: string]: any;
19
+ }> | ArrayLike<number> | {
20
+ [key: string]: any;
21
+ }> | ArrayLike<number> | {
22
+ [key: string]: any;
23
+ }> | ArrayLike<number> | {
24
+ [key: string]: any;
25
+ }> | ArrayLike<number> | {
26
+ [key: string]: any;
27
+ }> | ArrayLike<number> | {
28
+ [key: string]: any;
29
+ }>;
30
+ SIZER_SIZE: number;
31
+ SLIDER_SIZE: number;
32
+ SLIDER_MIN_LENGTH: number;
33
+ EXPANDER_SIZE: number;
34
+ LIST_ITEM_HEIGHT: number;
35
+ LIST_RENDERING_TRESHOLD: number;
36
+ LIST_AUTOSCROLL_TRESHOLD: number;
37
+ LIST_AUTOSCROLL_DELAY: number;
38
+ DEFAULT_TEXT_HIGHLIGHT_COLOR: string;
39
+ TOOLTIP_MARGIN: number;
40
+ MENU_ITEM_HEIGHT: number;
41
+ COLORPICKER_COLOR_SIZE: number;
42
+ DEFAULT_NUMBER_FORMAT: string;
43
+ BUTTON_HEIGHT: number;
44
+ FONT_SIZE: number;
45
+ FLOATING_WINDOW_MAX_WIDTH: number;
46
+ DEFAULT_OPTIONS: DashboardOptions;
47
+ };
48
+ export default _default;
49
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAW3C,wBAGC"}
@@ -0,0 +1,14 @@
1
+ import { constants as coreConstants } from '@omegagrid/core';
2
+ const DEFAULT_OPTIONS = {
3
+ columns: 12,
4
+ gap: 10,
5
+ orientation: 'vertical',
6
+ overlay: {
7
+ opacity: 0.9
8
+ }
9
+ };
10
+ export default {
11
+ DEFAULT_OPTIONS,
12
+ ...coreConstants
13
+ };
14
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +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,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}"]}
@@ -0,0 +1,5 @@
1
+ export * from './ui';
2
+ export * from './model';
3
+ export * from './constants';
4
+ export * from './types';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './ui';
2
+ export * from './model';
3
+ export * from './constants';
4
+ export * from './types';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC","sourcesContent":["export * from './ui';\nexport * from './model';\nexport * from './constants';\nexport * from './types';"]}
@@ -0,0 +1,20 @@
1
+ import { ComponentId } from "@omegagrid/core";
2
+ import { DashboardItemSource } from "../types";
3
+ import { DashboardModel } from "./dashboardModel";
4
+ export declare class DashboardItemModel {
5
+ readonly model: DashboardModel;
6
+ private _index;
7
+ get index(): number;
8
+ set index(value: number);
9
+ private _id;
10
+ get id(): ComponentId;
11
+ x: number;
12
+ y: number;
13
+ w: number;
14
+ h: number;
15
+ title: string;
16
+ constructor(model: DashboardModel, index: number, source?: DashboardItemSource);
17
+ pupulate(source: DashboardItemSource): void;
18
+ getSourceData(): DashboardItemSource;
19
+ }
20
+ //# sourceMappingURL=dashboardItemModel.d.ts.map
@@ -0,0 +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;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"}
@@ -0,0 +1,34 @@
1
+ export class DashboardItemModel {
2
+ get index() { return this._index; }
3
+ set index(value) { this._index = value; }
4
+ get id() { return this._id; }
5
+ constructor(model, index, source) {
6
+ this.model = model;
7
+ this.x = 0;
8
+ this.y = 0;
9
+ this.w = 1;
10
+ this.h = 1;
11
+ this._index = index;
12
+ if (source)
13
+ this.pupulate(source);
14
+ }
15
+ pupulate(source) {
16
+ this._id = source.id;
17
+ this.x = source.x;
18
+ this.y = source.y;
19
+ this.w = source.w || 1;
20
+ this.h = source.h || 1;
21
+ this.title = source.title || `#${this.index + 1}`;
22
+ }
23
+ getSourceData() {
24
+ return {
25
+ id: this.id,
26
+ title: this.title,
27
+ x: this.x,
28
+ y: this.y,
29
+ w: this.w,
30
+ h: this.h
31
+ };
32
+ }
33
+ }
34
+ //# sourceMappingURL=dashboardItemModel.js.map
@@ -0,0 +1 @@
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}"]}
@@ -0,0 +1,27 @@
1
+ import { Rect, Size } from "@omegagrid/core";
2
+ import { DashboardOptions, DashboardSource } from "../types";
3
+ import { DashboardItemModel } from "./dashboardItemModel";
4
+ export declare class DashboardModel {
5
+ private _options;
6
+ get options(): DashboardOptions;
7
+ private _items;
8
+ get items(): DashboardItemModel[];
9
+ constructor(source?: DashboardSource);
10
+ populate(source: DashboardSource): void;
11
+ private _size;
12
+ get size(): Size;
13
+ getSourceData(): DashboardSource;
14
+ updatePositions(positions: Rect[]): void;
15
+ calculatePositions(movingItem: DashboardItemModel, rect: Rect): Rect[];
16
+ /**
17
+ * Detects and fixes collisions between dashboard items
18
+ * Applies collision fixes directly to the dashboard items
19
+ */
20
+ detectAndFixCollisions(): void;
21
+ /**
22
+ * Detects if there are any collisions between dashboard items
23
+ * @returns True if collisions are detected, false otherwise
24
+ */
25
+ hasCollisions(): boolean;
26
+ }
27
+ //# sourceMappingURL=dashboardModel.d.ts.map
@@ -0,0 +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;IA0H7D;;;OAGG;IACH,sBAAsB,IAAI,IAAI;IAmG9B;;;OAGG;IACH,aAAa,IAAI,OAAO;CAYxB"}
@@ -0,0 +1,277 @@
1
+ import { utils } from "@omegagrid/core";
2
+ import constants from "../constants";
3
+ import { DashboardItemModel } from "./dashboardItemModel";
4
+ export class DashboardModel {
5
+ get options() { return this._options; }
6
+ get items() { return this._items; }
7
+ constructor(source) {
8
+ this._items = [];
9
+ if (source)
10
+ this.populate(source);
11
+ }
12
+ populate(source) {
13
+ this._items = source.items.map((item, i) => new DashboardItemModel(this, i, item));
14
+ this._options = utils.mergeDeep(constants.DEFAULT_OPTIONS, source.options);
15
+ }
16
+ get size() {
17
+ if (this._size)
18
+ return this._size;
19
+ this._size = { w: 0, h: 0 };
20
+ this._items.forEach(item => {
21
+ this._size.w = Math.max(this._size.w, item.x + item.w);
22
+ this._size.h = Math.max(this._size.h, item.y + item.h);
23
+ });
24
+ return this._size;
25
+ }
26
+ getSourceData() {
27
+ return {
28
+ items: this._items.map(item => item.getSourceData()),
29
+ options: this._options
30
+ };
31
+ }
32
+ updatePositions(positions) {
33
+ this._size = { w: 0, h: 0 };
34
+ this._items.forEach((item, i) => {
35
+ if (positions[i]) {
36
+ item.x = positions[i].x;
37
+ item.y = positions[i].y;
38
+ item.w = positions[i].w;
39
+ item.h = positions[i].h;
40
+ }
41
+ this._size.w = Math.max(this._size.w, item.x + item.w);
42
+ this._size.h = Math.max(this._size.h, item.y + item.h);
43
+ });
44
+ }
45
+ calculatePositions(movingItem, rect) {
46
+ const newPositions = new Array(this._items.length);
47
+ const columns = this._options.columns || Infinity;
48
+ const rows = this._options.rows || Infinity;
49
+ const orientation = this._options.orientation;
50
+ // Set the position for the moving item with boundary constraints
51
+ const movingIndex = this._items.indexOf(movingItem);
52
+ if (movingIndex !== -1) {
53
+ newPositions[movingIndex] = {
54
+ x: Math.max(0, rect.x),
55
+ y: Math.max(0, rect.y),
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
58
+ };
59
+ }
60
+ // First pass: identify collisions and set initial positions
61
+ this._items.forEach((item, i) => {
62
+ if (i !== movingIndex) {
63
+ newPositions[i] = { x: item.x, y: item.y, w: item.w, h: item.h };
64
+ }
65
+ });
66
+ // Resolve collisions recursively
67
+ const processedItems = new Set();
68
+ processedItems.add(movingIndex);
69
+ const resolveCollisions = (itemIndex) => {
70
+ const itemRect = newPositions[itemIndex];
71
+ for (let i = 0; i < this._items.length; i++) {
72
+ // Skip if it's the same item or already processed in this recursive call
73
+ if (i === itemIndex || processedItems.has(i))
74
+ continue;
75
+ const otherRect = newPositions[i];
76
+ const intersection = utils.rectIntersect(itemRect, otherRect);
77
+ if (intersection) {
78
+ // Calculate distances to move in each direction
79
+ const moveDown = itemRect.y + itemRect.h - otherRect.y;
80
+ const moveRight = itemRect.x + itemRect.w - otherRect.x;
81
+ const moveUp = otherRect.y + otherRect.h - itemRect.y;
82
+ const moveLeft = otherRect.x + otherRect.w - itemRect.x;
83
+ if (orientation === 'vertical') {
84
+ // In vertical orientation, prioritize downward movement
85
+ if (moveDown <= moveUp && moveDown <= moveRight && moveDown <= moveLeft) {
86
+ otherRect.y = Math.max(0, itemRect.y + itemRect.h);
87
+ }
88
+ else if (moveUp <= moveRight && moveUp <= moveLeft && itemRect.y - otherRect.h >= 0) {
89
+ otherRect.y = Math.max(0, itemRect.y - otherRect.h);
90
+ }
91
+ else if (moveRight <= moveLeft && itemRect.x + itemRect.w + otherRect.w <= columns) {
92
+ otherRect.x = Math.min(columns - otherRect.w, itemRect.x + itemRect.w);
93
+ }
94
+ else if (itemRect.x - otherRect.w >= 0) {
95
+ otherRect.x = Math.max(0, itemRect.x - otherRect.w);
96
+ }
97
+ else {
98
+ // Default to moving down if other directions would cause boundary violations
99
+ otherRect.y = Math.max(0, itemRect.y + itemRect.h);
100
+ }
101
+ // Ensure width doesn't exceed container
102
+ if (otherRect.x + otherRect.w > columns) {
103
+ otherRect.w = Math.max(1, columns - otherRect.x);
104
+ }
105
+ }
106
+ else {
107
+ // In horizontal orientation, prioritize rightward movement
108
+ if (moveRight <= moveUp && moveRight <= moveDown && moveRight <= moveLeft) {
109
+ otherRect.x = Math.max(0, itemRect.x + itemRect.w);
110
+ }
111
+ else if (moveLeft <= moveUp && moveLeft <= moveDown && itemRect.x - otherRect.w >= 0) {
112
+ otherRect.x = Math.max(0, itemRect.x - otherRect.w);
113
+ }
114
+ else if (moveDown <= moveUp && itemRect.y + itemRect.h + otherRect.h <= rows) {
115
+ otherRect.y = Math.min(rows - otherRect.h, itemRect.y + itemRect.h);
116
+ }
117
+ else if (itemRect.y - otherRect.h >= 0) {
118
+ otherRect.y = Math.max(0, itemRect.y - otherRect.h);
119
+ }
120
+ else {
121
+ // Default to moving right if other directions would cause boundary violations
122
+ otherRect.x = Math.max(0, itemRect.x + itemRect.w);
123
+ }
124
+ // Ensure height doesn't exceed container
125
+ if (otherRect.y + otherRect.h > rows) {
126
+ otherRect.h = Math.max(1, rows - otherRect.y);
127
+ }
128
+ }
129
+ // Mark this item as processed in the current recursive call
130
+ processedItems.add(i);
131
+ // Recursively resolve any new collisions this movement might have caused
132
+ resolveCollisions(i);
133
+ // Remove from processed set after recursion to allow for future collision checks
134
+ processedItems.delete(i);
135
+ }
136
+ }
137
+ };
138
+ // Start resolving collisions from the moving item
139
+ resolveCollisions(movingIndex);
140
+ // Final pass to ensure all items are within bounds
141
+ for (let i = 0; i < newPositions.length; i++) {
142
+ if (newPositions[i]) {
143
+ newPositions[i].x = Math.max(0, newPositions[i].x);
144
+ newPositions[i].y = Math.max(0, newPositions[i].y);
145
+ // Apply container constraints based on orientation
146
+ if (orientation === 'vertical') {
147
+ if (newPositions[i].x + newPositions[i].w > columns) {
148
+ newPositions[i].w = Math.max(1, columns - newPositions[i].x);
149
+ }
150
+ }
151
+ else {
152
+ if (newPositions[i].y + newPositions[i].h > rows) {
153
+ newPositions[i].h = Math.max(1, rows - newPositions[i].y);
154
+ }
155
+ }
156
+ }
157
+ }
158
+ return newPositions;
159
+ }
160
+ /**
161
+ * Detects and fixes collisions between dashboard items
162
+ * Applies collision fixes directly to the dashboard items
163
+ */
164
+ detectAndFixCollisions() {
165
+ const columns = this._options.columns || Infinity;
166
+ const rows = this._options.rows || Infinity;
167
+ const orientation = this._options.orientation;
168
+ const processedItems = new Set();
169
+ const resolveCollisions = (itemIndex) => {
170
+ if (processedItems.has(itemIndex))
171
+ return;
172
+ const itemRect = this._items[itemIndex];
173
+ if (!itemRect)
174
+ return;
175
+ for (let i = 0; i < this._items.length; i++) {
176
+ if (i === itemIndex)
177
+ continue;
178
+ const otherRect = this._items[i];
179
+ const intersection = utils.rectIntersect(itemRect, otherRect);
180
+ if (intersection) {
181
+ // Calculate distances to move in each direction
182
+ const moveDown = itemRect.y + itemRect.h - otherRect.y;
183
+ const moveRight = itemRect.x + itemRect.w - otherRect.x;
184
+ const moveUp = otherRect.y + otherRect.h - itemRect.y;
185
+ const moveLeft = otherRect.x + otherRect.w - itemRect.x;
186
+ // Choose movement direction based on orientation and smallest displacement
187
+ if (orientation === 'vertical') {
188
+ if (moveDown <= moveUp && moveDown <= moveRight && moveDown <= moveLeft) {
189
+ otherRect.y = Math.max(0, itemRect.y + itemRect.h);
190
+ }
191
+ else if (moveUp <= moveRight && moveUp <= moveLeft && itemRect.y - otherRect.h >= 0) {
192
+ otherRect.y = Math.max(0, itemRect.y - otherRect.h);
193
+ }
194
+ else if (moveRight <= moveLeft && itemRect.x + itemRect.w + otherRect.w <= columns) {
195
+ otherRect.x = Math.min(columns - otherRect.w, itemRect.x + itemRect.w);
196
+ }
197
+ else if (itemRect.x - otherRect.w >= 0) {
198
+ otherRect.x = Math.max(0, itemRect.x - otherRect.w);
199
+ }
200
+ else {
201
+ otherRect.y = Math.max(0, itemRect.y + itemRect.h);
202
+ }
203
+ // Ensure width doesn't exceed container
204
+ if (otherRect.x + otherRect.w > columns) {
205
+ otherRect.w = Math.max(1, columns - otherRect.x);
206
+ }
207
+ }
208
+ else {
209
+ // Horizontal orientation
210
+ if (moveRight <= moveUp && moveRight <= moveDown && moveRight <= moveLeft) {
211
+ otherRect.x = Math.max(0, itemRect.x + itemRect.w);
212
+ }
213
+ else if (moveLeft <= moveUp && moveLeft <= moveDown && itemRect.x - otherRect.w >= 0) {
214
+ otherRect.x = Math.max(0, itemRect.x - otherRect.w);
215
+ }
216
+ else if (moveDown <= moveUp && itemRect.y + itemRect.h + otherRect.h <= rows) {
217
+ otherRect.y = Math.min(rows - otherRect.h, itemRect.y + itemRect.h);
218
+ }
219
+ else if (itemRect.y - otherRect.h >= 0) {
220
+ otherRect.y = Math.max(0, itemRect.y - otherRect.h);
221
+ }
222
+ else {
223
+ otherRect.x = Math.max(0, itemRect.x + itemRect.w);
224
+ }
225
+ // Ensure height doesn't exceed container
226
+ if (otherRect.y + otherRect.h > rows) {
227
+ otherRect.h = Math.max(1, rows - otherRect.y);
228
+ }
229
+ }
230
+ // Recursively resolve new collisions
231
+ resolveCollisions(i);
232
+ }
233
+ }
234
+ };
235
+ // Process all items to resolve collisions
236
+ for (let i = 0; i < this._items.length; i++) {
237
+ if (!processedItems.has(i)) {
238
+ resolveCollisions(i);
239
+ processedItems.add(i);
240
+ }
241
+ }
242
+ // Final pass to ensure all items are within bounds
243
+ for (let i = 0; i < this._items.length; i++) {
244
+ const item = this._items[i];
245
+ item.x = Math.max(0, item.x);
246
+ item.y = Math.max(0, item.y);
247
+ // Apply container constraints based on orientation
248
+ if (orientation === 'vertical') {
249
+ if (item.x + item.w > columns) {
250
+ item.w = Math.max(1, columns - item.x);
251
+ }
252
+ }
253
+ else {
254
+ if (item.y + item.h > rows) {
255
+ item.h = Math.max(1, rows - item.y);
256
+ }
257
+ }
258
+ }
259
+ // Clear cached size since positions have changed
260
+ this._size = null;
261
+ }
262
+ /**
263
+ * Detects if there are any collisions between dashboard items
264
+ * @returns True if collisions are detected, false otherwise
265
+ */
266
+ hasCollisions() {
267
+ for (let i = 0; i < this._items.length; i++) {
268
+ for (let j = i + 1; j < this._items.length; j++) {
269
+ if (utils.rectIntersect(this._items[i], this._items[j])) {
270
+ return true;
271
+ }
272
+ }
273
+ }
274
+ return false;
275
+ }
276
+ }
277
+ //# sourceMappingURL=dashboardModel.js.map
@@ -0,0 +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,WA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AAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBACzD,OAAO,IAAI,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(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}"]}
@@ -0,0 +1,3 @@
1
+ export * from './dashboardModel';
2
+ export * from './dashboardItemModel';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './dashboardModel';
2
+ export * from './dashboardItemModel';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC","sourcesContent":["export * from './dashboardModel';\nexport * from './dashboardItemModel';"]}
@@ -0,0 +1,40 @@
1
+ import { ComponentId } from "@omegagrid/core";
2
+ export type DashboardItemSource = {
3
+ /** id of the component */
4
+ id: ComponentId;
5
+ /** x coord */
6
+ x: number;
7
+ /** y coord */
8
+ y: number;
9
+ /** width */
10
+ w?: number;
11
+ /** height */
12
+ h?: number;
13
+ /** title shown in design mode */
14
+ title?: string;
15
+ };
16
+ export type DashboardOptions = {
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;
25
+ /** The gap between items */
26
+ gap?: number;
27
+ /** Orientation of dashboard */
28
+ orientation?: 'horizontal' | 'vertical' | null;
29
+ overlay?: {
30
+ /** opacity of overlay in design mode */
31
+ opacity?: number;
32
+ };
33
+ };
34
+ export type DashboardSource = {
35
+ /** Dashboard items */
36
+ items?: DashboardItemSource[];
37
+ /** Dashboard options */
38
+ options?: DashboardOptions;
39
+ };
40
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,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 ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +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 */\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}"]}