draggable-dashboard-lete-pro 1.5.4 → 1.5.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.
|
@@ -12,6 +12,7 @@ import { GRID_GAP } from '../constants';
|
|
|
12
12
|
import { TileContent } from './TileContent';
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
export var DashboardTile = function DashboardTile(_ref) {
|
|
15
|
+
var _tile$x, _tile$y;
|
|
15
16
|
var tile = _ref.tile,
|
|
16
17
|
cellSize = _ref.cellSize,
|
|
17
18
|
editMode = _ref.editMode,
|
|
@@ -22,10 +23,10 @@ export var DashboardTile = function DashboardTile(_ref) {
|
|
|
22
23
|
isDragging = _ref.isDragging,
|
|
23
24
|
isResizing = _ref.isResizing,
|
|
24
25
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
-
var x = tile.x
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
var x = (_tile$x = tile.x) !== null && _tile$x !== void 0 ? _tile$x : 0;
|
|
27
|
+
var y = (_tile$y = tile.y) !== null && _tile$y !== void 0 ? _tile$y : 0;
|
|
28
|
+
var w = tile.width;
|
|
29
|
+
var h = tile.height;
|
|
29
30
|
var left = x * (cellSize + GRID_GAP);
|
|
30
31
|
var top = y * (cellSize + GRID_GAP);
|
|
31
32
|
var width = w * cellSize + (w - 1) * GRID_GAP;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
+
var _excluded = ["tiles", "setTiles", "dashboardId", "editMode", "theme", "onGetPositions", "onSetPositions", "onRemoveTilePosition", "onDeleteTile", "DeleteTileModal", "AddTileModal", "SVG", "Button"];
|
|
1
2
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["tiles", "setTiles", "dashboardId", "editMode", "theme", "fetchers"];
|
|
3
3
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
4
4
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
5
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
6
6
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
7
7
|
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
8
8
|
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
9
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
13
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
9
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
15
10
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
16
11
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
@@ -21,13 +16,38 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
21
16
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
22
17
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
23
18
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
24
|
-
|
|
19
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
22
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
23
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
24
|
+
import React, { useState, useRef, useEffect, useCallback, useMemo, forwardRef } from 'react';
|
|
25
25
|
import { GRID_COLS, GRID_GAP, MIN_UNITS, MOBILE_BREAKPOINT } from '../constants';
|
|
26
26
|
import { DashboardTile } from './DashboardTile';
|
|
27
|
-
import { getPositions, setPositions } from '../services/dashboardTileDB';
|
|
27
|
+
import { getPositions, setPositions, removeTilePosition } from '../services/dashboardTileDB';
|
|
28
28
|
import { TileContent } from './TileContent';
|
|
29
|
-
import {
|
|
30
|
-
|
|
29
|
+
import { AddTileModal } from './AddTileModal';
|
|
30
|
+
|
|
31
|
+
// Helper to convert between w/h and width/height formats
|
|
32
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
33
|
+
var tileToPosition = function tileToPosition(tile) {
|
|
34
|
+
var _tile$x, _tile$y;
|
|
35
|
+
return {
|
|
36
|
+
x: (_tile$x = tile.x) !== null && _tile$x !== void 0 ? _tile$x : 0,
|
|
37
|
+
y: (_tile$y = tile.y) !== null && _tile$y !== void 0 ? _tile$y : 0,
|
|
38
|
+
width: tile.width,
|
|
39
|
+
height: tile.height
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
var positionToTile = function positionToTile(pos, tile) {
|
|
43
|
+
return _objectSpread(_objectSpread({}, tile), {}, {
|
|
44
|
+
x: pos.x,
|
|
45
|
+
y: pos.y,
|
|
46
|
+
width: pos.width,
|
|
47
|
+
height: pos.height
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
export var DraggableDashboard = /*#__PURE__*/forwardRef(function (_ref, _ref1) {
|
|
31
51
|
var tiles = _ref.tiles,
|
|
32
52
|
setTiles = _ref.setTiles,
|
|
33
53
|
dashboardId = _ref.dashboardId,
|
|
@@ -35,7 +55,14 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
35
55
|
editMode = _ref$editMode === void 0 ? true : _ref$editMode,
|
|
36
56
|
_ref$theme = _ref.theme,
|
|
37
57
|
theme = _ref$theme === void 0 ? 'light' : _ref$theme,
|
|
38
|
-
|
|
58
|
+
onGetPositions = _ref.onGetPositions,
|
|
59
|
+
onSetPositions = _ref.onSetPositions,
|
|
60
|
+
onRemoveTilePosition = _ref.onRemoveTilePosition,
|
|
61
|
+
onDeleteTile = _ref.onDeleteTile,
|
|
62
|
+
DeleteTileModal = _ref.DeleteTileModal,
|
|
63
|
+
CustomAddTileModal = _ref.AddTileModal,
|
|
64
|
+
CustomSVG = _ref.SVG,
|
|
65
|
+
CustomButton = _ref.Button,
|
|
39
66
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
40
67
|
var containerRef = useRef(null);
|
|
41
68
|
var _useState = useState(0),
|
|
@@ -62,84 +89,135 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
62
89
|
_useState10 = _slicedToArray(_useState1, 2),
|
|
63
90
|
maximizedTileId = _useState10[0],
|
|
64
91
|
setMaximizedTileId = _useState10[1];
|
|
65
|
-
|
|
66
|
-
// Delete confirmation state
|
|
67
92
|
var _useState11 = useState(null),
|
|
68
93
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
69
94
|
tileToDeleteId = _useState12[0],
|
|
70
95
|
setTileToDeleteId = _useState12[1];
|
|
96
|
+
var _useState13 = useState(false),
|
|
97
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
98
|
+
showAddModal = _useState14[0],
|
|
99
|
+
setShowAddModal = _useState14[1];
|
|
71
100
|
|
|
72
101
|
// Persistence management
|
|
73
102
|
useEffect(function () {
|
|
74
103
|
var initPositions = /*#__PURE__*/function () {
|
|
75
104
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
76
|
-
var saved, _t;
|
|
105
|
+
var saved, legacyPositions, _t;
|
|
77
106
|
return _regenerator().w(function (_context) {
|
|
78
107
|
while (1) switch (_context.p = _context.n) {
|
|
79
108
|
case 0:
|
|
80
109
|
_context.p = 0;
|
|
110
|
+
saved = {};
|
|
111
|
+
if (!onGetPositions) {
|
|
112
|
+
_context.n = 2;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
81
115
|
_context.n = 1;
|
|
82
|
-
return
|
|
116
|
+
return onGetPositions(dashboardId);
|
|
83
117
|
case 1:
|
|
84
118
|
saved = _context.v;
|
|
119
|
+
_context.n = 4;
|
|
120
|
+
break;
|
|
121
|
+
case 2:
|
|
122
|
+
_context.n = 3;
|
|
123
|
+
return getPositions(dashboardId);
|
|
124
|
+
case 3:
|
|
125
|
+
legacyPositions = _context.v;
|
|
126
|
+
// Convert legacy format to new format
|
|
127
|
+
saved = Object.entries(legacyPositions).reduce(function (acc, _ref3) {
|
|
128
|
+
var _pos$x, _pos$y, _ref5, _pos$w, _ref6, _pos$h;
|
|
129
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
130
|
+
id = _ref4[0],
|
|
131
|
+
pos = _ref4[1];
|
|
132
|
+
acc[id] = {
|
|
133
|
+
x: (_pos$x = pos.x) !== null && _pos$x !== void 0 ? _pos$x : 0,
|
|
134
|
+
y: (_pos$y = pos.y) !== null && _pos$y !== void 0 ? _pos$y : 0,
|
|
135
|
+
width: (_ref5 = (_pos$w = pos.w) !== null && _pos$w !== void 0 ? _pos$w : pos.width) !== null && _ref5 !== void 0 ? _ref5 : 2,
|
|
136
|
+
height: (_ref6 = (_pos$h = pos.h) !== null && _pos$h !== void 0 ? _pos$h : pos.height) !== null && _ref6 !== void 0 ? _ref6 : 2
|
|
137
|
+
};
|
|
138
|
+
return acc;
|
|
139
|
+
}, {});
|
|
140
|
+
case 4:
|
|
85
141
|
if (saved && Object.keys(saved).length > 0) {
|
|
86
142
|
setTiles(function (prev) {
|
|
87
143
|
return prev.map(function (t) {
|
|
88
|
-
|
|
144
|
+
var savedPos = saved[t.id];
|
|
145
|
+
if (savedPos) {
|
|
146
|
+
return positionToTile(savedPos, t);
|
|
147
|
+
}
|
|
148
|
+
return t;
|
|
89
149
|
});
|
|
90
150
|
});
|
|
91
151
|
}
|
|
92
|
-
_context.n =
|
|
152
|
+
_context.n = 6;
|
|
93
153
|
break;
|
|
94
|
-
case
|
|
95
|
-
_context.p =
|
|
154
|
+
case 5:
|
|
155
|
+
_context.p = 5;
|
|
96
156
|
_t = _context.v;
|
|
97
157
|
console.warn('Could not load saved positions', _t);
|
|
98
|
-
case
|
|
158
|
+
case 6:
|
|
99
159
|
return _context.a(2);
|
|
100
160
|
}
|
|
101
|
-
}, _callee, null, [[0,
|
|
161
|
+
}, _callee, null, [[0, 5]]);
|
|
102
162
|
}));
|
|
103
163
|
return function initPositions() {
|
|
104
164
|
return _ref2.apply(this, arguments);
|
|
105
165
|
};
|
|
106
166
|
}();
|
|
107
167
|
initPositions();
|
|
108
|
-
}, [dashboardId, setTiles]);
|
|
168
|
+
}, [dashboardId, setTiles, onGetPositions]);
|
|
109
169
|
var savePositions = useCallback(/*#__PURE__*/function () {
|
|
110
|
-
var
|
|
111
|
-
var posMap, _t2;
|
|
170
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(currentTiles) {
|
|
171
|
+
var posMap, legacyPos, _t2;
|
|
112
172
|
return _regenerator().w(function (_context2) {
|
|
113
173
|
while (1) switch (_context2.p = _context2.n) {
|
|
114
174
|
case 0:
|
|
115
175
|
posMap = {};
|
|
116
176
|
currentTiles.forEach(function (t) {
|
|
117
|
-
posMap[t.id] =
|
|
118
|
-
x: t.x,
|
|
119
|
-
y: t.y,
|
|
120
|
-
w: t.w,
|
|
121
|
-
h: t.h
|
|
122
|
-
};
|
|
177
|
+
posMap[t.id] = tileToPosition(t);
|
|
123
178
|
});
|
|
124
179
|
_context2.p = 1;
|
|
180
|
+
if (!onSetPositions) {
|
|
181
|
+
_context2.n = 3;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
125
184
|
_context2.n = 2;
|
|
126
|
-
return
|
|
185
|
+
return onSetPositions(dashboardId, posMap);
|
|
127
186
|
case 2:
|
|
128
187
|
_context2.n = 4;
|
|
129
188
|
break;
|
|
130
189
|
case 3:
|
|
131
|
-
|
|
190
|
+
// Convert to legacy format for backward compatibility
|
|
191
|
+
legacyPos = {};
|
|
192
|
+
Object.entries(posMap).forEach(function (_ref8) {
|
|
193
|
+
var _ref9 = _slicedToArray(_ref8, 2),
|
|
194
|
+
id = _ref9[0],
|
|
195
|
+
pos = _ref9[1];
|
|
196
|
+
legacyPos[id] = {
|
|
197
|
+
x: pos.x,
|
|
198
|
+
y: pos.y,
|
|
199
|
+
w: pos.width,
|
|
200
|
+
h: pos.height
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
_context2.n = 4;
|
|
204
|
+
return setPositions(dashboardId, legacyPos);
|
|
205
|
+
case 4:
|
|
206
|
+
_context2.n = 6;
|
|
207
|
+
break;
|
|
208
|
+
case 5:
|
|
209
|
+
_context2.p = 5;
|
|
132
210
|
_t2 = _context2.v;
|
|
133
211
|
console.warn('Could not save positions', _t2);
|
|
134
|
-
case
|
|
212
|
+
case 6:
|
|
135
213
|
return _context2.a(2);
|
|
136
214
|
}
|
|
137
|
-
}, _callee2, null, [[1,
|
|
215
|
+
}, _callee2, null, [[1, 5]]);
|
|
138
216
|
}));
|
|
139
217
|
return function (_x) {
|
|
140
|
-
return
|
|
218
|
+
return _ref7.apply(this, arguments);
|
|
141
219
|
};
|
|
142
|
-
}(), [dashboardId]);
|
|
220
|
+
}(), [dashboardId, onSetPositions]);
|
|
143
221
|
|
|
144
222
|
// Responsive handling
|
|
145
223
|
useEffect(function () {
|
|
@@ -180,22 +258,30 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
180
258
|
|
|
181
259
|
// Collision & Placement Logic
|
|
182
260
|
var checkOverlap = function checkOverlap(a, b) {
|
|
183
|
-
|
|
261
|
+
var _a$x, _a$y, _b$x, _b$y;
|
|
262
|
+
var ax = (_a$x = a.x) !== null && _a$x !== void 0 ? _a$x : 0;
|
|
263
|
+
var ay = (_a$y = a.y) !== null && _a$y !== void 0 ? _a$y : 0;
|
|
264
|
+
var bx = (_b$x = b.x) !== null && _b$x !== void 0 ? _b$x : 0;
|
|
265
|
+
var by = (_b$y = b.y) !== null && _b$y !== void 0 ? _b$y : 0;
|
|
266
|
+
return ax < bx + b.width && ax + a.width > bx && ay < by + b.height && ay + a.height > by;
|
|
184
267
|
};
|
|
185
268
|
var findNearestAvailableSpot = function findNearestAvailableSpot(target, allTiles, excludeId) {
|
|
269
|
+
var _target$x, _target$y;
|
|
186
270
|
var others = allTiles.filter(function (t) {
|
|
187
271
|
return t.id !== excludeId;
|
|
188
272
|
});
|
|
189
273
|
if (!others.some(function (o) {
|
|
190
274
|
return checkOverlap(target, o);
|
|
191
275
|
})) return target;
|
|
276
|
+
var targetX = (_target$x = target.x) !== null && _target$x !== void 0 ? _target$x : 0;
|
|
277
|
+
var targetY = (_target$y = target.y) !== null && _target$y !== void 0 ? _target$y : 0;
|
|
192
278
|
for (var radius = 1; radius < 20; radius++) {
|
|
193
279
|
for (var dy = -radius; dy <= radius; dy++) {
|
|
194
280
|
var _loop = function _loop() {
|
|
195
281
|
if (Math.abs(dx) !== radius && Math.abs(dy) !== radius) return 0; // continue
|
|
196
|
-
var nx =
|
|
197
|
-
var ny =
|
|
198
|
-
if (nx >= 0 && nx <= GRID_COLS - target.
|
|
282
|
+
var nx = targetX + dx;
|
|
283
|
+
var ny = targetY + dy;
|
|
284
|
+
if (nx >= 0 && nx <= GRID_COLS - target.width && ny >= 0) {
|
|
199
285
|
var potential = _objectSpread(_objectSpread({}, target), {}, {
|
|
200
286
|
x: nx,
|
|
201
287
|
y: ny
|
|
@@ -235,7 +321,7 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
235
321
|
if (checkOverlap(currentLayout[i], currentLayout[j])) {
|
|
236
322
|
hasOverlap = true;
|
|
237
323
|
var targetIdx = currentLayout[i].id === movedTile.id ? j : i;
|
|
238
|
-
currentLayout[targetIdx] =
|
|
324
|
+
currentLayout[targetIdx] = findNearestAvailableSpot(currentLayout[targetIdx], currentLayout, currentLayout[targetIdx].id);
|
|
239
325
|
}
|
|
240
326
|
}
|
|
241
327
|
}
|
|
@@ -245,6 +331,7 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
245
331
|
|
|
246
332
|
// Event Handlers
|
|
247
333
|
var handleDragStart = function handleDragStart(e, tileId) {
|
|
334
|
+
var _tile$x2, _tile$y2;
|
|
248
335
|
if (!editMode) return;
|
|
249
336
|
var tile = tiles.find(function (t) {
|
|
250
337
|
return t.id === tileId;
|
|
@@ -255,8 +342,8 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
255
342
|
tileId: tileId,
|
|
256
343
|
startX: e.clientX,
|
|
257
344
|
startY: e.clientY,
|
|
258
|
-
originalX: tile.x,
|
|
259
|
-
originalY: tile.y
|
|
345
|
+
originalX: (_tile$x2 = tile.x) !== null && _tile$x2 !== void 0 ? _tile$x2 : 0,
|
|
346
|
+
originalY: (_tile$y2 = tile.y) !== null && _tile$y2 !== void 0 ? _tile$y2 : 0
|
|
260
347
|
});
|
|
261
348
|
e.target.setPointerCapture(e.pointerId);
|
|
262
349
|
};
|
|
@@ -271,24 +358,26 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
271
358
|
tileId: tileId,
|
|
272
359
|
startX: e.clientX,
|
|
273
360
|
startY: e.clientY,
|
|
274
|
-
startWidth: tile.
|
|
275
|
-
startHeight: tile.
|
|
276
|
-
|
|
277
|
-
|
|
361
|
+
startWidth: tile.width,
|
|
362
|
+
startHeight: tile.height,
|
|
363
|
+
originalWidth: tile.width,
|
|
364
|
+
originalHeight: tile.height
|
|
278
365
|
});
|
|
279
366
|
e.target.setPointerCapture(e.pointerId);
|
|
280
367
|
};
|
|
281
368
|
var handlePointerMove = function handlePointerMove(e) {
|
|
282
369
|
if (!editMode || isMobile) return;
|
|
283
370
|
if (dragState) {
|
|
371
|
+
var _tile$x3;
|
|
284
372
|
var gridDeltaX = Math.round((e.clientX - dragState.startX) / (cellSize + GRID_GAP));
|
|
285
373
|
var gridDeltaY = Math.round((e.clientY - dragState.startY) / (cellSize + GRID_GAP));
|
|
286
374
|
var tile = tiles.find(function (t) {
|
|
287
375
|
return t.id === dragState.tileId;
|
|
288
376
|
});
|
|
289
|
-
var
|
|
377
|
+
var tileX = (_tile$x3 = tile.x) !== null && _tile$x3 !== void 0 ? _tile$x3 : 0;
|
|
378
|
+
var newX = Math.max(0, Math.min(GRID_COLS - tile.width, dragState.originalX + gridDeltaX));
|
|
290
379
|
var newY = Math.max(0, dragState.originalY + gridDeltaY);
|
|
291
|
-
if (newX !==
|
|
380
|
+
if (newX !== tileX || newY !== tile.y) {
|
|
292
381
|
var movedTile = _objectSpread(_objectSpread({}, tile), {}, {
|
|
293
382
|
x: newX,
|
|
294
383
|
y: newY
|
|
@@ -298,17 +387,19 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
298
387
|
}
|
|
299
388
|
}
|
|
300
389
|
if (resizeState) {
|
|
390
|
+
var _tile$x4;
|
|
301
391
|
var gridDeltaW = Math.round((e.clientX - resizeState.startX) / (cellSize + GRID_GAP));
|
|
302
392
|
var gridDeltaH = Math.round((e.clientY - resizeState.startY) / (cellSize + GRID_GAP));
|
|
303
393
|
var _tile = tiles.find(function (t) {
|
|
304
394
|
return t.id === resizeState.tileId;
|
|
305
395
|
});
|
|
306
|
-
var
|
|
307
|
-
var
|
|
308
|
-
|
|
396
|
+
var _tileX = (_tile$x4 = _tile.x) !== null && _tile$x4 !== void 0 ? _tile$x4 : 0;
|
|
397
|
+
var newWidth = Math.max(MIN_UNITS, Math.min(GRID_COLS - _tileX, resizeState.originalWidth + gridDeltaW));
|
|
398
|
+
var newHeight = Math.max(MIN_UNITS, resizeState.originalHeight + gridDeltaH);
|
|
399
|
+
if (newWidth !== _tile.width || newHeight !== _tile.height) {
|
|
309
400
|
var resizedTile = _objectSpread(_objectSpread({}, _tile), {}, {
|
|
310
|
-
|
|
311
|
-
|
|
401
|
+
width: newWidth,
|
|
402
|
+
height: newHeight
|
|
312
403
|
});
|
|
313
404
|
var _newLayout = resolveCollisions(resizedTile, tiles);
|
|
314
405
|
setTiles(_newLayout);
|
|
@@ -321,28 +412,87 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
321
412
|
setResizeState(null);
|
|
322
413
|
setActiveTileId(null);
|
|
323
414
|
};
|
|
324
|
-
var confirmDelete = function
|
|
325
|
-
|
|
326
|
-
var updated
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
415
|
+
var confirmDelete = /*#__PURE__*/function () {
|
|
416
|
+
var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
417
|
+
var updated, _t3;
|
|
418
|
+
return _regenerator().w(function (_context3) {
|
|
419
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
420
|
+
case 0:
|
|
421
|
+
if (!tileToDeleteId) {
|
|
422
|
+
_context3.n = 8;
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
_context3.p = 1;
|
|
426
|
+
if (!onDeleteTile) {
|
|
427
|
+
_context3.n = 2;
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
_context3.n = 2;
|
|
431
|
+
return onDeleteTile(tileToDeleteId);
|
|
432
|
+
case 2:
|
|
433
|
+
updated = tiles.filter(function (t) {
|
|
434
|
+
return t.id !== tileToDeleteId;
|
|
435
|
+
});
|
|
436
|
+
setTiles(updated);
|
|
437
|
+
savePositions(updated);
|
|
438
|
+
if (!onRemoveTilePosition) {
|
|
439
|
+
_context3.n = 4;
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
_context3.n = 3;
|
|
443
|
+
return onRemoveTilePosition(dashboardId, tileToDeleteId);
|
|
444
|
+
case 3:
|
|
445
|
+
_context3.n = 5;
|
|
446
|
+
break;
|
|
447
|
+
case 4:
|
|
448
|
+
_context3.n = 5;
|
|
449
|
+
return removeTilePosition(dashboardId, tileToDeleteId);
|
|
450
|
+
case 5:
|
|
451
|
+
_context3.n = 7;
|
|
452
|
+
break;
|
|
453
|
+
case 6:
|
|
454
|
+
_context3.p = 6;
|
|
455
|
+
_t3 = _context3.v;
|
|
456
|
+
console.error('Error deleting tile', _t3);
|
|
457
|
+
case 7:
|
|
458
|
+
_context3.p = 7;
|
|
459
|
+
setTileToDeleteId(null);
|
|
460
|
+
return _context3.f(7);
|
|
461
|
+
case 8:
|
|
462
|
+
return _context3.a(2);
|
|
463
|
+
}
|
|
464
|
+
}, _callee3, null, [[1, 6, 7, 8]]);
|
|
465
|
+
}));
|
|
466
|
+
return function confirmDelete() {
|
|
467
|
+
return _ref0.apply(this, arguments);
|
|
468
|
+
};
|
|
469
|
+
}();
|
|
334
470
|
var renderDeleteConfirmation = function renderDeleteConfirmation() {
|
|
335
471
|
if (!tileToDeleteId) return null;
|
|
336
472
|
var tile = tiles.find(function (t) {
|
|
337
473
|
return t.id === tileToDeleteId;
|
|
338
474
|
});
|
|
475
|
+
if (DeleteTileModal) {
|
|
476
|
+
var Modal = DeleteTileModal;
|
|
477
|
+
return /*#__PURE__*/_jsx(Modal, {
|
|
478
|
+
isOpen: !!tileToDeleteId,
|
|
479
|
+
onClose: function onClose() {
|
|
480
|
+
return setTileToDeleteId(null);
|
|
481
|
+
},
|
|
482
|
+
onConfirm: confirmDelete,
|
|
483
|
+
tile: tile
|
|
484
|
+
});
|
|
485
|
+
}
|
|
339
486
|
return /*#__PURE__*/_jsx("div", {
|
|
340
487
|
className: "fixed inset-0 z-[300] bg-slate-900/60 backdrop-blur-md flex items-center justify-center p-4 animate-in fade-in duration-300",
|
|
341
488
|
children: /*#__PURE__*/_jsxs("div", {
|
|
342
489
|
className: "bg-white dark:bg-slate-900 w-full max-w-sm rounded-3xl shadow-2xl overflow-hidden p-8 flex flex-col items-center text-center space-y-6",
|
|
343
490
|
children: [/*#__PURE__*/_jsx("div", {
|
|
344
491
|
className: "w-16 h-16 bg-red-50 dark:bg-red-900/20 rounded-2xl flex items-center justify-center text-red-500",
|
|
345
|
-
children: /*#__PURE__*/_jsx(
|
|
492
|
+
children: CustomSVG ? /*#__PURE__*/_jsx(CustomSVG, {
|
|
493
|
+
icon: "trash",
|
|
494
|
+
className: "w-8 h-8"
|
|
495
|
+
}) : /*#__PURE__*/_jsx("svg", {
|
|
346
496
|
className: "w-8 h-8",
|
|
347
497
|
fill: "none",
|
|
348
498
|
stroke: "currentColor",
|
|
@@ -364,19 +514,32 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
364
514
|
children: tile === null || tile === void 0 ? void 0 : tile.title
|
|
365
515
|
}), "\"? This action cannot be undone."]
|
|
366
516
|
})]
|
|
367
|
-
}), /*#__PURE__*/
|
|
517
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
368
518
|
className: "flex gap-3 w-full",
|
|
369
|
-
children:
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
519
|
+
children: CustomButton ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
520
|
+
children: [/*#__PURE__*/_jsx(CustomButton, {
|
|
521
|
+
onClick: function onClick() {
|
|
522
|
+
return setTileToDeleteId(null);
|
|
523
|
+
},
|
|
524
|
+
children: "Cancel"
|
|
525
|
+
}), /*#__PURE__*/_jsx(CustomButton, {
|
|
526
|
+
onClick: confirmDelete,
|
|
527
|
+
variant: "danger",
|
|
528
|
+
children: "Delete"
|
|
529
|
+
})]
|
|
530
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
531
|
+
children: [/*#__PURE__*/_jsx("button", {
|
|
532
|
+
onClick: function onClick() {
|
|
533
|
+
return setTileToDeleteId(null);
|
|
534
|
+
},
|
|
535
|
+
className: "flex-1 px-4 py-3 text-xs font-black tracking-widest text-slate-500 dark:text-slate-400 hover:bg-slate-50 dark:hover:bg-slate-800 rounded-xl transition-colors uppercase",
|
|
536
|
+
children: "Cancel"
|
|
537
|
+
}), /*#__PURE__*/_jsx("button", {
|
|
538
|
+
onClick: confirmDelete,
|
|
539
|
+
className: "flex-1 px-4 py-3 text-xs font-black tracking-widest bg-red-500 text-white rounded-xl shadow-lg shadow-red-500/30 hover:bg-red-600 transition-all active:scale-95 uppercase",
|
|
540
|
+
children: "Delete"
|
|
541
|
+
})]
|
|
542
|
+
})
|
|
380
543
|
})]
|
|
381
544
|
})
|
|
382
545
|
});
|
|
@@ -402,7 +565,10 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
402
565
|
return navigateMaximized('prev');
|
|
403
566
|
},
|
|
404
567
|
className: "p-2 hover:bg-white dark:hover:bg-slate-700 rounded-lg transition-all shadow-sm active:scale-90 text-slate-600 dark:text-slate-300",
|
|
405
|
-
children: /*#__PURE__*/_jsx(
|
|
568
|
+
children: CustomSVG ? /*#__PURE__*/_jsx(CustomSVG, {
|
|
569
|
+
icon: "chevron-left",
|
|
570
|
+
className: "w-5 h-5"
|
|
571
|
+
}) : /*#__PURE__*/_jsx("svg", {
|
|
406
572
|
className: "w-5 h-5",
|
|
407
573
|
fill: "none",
|
|
408
574
|
stroke: "currentColor",
|
|
@@ -417,7 +583,10 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
417
583
|
return navigateMaximized('next');
|
|
418
584
|
},
|
|
419
585
|
className: "p-2 hover:bg-white dark:hover:bg-slate-700 rounded-lg transition-all shadow-sm active:scale-90 text-slate-600 dark:text-slate-300",
|
|
420
|
-
children: /*#__PURE__*/_jsx(
|
|
586
|
+
children: CustomSVG ? /*#__PURE__*/_jsx(CustomSVG, {
|
|
587
|
+
icon: "chevron-right",
|
|
588
|
+
className: "w-5 h-5"
|
|
589
|
+
}) : /*#__PURE__*/_jsx("svg", {
|
|
421
590
|
className: "w-5 h-5",
|
|
422
591
|
fill: "none",
|
|
423
592
|
stroke: "currentColor",
|
|
@@ -443,7 +612,10 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
443
612
|
return setMaximizedTileId(null);
|
|
444
613
|
},
|
|
445
614
|
className: "p-3 bg-slate-50 dark:bg-slate-800 hover:bg-red-50 dark:hover:bg-red-900/20 text-slate-400 hover:text-red-500 rounded-2xl transition-all",
|
|
446
|
-
children: /*#__PURE__*/_jsx(
|
|
615
|
+
children: CustomSVG ? /*#__PURE__*/_jsx(CustomSVG, {
|
|
616
|
+
icon: "close",
|
|
617
|
+
className: "w-6 h-6"
|
|
618
|
+
}) : /*#__PURE__*/_jsx("svg", {
|
|
447
619
|
className: "w-6 h-6",
|
|
448
620
|
fill: "none",
|
|
449
621
|
stroke: "currentColor",
|
|
@@ -463,8 +635,7 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
463
635
|
children: /*#__PURE__*/_jsx(TileContent, _objectSpread({
|
|
464
636
|
tile: tile,
|
|
465
637
|
setTiles: setTiles,
|
|
466
|
-
editMode: editMode
|
|
467
|
-
fetchers: fetchers
|
|
638
|
+
editMode: editMode
|
|
468
639
|
}, rest))
|
|
469
640
|
})
|
|
470
641
|
})
|
|
@@ -472,10 +643,37 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
472
643
|
})
|
|
473
644
|
});
|
|
474
645
|
};
|
|
646
|
+
var handleAddTile = function handleAddTile(tile) {
|
|
647
|
+
var _tile$x5, _tile$y3;
|
|
648
|
+
var newTile = _objectSpread(_objectSpread({}, tile), {}, {
|
|
649
|
+
x: (_tile$x5 = tile.x) !== null && _tile$x5 !== void 0 ? _tile$x5 : 0,
|
|
650
|
+
y: (_tile$y3 = tile.y) !== null && _tile$y3 !== void 0 ? _tile$y3 : 0,
|
|
651
|
+
width: tile.width || 2,
|
|
652
|
+
height: tile.height || 2
|
|
653
|
+
});
|
|
654
|
+
setTiles(function (prev) {
|
|
655
|
+
return [].concat(_toConsumableArray(prev), [newTile]);
|
|
656
|
+
});
|
|
657
|
+
setShowAddModal(false);
|
|
658
|
+
savePositions([].concat(_toConsumableArray(tiles), [newTile]));
|
|
659
|
+
};
|
|
475
660
|
if (isMobile) {
|
|
476
661
|
return /*#__PURE__*/_jsxs("div", {
|
|
477
662
|
className: "flex flex-col gap-6 p-6",
|
|
478
|
-
|
|
663
|
+
ref: _ref1,
|
|
664
|
+
children: [renderMaximizedView(), renderDeleteConfirmation(), CustomAddTileModal ? /*#__PURE__*/_jsx(CustomAddTileModal, {
|
|
665
|
+
isOpen: showAddModal,
|
|
666
|
+
onClose: function onClose() {
|
|
667
|
+
return setShowAddModal(false);
|
|
668
|
+
},
|
|
669
|
+
onAdd: handleAddTile
|
|
670
|
+
}) : showAddModal && /*#__PURE__*/_jsx(AddTileModal, {
|
|
671
|
+
isOpen: showAddModal,
|
|
672
|
+
onClose: function onClose() {
|
|
673
|
+
return setShowAddModal(false);
|
|
674
|
+
},
|
|
675
|
+
onAdd: handleAddTile
|
|
676
|
+
}), tiles.map(function (tile) {
|
|
479
677
|
return /*#__PURE__*/_jsxs("div", {
|
|
480
678
|
className: "bg-white dark:bg-slate-800 rounded-2xl shadow-md border border-slate-200 dark:border-slate-700 overflow-hidden flex flex-col min-h-[400px]",
|
|
481
679
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
@@ -490,7 +688,10 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
490
688
|
return setMaximizedTileId(tile.id);
|
|
491
689
|
},
|
|
492
690
|
className: "p-2 text-indigo-600 bg-indigo-50 dark:bg-indigo-900/20 rounded-lg",
|
|
493
|
-
children: /*#__PURE__*/_jsx(
|
|
691
|
+
children: CustomSVG ? /*#__PURE__*/_jsx(CustomSVG, {
|
|
692
|
+
icon: "maximize",
|
|
693
|
+
className: "w-4 h-4"
|
|
694
|
+
}) : /*#__PURE__*/_jsx("svg", {
|
|
494
695
|
className: "w-4 h-4",
|
|
495
696
|
fill: "none",
|
|
496
697
|
stroke: "currentColor",
|
|
@@ -505,7 +706,10 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
505
706
|
return setTileToDeleteId(tile.id);
|
|
506
707
|
},
|
|
507
708
|
className: "p-2 text-red-500 bg-red-50 dark:bg-red-900/20 rounded-lg",
|
|
508
|
-
children: /*#__PURE__*/_jsx(
|
|
709
|
+
children: CustomSVG ? /*#__PURE__*/_jsx(CustomSVG, {
|
|
710
|
+
icon: "trash",
|
|
711
|
+
className: "w-4 h-4"
|
|
712
|
+
}) : /*#__PURE__*/_jsx("svg", {
|
|
509
713
|
className: "w-4 h-4",
|
|
510
714
|
fill: "none",
|
|
511
715
|
stroke: "currentColor",
|
|
@@ -522,8 +726,7 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
522
726
|
children: /*#__PURE__*/_jsx(TileContent, _objectSpread({
|
|
523
727
|
tile: tile,
|
|
524
728
|
setTiles: setTiles,
|
|
525
|
-
editMode: editMode
|
|
526
|
-
fetchers: fetchers
|
|
729
|
+
editMode: editMode
|
|
527
730
|
}, rest))
|
|
528
731
|
})]
|
|
529
732
|
}, tile.id);
|
|
@@ -531,11 +734,16 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
531
734
|
});
|
|
532
735
|
}
|
|
533
736
|
var gridHeight = Math.max.apply(Math, _toConsumableArray(tiles.map(function (t) {
|
|
534
|
-
|
|
737
|
+
var _t$y;
|
|
738
|
+
return ((_t$y = t.y) !== null && _t$y !== void 0 ? _t$y : 0) + t.height;
|
|
535
739
|
})).concat([12])) * (cellSize + GRID_GAP) + 120;
|
|
740
|
+
var themeClass = typeof theme === 'string' ? theme : 'light';
|
|
536
741
|
return /*#__PURE__*/_jsxs("div", {
|
|
537
|
-
ref:
|
|
538
|
-
|
|
742
|
+
ref: function ref(node) {
|
|
743
|
+
if (typeof _ref1 === 'function') _ref1(node);else if (_ref1) _ref1.current = node;
|
|
744
|
+
containerRef.current = node;
|
|
745
|
+
},
|
|
746
|
+
className: "relative w-full grid-bg select-none p-8 transition-all duration-500 ".concat(editMode ? 'grid-active' : '', " ").concat(themeClass === 'dark' ? 'dark' : ''),
|
|
539
747
|
onPointerMove: handlePointerMove,
|
|
540
748
|
onPointerUp: handlePointerUp,
|
|
541
749
|
onPointerLeave: handlePointerUp,
|
|
@@ -543,7 +751,19 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
543
751
|
height: "".concat(gridHeight, "px"),
|
|
544
752
|
minHeight: '100vh'
|
|
545
753
|
},
|
|
546
|
-
children: [renderMaximizedView(), renderDeleteConfirmation(),
|
|
754
|
+
children: [renderMaximizedView(), renderDeleteConfirmation(), CustomAddTileModal ? /*#__PURE__*/_jsx(CustomAddTileModal, {
|
|
755
|
+
isOpen: showAddModal,
|
|
756
|
+
onClose: function onClose() {
|
|
757
|
+
return setShowAddModal(false);
|
|
758
|
+
},
|
|
759
|
+
onAdd: handleAddTile
|
|
760
|
+
}) : showAddModal && /*#__PURE__*/_jsx(AddTileModal, {
|
|
761
|
+
isOpen: showAddModal,
|
|
762
|
+
onClose: function onClose() {
|
|
763
|
+
return setShowAddModal(false);
|
|
764
|
+
},
|
|
765
|
+
onAdd: handleAddTile
|
|
766
|
+
}), tiles.map(function (tile) {
|
|
547
767
|
return /*#__PURE__*/_jsx(DashboardTile, _objectSpread({
|
|
548
768
|
tile: tile,
|
|
549
769
|
cellSize: cellSize,
|
|
@@ -554,9 +774,9 @@ export var DraggableDashboard = function DraggableDashboard(_ref) {
|
|
|
554
774
|
onMaximize: setMaximizedTileId,
|
|
555
775
|
isDragging: activeTileId === tile.id && !!dragState,
|
|
556
776
|
isResizing: activeTileId === tile.id && !!resizeState,
|
|
557
|
-
fetchers: fetchers,
|
|
558
777
|
setTiles: setTiles
|
|
559
778
|
}, rest), tile.id);
|
|
560
779
|
})]
|
|
561
780
|
});
|
|
562
|
-
};
|
|
781
|
+
});
|
|
782
|
+
DraggableDashboard.displayName = 'DraggableDashboard';
|
package/dist/types.js
CHANGED
|
@@ -1,20 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
TileType["NUMBER"] = "NUMBER";
|
|
3
|
-
TileType["TABLE"] = "TABLE";
|
|
4
|
-
TileType["CHART"] = "CHART";
|
|
5
|
-
TileType["IMAGE"] = "IMAGE";
|
|
6
|
-
TileType["TEXT"] = "TEXT";
|
|
7
|
-
TileType["RECENT"] = "RECENT";
|
|
8
|
-
TileType["BOOKMARK"] = "BOOKMARK";
|
|
9
|
-
TileType["DOCS"] = "DOCS";
|
|
10
|
-
TileType["FOLDERS"] = "FOLDERS";
|
|
11
|
-
TileType["CUSTOM"] = "CUSTOM";
|
|
12
|
-
return TileType;
|
|
13
|
-
}({});
|
|
14
|
-
export var AlignmentMode = /*#__PURE__*/function (AlignmentMode) {
|
|
15
|
-
AlignmentMode["FREESTYLE"] = "FREESTYLE";
|
|
16
|
-
AlignmentMode["ROW"] = "ROW";
|
|
17
|
-
AlignmentMode["COLUMN"] = "COLUMN";
|
|
18
|
-
AlignmentMode["ALPHABETICAL"] = "ALPHABETICAL";
|
|
19
|
-
return AlignmentMode;
|
|
20
|
-
}({});
|
|
1
|
+
export {};
|