@tenorlab/react-dashboard 1.5.26 → 1.5.41
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 +80 -0
- package/dist/core.es.js +295 -129
- package/dist/react-dashboard.d.ts +16 -0
- package/dist/react-dashboard.es.js +1628 -1698
- package/package.json +2 -2
package/dist/core.d.ts
CHANGED
|
@@ -70,6 +70,65 @@ export declare const dashboardSettingsUtils: {
|
|
|
70
70
|
incrementOrDecrementValue: (item: IDashboardSettingEntry, direction: -1 | 1) => IDashboardSettingEntry;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @name dashboardStoreUtils
|
|
75
|
+
* @description
|
|
76
|
+
* Framework-agnostic helpers for managing dashboard state. These utilities
|
|
77
|
+
* are designed to be consumed by specific store implementations.
|
|
78
|
+
* @see {@link https://www.npmjs.com/package/@tenorlab/react-dashboard | @tenorlab/react-dashboard}
|
|
79
|
+
* @see {@link https://www.npmjs.com/package/@tenorlab/vue-dashboard | @tenorlab/vue-dashboard}
|
|
80
|
+
*/
|
|
81
|
+
export declare const dashboardStoreUtils: {
|
|
82
|
+
/**
|
|
83
|
+
* @name getNextContainerName
|
|
84
|
+
* @description Generates the next container name based on existing containers in the dashboard configuration
|
|
85
|
+
* @param dashboardConfig
|
|
86
|
+
* @returns {string} The next container name in the format 'containerX', where X is the next available number
|
|
87
|
+
*/
|
|
88
|
+
getNextContainerName: (dashboardConfig: IDashboardConfig) => string;
|
|
89
|
+
/**
|
|
90
|
+
* @name getNextContainerKey
|
|
91
|
+
* @description Generates the next container widget key based on the dashboard configuration and a given container widget key
|
|
92
|
+
* @param dashboardConfig
|
|
93
|
+
* @param containerWidgetKey
|
|
94
|
+
* @returns {TDashboardWidgetKey} The next container widget key
|
|
95
|
+
*/
|
|
96
|
+
getNextContainerKey: (dashboardConfig: IDashboardConfig, containerWidgetKey: TDashboardWidgetKey) => TDashboardWidgetKey;
|
|
97
|
+
/**
|
|
98
|
+
* @description Adds a widget to the configuration. Supports root-level and nested containers.
|
|
99
|
+
* @param params - Configuration object for adding a widget.
|
|
100
|
+
* @param params.dashboardConfig - The current {@link IDashboardConfig}.
|
|
101
|
+
* @param params.widgetKey - The {@link TDashboardWidgetKey} to add.
|
|
102
|
+
* @param params.parentWidgetKey - Optional parent container key.
|
|
103
|
+
* @param params.noDuplicatedWidgets - If true, prevents adding the same key twice.
|
|
104
|
+
* @returns A {@link TCoreResponse} containing the success status and updated config.
|
|
105
|
+
*/
|
|
106
|
+
addWidget: (params: {
|
|
107
|
+
dashboardConfig: IDashboardConfig;
|
|
108
|
+
widgetKey: TDashboardWidgetKey;
|
|
109
|
+
parentWidgetKey?: TDashboardWidgetKey;
|
|
110
|
+
noDuplicatedWidgets?: boolean;
|
|
111
|
+
}) => TCoreResponse<TAddWidgetResponse>;
|
|
112
|
+
/**
|
|
113
|
+
* @name removeWidget
|
|
114
|
+
* @description Removes a widget from the dashboard configuration, either from the root level or from a specified parent container
|
|
115
|
+
* @param dashboardConfig
|
|
116
|
+
* @param widgetKey
|
|
117
|
+
* @param parentWidgetKey
|
|
118
|
+
* @returns {TCoreResponse<TRemoveWidgetResponse>} The response indicating success or failure and the updated dashboard configuration
|
|
119
|
+
*/
|
|
120
|
+
removeWidget: (dashboardConfig: IDashboardConfig, widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => TCoreResponse<TRemoveWidgetResponse>;
|
|
121
|
+
/**
|
|
122
|
+
* @description Moves a widget's position within its current depth (root or container).
|
|
123
|
+
* @param dashboardConfig - The current {@link IDashboardConfig}.
|
|
124
|
+
* @param direction - Use `1` for forward/down and `-1` for backward/up.
|
|
125
|
+
* @param widgetKey - The {@link TDashboardWidgetKey} to move.
|
|
126
|
+
* @param parentWidgetKey - The container key if the widget is nested.
|
|
127
|
+
* @returns A {@link TCoreResponse} with the new array order.
|
|
128
|
+
*/
|
|
129
|
+
moveWidget: (dashboardConfig: IDashboardConfig, direction: -1 | 1, widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => TCoreResponse<TMoveWidgetResponse>;
|
|
130
|
+
};
|
|
131
|
+
|
|
73
132
|
export declare const DashboardZoomStep: 0.05;
|
|
74
133
|
|
|
75
134
|
/**
|
|
@@ -294,6 +353,23 @@ export declare const removeEmptyContainers: (dashboardConfig: IDashboardConfig)
|
|
|
294
353
|
*/
|
|
295
354
|
export declare const resolveColorFromClass: (classNames: string | string[], property?: "color" | "backgroundColor") => string;
|
|
296
355
|
|
|
356
|
+
/**
|
|
357
|
+
* @name TAddWidgetResponse
|
|
358
|
+
* @description Type for the response of the addWidget mutation
|
|
359
|
+
* @property {boolean} success - Indicates if the widget was added successfully
|
|
360
|
+
* @property {string} [message] - Optional message providing additional information
|
|
361
|
+
* @property {IDashboardConfig} updatedDashboardConfig - The updated dashboard configuration after adding the widget
|
|
362
|
+
* @property {IDashboardConfig[]} allUpdatedDashboardConfigs - All updated dashboard configurations
|
|
363
|
+
*/
|
|
364
|
+
export declare type TAddWidgetResponse = {
|
|
365
|
+
success: boolean;
|
|
366
|
+
message?: string;
|
|
367
|
+
updatedDashboardConfig: IDashboardConfig;
|
|
368
|
+
allUpdatedDashboardConfigs: IDashboardConfig[];
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
declare type TCoreResponse<T> = Omit<T, 'allUpdatedDashboardConfigs'>;
|
|
372
|
+
|
|
297
373
|
/**
|
|
298
374
|
* @name TDashboardUndoStatus
|
|
299
375
|
* @description Type for the dashboard undo/redo status
|
|
@@ -372,6 +448,10 @@ export declare type TManifestEntry = {
|
|
|
372
448
|
meta: TWidgetMetaInfoBase;
|
|
373
449
|
};
|
|
374
450
|
|
|
451
|
+
export declare type TMoveWidgetResponse = TAddWidgetResponse;
|
|
452
|
+
|
|
453
|
+
export declare type TRemoveWidgetResponse = TAddWidgetResponse;
|
|
454
|
+
|
|
375
455
|
/**
|
|
376
456
|
* @name TSaveDashboards
|
|
377
457
|
* @description Function type to save dashboards for a user
|
package/dist/core.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const W = [
|
|
2
2
|
{
|
|
3
3
|
key: "grid-gap",
|
|
4
4
|
name: "Gap",
|
|
@@ -76,7 +76,7 @@ const w = [
|
|
|
76
76
|
defaultValue: "1.0rem",
|
|
77
77
|
value: "1.0rem"
|
|
78
78
|
}
|
|
79
|
-
],
|
|
79
|
+
], b = ["rem", "pc", "cm", "in", "em", "vh", "vw", "%"], S = (e, t) => b.includes(e) ? t : 1, E = {
|
|
80
80
|
/**
|
|
81
81
|
* @name incrementOrDecrementValue
|
|
82
82
|
* @description Increments or decrement a value based on the direction parameter
|
|
@@ -85,65 +85,65 @@ const w = [
|
|
|
85
85
|
* @returns the update item
|
|
86
86
|
*/
|
|
87
87
|
incrementOrDecrementValue: (e, t) => {
|
|
88
|
-
const
|
|
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
89
|
return {
|
|
90
90
|
...e,
|
|
91
|
-
value:
|
|
91
|
+
value: l
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
},
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
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
97
|
try {
|
|
98
|
-
const n = JSON.parse(
|
|
99
|
-
return n.length < 1 ? [
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
(o) =>
|
|
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
103
|
);
|
|
104
|
-
if (
|
|
105
|
-
|
|
104
|
+
if (l.length < 1)
|
|
105
|
+
s.cssSettings = [...a.cssSettings];
|
|
106
106
|
else {
|
|
107
|
-
|
|
107
|
+
l.forEach((d) => {
|
|
108
108
|
d.value = (d.value || "").replace(/NaN/g, "");
|
|
109
|
-
const
|
|
109
|
+
const c = a.cssSettings.find(
|
|
110
110
|
(g) => g.key === d.key
|
|
111
111
|
);
|
|
112
|
-
|
|
113
|
-
g in d || (d[g] =
|
|
114
|
-
}), d.step =
|
|
112
|
+
c && (Object.keys(c).forEach((g) => {
|
|
113
|
+
g in d || (d[g] = c[g]);
|
|
114
|
+
}), 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"));
|
|
115
115
|
});
|
|
116
|
-
const o =
|
|
117
|
-
(
|
|
116
|
+
const o = a.cssSettings.filter((d) => !l.some(
|
|
117
|
+
(c) => c.key === d.key
|
|
118
118
|
));
|
|
119
|
-
|
|
119
|
+
s.cssSettings = [...l, ...o];
|
|
120
120
|
}
|
|
121
|
-
|
|
122
|
-
(o) => o.includes("WidgetContainer") ||
|
|
123
|
-
),
|
|
124
|
-
(o) =>
|
|
125
|
-
),
|
|
121
|
+
s.widgets = s.widgets.filter(
|
|
122
|
+
(o) => o.includes("WidgetContainer") || i.has(o)
|
|
123
|
+
), s.childWidgetsConfig = s.childWidgetsConfig.filter(
|
|
124
|
+
(o) => i.has(o.widgetKey)
|
|
125
|
+
), s.zoomScale ? s.zoomScale < 0.7 && (s.zoomScale = 0.7) : s.zoomScale = 1;
|
|
126
126
|
}), n);
|
|
127
127
|
} catch (n) {
|
|
128
128
|
console.warn("Error parsing saved dashboard config:", n);
|
|
129
129
|
}
|
|
130
|
-
return [
|
|
131
|
-
},
|
|
132
|
-
|
|
130
|
+
return [a];
|
|
131
|
+
}, $ = async (e, t, i, a) => {
|
|
132
|
+
i.forEach((n) => {
|
|
133
133
|
if (n.userID = e, n.clientAppKey = t, n.responsiveGrid = n.responsiveGrid ?? !1, typeof n != "object")
|
|
134
134
|
throw new Error("Invalid dashboard configuration");
|
|
135
135
|
n.widgets = n.widgets.filter(
|
|
136
|
-
(
|
|
136
|
+
(s) => s.includes("WidgetContainer") || a.has(s)
|
|
137
137
|
), n.childWidgetsConfig = n.childWidgetsConfig.filter(
|
|
138
|
-
(
|
|
138
|
+
(s) => a.has(s.widgetKey)
|
|
139
139
|
), n.zoomScale ? n.zoomScale < 0.7 && (n.zoomScale = 0.7) : n.zoomScale = 1;
|
|
140
140
|
});
|
|
141
|
-
const
|
|
142
|
-
return localStorage.setItem(
|
|
143
|
-
},
|
|
141
|
+
const r = JSON.stringify(i);
|
|
142
|
+
return localStorage.setItem(y(e, t), r), !0;
|
|
143
|
+
}, D = {
|
|
144
144
|
getSavedDashboards: v,
|
|
145
|
-
saveDashboards:
|
|
146
|
-
}, P = () =>
|
|
145
|
+
saveDashboards: $
|
|
146
|
+
}, P = () => D, U = {
|
|
147
147
|
userID: 0,
|
|
148
148
|
clientAppKey: "",
|
|
149
149
|
dashboardId: "default",
|
|
@@ -152,158 +152,323 @@ const w = [
|
|
|
152
152
|
responsiveGrid: !1,
|
|
153
153
|
widgets: [],
|
|
154
154
|
childWidgetsConfig: [],
|
|
155
|
-
cssSettings: [...
|
|
156
|
-
},
|
|
155
|
+
cssSettings: [...W]
|
|
156
|
+
}, z = (e) => {
|
|
157
157
|
const t = `${e}`.split("_");
|
|
158
158
|
return t.length > 1 ? t[1].replace(/(\D)(\d+)/, "$1 $2") : "Container";
|
|
159
|
-
},
|
|
159
|
+
}, p = 0.7, h = 1, V = 0.05, K = (e) => {
|
|
160
160
|
let t = Number(e || 0);
|
|
161
|
-
return t <
|
|
162
|
-
},
|
|
163
|
-
let
|
|
164
|
-
return
|
|
165
|
-
},
|
|
161
|
+
return t < p && (t = p), t > h && (t = h), t;
|
|
162
|
+
}, L = (e, t) => {
|
|
163
|
+
let i = Number(Number((V * t).toFixed(2)).toFixed(2)), a = Number((Number(e) + i).toFixed(2));
|
|
164
|
+
return K(a);
|
|
165
|
+
}, j = (e) => {
|
|
166
166
|
let t = {
|
|
167
167
|
...e
|
|
168
168
|
};
|
|
169
|
-
return t.widgets = t.widgets.filter((
|
|
170
|
-
if (`${
|
|
171
|
-
const
|
|
172
|
-
(
|
|
169
|
+
return t.widgets = t.widgets.filter((i) => {
|
|
170
|
+
if (`${i}`.includes("WidgetContainer")) {
|
|
171
|
+
const a = t.childWidgetsConfig.filter(
|
|
172
|
+
(r) => r.parentWidgetKey === i
|
|
173
173
|
);
|
|
174
|
-
if (!
|
|
174
|
+
if (!a || a.length === 0)
|
|
175
175
|
return t.widgets = t.widgets.filter(
|
|
176
|
-
(
|
|
176
|
+
(r) => r !== i
|
|
177
177
|
), !1;
|
|
178
178
|
}
|
|
179
179
|
return !0;
|
|
180
180
|
}), t;
|
|
181
181
|
}, x = (e) => {
|
|
182
182
|
const t = e.widgets.filter(
|
|
183
|
-
(
|
|
184
|
-
),
|
|
185
|
-
return t.forEach((
|
|
186
|
-
const n = `${
|
|
187
|
-
a
|
|
188
|
-
}), e.widgets = e.widgets.map((
|
|
189
|
-
const
|
|
183
|
+
(a) => a.includes("WidgetContainer")
|
|
184
|
+
), i = {};
|
|
185
|
+
return t.forEach((a, r) => {
|
|
186
|
+
const n = `${a.split("_container")[0]}_container${r + 1}`;
|
|
187
|
+
i[a] = n;
|
|
188
|
+
}), e.widgets = e.widgets.map((a) => i[a] || a), e.childWidgetsConfig = e.childWidgetsConfig.map((a) => {
|
|
189
|
+
const r = a.parentWidgetKey, n = i[r];
|
|
190
190
|
return {
|
|
191
|
-
...
|
|
191
|
+
...a,
|
|
192
192
|
// If a new key exists, use it. If not, keep the original key.
|
|
193
|
-
parentWidgetKey: n ||
|
|
193
|
+
parentWidgetKey: n || r
|
|
194
194
|
};
|
|
195
195
|
}), e;
|
|
196
196
|
}, m = (e, t) => {
|
|
197
|
-
const
|
|
197
|
+
const i = `${e}`.includes("Container"), a = i ? ["Container"] : ["Widget"], r = t?.name || e, n = t?.description || (i ? "Container" : "Unknown");
|
|
198
198
|
return {
|
|
199
|
-
name:
|
|
199
|
+
name: r,
|
|
200
200
|
description: n,
|
|
201
|
-
categories:
|
|
201
|
+
categories: a,
|
|
202
202
|
noDuplicatedWidgets: !0,
|
|
203
203
|
icon: void 0,
|
|
204
204
|
externalDependencies: []
|
|
205
205
|
};
|
|
206
|
-
},
|
|
207
|
-
const
|
|
206
|
+
}, M = (e, t, i) => t[e] || m(e, i), I = (e, t) => t.get(e)?.meta || m(e), k = (e, t, i) => {
|
|
207
|
+
const a = i || m(e);
|
|
208
208
|
return [
|
|
209
209
|
e,
|
|
210
210
|
{
|
|
211
211
|
key: e,
|
|
212
|
-
title:
|
|
212
|
+
title: a.name,
|
|
213
213
|
isContainer: `${e}`.includes("Container"),
|
|
214
214
|
isRemote: !1,
|
|
215
|
-
meta:
|
|
215
|
+
meta: a,
|
|
216
216
|
component: t
|
|
217
217
|
}
|
|
218
218
|
];
|
|
219
|
-
},
|
|
220
|
-
const
|
|
219
|
+
}, C = (e, t, i, a) => {
|
|
220
|
+
const r = a || m(e);
|
|
221
221
|
return [
|
|
222
222
|
e,
|
|
223
223
|
{
|
|
224
224
|
key: e,
|
|
225
|
-
title:
|
|
225
|
+
title: r.name,
|
|
226
226
|
isContainer: !1,
|
|
227
|
-
isRemote:
|
|
228
|
-
meta:
|
|
227
|
+
isRemote: i,
|
|
228
|
+
meta: r,
|
|
229
229
|
loader: t
|
|
230
230
|
}
|
|
231
231
|
];
|
|
232
232
|
}, F = (e) => {
|
|
233
233
|
const t = e.match(/\/widget-([a-zA-Z0-9-]+)\/index\.ts$/);
|
|
234
234
|
if (t && t[1]) {
|
|
235
|
-
const
|
|
235
|
+
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(" ");
|
|
236
236
|
return {
|
|
237
|
-
key:
|
|
237
|
+
key: r,
|
|
238
238
|
name: n,
|
|
239
|
-
folder:
|
|
239
|
+
folder: i
|
|
240
240
|
};
|
|
241
241
|
}
|
|
242
242
|
return null;
|
|
243
|
-
},
|
|
244
|
-
const
|
|
243
|
+
}, N = (e, t, i, a) => {
|
|
244
|
+
const r = `${t}/widget-${i}/meta.ts`, n = e[r];
|
|
245
245
|
if (!n)
|
|
246
246
|
return;
|
|
247
|
-
const
|
|
248
|
-
return n[
|
|
249
|
-
}, A = async (e) => new Promise(async (t,
|
|
250
|
-
const
|
|
247
|
+
const s = `${a}Meta`;
|
|
248
|
+
return n[s] || void 0;
|
|
249
|
+
}, A = async (e) => new Promise(async (t, i) => {
|
|
250
|
+
const a = [];
|
|
251
251
|
try {
|
|
252
|
-
const
|
|
253
|
-
for (const n in
|
|
254
|
-
const
|
|
252
|
+
const r = await (await fetch(`${e}?${Math.random()}`)).json();
|
|
253
|
+
for (const n in r) {
|
|
254
|
+
const s = r[n], l = () => import(
|
|
255
255
|
/* @vite-ignore */
|
|
256
|
-
|
|
256
|
+
s.url
|
|
257
257
|
), o = {
|
|
258
|
-
name:
|
|
259
|
-
description:
|
|
260
|
-
categories:
|
|
261
|
-
noDuplicatedWidgets:
|
|
258
|
+
name: s.meta?.name || "Unknown",
|
|
259
|
+
description: s.meta?.description || "Remote Plugin",
|
|
260
|
+
categories: s.meta?.categories || ["Widget"],
|
|
261
|
+
noDuplicatedWidgets: s.meta?.noDuplicatedWidgets ?? !0,
|
|
262
262
|
icon: void 0,
|
|
263
263
|
// Or a logic to map a string name to a Lucide component
|
|
264
|
-
externalDependencies:
|
|
264
|
+
externalDependencies: s.meta?.externalDependencies || []
|
|
265
265
|
};
|
|
266
|
-
|
|
266
|
+
a.push(C(n, l, !0, o));
|
|
267
267
|
}
|
|
268
268
|
t({
|
|
269
|
-
entries:
|
|
269
|
+
entries: a,
|
|
270
270
|
message: "",
|
|
271
271
|
details: ""
|
|
272
272
|
});
|
|
273
|
-
} catch (
|
|
274
|
-
console.error("Remote plugin discovery failed:",
|
|
273
|
+
} catch (r) {
|
|
274
|
+
console.error("Remote plugin discovery failed:", r), i({
|
|
275
275
|
entries: [],
|
|
276
276
|
message: "Remote plugin discovery failed:",
|
|
277
|
-
details: typeof
|
|
277
|
+
details: typeof r == "object" ? JSON.stringify(r) : r
|
|
278
278
|
});
|
|
279
279
|
}
|
|
280
|
-
}),
|
|
281
|
-
const
|
|
280
|
+
}), R = (e, t, i, a = !0) => {
|
|
281
|
+
const r = [];
|
|
282
282
|
for (const n in t) {
|
|
283
|
-
const
|
|
284
|
-
if (
|
|
285
|
-
const { key: o, name: d, folder:
|
|
286
|
-
let g =
|
|
283
|
+
const s = t[n], l = F(n);
|
|
284
|
+
if (l && s) {
|
|
285
|
+
const { key: o, name: d, folder: c } = l;
|
|
286
|
+
let g = N(i, e, c, o);
|
|
287
287
|
if (g || (g = m(o, {
|
|
288
288
|
name: d,
|
|
289
|
-
description: `Local ${
|
|
290
|
-
})),
|
|
291
|
-
|
|
292
|
-
|
|
289
|
+
description: `Local ${a ? "dynamic" : "static"} widget`
|
|
290
|
+
})), a)
|
|
291
|
+
r.push(
|
|
292
|
+
C(o, s, !1, g)
|
|
293
293
|
);
|
|
294
294
|
else {
|
|
295
|
-
const
|
|
296
|
-
|
|
295
|
+
const f = s.default || s;
|
|
296
|
+
r.push(k(o, f, g));
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
|
-
return
|
|
301
|
-
},
|
|
300
|
+
return r;
|
|
301
|
+
}, w = (e) => {
|
|
302
|
+
const t = e.widgets.filter((i) => i.includes("WidgetContainer")).map((i) => Number(i.split("_")[1].replace("container", "")));
|
|
303
|
+
return `container${t.length > 0 ? Math.max(...t) + 1 : 1}`;
|
|
304
|
+
}, O = {
|
|
305
|
+
/**
|
|
306
|
+
* @name getNextContainerName
|
|
307
|
+
* @description Generates the next container name based on existing containers in the dashboard configuration
|
|
308
|
+
* @param dashboardConfig
|
|
309
|
+
* @returns {string} The next container name in the format 'containerX', where X is the next available number
|
|
310
|
+
*/
|
|
311
|
+
getNextContainerName: w,
|
|
312
|
+
/**
|
|
313
|
+
* @name getNextContainerKey
|
|
314
|
+
* @description Generates the next container widget key based on the dashboard configuration and a given container widget key
|
|
315
|
+
* @param dashboardConfig
|
|
316
|
+
* @param containerWidgetKey
|
|
317
|
+
* @returns {TDashboardWidgetKey} The next container widget key
|
|
318
|
+
*/
|
|
319
|
+
getNextContainerKey: (e, t) => {
|
|
320
|
+
const i = w(e);
|
|
321
|
+
return `${t}_${i}`;
|
|
322
|
+
},
|
|
323
|
+
/**
|
|
324
|
+
* @description Adds a widget to the configuration. Supports root-level and nested containers.
|
|
325
|
+
* @param params - Configuration object for adding a widget.
|
|
326
|
+
* @param params.dashboardConfig - The current {@link IDashboardConfig}.
|
|
327
|
+
* @param params.widgetKey - The {@link TDashboardWidgetKey} to add.
|
|
328
|
+
* @param params.parentWidgetKey - Optional parent container key.
|
|
329
|
+
* @param params.noDuplicatedWidgets - If true, prevents adding the same key twice.
|
|
330
|
+
* @returns A {@link TCoreResponse} containing the success status and updated config.
|
|
331
|
+
*/
|
|
332
|
+
addWidget: (e) => {
|
|
333
|
+
const { dashboardConfig: t, widgetKey: i, parentWidgetKey: a, noDuplicatedWidgets: r } = e;
|
|
334
|
+
if (a) {
|
|
335
|
+
if (r && t.childWidgetsConfig.find(
|
|
336
|
+
(s) => s.parentWidgetKey === a && s.widgetKey === i
|
|
337
|
+
))
|
|
338
|
+
return {
|
|
339
|
+
success: !1,
|
|
340
|
+
message: `DashboardStore: addWidget: Widget already added (${i})`,
|
|
341
|
+
updatedDashboardConfig: t
|
|
342
|
+
};
|
|
343
|
+
const n = [
|
|
344
|
+
...t.childWidgetsConfig,
|
|
345
|
+
{ parentWidgetKey: a, widgetKey: i }
|
|
346
|
+
// new entry
|
|
347
|
+
];
|
|
348
|
+
return {
|
|
349
|
+
success: !0,
|
|
350
|
+
updatedDashboardConfig: {
|
|
351
|
+
...t,
|
|
352
|
+
childWidgetsConfig: n
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
} else {
|
|
356
|
+
if (r && t.widgets.includes(i))
|
|
357
|
+
return {
|
|
358
|
+
success: !1,
|
|
359
|
+
message: `DashboardStore: addWidget: Widget already added (${i})`,
|
|
360
|
+
updatedDashboardConfig: t
|
|
361
|
+
};
|
|
362
|
+
const n = [...t.widgets, i];
|
|
363
|
+
return {
|
|
364
|
+
success: !0,
|
|
365
|
+
updatedDashboardConfig: {
|
|
366
|
+
...t,
|
|
367
|
+
widgets: n
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
/**
|
|
373
|
+
* @name removeWidget
|
|
374
|
+
* @description Removes a widget from the dashboard configuration, either from the root level or from a specified parent container
|
|
375
|
+
* @param dashboardConfig
|
|
376
|
+
* @param widgetKey
|
|
377
|
+
* @param parentWidgetKey
|
|
378
|
+
* @returns {TCoreResponse<TRemoveWidgetResponse>} The response indicating success or failure and the updated dashboard configuration
|
|
379
|
+
*/
|
|
380
|
+
removeWidget: (e, t, i) => {
|
|
381
|
+
const a = `${t || ""}`.trim().toLowerCase(), r = `${i || ""}`.trim().toLowerCase();
|
|
382
|
+
if (r.length > 0) {
|
|
383
|
+
const n = e.childWidgetsConfig.filter(
|
|
384
|
+
(d) => `${d.parentWidgetKey}`.trim().toLowerCase() !== r
|
|
385
|
+
), s = e.childWidgetsConfig.filter(
|
|
386
|
+
(d) => `${d.parentWidgetKey}`.trim().toLowerCase() === r && `${d.widgetKey}`.trim().toLowerCase() !== a
|
|
387
|
+
), l = [...n, ...s];
|
|
388
|
+
let o = {
|
|
389
|
+
...e,
|
|
390
|
+
childWidgetsConfig: l
|
|
391
|
+
};
|
|
392
|
+
return a.includes("container") && (o = x(o)), {
|
|
393
|
+
success: !0,
|
|
394
|
+
updatedDashboardConfig: o
|
|
395
|
+
};
|
|
396
|
+
} else {
|
|
397
|
+
const n = (e.widgets || []).filter(
|
|
398
|
+
(l) => `${l}`.trim().toLowerCase() !== a
|
|
399
|
+
), s = e.childWidgetsConfig.filter(
|
|
400
|
+
(l) => `${l.parentWidgetKey}`.trim().toLowerCase() !== a
|
|
401
|
+
);
|
|
402
|
+
return {
|
|
403
|
+
success: !0,
|
|
404
|
+
updatedDashboardConfig: {
|
|
405
|
+
...e,
|
|
406
|
+
widgets: n,
|
|
407
|
+
childWidgetsConfig: s
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
/**
|
|
413
|
+
* @description Moves a widget's position within its current depth (root or container).
|
|
414
|
+
* @param dashboardConfig - The current {@link IDashboardConfig}.
|
|
415
|
+
* @param direction - Use `1` for forward/down and `-1` for backward/up.
|
|
416
|
+
* @param widgetKey - The {@link TDashboardWidgetKey} to move.
|
|
417
|
+
* @param parentWidgetKey - The container key if the widget is nested.
|
|
418
|
+
* @returns A {@link TCoreResponse} with the new array order.
|
|
419
|
+
*/
|
|
420
|
+
moveWidget: (e, t, i, a) => {
|
|
421
|
+
const r = `${i || ""}`.trim().toLowerCase(), n = `${a || ""}`.trim().toLowerCase();
|
|
422
|
+
if (n.length > 0) {
|
|
423
|
+
const s = e.childWidgetsConfig.filter(
|
|
424
|
+
(u) => `${u.parentWidgetKey}`.trim().toLowerCase() !== n
|
|
425
|
+
);
|
|
426
|
+
let l = e.childWidgetsConfig.filter(
|
|
427
|
+
(u) => `${u.parentWidgetKey}`.trim().toLowerCase() === n
|
|
428
|
+
);
|
|
429
|
+
const o = l.find(
|
|
430
|
+
(u) => `${u.widgetKey}`.trim().toLowerCase() === r
|
|
431
|
+
), d = l.indexOf(o);
|
|
432
|
+
let c = d + t;
|
|
433
|
+
if (c = Math.max(0, c), c = Math.min(l.length - 1, c), c === d)
|
|
434
|
+
return {
|
|
435
|
+
success: !1,
|
|
436
|
+
message: `DashboardStore: moveWidget: Widget already at min/max position (${i})`,
|
|
437
|
+
updatedDashboardConfig: e
|
|
438
|
+
};
|
|
439
|
+
const g = [...l], [f] = g.splice(d, 1);
|
|
440
|
+
return g.splice(c, 0, f), {
|
|
441
|
+
success: !0,
|
|
442
|
+
updatedDashboardConfig: {
|
|
443
|
+
...e,
|
|
444
|
+
childWidgetsConfig: [...s, ...g]
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
} else {
|
|
448
|
+
const s = e.widgets || [], l = s.map((g) => `${g}`.trim().toLowerCase()).indexOf(r);
|
|
449
|
+
let o = l + t;
|
|
450
|
+
if (o = Math.max(0, o), o = Math.min(s.length - 1, o), o === l)
|
|
451
|
+
return {
|
|
452
|
+
success: !1,
|
|
453
|
+
message: `DashboardStore: moveWidget: Widget already at min/max position (${i})`,
|
|
454
|
+
updatedDashboardConfig: e
|
|
455
|
+
};
|
|
456
|
+
const d = [...s], [c] = d.splice(l, 1);
|
|
457
|
+
return d.splice(o, 0, c), {
|
|
458
|
+
success: !0,
|
|
459
|
+
updatedDashboardConfig: {
|
|
460
|
+
...e,
|
|
461
|
+
widgets: d
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}, _ = (e, t = "color") => {
|
|
302
467
|
if (typeof window > "u") return "#FFFFFF";
|
|
303
|
-
const
|
|
304
|
-
Array.isArray(e) ? e.forEach((
|
|
305
|
-
const
|
|
306
|
-
return document.body.removeChild(
|
|
468
|
+
const i = document.createElement("div");
|
|
469
|
+
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);
|
|
470
|
+
const a = window.getComputedStyle(i)[t];
|
|
471
|
+
return document.body.removeChild(i), a;
|
|
307
472
|
}, G = {
|
|
308
473
|
/**
|
|
309
474
|
* @name getCssVariableValue
|
|
@@ -333,8 +498,8 @@ const w = [
|
|
|
333
498
|
*/
|
|
334
499
|
restoreCssVarsFromSettings: (e) => {
|
|
335
500
|
const t = document.documentElement;
|
|
336
|
-
e.forEach((
|
|
337
|
-
t.style.setProperty(
|
|
501
|
+
e.forEach((i) => {
|
|
502
|
+
t.style.setProperty(i.cssProperty, i.value);
|
|
338
503
|
});
|
|
339
504
|
}
|
|
340
505
|
}, Z = (e, ...t) => [
|
|
@@ -343,28 +508,29 @@ const w = [
|
|
|
343
508
|
)
|
|
344
509
|
].join(" ").trim();
|
|
345
510
|
export {
|
|
346
|
-
|
|
347
|
-
|
|
511
|
+
h as DashboardMaxZoomScale,
|
|
512
|
+
p as DashboardMinZoomScale,
|
|
348
513
|
V as DashboardZoomStep,
|
|
349
|
-
|
|
350
|
-
|
|
514
|
+
U as blankDashboardConfig,
|
|
515
|
+
C as createDynamicEntry,
|
|
351
516
|
k as createStaticEntry,
|
|
352
|
-
|
|
517
|
+
W as cssSettingsCatalog,
|
|
353
518
|
G as cssVarsUtils,
|
|
354
519
|
E as dashboardSettingsUtils,
|
|
520
|
+
O as dashboardStoreUtils,
|
|
355
521
|
x as ensureContainersSequence,
|
|
356
|
-
|
|
522
|
+
K as ensureZoomScaleIsWithinRange,
|
|
357
523
|
m as getDefaultWidgetMetaFromKey,
|
|
358
|
-
|
|
524
|
+
M as getDefaultWidgetMetaFromMap,
|
|
359
525
|
Z as getDistinctCssClasses,
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
526
|
+
N as getMetaInfoFromFile,
|
|
527
|
+
L as getNewZoomScaleWithinRange,
|
|
528
|
+
I as getWidgetMetaFromCatalog,
|
|
529
|
+
R as localWidgetDiscovery,
|
|
530
|
+
z as parseContainerTitle,
|
|
365
531
|
F as parseKeyAndTitleFromFilePath,
|
|
366
532
|
A as remoteWidgetDiscovery,
|
|
367
|
-
|
|
368
|
-
|
|
533
|
+
j as removeEmptyContainers,
|
|
534
|
+
_ as resolveColorFromClass,
|
|
369
535
|
P as useDashboardStorageService
|
|
370
536
|
};
|