@trops/dash-core 0.1.151 → 0.1.153
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/index.esm.js +345 -48
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +345 -47
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2713,9 +2713,9 @@ var LayoutContainer = function LayoutContainer(_ref) {
|
|
|
2713
2713
|
|
|
2714
2714
|
function ownKeys$A(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; }
|
|
2715
2715
|
function _objectSpread$A(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$A(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$A(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2716
|
-
function _createForOfIteratorHelper$
|
|
2717
|
-
function _unsupportedIterableToArray$
|
|
2718
|
-
function _arrayLikeToArray$
|
|
2716
|
+
function _createForOfIteratorHelper$e(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$e(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
2717
|
+
function _unsupportedIterableToArray$e(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$e(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$e(r, a) : void 0; } }
|
|
2718
|
+
function _arrayLikeToArray$e(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
2719
2719
|
/**
|
|
2720
2720
|
* Layout template definitions for the dashboard template picker.
|
|
2721
2721
|
*
|
|
@@ -2951,7 +2951,7 @@ function createLayoutFromTemplate(template) {
|
|
|
2951
2951
|
cols: template.cols,
|
|
2952
2952
|
gap: "gap-2"
|
|
2953
2953
|
};
|
|
2954
|
-
var _iterator = _createForOfIteratorHelper$
|
|
2954
|
+
var _iterator = _createForOfIteratorHelper$e(template.cells),
|
|
2955
2955
|
_step;
|
|
2956
2956
|
try {
|
|
2957
2957
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -9794,9 +9794,9 @@ var PanelEditItem = function PanelEditItem(_ref) {
|
|
|
9794
9794
|
};
|
|
9795
9795
|
|
|
9796
9796
|
var _excluded$5 = ["rows", "cols"];
|
|
9797
|
-
function _createForOfIteratorHelper$
|
|
9798
|
-
function _unsupportedIterableToArray$
|
|
9799
|
-
function _arrayLikeToArray$
|
|
9797
|
+
function _createForOfIteratorHelper$d(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$d(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
9798
|
+
function _unsupportedIterableToArray$d(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$d(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$d(r, a) : void 0; } }
|
|
9799
|
+
function _arrayLikeToArray$d(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
9800
9800
|
function ownKeys$x(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; }
|
|
9801
9801
|
function _objectSpread$x(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$x(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$x(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9802
9802
|
var defaultGrid = {
|
|
@@ -9949,7 +9949,7 @@ function GridEditor(_ref) {
|
|
|
9949
9949
|
function sortObjectByKeys(obj) {
|
|
9950
9950
|
var sortedKeys = Object.keys(obj).sort();
|
|
9951
9951
|
var sortedObj = {};
|
|
9952
|
-
var _iterator = _createForOfIteratorHelper$
|
|
9952
|
+
var _iterator = _createForOfIteratorHelper$d(sortedKeys),
|
|
9953
9953
|
_step;
|
|
9954
9954
|
try {
|
|
9955
9955
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -10422,9 +10422,9 @@ var PanelEditItemNotifications = function PanelEditItemNotifications(_ref) {
|
|
|
10422
10422
|
});
|
|
10423
10423
|
};
|
|
10424
10424
|
|
|
10425
|
-
function _createForOfIteratorHelper$
|
|
10426
|
-
function _unsupportedIterableToArray$
|
|
10427
|
-
function _arrayLikeToArray$
|
|
10425
|
+
function _createForOfIteratorHelper$c(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$c(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
10426
|
+
function _unsupportedIterableToArray$c(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$c(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$c(r, a) : void 0; } }
|
|
10427
|
+
function _arrayLikeToArray$c(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
10428
10428
|
function ownKeys$v(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; }
|
|
10429
10429
|
function _objectSpread$v(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$v(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$v(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10430
10430
|
var DAYS = [{
|
|
@@ -10753,7 +10753,7 @@ var PanelEditItemSchedule = function PanelEditItemSchedule(_ref2) {
|
|
|
10753
10753
|
setIsLoading(true);
|
|
10754
10754
|
window.mainApi.scheduler.getTasks(widgetUuid).then(function (tasks) {
|
|
10755
10755
|
var stateMap = {};
|
|
10756
|
-
var _iterator = _createForOfIteratorHelper$
|
|
10756
|
+
var _iterator = _createForOfIteratorHelper$c(tasks || []),
|
|
10757
10757
|
_step;
|
|
10758
10758
|
try {
|
|
10759
10759
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -13603,9 +13603,9 @@ var getUserConfigurableProviders = function getUserConfigurableProviders(provide
|
|
|
13603
13603
|
});
|
|
13604
13604
|
};
|
|
13605
13605
|
|
|
13606
|
-
function _createForOfIteratorHelper$
|
|
13607
|
-
function _unsupportedIterableToArray$
|
|
13608
|
-
function _arrayLikeToArray$
|
|
13606
|
+
function _createForOfIteratorHelper$b(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$b(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
13607
|
+
function _unsupportedIterableToArray$b(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$b(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$b(r, a) : void 0; } }
|
|
13608
|
+
function _arrayLikeToArray$b(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13609
13609
|
function ownKeys$s(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; }
|
|
13610
13610
|
function _objectSpread$s(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$s(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$s(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13611
13611
|
var EnhancedWidgetDropdown = function EnhancedWidgetDropdown(_ref) {
|
|
@@ -13872,11 +13872,11 @@ var EnhancedWidgetDropdown = function EnhancedWidgetDropdown(_ref) {
|
|
|
13872
13872
|
|
|
13873
13873
|
// Flatten all widgets from all packages for the widget list
|
|
13874
13874
|
flatWidgets = [];
|
|
13875
|
-
_iterator = _createForOfIteratorHelper$
|
|
13875
|
+
_iterator = _createForOfIteratorHelper$b(result.packages || []);
|
|
13876
13876
|
try {
|
|
13877
13877
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
13878
13878
|
pkg = _step.value;
|
|
13879
|
-
_iterator2 = _createForOfIteratorHelper$
|
|
13879
|
+
_iterator2 = _createForOfIteratorHelper$b(pkg.widgets || []);
|
|
13880
13880
|
try {
|
|
13881
13881
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
13882
13882
|
widget = _step2.value;
|
|
@@ -15432,9 +15432,9 @@ var ProviderBadge = function ProviderBadge(_ref) {
|
|
|
15432
15432
|
});
|
|
15433
15433
|
};
|
|
15434
15434
|
|
|
15435
|
-
function _createForOfIteratorHelper$
|
|
15436
|
-
function _unsupportedIterableToArray$
|
|
15437
|
-
function _arrayLikeToArray$
|
|
15435
|
+
function _createForOfIteratorHelper$a(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$a(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
15436
|
+
function _unsupportedIterableToArray$a(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$a(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$a(r, a) : void 0; } }
|
|
15437
|
+
function _arrayLikeToArray$a(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15438
15438
|
var WidgetCardHeader = function WidgetCardHeader(_ref) {
|
|
15439
15439
|
var item = _ref.item,
|
|
15440
15440
|
widget = _ref.widget,
|
|
@@ -15478,7 +15478,7 @@ var WidgetCardHeader = function WidgetCardHeader(_ref) {
|
|
|
15478
15478
|
var el = headerRef.current;
|
|
15479
15479
|
if (!el) return;
|
|
15480
15480
|
var observer = new ResizeObserver(function (entries) {
|
|
15481
|
-
var _iterator = _createForOfIteratorHelper$
|
|
15481
|
+
var _iterator = _createForOfIteratorHelper$a(entries),
|
|
15482
15482
|
_step;
|
|
15483
15483
|
try {
|
|
15484
15484
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -15779,6 +15779,288 @@ var WidgetCardHeader = function WidgetCardHeader(_ref) {
|
|
|
15779
15779
|
});
|
|
15780
15780
|
};
|
|
15781
15781
|
|
|
15782
|
+
/**
|
|
15783
|
+
* useWidgetSchedulerStatus
|
|
15784
|
+
*
|
|
15785
|
+
* Display-only hook for reading scheduler task state outside WidgetContext.
|
|
15786
|
+
* Used by WidgetCardStatusBar to show live timer status in the widget footer.
|
|
15787
|
+
*
|
|
15788
|
+
* Unlike useScheduler, this hook:
|
|
15789
|
+
* - Does NOT require WidgetContext (works outside the widget tree)
|
|
15790
|
+
* - Does NOT execute handlers — purely for display
|
|
15791
|
+
* - Calls mainApi.scheduler.getTasks() directly
|
|
15792
|
+
*
|
|
15793
|
+
* @param {string} widgetId - The widget instance UUID
|
|
15794
|
+
* @returns {{ tasks: Array, isLoading: boolean }}
|
|
15795
|
+
*/
|
|
15796
|
+
var useWidgetSchedulerStatus = function useWidgetSchedulerStatus(widgetId) {
|
|
15797
|
+
var _useState = React.useState([]),
|
|
15798
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
15799
|
+
tasks = _useState2[0],
|
|
15800
|
+
setTasks = _useState2[1];
|
|
15801
|
+
var _useState3 = React.useState(true),
|
|
15802
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
15803
|
+
isLoading = _useState4[0],
|
|
15804
|
+
setIsLoading = _useState4[1];
|
|
15805
|
+
var fetchTasks = React.useCallback(function () {
|
|
15806
|
+
var _window$mainApi;
|
|
15807
|
+
if (!widgetId || !((_window$mainApi = window.mainApi) !== null && _window$mainApi !== void 0 && _window$mainApi.scheduler)) {
|
|
15808
|
+
setIsLoading(false);
|
|
15809
|
+
return;
|
|
15810
|
+
}
|
|
15811
|
+
window.mainApi.scheduler.getTasks(widgetId).then(function (result) {
|
|
15812
|
+
setTasks(result || []);
|
|
15813
|
+
setIsLoading(false);
|
|
15814
|
+
});
|
|
15815
|
+
}, [widgetId]);
|
|
15816
|
+
|
|
15817
|
+
// Load tasks on mount
|
|
15818
|
+
React.useEffect(function () {
|
|
15819
|
+
fetchTasks();
|
|
15820
|
+
}, [fetchTasks]);
|
|
15821
|
+
|
|
15822
|
+
// Subscribe to task-fired events to auto-refresh
|
|
15823
|
+
React.useEffect(function () {
|
|
15824
|
+
var _window$mainApi2;
|
|
15825
|
+
if (!widgetId || !((_window$mainApi2 = window.mainApi) !== null && _window$mainApi2 !== void 0 && (_window$mainApi2 = _window$mainApi2.scheduler) !== null && _window$mainApi2 !== void 0 && _window$mainApi2.onTaskFired)) return;
|
|
15826
|
+
var removeListener = window.mainApi.scheduler.onTaskFired(function (data) {
|
|
15827
|
+
if (data.widgetId !== widgetId) return;
|
|
15828
|
+
fetchTasks();
|
|
15829
|
+
});
|
|
15830
|
+
return removeListener;
|
|
15831
|
+
}, [widgetId, fetchTasks]);
|
|
15832
|
+
return {
|
|
15833
|
+
tasks: tasks,
|
|
15834
|
+
isLoading: isLoading
|
|
15835
|
+
};
|
|
15836
|
+
};
|
|
15837
|
+
|
|
15838
|
+
function _createForOfIteratorHelper$9(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$9(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
15839
|
+
function _unsupportedIterableToArray$9(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$9(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$9(r, a) : void 0; } }
|
|
15840
|
+
function _arrayLikeToArray$9(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15841
|
+
function formatCountdown(ms) {
|
|
15842
|
+
if (ms == null || ms < 0) return "--";
|
|
15843
|
+
if (ms < 1000) return "< 1s";
|
|
15844
|
+
var totalSeconds = Math.floor(ms / 1000);
|
|
15845
|
+
var hours = Math.floor(totalSeconds / 3600);
|
|
15846
|
+
var minutes = Math.floor(totalSeconds % 3600 / 60);
|
|
15847
|
+
var seconds = totalSeconds % 60;
|
|
15848
|
+
if (hours > 0) return "".concat(hours, "h ").concat(minutes, "m");
|
|
15849
|
+
if (minutes > 0) return "".concat(minutes, "m ").concat(seconds, "s");
|
|
15850
|
+
return "".concat(seconds, "s");
|
|
15851
|
+
}
|
|
15852
|
+
|
|
15853
|
+
/**
|
|
15854
|
+
* Format a timestamp as an absolute time string.
|
|
15855
|
+
* @param {number|string} timestamp - epoch ms or ISO string
|
|
15856
|
+
* @returns {string} e.g. "1:05:30 PM" for today, or full date+time for older
|
|
15857
|
+
*/
|
|
15858
|
+
function formatRelativeTime(timestamp) {
|
|
15859
|
+
if (!timestamp) return null;
|
|
15860
|
+
var ts = typeof timestamp === "string" ? new Date(timestamp).getTime() : timestamp;
|
|
15861
|
+
var date = new Date(ts);
|
|
15862
|
+
var now = new Date();
|
|
15863
|
+
var isToday = date.getFullYear() === now.getFullYear() && date.getMonth() === now.getMonth() && date.getDate() === now.getDate();
|
|
15864
|
+
if (isToday) {
|
|
15865
|
+
return date.toLocaleTimeString();
|
|
15866
|
+
}
|
|
15867
|
+
return date.toLocaleString();
|
|
15868
|
+
}
|
|
15869
|
+
|
|
15870
|
+
/**
|
|
15871
|
+
* Format a task's schedule as a human-readable description.
|
|
15872
|
+
* @param {Object} task - scheduler task object
|
|
15873
|
+
* @returns {string} e.g. "Every 5 min", "Mon, Wed at 09:00"
|
|
15874
|
+
*/
|
|
15875
|
+
function formatScheduleDescription(task) {
|
|
15876
|
+
if (task.scheduleType === "interval" && task.intervalMs) {
|
|
15877
|
+
var totalSeconds = Math.floor(task.intervalMs / 1000);
|
|
15878
|
+
if (totalSeconds < 60) return "Every ".concat(totalSeconds, "s");
|
|
15879
|
+
var minutes = Math.floor(totalSeconds / 60);
|
|
15880
|
+
if (minutes < 60) return "Every ".concat(minutes, " min");
|
|
15881
|
+
var hours = Math.floor(minutes / 60);
|
|
15882
|
+
var remainingMin = minutes % 60;
|
|
15883
|
+
if (remainingMin === 0) return "Every ".concat(hours, " hr");
|
|
15884
|
+
return "Every ".concat(hours, "h ").concat(remainingMin, "m");
|
|
15885
|
+
}
|
|
15886
|
+
if (task.scheduleType === "dayTime") {
|
|
15887
|
+
var dayMap = {
|
|
15888
|
+
mon: "Mon",
|
|
15889
|
+
tue: "Tue",
|
|
15890
|
+
wed: "Wed",
|
|
15891
|
+
thu: "Thu",
|
|
15892
|
+
fri: "Fri",
|
|
15893
|
+
sat: "Sat",
|
|
15894
|
+
sun: "Sun"
|
|
15895
|
+
};
|
|
15896
|
+
var days = (task.days || []).map(function (d) {
|
|
15897
|
+
return dayMap[d] || d;
|
|
15898
|
+
});
|
|
15899
|
+
var time = task.time || "00:00";
|
|
15900
|
+
if (days.length === 7) return "Daily at ".concat(time);
|
|
15901
|
+
if (days.length === 5 && ["mon", "tue", "wed", "thu", "fri"].every(function (d) {
|
|
15902
|
+
return (task.days || []).includes(d);
|
|
15903
|
+
})) {
|
|
15904
|
+
return "Mon\u2013Fri at ".concat(time);
|
|
15905
|
+
}
|
|
15906
|
+
return "".concat(days.join(", "), " at ").concat(time);
|
|
15907
|
+
}
|
|
15908
|
+
return "Scheduled";
|
|
15909
|
+
}
|
|
15910
|
+
|
|
15911
|
+
// ── Component ───────────────────────────────────────────────────────
|
|
15912
|
+
|
|
15913
|
+
var WidgetCardStatusBar = function WidgetCardStatusBar(_ref) {
|
|
15914
|
+
var item = _ref.item,
|
|
15915
|
+
_ref$className = _ref.className,
|
|
15916
|
+
className = _ref$className === void 0 ? "" : _ref$className;
|
|
15917
|
+
var _useState = React.useState(false),
|
|
15918
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
15919
|
+
expanded = _useState2[0],
|
|
15920
|
+
setExpanded = _useState2[1];
|
|
15921
|
+
var _useState3 = React.useState(Date.now()),
|
|
15922
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
15923
|
+
now = _useState4[0],
|
|
15924
|
+
setNow = _useState4[1];
|
|
15925
|
+
|
|
15926
|
+
// Check if widget declares scheduledTasks in its config
|
|
15927
|
+
var widgetConfig = item !== null && item !== void 0 && item.component ? ComponentManager.config(item.component, item) : null;
|
|
15928
|
+
var declaredTasks = (widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.scheduledTasks) || [];
|
|
15929
|
+
|
|
15930
|
+
// Fetch live task state from the scheduler
|
|
15931
|
+
var _useWidgetSchedulerSt = useWidgetSchedulerStatus(item === null || item === void 0 ? void 0 : item.uuid),
|
|
15932
|
+
tasks = _useWidgetSchedulerSt.tasks,
|
|
15933
|
+
isLoading = _useWidgetSchedulerSt.isLoading;
|
|
15934
|
+
|
|
15935
|
+
// Tick every second for live countdowns
|
|
15936
|
+
React.useEffect(function () {
|
|
15937
|
+
if (tasks.length === 0) return;
|
|
15938
|
+
var interval = setInterval(function () {
|
|
15939
|
+
return setNow(Date.now());
|
|
15940
|
+
}, 1000);
|
|
15941
|
+
return function () {
|
|
15942
|
+
return clearInterval(interval);
|
|
15943
|
+
};
|
|
15944
|
+
}, [tasks.length]);
|
|
15945
|
+
|
|
15946
|
+
// Don't render if widget doesn't declare scheduled tasks or none are configured
|
|
15947
|
+
if (declaredTasks.length === 0) return null;
|
|
15948
|
+
if (isLoading) return null;
|
|
15949
|
+
if (tasks.length === 0) return null;
|
|
15950
|
+
var enabledTasks = tasks.filter(function (t) {
|
|
15951
|
+
return t.enabled;
|
|
15952
|
+
});
|
|
15953
|
+
var allPaused = enabledTasks.length === 0;
|
|
15954
|
+
|
|
15955
|
+
// Find soonest countdown among enabled tasks
|
|
15956
|
+
var soonestMs = null;
|
|
15957
|
+
var _iterator = _createForOfIteratorHelper$9(enabledTasks),
|
|
15958
|
+
_step;
|
|
15959
|
+
try {
|
|
15960
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
15961
|
+
var _task = _step.value;
|
|
15962
|
+
if (_task.nextFireAt) {
|
|
15963
|
+
var remaining = _task.nextFireAt - now;
|
|
15964
|
+
if (soonestMs === null || remaining < soonestMs) {
|
|
15965
|
+
soonestMs = remaining;
|
|
15966
|
+
}
|
|
15967
|
+
}
|
|
15968
|
+
}
|
|
15969
|
+
|
|
15970
|
+
// Collapsed summary text
|
|
15971
|
+
} catch (err) {
|
|
15972
|
+
_iterator.e(err);
|
|
15973
|
+
} finally {
|
|
15974
|
+
_iterator.f();
|
|
15975
|
+
}
|
|
15976
|
+
var summaryText;
|
|
15977
|
+
if (allPaused) {
|
|
15978
|
+
summaryText = "".concat(tasks.length, " timer").concat(tasks.length > 1 ? "s" : "", " (paused)");
|
|
15979
|
+
} else if (tasks.length === 1) {
|
|
15980
|
+
var task = tasks[0];
|
|
15981
|
+
var label = task.displayName || task.taskKey;
|
|
15982
|
+
if (task.enabled && soonestMs != null) {
|
|
15983
|
+
summaryText = "".concat(label, " \xB7 ").concat(formatCountdown(soonestMs));
|
|
15984
|
+
} else {
|
|
15985
|
+
summaryText = "".concat(label, " (paused)");
|
|
15986
|
+
}
|
|
15987
|
+
} else {
|
|
15988
|
+
summaryText = "".concat(tasks.length, " timers \xB7 next in ").concat(formatCountdown(soonestMs));
|
|
15989
|
+
}
|
|
15990
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
15991
|
+
className: "border-t border-gray-700/50 bg-gray-900/30 select-none ".concat(className),
|
|
15992
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("button", {
|
|
15993
|
+
type: "button",
|
|
15994
|
+
onClick: function onClick() {
|
|
15995
|
+
return setExpanded(!expanded);
|
|
15996
|
+
},
|
|
15997
|
+
className: "flex items-center w-full px-3 py-1 text-xs gap-2 cursor-pointer transition-colors hover:bg-gray-800/40 ".concat(allPaused ? "text-gray-500" : "text-blue-400"),
|
|
15998
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
|
|
15999
|
+
icon: "clock",
|
|
16000
|
+
className: "text-[10px] shrink-0"
|
|
16001
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
16002
|
+
className: "truncate flex-1 text-left",
|
|
16003
|
+
children: summaryText
|
|
16004
|
+
}), /*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
|
|
16005
|
+
icon: expanded ? "chevron-up" : "chevron-down",
|
|
16006
|
+
className: "text-[10px] text-gray-500 shrink-0"
|
|
16007
|
+
})]
|
|
16008
|
+
}), expanded && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
16009
|
+
className: "px-3 pb-2 pt-1 space-y-2",
|
|
16010
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
16011
|
+
className: "text-[10px] font-semibold text-gray-400 uppercase tracking-wider",
|
|
16012
|
+
children: "Scheduled Tasks"
|
|
16013
|
+
}), tasks.map(function (task) {
|
|
16014
|
+
var remaining = task.enabled && task.nextFireAt ? task.nextFireAt - now : null;
|
|
16015
|
+
var lastFiredText = formatRelativeTime(task.lastFiredAt);
|
|
16016
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
16017
|
+
className: "flex flex-col gap-0.5",
|
|
16018
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
16019
|
+
className: "flex items-center justify-between text-xs",
|
|
16020
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
16021
|
+
className: "flex items-center gap-1.5",
|
|
16022
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
16023
|
+
className: "inline-block w-1.5 h-1.5 rounded-full ".concat(task.enabled ? "bg-green-500" : "bg-gray-600")
|
|
16024
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
16025
|
+
className: task.enabled ? "text-gray-200" : "text-gray-500",
|
|
16026
|
+
children: task.displayName || task.taskKey
|
|
16027
|
+
}), !task.enabled && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
16028
|
+
className: "text-gray-600 text-[10px]",
|
|
16029
|
+
children: "(paused)"
|
|
16030
|
+
})]
|
|
16031
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
16032
|
+
className: "text-gray-500 text-[10px]",
|
|
16033
|
+
children: formatScheduleDescription(task)
|
|
16034
|
+
})]
|
|
16035
|
+
}), task.enabled && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
16036
|
+
className: "text-[10px] text-gray-500 pl-4 flex items-center gap-1.5",
|
|
16037
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
16038
|
+
children: ["Next in ", formatCountdown(remaining)]
|
|
16039
|
+
}), lastFiredText && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
16040
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
16041
|
+
className: "text-gray-700",
|
|
16042
|
+
children: "\xB7"
|
|
16043
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
16044
|
+
children: ["Last: ", lastFiredText]
|
|
16045
|
+
})]
|
|
16046
|
+
}), task.fireCount > 0 && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
16047
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
16048
|
+
className: "text-gray-700",
|
|
16049
|
+
children: "\xB7"
|
|
16050
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
16051
|
+
children: ["#", task.fireCount]
|
|
16052
|
+
})]
|
|
16053
|
+
})]
|
|
16054
|
+
}), !task.enabled && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
16055
|
+
className: "text-[10px] text-gray-600 pl-4",
|
|
16056
|
+
children: formatScheduleDescription(task)
|
|
16057
|
+
})]
|
|
16058
|
+
}, task.taskId);
|
|
16059
|
+
})]
|
|
16060
|
+
})]
|
|
16061
|
+
});
|
|
16062
|
+
};
|
|
16063
|
+
|
|
15782
16064
|
/**
|
|
15783
16065
|
* WidgetCard
|
|
15784
16066
|
*
|
|
@@ -15958,6 +16240,7 @@ var WidgetCard = function WidgetCard(_ref4) {
|
|
|
15958
16240
|
WidgetCard.Header = WidgetCardHeader_Component;
|
|
15959
16241
|
WidgetCard.Body = WidgetCardBody;
|
|
15960
16242
|
WidgetCard.Footer = WidgetCardFooter;
|
|
16243
|
+
WidgetCard.StatusBar = WidgetCardStatusBar;
|
|
15961
16244
|
|
|
15962
16245
|
var ProviderSelector = function ProviderSelector(_ref) {
|
|
15963
16246
|
var isOpen = _ref.isOpen,
|
|
@@ -18828,6 +19111,8 @@ var WidgetContainerGridItem = function WidgetContainerGridItem(_ref) {
|
|
|
18828
19111
|
}), /*#__PURE__*/jsxRuntime.jsx(WidgetCard.Footer, {
|
|
18829
19112
|
item: item,
|
|
18830
19113
|
onConfigure: handleOpenConfig
|
|
19114
|
+
}), /*#__PURE__*/jsxRuntime.jsx(WidgetCard.StatusBar, {
|
|
19115
|
+
item: item
|
|
18831
19116
|
})]
|
|
18832
19117
|
}), (item.type !== "widget") && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
18833
19118
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
@@ -18889,6 +19174,8 @@ var WidgetContainerGridItem = function WidgetContainerGridItem(_ref) {
|
|
|
18889
19174
|
}), /*#__PURE__*/jsxRuntime.jsx(WidgetCard.Footer, {
|
|
18890
19175
|
item: item,
|
|
18891
19176
|
onConfigure: handleOpenConfig
|
|
19177
|
+
}), /*#__PURE__*/jsxRuntime.jsx(WidgetCard.StatusBar, {
|
|
19178
|
+
item: item
|
|
18892
19179
|
})]
|
|
18893
19180
|
}), (item.type !== "widget") && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
18894
19181
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -20072,38 +20359,48 @@ var WidgetRenderer = function WidgetRenderer(_ref) {
|
|
|
20072
20359
|
var widgetContextValue = {
|
|
20073
20360
|
widgetData: widgetData
|
|
20074
20361
|
};
|
|
20362
|
+
var hasScheduledTasks = ((config === null || config === void 0 ? void 0 : config.scheduledTasks) || []).length > 0;
|
|
20363
|
+
var widgetElement = children === null ? /*#__PURE__*/jsxRuntime.jsx(WidgetComponent, _objectSpread$m(_objectSpread$m(_objectSpread$m({
|
|
20364
|
+
id: "widget-nokids-".concat(widgetKey),
|
|
20365
|
+
listen: function listen(listeners, handlers) {
|
|
20366
|
+
return helpers.listen(listeners, handlers);
|
|
20367
|
+
},
|
|
20368
|
+
publishEvent: function publishEvent(eventName, payload) {
|
|
20369
|
+
return helpers.publishEvent(eventName, payload);
|
|
20370
|
+
},
|
|
20371
|
+
api: w
|
|
20372
|
+
}, params), userPrefs), {}, {
|
|
20373
|
+
backgroundColor: bgColor,
|
|
20374
|
+
widgetConfig: helpers.config(),
|
|
20375
|
+
widgetEventNames: helpers.events()
|
|
20376
|
+
}), "widget-nokids-".concat(widgetKey)) : /*#__PURE__*/jsxRuntime.jsx(WidgetComponent, _objectSpread$m(_objectSpread$m(_objectSpread$m({
|
|
20377
|
+
listen: function listen(listeners, handlers) {
|
|
20378
|
+
return helpers.listen(listeners, handlers);
|
|
20379
|
+
},
|
|
20380
|
+
publishEvent: function publishEvent(eventName, payload) {
|
|
20381
|
+
return helpers.publishEvent(eventName, payload);
|
|
20382
|
+
},
|
|
20383
|
+
api: w,
|
|
20384
|
+
id: "widget-kids-".concat(widgetKey)
|
|
20385
|
+
}, params), userPrefs), {}, {
|
|
20386
|
+
backgroundColor: bgColor,
|
|
20387
|
+
children: children
|
|
20388
|
+
}), "widget-kids-".concat(widgetKey));
|
|
20075
20389
|
|
|
20076
20390
|
// Wrap widget rendering with WidgetContext + error boundary
|
|
20077
20391
|
return /*#__PURE__*/jsxRuntime.jsx(WidgetContext.Provider, {
|
|
20078
20392
|
value: widgetContextValue,
|
|
20079
20393
|
children: /*#__PURE__*/jsxRuntime.jsx(WidgetErrorBoundary, {
|
|
20080
20394
|
widgetName: component,
|
|
20081
|
-
children:
|
|
20082
|
-
|
|
20083
|
-
|
|
20084
|
-
|
|
20085
|
-
|
|
20086
|
-
|
|
20087
|
-
|
|
20088
|
-
}
|
|
20089
|
-
|
|
20090
|
-
}, params), userPrefs), {}, {
|
|
20091
|
-
backgroundColor: bgColor,
|
|
20092
|
-
widgetConfig: helpers.config(),
|
|
20093
|
-
widgetEventNames: helpers.events()
|
|
20094
|
-
}), "widget-nokids-".concat(widgetKey)) : /*#__PURE__*/jsxRuntime.jsx(WidgetComponent, _objectSpread$m(_objectSpread$m(_objectSpread$m({
|
|
20095
|
-
listen: function listen(listeners, handlers) {
|
|
20096
|
-
return helpers.listen(listeners, handlers);
|
|
20097
|
-
},
|
|
20098
|
-
publishEvent: function publishEvent(eventName, payload) {
|
|
20099
|
-
return helpers.publishEvent(eventName, payload);
|
|
20100
|
-
},
|
|
20101
|
-
api: w,
|
|
20102
|
-
id: "widget-kids-".concat(widgetKey)
|
|
20103
|
-
}, params), userPrefs), {}, {
|
|
20104
|
-
backgroundColor: bgColor,
|
|
20105
|
-
children: children
|
|
20106
|
-
}), "widget-kids-".concat(widgetKey))
|
|
20395
|
+
children: hasScheduledTasks ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
20396
|
+
className: "flex flex-col w-full h-full min-h-0",
|
|
20397
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
20398
|
+
className: "flex-1 min-h-0 overflow-auto",
|
|
20399
|
+
children: widgetElement
|
|
20400
|
+
}), /*#__PURE__*/jsxRuntime.jsx(WidgetCardStatusBar, {
|
|
20401
|
+
item: params
|
|
20402
|
+
})]
|
|
20403
|
+
}) : widgetElement
|
|
20107
20404
|
})
|
|
20108
20405
|
});
|
|
20109
20406
|
}
|
|
@@ -46011,6 +46308,7 @@ exports.useProviderClient = useProviderClient;
|
|
|
46011
46308
|
exports.useScheduler = useScheduler;
|
|
46012
46309
|
exports.useWidgetEvents = useWidgetEvents;
|
|
46013
46310
|
exports.useWidgetProviders = useWidgetProviders;
|
|
46311
|
+
exports.useWidgetSchedulerStatus = useWidgetSchedulerStatus;
|
|
46014
46312
|
exports.validateCellMerge = validateCellMerge;
|
|
46015
46313
|
exports.validateGridCell = validateGridCell;
|
|
46016
46314
|
exports.validateGridPlacement = validateGridPlacement;
|