@tenorlab/react-dashboard 1.4.2 → 1.4.4
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/README.md +346 -22
- package/dist/core.d.ts +2 -1
- package/dist/core.es.js +69 -67
- package/dist/react-dashboard.d.ts +50 -0
- package/dist/react-dashboard.es.js +880 -874
- package/package.json +2 -2
package/dist/core.es.js
CHANGED
|
@@ -85,60 +85,60 @@ const w = [
|
|
|
85
85
|
* @returns the update item
|
|
86
86
|
*/
|
|
87
87
|
incrementOrDecrementValue: (e, t) => {
|
|
88
|
-
const
|
|
88
|
+
const a = e.value.match(/([\d.]+)/), i = a ? parseFloat(a[1]) : 0, s = e.value.match(/([^\d.]+)/), n = s ? s[1] : e.defaultUnit, r = b(n, e.step) * t, c = `${Math.max(i + r, e.minValue).toFixed(1)}${n}`;
|
|
89
89
|
return {
|
|
90
90
|
...e,
|
|
91
91
|
value: c
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
}, f = (e, t) => `dashboards_${t}_${e}`, v = async (e, t,
|
|
94
|
+
}, f = (e, t) => `dashboards_${t}_${e}`, v = async (e, t, a, i) => {
|
|
95
95
|
const s = localStorage.getItem(f(e, t));
|
|
96
96
|
if (s)
|
|
97
97
|
try {
|
|
98
98
|
const n = JSON.parse(s);
|
|
99
|
-
return n.length < 1 ? [
|
|
100
|
-
r.dashboardId || (r.dashboardId = "default"), r.dashboardName || (r.dashboardName = `Dashboard ${r.dashboardId}`), r.responsiveGrid = r.responsiveGrid ?? !1, (r.widgets || []).length < 1 && (r.widgets =
|
|
99
|
+
return n.length < 1 ? [i] : (n.forEach((r) => {
|
|
100
|
+
r.dashboardId || (r.dashboardId = "default"), r.dashboardName || (r.dashboardName = `Dashboard ${r.dashboardId}`), r.responsiveGrid = r.responsiveGrid ?? !1, (r.widgets || []).length < 1 && (r.widgets = i.widgets);
|
|
101
101
|
const c = (r.cssSettings || []).filter(
|
|
102
|
-
(o) =>
|
|
102
|
+
(o) => i.cssSettings.some((d) => d.key === o.key)
|
|
103
103
|
);
|
|
104
104
|
if (c.length < 1)
|
|
105
|
-
r.cssSettings = [...
|
|
105
|
+
r.cssSettings = [...i.cssSettings];
|
|
106
106
|
else {
|
|
107
107
|
c.forEach((d) => {
|
|
108
108
|
d.value = (d.value || "").replace(/NaN/g, "");
|
|
109
|
-
const l =
|
|
109
|
+
const l = i.cssSettings.find(
|
|
110
110
|
(g) => g.key === d.key
|
|
111
111
|
);
|
|
112
112
|
l && (Object.keys(l).forEach((g) => {
|
|
113
113
|
g in d || (d[g] = l[g]);
|
|
114
114
|
}), d.step = l.step, d.minValue = l.minValue, d.defaultValue = l.defaultValue, d.defaultUnit = l.defaultUnit, /\d+/g.test(d.value) === !1 && (d.value = l ? l.value : "1.0rem"));
|
|
115
115
|
});
|
|
116
|
-
const o =
|
|
116
|
+
const o = i.cssSettings.filter((d) => !c.some(
|
|
117
117
|
(l) => l.key === d.key
|
|
118
118
|
));
|
|
119
119
|
r.cssSettings = [...c, ...o];
|
|
120
120
|
}
|
|
121
121
|
r.widgets = r.widgets.filter(
|
|
122
|
-
(o) => o.includes("WidgetContainer") ||
|
|
122
|
+
(o) => o.includes("WidgetContainer") || a.has(o)
|
|
123
123
|
), r.childWidgetsConfig = r.childWidgetsConfig.filter(
|
|
124
|
-
(o) =>
|
|
124
|
+
(o) => a.has(o.widgetKey)
|
|
125
125
|
), r.zoomScale ? r.zoomScale < 0.7 && (r.zoomScale = 0.7) : r.zoomScale = 1;
|
|
126
126
|
}), n);
|
|
127
127
|
} catch (n) {
|
|
128
128
|
console.warn("Error parsing saved dashboard config:", n);
|
|
129
129
|
}
|
|
130
|
-
return [
|
|
131
|
-
}, C = async (e, t,
|
|
132
|
-
|
|
130
|
+
return [i];
|
|
131
|
+
}, C = async (e, t, a, i) => {
|
|
132
|
+
a.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
|
-
(r) => r.includes("WidgetContainer") ||
|
|
136
|
+
(r) => r.includes("WidgetContainer") || i.has(r)
|
|
137
137
|
), n.childWidgetsConfig = n.childWidgetsConfig.filter(
|
|
138
|
-
(r) =>
|
|
138
|
+
(r) => i.has(r.widgetKey)
|
|
139
139
|
), n.zoomScale ? n.zoomScale < 0.7 && (n.zoomScale = 0.7) : n.zoomScale = 1;
|
|
140
140
|
});
|
|
141
|
-
const s = JSON.stringify(
|
|
141
|
+
const s = JSON.stringify(a);
|
|
142
142
|
return localStorage.setItem(f(e, t), s), !0;
|
|
143
143
|
}, W = {
|
|
144
144
|
getSavedDashboards: v,
|
|
@@ -160,92 +160,94 @@ const w = [
|
|
|
160
160
|
let t = Number(e || 0);
|
|
161
161
|
return t < m && (t = m), t > p && (t = p), t;
|
|
162
162
|
}, j = (e, t) => {
|
|
163
|
-
let
|
|
164
|
-
return D(
|
|
163
|
+
let a = Number(Number((V * t).toFixed(2)).toFixed(2)), i = Number((Number(e) + a).toFixed(2));
|
|
164
|
+
return D(i);
|
|
165
165
|
}, N = (e) => {
|
|
166
166
|
let t = {
|
|
167
167
|
...e
|
|
168
168
|
};
|
|
169
|
-
return t.widgets = t.widgets.filter((
|
|
170
|
-
if (`${
|
|
171
|
-
const
|
|
172
|
-
(s) => s.parentWidgetKey ===
|
|
169
|
+
return t.widgets = t.widgets.filter((a) => {
|
|
170
|
+
if (`${a}`.includes("WidgetContainer")) {
|
|
171
|
+
const i = t.childWidgetsConfig.filter(
|
|
172
|
+
(s) => s.parentWidgetKey === a
|
|
173
173
|
);
|
|
174
|
-
if (!
|
|
174
|
+
if (!i || i.length === 0)
|
|
175
175
|
return t.widgets = t.widgets.filter(
|
|
176
|
-
(s) => s !==
|
|
176
|
+
(s) => s !== a
|
|
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
|
-
i
|
|
188
|
-
}), e.widgets = e.widgets.map((
|
|
189
|
-
const s =
|
|
183
|
+
(i) => i.includes("WidgetContainer")
|
|
184
|
+
), a = {};
|
|
185
|
+
return t.forEach((i, s) => {
|
|
186
|
+
const n = `${i.split("_container")[0]}_container${s + 1}`;
|
|
187
|
+
a[i] = n;
|
|
188
|
+
}), e.widgets = e.widgets.map((i) => a[i] || i), e.childWidgetsConfig = e.childWidgetsConfig.map((i) => {
|
|
189
|
+
const s = i.parentWidgetKey, n = a[s];
|
|
190
190
|
return {
|
|
191
|
-
...
|
|
191
|
+
...i,
|
|
192
192
|
// If a new key exists, use it. If not, keep the original key.
|
|
193
193
|
parentWidgetKey: n || s
|
|
194
194
|
};
|
|
195
195
|
}), e;
|
|
196
196
|
}, u = (e, t) => {
|
|
197
|
-
const
|
|
197
|
+
const a = `${e}`.includes("Container"), i = a ? ["Container"] : ["Widget"], s = t?.name || e, n = t?.description || (a ? "Container" : "Unknown");
|
|
198
198
|
return {
|
|
199
199
|
name: s,
|
|
200
200
|
description: n,
|
|
201
|
-
categories:
|
|
201
|
+
categories: i,
|
|
202
202
|
noDuplicatedWidgets: !0,
|
|
203
203
|
icon: void 0,
|
|
204
204
|
externalDependencies: []
|
|
205
205
|
};
|
|
206
|
-
}, I = (e, t,
|
|
207
|
-
const
|
|
206
|
+
}, I = (e, t, a) => t[e] || u(e, a), M = (e, t) => t.get(e)?.meta || u(e), k = (e, t, a) => {
|
|
207
|
+
const i = a || u(e);
|
|
208
208
|
return [
|
|
209
209
|
e,
|
|
210
210
|
{
|
|
211
211
|
key: e,
|
|
212
|
-
title:
|
|
212
|
+
title: i.name,
|
|
213
213
|
isContainer: `${e}`.includes("Container"),
|
|
214
|
-
|
|
214
|
+
isRemote: !1,
|
|
215
|
+
meta: i,
|
|
215
216
|
component: t
|
|
216
217
|
}
|
|
217
218
|
];
|
|
218
|
-
}, h = (e, t, i) => {
|
|
219
|
-
const
|
|
219
|
+
}, h = (e, t, a, i) => {
|
|
220
|
+
const s = i || u(e);
|
|
220
221
|
return [
|
|
221
222
|
e,
|
|
222
223
|
{
|
|
223
224
|
key: e,
|
|
224
|
-
title:
|
|
225
|
+
title: s.name,
|
|
225
226
|
isContainer: !1,
|
|
226
|
-
|
|
227
|
+
isRemote: a,
|
|
228
|
+
meta: s,
|
|
227
229
|
loader: t
|
|
228
230
|
}
|
|
229
231
|
];
|
|
230
232
|
}, F = (e) => {
|
|
231
233
|
const t = e.match(/\/widget-([a-zA-Z0-9-]+)\/index\.ts$/);
|
|
232
234
|
if (t && t[1]) {
|
|
233
|
-
const
|
|
235
|
+
const a = t[1], i = a.split("-"), s = `Widget${i.map((r) => r.charAt(0).toUpperCase() + r.slice(1)).join("")}`, n = i.map((r) => r.charAt(0).toUpperCase() + r.slice(1)).join(" ");
|
|
234
236
|
return {
|
|
235
237
|
key: s,
|
|
236
238
|
title: n,
|
|
237
|
-
folder:
|
|
239
|
+
folder: a
|
|
238
240
|
};
|
|
239
241
|
}
|
|
240
242
|
return null;
|
|
241
|
-
}, $ = (e, t,
|
|
242
|
-
const s = `${t}/widget-${
|
|
243
|
+
}, $ = (e, t, a, i) => {
|
|
244
|
+
const s = `${t}/widget-${a}/meta.ts`, n = e[s];
|
|
243
245
|
if (!n)
|
|
244
246
|
return;
|
|
245
|
-
const r = `${
|
|
247
|
+
const r = `${i}Meta`;
|
|
246
248
|
return n[r] || void 0;
|
|
247
|
-
}, A = async (e) => new Promise(async (t,
|
|
248
|
-
const
|
|
249
|
+
}, A = async (e) => new Promise(async (t, a) => {
|
|
250
|
+
const i = [];
|
|
249
251
|
try {
|
|
250
252
|
const s = await (await fetch(`${e}?${Math.random()}`)).json();
|
|
251
253
|
for (const n in s) {
|
|
@@ -261,32 +263,32 @@ const w = [
|
|
|
261
263
|
// Or a logic to map a string name to a Lucide component
|
|
262
264
|
externalDependencies: r.meta?.externalDependencies || []
|
|
263
265
|
};
|
|
264
|
-
|
|
266
|
+
i.push(h(n, c, !0, o));
|
|
265
267
|
}
|
|
266
268
|
t({
|
|
267
|
-
entries:
|
|
269
|
+
entries: i,
|
|
268
270
|
message: "",
|
|
269
271
|
details: ""
|
|
270
272
|
});
|
|
271
273
|
} catch (s) {
|
|
272
|
-
console.error("Remote plugin discovery failed:", s),
|
|
274
|
+
console.error("Remote plugin discovery failed:", s), a({
|
|
273
275
|
entries: [],
|
|
274
276
|
message: "Remote plugin discovery failed:",
|
|
275
277
|
details: typeof s == "object" ? JSON.stringify(s) : s
|
|
276
278
|
});
|
|
277
279
|
}
|
|
278
|
-
}), K = (e, t,
|
|
280
|
+
}), K = (e, t, a, i = !0) => {
|
|
279
281
|
const s = [];
|
|
280
282
|
for (const n in t) {
|
|
281
283
|
const r = t[n], c = F(n);
|
|
282
284
|
if (c && r) {
|
|
283
285
|
const { key: o, title: d, folder: l } = c;
|
|
284
|
-
let g = $(
|
|
286
|
+
let g = $(a, e, l, o);
|
|
285
287
|
if (g || (g = u(o, {
|
|
286
|
-
description: `Local ${
|
|
287
|
-
})),
|
|
288
|
+
description: `Local ${i ? "dynamic" : "static"} widget`
|
|
289
|
+
})), i)
|
|
288
290
|
s.push(
|
|
289
|
-
h(o, r, g)
|
|
291
|
+
h(o, r, !1, g)
|
|
290
292
|
);
|
|
291
293
|
else {
|
|
292
294
|
const y = r.default || r;
|
|
@@ -295,13 +297,13 @@ const w = [
|
|
|
295
297
|
}
|
|
296
298
|
}
|
|
297
299
|
return s;
|
|
298
|
-
},
|
|
300
|
+
}, R = (e, t = "color") => {
|
|
299
301
|
if (typeof window > "u") return "#FFFFFF";
|
|
300
|
-
const
|
|
301
|
-
Array.isArray(e) ? e.forEach((s) =>
|
|
302
|
-
const
|
|
303
|
-
return document.body.removeChild(
|
|
304
|
-
},
|
|
302
|
+
const a = document.createElement("div");
|
|
303
|
+
Array.isArray(e) ? e.forEach((s) => a.classList.add(s)) : e.split(" ").forEach((s) => a.classList.add(s)), a.style.display = "none", document.body.appendChild(a);
|
|
304
|
+
const i = window.getComputedStyle(a)[t];
|
|
305
|
+
return document.body.removeChild(a), i;
|
|
306
|
+
}, G = {
|
|
305
307
|
/**
|
|
306
308
|
* @name getCssVariableValue
|
|
307
309
|
* @description Return the value of a CSS custom property from the current HTML document
|
|
@@ -330,8 +332,8 @@ const w = [
|
|
|
330
332
|
*/
|
|
331
333
|
restoreCssVarsFromSettings: (e) => {
|
|
332
334
|
const t = document.documentElement;
|
|
333
|
-
e.forEach((
|
|
334
|
-
t.style.setProperty(
|
|
335
|
+
e.forEach((a) => {
|
|
336
|
+
t.style.setProperty(a.cssProperty, a.value);
|
|
335
337
|
});
|
|
336
338
|
}
|
|
337
339
|
}, Z = (e, ...t) => [
|
|
@@ -347,7 +349,7 @@ export {
|
|
|
347
349
|
h as createDynamicEntry,
|
|
348
350
|
k as createStaticEntry,
|
|
349
351
|
w as cssSettingsCatalog,
|
|
350
|
-
|
|
352
|
+
G as cssVarsUtils,
|
|
351
353
|
E as dashboardSettingsUtils,
|
|
352
354
|
x as ensureContainersSequence,
|
|
353
355
|
D as ensureZoomScaleIsWithinRange,
|
|
@@ -362,6 +364,6 @@ export {
|
|
|
362
364
|
F as parseKeyAndTitleFromFilePath,
|
|
363
365
|
A as remoteWidgetDiscovery,
|
|
364
366
|
N as removeEmptyContainers,
|
|
365
|
-
|
|
367
|
+
R as resolveColorFromClass,
|
|
366
368
|
P as useDashboardStorageService
|
|
367
369
|
};
|
|
@@ -97,6 +97,11 @@ export declare interface IDashboardConfig {
|
|
|
97
97
|
_stateDescription?: string;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* @name IDashboardGridProps
|
|
102
|
+
* @description Dashboard grid properties interface specific to React framework.
|
|
103
|
+
* This interface extends the base dashboard grid properties interface with optional children.
|
|
104
|
+
*/
|
|
100
105
|
export declare interface IDashboardGridProps extends IDashboardGridPropsBase {
|
|
101
106
|
children?: ReactNode;
|
|
102
107
|
}
|
|
@@ -124,9 +129,20 @@ export declare interface IDashboardStorageService {
|
|
|
124
129
|
saveDashboards: TSaveDashboards;
|
|
125
130
|
}
|
|
126
131
|
|
|
132
|
+
/**
|
|
133
|
+
* @name IDashboardWidget
|
|
134
|
+
* @description A type representing a React dashboard widget element.
|
|
135
|
+
* This type is defined as a JSX.Element.
|
|
136
|
+
*/
|
|
127
137
|
export declare interface IDashboardWidget extends JSX.Element {
|
|
128
138
|
}
|
|
129
139
|
|
|
140
|
+
/**
|
|
141
|
+
* @name IDashboardWidgetProps
|
|
142
|
+
* @description Dashboard widget properties interface specific to React framework.
|
|
143
|
+
* This interface extends the base dashboard widget properties interface with additional React-specific properties.
|
|
144
|
+
* @template TExtraProps - Additional properties specific to the widget.
|
|
145
|
+
*/
|
|
130
146
|
export declare interface IDashboardWidgetProps<TExtraProps = any> extends IDashboardWidgetPropsBase<TExtraProps> {
|
|
131
147
|
children?: ReactNode;
|
|
132
148
|
onRemoveClick?: (widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => void;
|
|
@@ -154,6 +170,13 @@ export declare interface IDashboardWidgetPropsBase<TExtraProps = any> {
|
|
|
154
170
|
extraProps?: TExtraProps;
|
|
155
171
|
}
|
|
156
172
|
|
|
173
|
+
/**
|
|
174
|
+
* @name IDynamicWidgetCatalogEntry
|
|
175
|
+
* @description Dynamic widget catalog entry interface specific to React framework.
|
|
176
|
+
* This interface extends the base dynamic widget catalog entry interface with React-specific element and component types.
|
|
177
|
+
* @template TFrameworkElementType - The React element type.
|
|
178
|
+
* @template TFrameworkComponentType - The React component type.
|
|
179
|
+
*/
|
|
157
180
|
export declare interface IDynamicWidgetCatalogEntry extends IDynamicWidgetCatalogEntryBase<TFrameworkElementType, TFrameworkComponentType> {
|
|
158
181
|
}
|
|
159
182
|
|
|
@@ -169,6 +192,7 @@ export declare interface IDynamicWidgetCatalogEntryBase<TFrameworkElementType =
|
|
|
169
192
|
key: TDashboardWidgetKey;
|
|
170
193
|
title: string;
|
|
171
194
|
isContainer?: boolean;
|
|
195
|
+
isRemote?: boolean;
|
|
172
196
|
meta?: TWidgetMetaInfoBase<TFrameworkElementType>;
|
|
173
197
|
component?: TFrameworkComponentType;
|
|
174
198
|
loader?: TWidgetFactoryBase<TFrameworkComponentType>;
|
|
@@ -280,6 +304,13 @@ export declare type TDashboardUndoStatus = {
|
|
|
280
304
|
_historyLength?: number;
|
|
281
305
|
};
|
|
282
306
|
|
|
307
|
+
/**
|
|
308
|
+
* @name TDashboardWidgetCatalog
|
|
309
|
+
* @description Dashboard widget catalog type specific to React framework.
|
|
310
|
+
* This type extends the base dashboard widget catalog type with React-specific element and component types.
|
|
311
|
+
* @template TFrameworkElementType - The React element type.
|
|
312
|
+
* @template TFrameworkComponentType - The React component type.
|
|
313
|
+
*/
|
|
283
314
|
export declare type TDashboardWidgetCatalog = TDashboardWidgetCatalogBase<TFrameworkElementType, TFrameworkComponentType>;
|
|
284
315
|
|
|
285
316
|
export declare type TDashboardWidgetCatalogBase<TFrameworkElementType = any, TFrameworkComponentType = any> = Map<TDashboardWidgetKey, IDynamicWidgetCatalogEntryBase<TFrameworkElementType, TFrameworkComponentType>>;
|
|
@@ -306,8 +337,16 @@ declare type TDynamicWidgetLoaderProps<TExtraProps = any> = {
|
|
|
306
337
|
*/
|
|
307
338
|
export declare const TextField: default_2.FC<ITextFieldProps>;
|
|
308
339
|
|
|
340
|
+
/**
|
|
341
|
+
* @name TFrameworkComponentType
|
|
342
|
+
* @description A type representing a React component type.
|
|
343
|
+
*/
|
|
309
344
|
declare type TFrameworkComponentType = React.ComponentType<any>;
|
|
310
345
|
|
|
346
|
+
/**
|
|
347
|
+
* @name TFrameworkElementType
|
|
348
|
+
* @description A type representing a React element type.
|
|
349
|
+
*/
|
|
311
350
|
declare type TFrameworkElementType = React.ElementType;
|
|
312
351
|
|
|
313
352
|
declare type TGetSavedDashboards = (userID: number | string, clientAppKey: string, widgetCatalog: TDashboardWidgetCatalogBase, defaultDashboardConfig: IDashboardConfig) => Promise<IDashboardConfig[]>;
|
|
@@ -357,6 +396,12 @@ export declare type TWidgetCategory = 'Widget' | 'Chart' | 'Container';
|
|
|
357
396
|
|
|
358
397
|
export declare type TWidgetDirection = 'row' | 'column';
|
|
359
398
|
|
|
399
|
+
/**
|
|
400
|
+
* @name TWidgetFactory
|
|
401
|
+
* @description A type representing a widget factory function specific to React framework.
|
|
402
|
+
* This type extends the base widget factory type with React-specific component type.
|
|
403
|
+
* @template TFrameworkComponentType - The React component type.
|
|
404
|
+
*/
|
|
360
405
|
export declare type TWidgetFactory = TWidgetFactoryBase<TFrameworkComponentType>;
|
|
361
406
|
|
|
362
407
|
/**
|
|
@@ -371,6 +416,11 @@ export declare type TWidgetFactoryBase<TFrameworkComponent = any> = () => Promis
|
|
|
371
416
|
default: TFrameworkComponent;
|
|
372
417
|
}>;
|
|
373
418
|
|
|
419
|
+
/**
|
|
420
|
+
* @name TWidgetMetaInfo
|
|
421
|
+
* @description Widget meta information type specific to React framework.
|
|
422
|
+
* This type extends the base widget meta information type with React-specific element type.
|
|
423
|
+
*/
|
|
374
424
|
export declare type TWidgetMetaInfo = TWidgetMetaInfoBase<TFrameworkElementType | undefined>;
|
|
375
425
|
|
|
376
426
|
export declare type TWidgetMetaInfoBase<TFrameworkElementType = any> = {
|