@tenorlab/react-dashboard 1.6.5 → 1.6.6
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/core.d.ts +591 -0
- package/dist/core.es.js +526 -0
- package/dist/react-dashboard.d.ts +719 -0
- package/dist/react-dashboard.es.js +3261 -0
- package/dist/styles.css +1 -0
- package/package.json +1 -1
package/dist/core.es.js
ADDED
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
const W = [
|
|
2
|
+
{
|
|
3
|
+
key: "grid-gap",
|
|
4
|
+
name: "Gap",
|
|
5
|
+
description: "Set the gap between widgets in the dashboard grid",
|
|
6
|
+
cssProperty: "--bwj-dashboard-gap",
|
|
7
|
+
step: 0.1,
|
|
8
|
+
defaultUnit: "rem",
|
|
9
|
+
minValue: 0,
|
|
10
|
+
defaultValue: "1.25rem",
|
|
11
|
+
value: "1.25rem"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
key: "widget-width",
|
|
15
|
+
name: "Widget Width",
|
|
16
|
+
description: "Set the min width for the widgets",
|
|
17
|
+
cssProperty: "--bwj-widget-width",
|
|
18
|
+
step: 0.1,
|
|
19
|
+
defaultUnit: "rem",
|
|
20
|
+
minValue: 6,
|
|
21
|
+
defaultValue: "21rem",
|
|
22
|
+
value: "21rem"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
key: "widget-border-radius",
|
|
26
|
+
name: "Widget Border Radius",
|
|
27
|
+
description: "Set the border radius for the widgets",
|
|
28
|
+
cssProperty: "--bwj-widget-border-radius",
|
|
29
|
+
step: 0.1,
|
|
30
|
+
defaultUnit: "rem",
|
|
31
|
+
minValue: 0,
|
|
32
|
+
defaultValue: "0.33rem",
|
|
33
|
+
value: "0.33rem"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
key: "widget-inner-padding-x",
|
|
37
|
+
name: "Widget Horiz Padding",
|
|
38
|
+
description: "Set the horizontal padding for the widgets",
|
|
39
|
+
cssProperty: "--bwj-widget-inner-px",
|
|
40
|
+
step: 0.1,
|
|
41
|
+
defaultUnit: "rem",
|
|
42
|
+
minValue: 0,
|
|
43
|
+
defaultValue: "1.0rem",
|
|
44
|
+
value: "1.0rem"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
key: "widget-inner-padding-y",
|
|
48
|
+
name: "Widget Vertical Padding",
|
|
49
|
+
description: "Set the vertical padding for the widgets",
|
|
50
|
+
cssProperty: "--bwj-widget-inner-py",
|
|
51
|
+
step: 0.1,
|
|
52
|
+
defaultUnit: "rem",
|
|
53
|
+
minValue: 0,
|
|
54
|
+
defaultValue: "0.75rem",
|
|
55
|
+
value: "0.75rem"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
key: "widget-header-padding-y",
|
|
59
|
+
name: "Widget Header Vertical Padding",
|
|
60
|
+
description: "Set the vertical padding for the widget headers",
|
|
61
|
+
cssProperty: "--bwj-widget-header-py",
|
|
62
|
+
step: 0.1,
|
|
63
|
+
defaultUnit: "rem",
|
|
64
|
+
minValue: 0,
|
|
65
|
+
defaultValue: "1.0rem",
|
|
66
|
+
value: "1.0rem"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
key: "widget-title-font-size",
|
|
70
|
+
name: "Widget Title Font Size",
|
|
71
|
+
description: "Set the font size for the widget titles",
|
|
72
|
+
cssProperty: "--bwj-widget-title-size",
|
|
73
|
+
step: 0.1,
|
|
74
|
+
defaultUnit: "rem",
|
|
75
|
+
minValue: 0,
|
|
76
|
+
defaultValue: "1.0rem",
|
|
77
|
+
value: "1.0rem"
|
|
78
|
+
}
|
|
79
|
+
], b = ["rem", "pc", "cm", "in", "em", "vh", "vw", "%"], S = (e, t) => b.includes(e) ? t : 1, E = {
|
|
80
|
+
/**
|
|
81
|
+
* @name incrementOrDecrementValue
|
|
82
|
+
* @description Increments or decrement a value based on the direction parameter
|
|
83
|
+
* @param item: an instance of IDashboardSettingEntry
|
|
84
|
+
* @param direction: -1 (for decrement) or 1 (for increment)
|
|
85
|
+
* @returns the update item
|
|
86
|
+
*/
|
|
87
|
+
incrementOrDecrementValue: (e, t) => {
|
|
88
|
+
const i = e.value.match(/([\d.]+)/), a = i ? parseFloat(i[1]) : 0, r = e.value.match(/([^\d.]+)/), n = r ? r[1] : e.defaultUnit, s = S(n, e.step) * t, l = `${Math.max(a + s, e.minValue).toFixed(1)}${n}`;
|
|
89
|
+
return {
|
|
90
|
+
...e,
|
|
91
|
+
value: l
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}, y = (e, t) => `dashboards_${t}_${e}`, v = async (e, t, i, a) => {
|
|
95
|
+
const r = localStorage.getItem(y(e, t));
|
|
96
|
+
if (r)
|
|
97
|
+
try {
|
|
98
|
+
const n = JSON.parse(r);
|
|
99
|
+
return n.length < 1 ? [a] : (n.forEach((s) => {
|
|
100
|
+
s.dashboardId || (s.dashboardId = "default"), s.dashboardName || (s.dashboardName = `Dashboard ${s.dashboardId}`), s.responsiveGrid = s.responsiveGrid ?? !1, (s.widgets || []).length < 1 && (s.widgets = a.widgets);
|
|
101
|
+
const l = (s.cssSettings || []).filter(
|
|
102
|
+
(o) => a.cssSettings.some((d) => d.key === o.key)
|
|
103
|
+
);
|
|
104
|
+
if (l.length < 1)
|
|
105
|
+
s.cssSettings = [...a.cssSettings];
|
|
106
|
+
else {
|
|
107
|
+
l.forEach((d) => {
|
|
108
|
+
d.value = (d.value || "").replace(/NaN/g, "");
|
|
109
|
+
const c = a.cssSettings.find((g) => g.key === d.key);
|
|
110
|
+
c && (Object.keys(c).forEach((g) => {
|
|
111
|
+
g in d || (d[g] = c[g]);
|
|
112
|
+
}), d.step = c.step, d.minValue = c.minValue, d.defaultValue = c.defaultValue, d.defaultUnit = c.defaultUnit, /\d+/g.test(d.value) === !1 && (d.value = c ? c.value : "1.0rem"));
|
|
113
|
+
});
|
|
114
|
+
const o = a.cssSettings.filter((d) => !l.some((c) => c.key === d.key));
|
|
115
|
+
s.cssSettings = [...l, ...o];
|
|
116
|
+
}
|
|
117
|
+
s.widgets = s.widgets.filter(
|
|
118
|
+
(o) => o.includes("WidgetContainer") || i.has(o)
|
|
119
|
+
), s.childWidgetsConfig = s.childWidgetsConfig.filter(
|
|
120
|
+
(o) => i.has(o.widgetKey)
|
|
121
|
+
), s.zoomScale ? s.zoomScale < 0.7 && (s.zoomScale = 0.7) : s.zoomScale = 1;
|
|
122
|
+
}), n);
|
|
123
|
+
} catch (n) {
|
|
124
|
+
console.warn("Error parsing saved dashboard config:", n);
|
|
125
|
+
}
|
|
126
|
+
return [a];
|
|
127
|
+
}, $ = async (e, t, i, a) => {
|
|
128
|
+
i.forEach((n) => {
|
|
129
|
+
if (n.userID = e, n.clientAppKey = t, n.responsiveGrid = n.responsiveGrid ?? !1, typeof n != "object")
|
|
130
|
+
throw new Error("Invalid dashboard configuration");
|
|
131
|
+
n.widgets = n.widgets.filter(
|
|
132
|
+
(s) => s.includes("WidgetContainer") || a.has(s)
|
|
133
|
+
), n.childWidgetsConfig = n.childWidgetsConfig.filter(
|
|
134
|
+
(s) => a.has(s.widgetKey)
|
|
135
|
+
), n.zoomScale ? n.zoomScale < 0.7 && (n.zoomScale = 0.7) : n.zoomScale = 1;
|
|
136
|
+
});
|
|
137
|
+
const r = JSON.stringify(i);
|
|
138
|
+
return localStorage.setItem(y(e, t), r), !0;
|
|
139
|
+
}, D = {
|
|
140
|
+
getSavedDashboards: v,
|
|
141
|
+
saveDashboards: $
|
|
142
|
+
}, P = () => D, U = {
|
|
143
|
+
userID: 0,
|
|
144
|
+
clientAppKey: "",
|
|
145
|
+
dashboardId: "default",
|
|
146
|
+
dashboardName: "Default",
|
|
147
|
+
zoomScale: 1,
|
|
148
|
+
responsiveGrid: !1,
|
|
149
|
+
widgets: [],
|
|
150
|
+
childWidgetsConfig: [],
|
|
151
|
+
cssSettings: [...W]
|
|
152
|
+
}, z = (e) => {
|
|
153
|
+
const t = `${e}`.split("_");
|
|
154
|
+
return t.length > 1 ? t[1].replace(/(\D)(\d+)/, "$1 $2") : "Container";
|
|
155
|
+
}, p = 0.7, h = 1, V = 0.05, K = (e) => {
|
|
156
|
+
let t = Number(e || 0);
|
|
157
|
+
return t < p && (t = p), t > h && (t = h), t;
|
|
158
|
+
}, L = (e, t) => {
|
|
159
|
+
let i = Number(Number((V * t).toFixed(2)).toFixed(2)), a = Number((Number(e) + i).toFixed(2));
|
|
160
|
+
return K(a);
|
|
161
|
+
}, j = (e) => {
|
|
162
|
+
let t = {
|
|
163
|
+
...e
|
|
164
|
+
};
|
|
165
|
+
return t.widgets = t.widgets.filter((i) => {
|
|
166
|
+
if (`${i}`.includes("WidgetContainer")) {
|
|
167
|
+
const a = t.childWidgetsConfig.filter(
|
|
168
|
+
(r) => r.parentWidgetKey === i
|
|
169
|
+
);
|
|
170
|
+
if (!a || a.length === 0)
|
|
171
|
+
return t.widgets = t.widgets.filter((r) => r !== i), !1;
|
|
172
|
+
}
|
|
173
|
+
return !0;
|
|
174
|
+
}), t;
|
|
175
|
+
}, x = (e) => {
|
|
176
|
+
const t = e.widgets.filter((a) => a.includes("WidgetContainer")), i = {};
|
|
177
|
+
return t.forEach((a, r) => {
|
|
178
|
+
const n = `${a.split("_container")[0]}_container${r + 1}`;
|
|
179
|
+
i[a] = n;
|
|
180
|
+
}), e.widgets = e.widgets.map((a) => i[a] || a), e.childWidgetsConfig = e.childWidgetsConfig.map((a) => {
|
|
181
|
+
const r = a.parentWidgetKey, n = i[r];
|
|
182
|
+
return {
|
|
183
|
+
...a,
|
|
184
|
+
// If a new key exists, use it. If not, keep the original key.
|
|
185
|
+
parentWidgetKey: n || r
|
|
186
|
+
};
|
|
187
|
+
}), e;
|
|
188
|
+
}, m = (e, t) => {
|
|
189
|
+
const i = `${e}`.includes("Container"), a = i ? ["Container"] : ["Widget"], r = t?.name || e, n = t?.description || (i ? "Container" : "Unknown");
|
|
190
|
+
return {
|
|
191
|
+
name: r,
|
|
192
|
+
description: n,
|
|
193
|
+
categories: a,
|
|
194
|
+
noDuplicatedWidgets: !0,
|
|
195
|
+
icon: void 0,
|
|
196
|
+
externalDependencies: []
|
|
197
|
+
};
|
|
198
|
+
}, M = (e, t, i) => t[e] || m(e, i), I = (e, t) => t.get(e)?.meta || m(e), k = (e, t, i) => {
|
|
199
|
+
const a = i || m(e);
|
|
200
|
+
return [
|
|
201
|
+
e,
|
|
202
|
+
{
|
|
203
|
+
key: e,
|
|
204
|
+
title: a.name,
|
|
205
|
+
isContainer: `${e}`.includes("Container"),
|
|
206
|
+
isRemote: !1,
|
|
207
|
+
meta: a,
|
|
208
|
+
component: t
|
|
209
|
+
}
|
|
210
|
+
];
|
|
211
|
+
}, C = (e, t, i, a) => {
|
|
212
|
+
const r = a || m(e);
|
|
213
|
+
return [
|
|
214
|
+
e,
|
|
215
|
+
{
|
|
216
|
+
key: e,
|
|
217
|
+
title: r.name,
|
|
218
|
+
isContainer: !1,
|
|
219
|
+
isRemote: i,
|
|
220
|
+
meta: r,
|
|
221
|
+
loader: t
|
|
222
|
+
}
|
|
223
|
+
];
|
|
224
|
+
}, F = (e) => {
|
|
225
|
+
const t = e.match(/\/widget-([a-zA-Z0-9-]+)\/index\.ts$/);
|
|
226
|
+
if (t && t[1]) {
|
|
227
|
+
const i = t[1], a = i.split("-"), r = `Widget${a.map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join("")}`, n = a.map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(" ");
|
|
228
|
+
return {
|
|
229
|
+
key: r,
|
|
230
|
+
name: n,
|
|
231
|
+
folder: i
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
return null;
|
|
235
|
+
}, N = (e, t, i, a) => {
|
|
236
|
+
const r = `${t}/widget-${i}/meta.ts`, n = e[r];
|
|
237
|
+
if (!n)
|
|
238
|
+
return;
|
|
239
|
+
const s = `${a}Meta`;
|
|
240
|
+
return n[s] || void 0;
|
|
241
|
+
}, A = async (e) => new Promise(async (t, i) => {
|
|
242
|
+
const a = [];
|
|
243
|
+
try {
|
|
244
|
+
const r = await (await fetch(`${e}?${Math.random()}`)).json();
|
|
245
|
+
for (const n in r) {
|
|
246
|
+
const s = r[n], l = () => import(
|
|
247
|
+
/* @vite-ignore */
|
|
248
|
+
s.url
|
|
249
|
+
), o = {
|
|
250
|
+
name: s.meta?.name || "Unknown",
|
|
251
|
+
description: s.meta?.description || "Remote Plugin",
|
|
252
|
+
categories: s.meta?.categories || ["Widget"],
|
|
253
|
+
noDuplicatedWidgets: s.meta?.noDuplicatedWidgets ?? !0,
|
|
254
|
+
icon: void 0,
|
|
255
|
+
// Or a logic to map a string name to a Lucide component
|
|
256
|
+
externalDependencies: s.meta?.externalDependencies || []
|
|
257
|
+
};
|
|
258
|
+
a.push(C(n, l, !0, o));
|
|
259
|
+
}
|
|
260
|
+
t({
|
|
261
|
+
entries: a,
|
|
262
|
+
message: "",
|
|
263
|
+
details: ""
|
|
264
|
+
});
|
|
265
|
+
} catch (r) {
|
|
266
|
+
console.error("Remote plugin discovery failed:", r), i({
|
|
267
|
+
entries: [],
|
|
268
|
+
message: "Remote plugin discovery failed:",
|
|
269
|
+
details: typeof r == "object" ? JSON.stringify(r) : r
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}), R = (e, t, i, a = !0) => {
|
|
273
|
+
const r = [];
|
|
274
|
+
for (const n in t) {
|
|
275
|
+
const s = t[n], l = F(n);
|
|
276
|
+
if (l && s) {
|
|
277
|
+
const { key: o, name: d, folder: c } = l;
|
|
278
|
+
let g = N(i, e, c, o);
|
|
279
|
+
if (g || (g = m(o, {
|
|
280
|
+
name: d,
|
|
281
|
+
description: `Local ${a ? "dynamic" : "static"} widget`
|
|
282
|
+
})), a)
|
|
283
|
+
r.push(
|
|
284
|
+
C(o, s, !1, g)
|
|
285
|
+
);
|
|
286
|
+
else {
|
|
287
|
+
const f = s.default || s;
|
|
288
|
+
r.push(k(o, f, g));
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return r;
|
|
293
|
+
}, w = (e) => {
|
|
294
|
+
const t = e.widgets.filter((i) => i.includes("WidgetContainer")).map((i) => Number(i.split("_")[1].replace("container", "")));
|
|
295
|
+
return `container${t.length > 0 ? Math.max(...t) + 1 : 1}`;
|
|
296
|
+
}, O = {
|
|
297
|
+
/**
|
|
298
|
+
* @name getNextContainerName
|
|
299
|
+
* @description Generates the next container name based on existing containers in the dashboard configuration
|
|
300
|
+
* @param dashboardConfig
|
|
301
|
+
* @returns {string} The next container name in the format 'containerX', where X is the next available number
|
|
302
|
+
*/
|
|
303
|
+
getNextContainerName: w,
|
|
304
|
+
/**
|
|
305
|
+
* @name getNextContainerKey
|
|
306
|
+
* @description Generates the next container widget key based on the dashboard configuration and a given container widget key
|
|
307
|
+
* @param dashboardConfig
|
|
308
|
+
* @param containerWidgetKey
|
|
309
|
+
* @returns {TDashboardWidgetKey} The next container widget key
|
|
310
|
+
*/
|
|
311
|
+
getNextContainerKey: (e, t) => {
|
|
312
|
+
const i = w(e);
|
|
313
|
+
return `${t}_${i}`;
|
|
314
|
+
},
|
|
315
|
+
/**
|
|
316
|
+
* @description Adds a widget to the configuration. Supports root-level and nested containers.
|
|
317
|
+
* @param params - Configuration object for adding a widget.
|
|
318
|
+
* @param params.dashboardConfig - The current {@link IDashboardConfig}.
|
|
319
|
+
* @param params.widgetKey - The {@link TDashboardWidgetKey} to add.
|
|
320
|
+
* @param params.parentWidgetKey - Optional parent container key.
|
|
321
|
+
* @param params.noDuplicatedWidgets - If true, prevents adding the same key twice.
|
|
322
|
+
* @returns A {@link TCoreResponse} containing the success status and updated config.
|
|
323
|
+
*/
|
|
324
|
+
addWidget: (e) => {
|
|
325
|
+
const { dashboardConfig: t, widgetKey: i, parentWidgetKey: a, noDuplicatedWidgets: r } = e;
|
|
326
|
+
if (a) {
|
|
327
|
+
if (r && t.childWidgetsConfig.find(
|
|
328
|
+
(s) => s.parentWidgetKey === a && s.widgetKey === i
|
|
329
|
+
))
|
|
330
|
+
return {
|
|
331
|
+
success: !1,
|
|
332
|
+
message: `DashboardStore: addWidget: Widget already added (${i})`,
|
|
333
|
+
updatedDashboardConfig: t
|
|
334
|
+
};
|
|
335
|
+
const n = [
|
|
336
|
+
...t.childWidgetsConfig,
|
|
337
|
+
{ parentWidgetKey: a, widgetKey: i }
|
|
338
|
+
// new entry
|
|
339
|
+
];
|
|
340
|
+
return {
|
|
341
|
+
success: !0,
|
|
342
|
+
updatedDashboardConfig: {
|
|
343
|
+
...t,
|
|
344
|
+
childWidgetsConfig: n
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
} else {
|
|
348
|
+
if (r && t.widgets.includes(i))
|
|
349
|
+
return {
|
|
350
|
+
success: !1,
|
|
351
|
+
message: `DashboardStore: addWidget: Widget already added (${i})`,
|
|
352
|
+
updatedDashboardConfig: t
|
|
353
|
+
};
|
|
354
|
+
const n = [...t.widgets, i];
|
|
355
|
+
return {
|
|
356
|
+
success: !0,
|
|
357
|
+
updatedDashboardConfig: {
|
|
358
|
+
...t,
|
|
359
|
+
widgets: n
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
/**
|
|
365
|
+
* @name removeWidget
|
|
366
|
+
* @description Removes a widget from the dashboard configuration, either from the root level or from a specified parent container
|
|
367
|
+
* @param dashboardConfig
|
|
368
|
+
* @param widgetKey
|
|
369
|
+
* @param parentWidgetKey
|
|
370
|
+
* @returns {TCoreResponse<TRemoveWidgetResponse>} The response indicating success or failure and the updated dashboard configuration
|
|
371
|
+
*/
|
|
372
|
+
removeWidget: (e, t, i) => {
|
|
373
|
+
const a = `${t || ""}`.trim().toLowerCase(), r = `${i || ""}`.trim().toLowerCase();
|
|
374
|
+
if (r.length > 0) {
|
|
375
|
+
const n = e.childWidgetsConfig.filter(
|
|
376
|
+
(d) => `${d.parentWidgetKey}`.trim().toLowerCase() !== r
|
|
377
|
+
), s = e.childWidgetsConfig.filter(
|
|
378
|
+
(d) => `${d.parentWidgetKey}`.trim().toLowerCase() === r && `${d.widgetKey}`.trim().toLowerCase() !== a
|
|
379
|
+
), l = [...n, ...s];
|
|
380
|
+
let o = {
|
|
381
|
+
...e,
|
|
382
|
+
childWidgetsConfig: l
|
|
383
|
+
};
|
|
384
|
+
return a.includes("container") && (o = x(o)), {
|
|
385
|
+
success: !0,
|
|
386
|
+
updatedDashboardConfig: o
|
|
387
|
+
};
|
|
388
|
+
} else {
|
|
389
|
+
const n = (e.widgets || []).filter((l) => `${l}`.trim().toLowerCase() !== a), s = e.childWidgetsConfig.filter(
|
|
390
|
+
(l) => `${l.parentWidgetKey}`.trim().toLowerCase() !== a
|
|
391
|
+
);
|
|
392
|
+
return {
|
|
393
|
+
success: !0,
|
|
394
|
+
updatedDashboardConfig: {
|
|
395
|
+
...e,
|
|
396
|
+
widgets: n,
|
|
397
|
+
childWidgetsConfig: s
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
/**
|
|
403
|
+
* @description Moves a widget's position within its current depth (root or container).
|
|
404
|
+
* @param dashboardConfig - The current {@link IDashboardConfig}.
|
|
405
|
+
* @param direction - Use `1` for forward/down and `-1` for backward/up.
|
|
406
|
+
* @param widgetKey - The {@link TDashboardWidgetKey} to move.
|
|
407
|
+
* @param parentWidgetKey - The container key if the widget is nested.
|
|
408
|
+
* @returns A {@link TCoreResponse} with the new array order.
|
|
409
|
+
*/
|
|
410
|
+
moveWidget: (e, t, i, a) => {
|
|
411
|
+
const r = `${i || ""}`.trim().toLowerCase(), n = `${a || ""}`.trim().toLowerCase();
|
|
412
|
+
if (n.length > 0) {
|
|
413
|
+
const s = e.childWidgetsConfig.filter(
|
|
414
|
+
(u) => `${u.parentWidgetKey}`.trim().toLowerCase() !== n
|
|
415
|
+
);
|
|
416
|
+
let l = e.childWidgetsConfig.filter(
|
|
417
|
+
(u) => `${u.parentWidgetKey}`.trim().toLowerCase() === n
|
|
418
|
+
);
|
|
419
|
+
const o = l.find(
|
|
420
|
+
(u) => `${u.widgetKey}`.trim().toLowerCase() === r
|
|
421
|
+
), d = l.indexOf(o);
|
|
422
|
+
let c = d + t;
|
|
423
|
+
if (c = Math.max(0, c), c = Math.min(l.length - 1, c), c === d)
|
|
424
|
+
return {
|
|
425
|
+
success: !1,
|
|
426
|
+
message: `DashboardStore: moveWidget: Widget already at min/max position (${i})`,
|
|
427
|
+
updatedDashboardConfig: e
|
|
428
|
+
};
|
|
429
|
+
const g = [...l], [f] = g.splice(d, 1);
|
|
430
|
+
return g.splice(c, 0, f), {
|
|
431
|
+
success: !0,
|
|
432
|
+
updatedDashboardConfig: {
|
|
433
|
+
...e,
|
|
434
|
+
childWidgetsConfig: [...s, ...g]
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
} else {
|
|
438
|
+
const s = e.widgets || [], l = s.map((g) => `${g}`.trim().toLowerCase()).indexOf(r);
|
|
439
|
+
let o = l + t;
|
|
440
|
+
if (o = Math.max(0, o), o = Math.min(s.length - 1, o), o === l)
|
|
441
|
+
return {
|
|
442
|
+
success: !1,
|
|
443
|
+
message: `DashboardStore: moveWidget: Widget already at min/max position (${i})`,
|
|
444
|
+
updatedDashboardConfig: e
|
|
445
|
+
};
|
|
446
|
+
const d = [...s], [c] = d.splice(l, 1);
|
|
447
|
+
return d.splice(o, 0, c), {
|
|
448
|
+
success: !0,
|
|
449
|
+
updatedDashboardConfig: {
|
|
450
|
+
...e,
|
|
451
|
+
widgets: d
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}, _ = (e, t = "color") => {
|
|
457
|
+
if (typeof window > "u") return "#FFFFFF";
|
|
458
|
+
const i = document.createElement("div");
|
|
459
|
+
Array.isArray(e) ? e.forEach((r) => i.classList.add(r)) : e.split(" ").forEach((r) => i.classList.add(r)), i.style.display = "none", document.body.appendChild(i);
|
|
460
|
+
const a = window.getComputedStyle(i)[t];
|
|
461
|
+
return document.body.removeChild(i), a;
|
|
462
|
+
}, G = {
|
|
463
|
+
/**
|
|
464
|
+
* @name getCssVariableValue
|
|
465
|
+
* @description Return the value of a CSS custom property from the current HTML document
|
|
466
|
+
* @param cssPropertyName
|
|
467
|
+
* @returns
|
|
468
|
+
*/
|
|
469
|
+
getCssVariableValue: (e) => {
|
|
470
|
+
const t = document.documentElement;
|
|
471
|
+
return getComputedStyle(t).getPropertyValue(e).trim() || null;
|
|
472
|
+
},
|
|
473
|
+
/**
|
|
474
|
+
* @name setCssVariableValue
|
|
475
|
+
* @description Sets the value of a CSS custom property on the current HTML document
|
|
476
|
+
* @param cssPropertyName
|
|
477
|
+
* @param value
|
|
478
|
+
*/
|
|
479
|
+
setCssVariableValue: (e, t) => {
|
|
480
|
+
document.documentElement.style.setProperty(e, t);
|
|
481
|
+
},
|
|
482
|
+
/**
|
|
483
|
+
* @name restoreCssVarsFromSettings
|
|
484
|
+
* @description
|
|
485
|
+
* Sets the values of many CSS custom properties on the current HTML document
|
|
486
|
+
* from the list of dashboard settings provided
|
|
487
|
+
* @param settings, an array of IDashboardSettingEntry
|
|
488
|
+
*/
|
|
489
|
+
restoreCssVarsFromSettings: (e) => {
|
|
490
|
+
const t = document.documentElement;
|
|
491
|
+
e.forEach((i) => {
|
|
492
|
+
t.style.setProperty(i.cssProperty, i.value);
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
}, Z = (e, ...t) => [
|
|
496
|
+
...new Set(
|
|
497
|
+
[e || "", ...t].join(" ").trim().replace(/\n+/gi, " ").replace(/\s+/gi, " ").split(" ")
|
|
498
|
+
)
|
|
499
|
+
].join(" ").trim();
|
|
500
|
+
export {
|
|
501
|
+
h as DashboardMaxZoomScale,
|
|
502
|
+
p as DashboardMinZoomScale,
|
|
503
|
+
V as DashboardZoomStep,
|
|
504
|
+
U as blankDashboardConfig,
|
|
505
|
+
C as createDynamicEntry,
|
|
506
|
+
k as createStaticEntry,
|
|
507
|
+
W as cssSettingsCatalog,
|
|
508
|
+
G as cssVarsUtils,
|
|
509
|
+
E as dashboardSettingsUtils,
|
|
510
|
+
O as dashboardStoreUtils,
|
|
511
|
+
x as ensureContainersSequence,
|
|
512
|
+
K as ensureZoomScaleIsWithinRange,
|
|
513
|
+
m as getDefaultWidgetMetaFromKey,
|
|
514
|
+
M as getDefaultWidgetMetaFromMap,
|
|
515
|
+
Z as getDistinctCssClasses,
|
|
516
|
+
N as getMetaInfoFromFile,
|
|
517
|
+
L as getNewZoomScaleWithinRange,
|
|
518
|
+
I as getWidgetMetaFromCatalog,
|
|
519
|
+
R as localWidgetDiscovery,
|
|
520
|
+
z as parseContainerTitle,
|
|
521
|
+
F as parseKeyAndTitleFromFilePath,
|
|
522
|
+
A as remoteWidgetDiscovery,
|
|
523
|
+
j as removeEmptyContainers,
|
|
524
|
+
_ as resolveColorFromClass,
|
|
525
|
+
P as useDashboardStorageService
|
|
526
|
+
};
|