@tenorlab/react-dashboard 1.2.8 → 1.2.9
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/components/index.d.ts +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/react-dashboard.es.js +57 -57
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
import ae, { useState as se, useCallback as ce, useMemo as ot, forwardRef as le, useRef as wt, Suspense as Ct, useEffect as St } from "react";
|
|
2
2
|
import { jsxs as $, jsx as s } from "react/jsx-runtime";
|
|
3
3
|
import st from "react-dom";
|
|
4
|
-
const
|
|
4
|
+
const je = (e) => {
|
|
5
|
+
let n;
|
|
6
|
+
const t = /* @__PURE__ */ new Set(), r = (p, g) => {
|
|
7
|
+
const c = typeof p == "function" ? p(n) : p;
|
|
8
|
+
if (!Object.is(c, n)) {
|
|
9
|
+
const b = n;
|
|
10
|
+
n = g ?? (typeof c != "object" || c === null) ? c : Object.assign({}, n, c), t.forEach((v) => v(n, b));
|
|
11
|
+
}
|
|
12
|
+
}, a = () => n, u = { setState: r, getState: a, getInitialState: () => y, subscribe: (p) => (t.add(p), () => t.delete(p)) }, y = n = e(r, a, u);
|
|
13
|
+
return u;
|
|
14
|
+
}, Dt = ((e) => e ? je(e) : je), Tt = (e) => e;
|
|
15
|
+
function Et(e, n = Tt) {
|
|
16
|
+
const t = ae.useSyncExternalStore(
|
|
17
|
+
e.subscribe,
|
|
18
|
+
ae.useCallback(() => n(e.getState()), [e, n]),
|
|
19
|
+
ae.useCallback(() => n(e.getInitialState()), [e, n])
|
|
20
|
+
);
|
|
21
|
+
return ae.useDebugValue(t), t;
|
|
22
|
+
}
|
|
23
|
+
const Nt = (e) => {
|
|
24
|
+
const n = Dt(e), t = (r) => Et(n, r);
|
|
25
|
+
return Object.assign(t, n), t;
|
|
26
|
+
}, _t = ((e) => Nt), Mt = [
|
|
5
27
|
{
|
|
6
28
|
key: "grid-gap",
|
|
7
29
|
name: "Gap",
|
|
@@ -79,15 +101,15 @@ const Dt = [
|
|
|
79
101
|
defaultValue: "1.0rem",
|
|
80
102
|
value: "1.0rem"
|
|
81
103
|
}
|
|
82
|
-
],
|
|
104
|
+
], Pt = ["rem", "pc", "cm", "in", "em", "vh", "vw", "%"], $t = (e, n) => Pt.includes(e) ? n : 1, Wt = {
|
|
83
105
|
incrementOrDecrementValue: (e, n) => {
|
|
84
|
-
const t = e.value.match(/([\d.]+)/), r = t ? parseFloat(t[1]) : 0, a = e.value.match(/([^\d.]+)/), i = a ? a[1] : e.defaultUnit, o =
|
|
106
|
+
const t = e.value.match(/([\d.]+)/), r = t ? parseFloat(t[1]) : 0, a = e.value.match(/([^\d.]+)/), i = a ? a[1] : e.defaultUnit, o = $t(i, e.step) * n, u = `${Math.max(r + o, e.minValue).toFixed(1)}${i}`;
|
|
85
107
|
return {
|
|
86
108
|
...e,
|
|
87
109
|
value: u
|
|
88
110
|
};
|
|
89
111
|
}
|
|
90
|
-
}, lt = (e, n) => `dashboards_${n}_${e}`,
|
|
112
|
+
}, lt = (e, n) => `dashboards_${n}_${e}`, It = async (e, n, t, r) => {
|
|
91
113
|
const a = localStorage.getItem(lt(e, n));
|
|
92
114
|
if (a)
|
|
93
115
|
try {
|
|
@@ -124,7 +146,7 @@ const Dt = [
|
|
|
124
146
|
console.warn("Error parsing saved dashboard config:", i);
|
|
125
147
|
}
|
|
126
148
|
return [r];
|
|
127
|
-
},
|
|
149
|
+
}, Rt = async (e, n, t, r) => {
|
|
128
150
|
t.forEach((i) => {
|
|
129
151
|
if (i.userID = e, i.clientAppKey = n, i.responsiveGrid = i.responsiveGrid ?? !1, typeof i != "object")
|
|
130
152
|
throw new Error("Invalid dashboard configuration");
|
|
@@ -136,10 +158,10 @@ const Dt = [
|
|
|
136
158
|
});
|
|
137
159
|
const a = JSON.stringify(t);
|
|
138
160
|
return localStorage.setItem(lt(e, n), a), !0;
|
|
139
|
-
},
|
|
140
|
-
getSavedDashboards:
|
|
141
|
-
saveDashboards:
|
|
142
|
-
}, Mn = () =>
|
|
161
|
+
}, Ot = {
|
|
162
|
+
getSavedDashboards: It,
|
|
163
|
+
saveDashboards: Rt
|
|
164
|
+
}, Mn = () => Ot, we = {
|
|
143
165
|
userID: 0,
|
|
144
166
|
clientAppKey: "",
|
|
145
167
|
dashboardId: "default",
|
|
@@ -148,15 +170,15 @@ const Dt = [
|
|
|
148
170
|
responsiveGrid: !1,
|
|
149
171
|
widgets: [],
|
|
150
172
|
childWidgetsConfig: [],
|
|
151
|
-
cssSettings: [...
|
|
173
|
+
cssSettings: [...Mt]
|
|
152
174
|
}, dt = (e) => {
|
|
153
175
|
const n = `${e}`.split("_");
|
|
154
176
|
return n.length > 1 ? n[1].replace(/(\D)(\d+)/, "$1 $2") : "Container";
|
|
155
|
-
},
|
|
177
|
+
}, Ae = 0.7, Fe = 1, kt = 0.05, ct = (e) => {
|
|
156
178
|
let n = Number(e || 0);
|
|
157
|
-
return n <
|
|
179
|
+
return n < Ae && (n = Ae), n > Fe && (n = Fe), n;
|
|
158
180
|
}, Pn = (e, n) => {
|
|
159
|
-
let t = Number(Number((
|
|
181
|
+
let t = Number(Number((kt * n).toFixed(2)).toFixed(2)), r = Number((Number(e) + t).toFixed(2));
|
|
160
182
|
return ct(r);
|
|
161
183
|
}, $n = (e) => {
|
|
162
184
|
let n = {
|
|
@@ -174,7 +196,7 @@ const Dt = [
|
|
|
174
196
|
}
|
|
175
197
|
return !0;
|
|
176
198
|
}), n;
|
|
177
|
-
},
|
|
199
|
+
}, jt = (e) => {
|
|
178
200
|
const n = e.widgets.filter(
|
|
179
201
|
(r) => r.includes("WidgetContainer")
|
|
180
202
|
), t = {};
|
|
@@ -199,7 +221,7 @@ const Dt = [
|
|
|
199
221
|
icon: void 0,
|
|
200
222
|
externalDependencies: []
|
|
201
223
|
};
|
|
202
|
-
}, Wn = (e, n, t) => n[e] || he(e, t),
|
|
224
|
+
}, Wn = (e, n, t) => n[e] || he(e, t), At = (e, n) => n.get(e)?.meta || he(e), Ft = (e, n, t) => {
|
|
203
225
|
const r = t || he(e);
|
|
204
226
|
return [
|
|
205
227
|
e,
|
|
@@ -223,7 +245,7 @@ const Dt = [
|
|
|
223
245
|
loader: n
|
|
224
246
|
}
|
|
225
247
|
];
|
|
226
|
-
},
|
|
248
|
+
}, Lt = (e) => {
|
|
227
249
|
const n = e.match(/\/widget-([a-zA-Z0-9-]+)\/index\.ts$/);
|
|
228
250
|
if (n && n[1]) {
|
|
229
251
|
const t = n[1], r = t.split("-"), a = `Widget${r.map((o) => o.charAt(0).toUpperCase() + o.slice(1)).join("")}`, i = r.map((o) => o.charAt(0).toUpperCase() + o.slice(1)).join(" ");
|
|
@@ -234,7 +256,7 @@ const Dt = [
|
|
|
234
256
|
};
|
|
235
257
|
}
|
|
236
258
|
return null;
|
|
237
|
-
},
|
|
259
|
+
}, Ut = (e, n, t, r) => {
|
|
238
260
|
const a = `${n}/widget-${t}/meta.ts`, i = e[a];
|
|
239
261
|
if (!i)
|
|
240
262
|
return;
|
|
@@ -274,10 +296,10 @@ const Dt = [
|
|
|
274
296
|
}), Rn = (e, n, t, r = !0) => {
|
|
275
297
|
const a = [];
|
|
276
298
|
for (const i in n) {
|
|
277
|
-
const o = n[i], u =
|
|
299
|
+
const o = n[i], u = Lt(i);
|
|
278
300
|
if (u && o) {
|
|
279
301
|
const { key: y, title: p, folder: g } = u;
|
|
280
|
-
let c =
|
|
302
|
+
let c = Ut(t, e, g, y);
|
|
281
303
|
if (c || (c = he(y, {
|
|
282
304
|
description: `Local ${r ? "dynamic" : "static"} widget`
|
|
283
305
|
})), r)
|
|
@@ -286,7 +308,7 @@ const Dt = [
|
|
|
286
308
|
);
|
|
287
309
|
else {
|
|
288
310
|
const b = o.default || o;
|
|
289
|
-
a.push(
|
|
311
|
+
a.push(Ft(y, b, c));
|
|
290
312
|
}
|
|
291
313
|
}
|
|
292
314
|
}
|
|
@@ -334,29 +356,7 @@ const Dt = [
|
|
|
334
356
|
...new Set(
|
|
335
357
|
[e || "", ...n].join(" ").trim().replace(/\n+/gi, " ").replace(/\s+/gi, " ").split(" ")
|
|
336
358
|
)
|
|
337
|
-
].join(" ").trim(),
|
|
338
|
-
let n;
|
|
339
|
-
const t = /* @__PURE__ */ new Set(), r = (p, g) => {
|
|
340
|
-
const c = typeof p == "function" ? p(n) : p;
|
|
341
|
-
if (!Object.is(c, n)) {
|
|
342
|
-
const b = n;
|
|
343
|
-
n = g ?? (typeof c != "object" || c === null) ? c : Object.assign({}, n, c), t.forEach((v) => v(n, b));
|
|
344
|
-
}
|
|
345
|
-
}, a = () => n, u = { setState: r, getState: a, getInitialState: () => y, subscribe: (p) => (t.add(p), () => t.delete(p)) }, y = n = e(r, a, u);
|
|
346
|
-
return u;
|
|
347
|
-
}, jt = ((e) => e ? Fe(e) : Fe), At = (e) => e;
|
|
348
|
-
function Ft(e, n = At) {
|
|
349
|
-
const t = ae.useSyncExternalStore(
|
|
350
|
-
e.subscribe,
|
|
351
|
-
ae.useCallback(() => n(e.getState()), [e, n]),
|
|
352
|
-
ae.useCallback(() => n(e.getInitialState()), [e, n])
|
|
353
|
-
);
|
|
354
|
-
return ae.useDebugValue(t), t;
|
|
355
|
-
}
|
|
356
|
-
const Lt = (e) => {
|
|
357
|
-
const n = jt(e), t = (r) => Ft(n, r);
|
|
358
|
-
return Object.assign(t, n), t;
|
|
359
|
-
}, Ut = ((e) => Lt), Vt = (e) => {
|
|
359
|
+
].join(" ").trim(), Vt = (e) => {
|
|
360
360
|
const n = e.widgets.filter((r) => r.includes("WidgetContainer")).map((r) => Number(r.split("_")[1].replace("container", "")));
|
|
361
361
|
return `container${n.length > 0 ? Math.max(...n) + 1 : 1}`;
|
|
362
362
|
}, qt = (e, n) => {
|
|
@@ -412,7 +412,7 @@ const Lt = (e) => {
|
|
|
412
412
|
...e,
|
|
413
413
|
childWidgetsConfig: i
|
|
414
414
|
};
|
|
415
|
-
return `${n}`.includes("Container") && (o =
|
|
415
|
+
return `${n}`.includes("Container") && (o = jt(o)), {
|
|
416
416
|
success: !0,
|
|
417
417
|
updatedDashboardConfig: o
|
|
418
418
|
};
|
|
@@ -571,7 +571,7 @@ const Lt = (e) => {
|
|
|
571
571
|
allUpdatedDashboardConfigs: u
|
|
572
572
|
};
|
|
573
573
|
}
|
|
574
|
-
}), jn =
|
|
574
|
+
}), jn = _t()((...e) => ({
|
|
575
575
|
...Bt(...e)
|
|
576
576
|
})), An = () => {
|
|
577
577
|
const [e, n] = se({}), [t, r] = se({}), a = ce((g) => {
|
|
@@ -3022,7 +3022,7 @@ function Tn({ item: e, onSettingItemChanged: n }) {
|
|
|
3022
3022
|
const y = u.key;
|
|
3023
3023
|
if (["ArrowUp", "ArrowDown"].includes(y)) {
|
|
3024
3024
|
u.preventDefault();
|
|
3025
|
-
const p =
|
|
3025
|
+
const p = Wt.incrementOrDecrementValue(
|
|
3026
3026
|
e,
|
|
3027
3027
|
y === "ArrowUp" ? 1 : -1
|
|
3028
3028
|
);
|
|
@@ -3067,7 +3067,7 @@ function sr(e) {
|
|
|
3067
3067
|
onDoneClick: o
|
|
3068
3068
|
} = e, [u, y] = se("Editing"), [p, g] = se(0), [c, b] = se(""), T = Array.from(e.widgetsCatalog.keys()).map((f) => ({
|
|
3069
3069
|
widgetKey: f,
|
|
3070
|
-
metaData:
|
|
3070
|
+
metaData: At(f, e.widgetsCatalog)
|
|
3071
3071
|
})), m = !!e.targetContainerKey, x = (f) => {
|
|
3072
3072
|
b(f.target.value);
|
|
3073
3073
|
}, C = (f) => {
|
|
@@ -3255,10 +3255,10 @@ export {
|
|
|
3255
3255
|
tn as CircleQuestionMark,
|
|
3256
3256
|
en as CrosshairIcon,
|
|
3257
3257
|
rr as DashboardGrid,
|
|
3258
|
-
|
|
3259
|
-
|
|
3258
|
+
Fe as DashboardMaxZoomScale,
|
|
3259
|
+
Ae as DashboardMinZoomScale,
|
|
3260
3260
|
at as DashboardWidgetBase,
|
|
3261
|
-
|
|
3261
|
+
kt as DashboardZoomStep,
|
|
3262
3262
|
Ln as DeleteIcon,
|
|
3263
3263
|
vn as DraggablePanel,
|
|
3264
3264
|
Dn as DynamicWidgetLoader,
|
|
@@ -3295,21 +3295,21 @@ export {
|
|
|
3295
3295
|
Cn as _isVersionCompatible,
|
|
3296
3296
|
we as blankDashboardConfig,
|
|
3297
3297
|
ut as createDynamicEntry,
|
|
3298
|
-
|
|
3299
|
-
|
|
3298
|
+
Ft as createStaticEntry,
|
|
3299
|
+
Mt as cssSettingsCatalog,
|
|
3300
3300
|
kn as cssVarsUtils,
|
|
3301
|
-
|
|
3302
|
-
|
|
3301
|
+
Wt as dashboardSettingsUtils,
|
|
3302
|
+
jt as ensureContainersSequence,
|
|
3303
3303
|
ct as ensureZoomScaleIsWithinRange,
|
|
3304
3304
|
he as getDefaultWidgetMetaFromKey,
|
|
3305
3305
|
Wn as getDefaultWidgetMetaFromMap,
|
|
3306
3306
|
G as getDistinctCssClasses,
|
|
3307
|
-
|
|
3307
|
+
Ut as getMetaInfoFromFile,
|
|
3308
3308
|
Pn as getNewZoomScaleWithinRange,
|
|
3309
|
-
|
|
3309
|
+
At as getWidgetMetaFromCatalog,
|
|
3310
3310
|
Rn as localWidgetDiscovery,
|
|
3311
3311
|
dt as parseContainerTitle,
|
|
3312
|
-
|
|
3312
|
+
Lt as parseKeyAndTitleFromFilePath,
|
|
3313
3313
|
In as remoteWidgetDiscovery,
|
|
3314
3314
|
$n as removeEmptyContainers,
|
|
3315
3315
|
On as resolveColorFromClass,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tenorlab/react-dashboard",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
4
4
|
"description": "Foundation components for creating user-configurable dashboards in React",
|
|
5
5
|
"author": "Damiano Fusco",
|
|
6
6
|
"type": "module",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"react-draggable": "^4.5.0",
|
|
61
61
|
"typescript": "~5.9.3",
|
|
62
62
|
"vite": "^7.2.4",
|
|
63
|
+
"vite-plugin-dts": "^4.5.4",
|
|
63
64
|
"vitest": "^4.0.16",
|
|
64
65
|
"zustand": "^5.0.9"
|
|
65
66
|
}
|