@tenorlab/vue-dashboard 1.0.0

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.
@@ -0,0 +1,367 @@
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
+ ], S = ["rem", "pc", "cm", "in", "em", "vh", "vw", "%"], b = (e, t) => S.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, s = e.value.match(/([^\d.]+)/), n = s ? s[1] : e.defaultUnit, r = b(n, e.step) * t, c = `${Math.max(a + r, e.minValue).toFixed(1)}${n}`;
89
+ return {
90
+ ...e,
91
+ value: c
92
+ };
93
+ }
94
+ }, f = (e, t) => `dashboards_${t}_${e}`, v = async (e, t, i, a) => {
95
+ const s = localStorage.getItem(f(e, t));
96
+ if (s)
97
+ try {
98
+ const n = JSON.parse(s);
99
+ return n.length < 1 ? [a] : (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 = a.widgets);
101
+ const c = (r.cssSettings || []).filter(
102
+ (o) => a.cssSettings.some((d) => d.key === o.key)
103
+ );
104
+ if (c.length < 1)
105
+ r.cssSettings = [...a.cssSettings];
106
+ else {
107
+ c.forEach((d) => {
108
+ d.value = (d.value || "").replace(/NaN/g, "");
109
+ const l = a.cssSettings.find(
110
+ (g) => g.key === d.key
111
+ );
112
+ l && (Object.keys(l).forEach((g) => {
113
+ g in d || (d[g] = l[g]);
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
+ });
116
+ const o = a.cssSettings.filter((d) => !c.some(
117
+ (l) => l.key === d.key
118
+ ));
119
+ r.cssSettings = [...c, ...o];
120
+ }
121
+ r.widgets = r.widgets.filter(
122
+ (o) => o.includes("WidgetContainer") || i.has(o)
123
+ ), r.childWidgetsConfig = r.childWidgetsConfig.filter(
124
+ (o) => i.has(o.widgetKey)
125
+ ), r.zoomScale ? r.zoomScale < 0.7 && (r.zoomScale = 0.7) : r.zoomScale = 1;
126
+ }), n);
127
+ } catch (n) {
128
+ console.warn("Error parsing saved dashboard config:", n);
129
+ }
130
+ return [a];
131
+ }, C = async (e, t, i, a) => {
132
+ i.forEach((n) => {
133
+ if (n.userID = e, n.clientAppKey = t, n.responsiveGrid = n.responsiveGrid ?? !1, typeof n != "object")
134
+ throw new Error("Invalid dashboard configuration");
135
+ n.widgets = n.widgets.filter(
136
+ (r) => r.includes("WidgetContainer") || a.has(r)
137
+ ), n.childWidgetsConfig = n.childWidgetsConfig.filter(
138
+ (r) => a.has(r.widgetKey)
139
+ ), n.zoomScale ? n.zoomScale < 0.7 && (n.zoomScale = 0.7) : n.zoomScale = 1;
140
+ });
141
+ const s = JSON.stringify(i);
142
+ return localStorage.setItem(f(e, t), s), !0;
143
+ }, W = {
144
+ getSavedDashboards: v,
145
+ saveDashboards: C
146
+ }, P = () => W, z = {
147
+ userID: 0,
148
+ clientAppKey: "",
149
+ dashboardId: "default",
150
+ dashboardName: "Default",
151
+ zoomScale: 1,
152
+ responsiveGrid: !1,
153
+ widgets: [],
154
+ childWidgetsConfig: [],
155
+ cssSettings: [...w]
156
+ }, U = (e) => {
157
+ const t = `${e}`.split("_");
158
+ return t.length > 1 ? t[1].replace(/(\D)(\d+)/, "$1 $2") : "Container";
159
+ }, m = 0.7, p = 1, V = 0.05, D = (e) => {
160
+ let t = Number(e || 0);
161
+ return t < m && (t = m), t > p && (t = p), t;
162
+ }, j = (e, t) => {
163
+ let i = Number(Number((V * t).toFixed(2)).toFixed(2)), a = Number((Number(e) + i).toFixed(2));
164
+ return D(a);
165
+ }, N = (e) => {
166
+ let t = {
167
+ ...e
168
+ };
169
+ return t.widgets = t.widgets.filter((i) => {
170
+ if (`${i}`.includes("WidgetContainer")) {
171
+ const a = t.childWidgetsConfig.filter(
172
+ (s) => s.parentWidgetKey === i
173
+ );
174
+ if (!a || a.length === 0)
175
+ return t.widgets = t.widgets.filter(
176
+ (s) => s !== i
177
+ ), !1;
178
+ }
179
+ return !0;
180
+ }), t;
181
+ }, x = (e) => {
182
+ const t = e.widgets.filter(
183
+ (a) => a.includes("WidgetContainer")
184
+ ), i = {};
185
+ return t.forEach((a, s) => {
186
+ const n = `${a.split("_container")[0]}_container${s + 1}`;
187
+ i[a] = n;
188
+ }), e.widgets = e.widgets.map((a) => i[a] || a), e.childWidgetsConfig = e.childWidgetsConfig.map((a) => {
189
+ const s = a.parentWidgetKey, n = i[s];
190
+ return {
191
+ ...a,
192
+ // If a new key exists, use it. If not, keep the original key.
193
+ parentWidgetKey: n || s
194
+ };
195
+ }), e;
196
+ }, u = (e, t) => {
197
+ const i = `${e}`.includes("Container"), a = i ? ["Container"] : ["Widget"], s = t?.name || e, n = t?.description || (i ? "Container" : "Unknown");
198
+ return {
199
+ name: s,
200
+ description: n,
201
+ categories: a,
202
+ noDuplicatedWidgets: !0,
203
+ icon: void 0,
204
+ externalDependencies: []
205
+ };
206
+ }, I = (e, t, i) => t[e] || u(e, i), M = (e, t) => t.get(e)?.meta || u(e), k = (e, t, i) => {
207
+ const a = i || u(e);
208
+ return [
209
+ e,
210
+ {
211
+ key: e,
212
+ title: a.name,
213
+ isContainer: `${e}`.includes("Container"),
214
+ meta: a,
215
+ component: t
216
+ }
217
+ ];
218
+ }, h = (e, t, i) => {
219
+ const a = i || u(e);
220
+ return [
221
+ e,
222
+ {
223
+ key: e,
224
+ title: a.name,
225
+ isContainer: !1,
226
+ meta: a,
227
+ loader: t
228
+ }
229
+ ];
230
+ }, F = (e) => {
231
+ const t = e.match(/\/widget-([a-zA-Z0-9-]+)\/index\.ts$/);
232
+ if (t && t[1]) {
233
+ const i = t[1], a = i.split("-"), s = `Widget${a.map((r) => r.charAt(0).toUpperCase() + r.slice(1)).join("")}`, n = a.map((r) => r.charAt(0).toUpperCase() + r.slice(1)).join(" ");
234
+ return {
235
+ key: s,
236
+ title: n,
237
+ folder: i
238
+ };
239
+ }
240
+ return null;
241
+ }, $ = (e, t, i, a) => {
242
+ const s = `${t}/widget-${i}/meta.ts`, n = e[s];
243
+ if (!n)
244
+ return;
245
+ const r = `${a}Meta`;
246
+ return n[r] || void 0;
247
+ }, A = async (e) => new Promise(async (t, i) => {
248
+ const a = [];
249
+ try {
250
+ const s = await (await fetch(`${e}?${Math.random()}`)).json();
251
+ for (const n in s) {
252
+ const r = s[n], c = () => import(
253
+ /* @vite-ignore */
254
+ r.url
255
+ ), o = {
256
+ name: r.meta?.name || "Unknown",
257
+ description: r.meta?.description || "Remote Plugin",
258
+ categories: r.meta?.categories || ["Widget"],
259
+ noDuplicatedWidgets: r.meta?.noDuplicatedWidgets ?? !0,
260
+ icon: void 0,
261
+ // Or a logic to map a string name to a Lucide component
262
+ externalDependencies: r.meta?.externalDependencies || []
263
+ };
264
+ a.push(h(n, c, o));
265
+ }
266
+ t({
267
+ entries: a,
268
+ message: "",
269
+ details: ""
270
+ });
271
+ } catch (s) {
272
+ console.error("Remote plugin discovery failed:", s), i({
273
+ entries: [],
274
+ message: "Remote plugin discovery failed:",
275
+ details: typeof s == "object" ? JSON.stringify(s) : s
276
+ });
277
+ }
278
+ }), K = (e, t, i, a = !0) => {
279
+ const s = [];
280
+ for (const n in t) {
281
+ const r = t[n], c = F(n);
282
+ if (c && r) {
283
+ const { key: o, title: d, folder: l } = c;
284
+ let g = $(i, e, l, o);
285
+ if (g || (g = u(o, {
286
+ description: `Local ${a ? "dynamic" : "static"} widget`
287
+ })), a)
288
+ s.push(
289
+ h(o, r, g)
290
+ );
291
+ else {
292
+ const y = r.default || r;
293
+ s.push(k(o, y, g));
294
+ }
295
+ }
296
+ }
297
+ return s;
298
+ }, G = (e, t = "color") => {
299
+ if (typeof window > "u") return "#FFFFFF";
300
+ const i = document.createElement("div");
301
+ Array.isArray(e) ? e.forEach((s) => i.classList.add(s)) : e.split(" ").forEach((s) => i.classList.add(s)), i.style.display = "none", document.body.appendChild(i);
302
+ const a = window.getComputedStyle(i)[t];
303
+ return document.body.removeChild(i), a;
304
+ }, R = {
305
+ /**
306
+ * @name getCssVariableValue
307
+ * @description Return the value of a CSS custom property from the current HTML document
308
+ * @param cssPropertyName
309
+ * @returns
310
+ */
311
+ getCssVariableValue: (e) => {
312
+ const t = document.documentElement;
313
+ return getComputedStyle(t).getPropertyValue(e).trim() || null;
314
+ },
315
+ /**
316
+ * @name setCssVariableValue
317
+ * @description Sets the value of a CSS custom property on the current HTML document
318
+ * @param cssPropertyName
319
+ * @param value
320
+ */
321
+ setCssVariableValue: (e, t) => {
322
+ document.documentElement.style.setProperty(e, t);
323
+ },
324
+ /**
325
+ * @name restoreCssVarsFromSettings
326
+ * @description
327
+ * Sets the values of many CSS custom properties on the current HTML document
328
+ * from the list of dashboard settings provided
329
+ * @param settings, an array of IDashboardSettingEntry
330
+ */
331
+ restoreCssVarsFromSettings: (e) => {
332
+ const t = document.documentElement;
333
+ e.forEach((i) => {
334
+ t.style.setProperty(i.cssProperty, i.value);
335
+ });
336
+ }
337
+ }, Z = (e, ...t) => [
338
+ ...new Set(
339
+ [e || "", ...t].join(" ").trim().replace(/\n+/gi, " ").replace(/\s+/gi, " ").split(" ")
340
+ )
341
+ ].join(" ").trim();
342
+ export {
343
+ p as DashboardMaxZoomScale,
344
+ m as DashboardMinZoomScale,
345
+ V as DashboardZoomStep,
346
+ z as blankDashboardConfig,
347
+ h as createDynamicEntry,
348
+ k as createStaticEntry,
349
+ w as cssSettingsCatalog,
350
+ R as cssVarsUtils,
351
+ E as dashboardSettingsUtils,
352
+ x as ensureContainersSequence,
353
+ D as ensureZoomScaleIsWithinRange,
354
+ u as getDefaultWidgetMetaFromKey,
355
+ I as getDefaultWidgetMetaFromMap,
356
+ Z as getDistinctCssClasses,
357
+ $ as getMetaInfoFromFile,
358
+ j as getNewZoomScaleWithinRange,
359
+ M as getWidgetMetaFromCatalog,
360
+ K as localWidgetDiscovery,
361
+ U as parseContainerTitle,
362
+ F as parseKeyAndTitleFromFilePath,
363
+ A as remoteWidgetDiscovery,
364
+ N as removeEmptyContainers,
365
+ G as resolveColorFromClass,
366
+ P as useDashboardStorageService
367
+ };
@@ -0,0 +1 @@
1
+ html{--bwj-dashboard-num-columns: 3;--bwj-dashboard-gap: 1.25rem;--bwj-dashboard-transform-scale: 1;--bwj-dashboard-add-cols: 1;--bwj-widget-width: 21rem;--bwj-widget-border-radius: .33rem;--bwj-widget-inner-px: 1rem;--bwj-widget-inner-py: .75rem;--bwj-widget-header-px: var(--bwj-widget-inner-px);--bwj-widget-header-py: 1rem;--bwj-widget-title-size: .8rem;--bwj-widget-title-weight: 600;--bwj-dashboard-debug-container-flex-row: none;--bwj-dashboard-debug-container-flex-column: none;--bwj-dashboard-debug-container-grid-large-inner: none}html .dashboard-main-grid{width:100%;display:grid;grid-template-columns:repeat(var(--bwj-dashboard-num-columns, 4),minmax(var(--bwj-widget-width),1fr));gap:var(--bwj-dashboard-gap, 1.5rem);transform:scale(var(--bwj-dashboard-transform-scale, 1));transform-origin:top left}html .dashboard-main-grid.editing{row-gap:calc(var(--bwj-dashboard-gap) + .8rem)}html .dashboard-main-grid:not(.responsive-grid){max-width:min-content}html .dashboard-main-grid.responsive-grid{width:100%}html .dashboard-widget-container{--bwj-border-opacity: .5;flex:1 1 0%;width:100%}html .dashboard-widget-container .widget-container-header{display:none;position:absolute;height:1.85rem;inset:-1.85rem -1px auto;cursor:pointer;padding:0 .33rem}html .dashboard-widget-container .widget-container-header .actions-inner{transition:all .3s ease-in-out;width:100%;display:none;align-items:center;justify-content:space-between;font-size:.8rem}html .dashboard-widget-container.editing{border-top:none!important;border-bottom-left-radius:var(--bwj-widget-border-radius, .3rem);border-bottom-right-radius:var(--bwj-widget-border-radius, .3rem)}html .dashboard-widget-container.editing .widget-container-header{display:flex;border-bottom:none!important;border-top-left-radius:var(--bwj-widget-border-radius, .3rem);border-top-right-radius:var(--bwj-widget-border-radius, .3rem)}html .dashboard-widget-container.editing .widget-container-header>.actions-inner{display:flex!important}html .dashboard-widget-container.editing.highlight-container:before{content:"";position:absolute;inset:-1.85rem 0 0;box-shadow:0 2px 10px 6px oklch(var(--bwj-primary-okl) var(--bwj-primary-okc) var(--bwj-primary-okh) / .5);pointer-events:none}html .dashboard-widget{flex:1 1 0%;display:flex;flex-direction:column;position:relative;border-radius:var(--bwj-widget-border-radius, .3rem);height:100%;width:100%}html .dashboard-widget:not(.no-shadow){box-shadow:1px 2px 8px #0000001a}html .dashboard-widget.no-shadow{box-shadow:none}html .dashboard-widget.transparent-widget{background-color:transparent}html .dashboard-widget .widget-title-wrapper .widget-title{font-size:var(--bwj-widget-title-size, .75rem);font-weight:var(--bwj-widget-title-weight, 600)}html .dashboard-widget .widget-inner{flex:1 1 0%;display:flex;flex-direction:column;justify-content:space-between}html .dashboard-widget:not(.no-padding) .widget-inner{padding:var(--bwj-widget-inner-py, 1rem) var(--bwj-widget-inner-px, 1.5rem)}html .dashboard-widget.no-padding .widget-inner{padding:0}html .dashboard-widget .widget-header{padding:var(--bwj-widget-header-py, 1rem) var(--bwj-widget-header-px, 1.5rem)}html .dashboard-widget-container .widget-container-inner{padding:0;gap:var(--bwj-dashboard-gap, 1.5rem)}html .dashboard-widget-container.direction-row.widget-container-flex{grid-column:1 / -1;width:100%;outline:var(--bwj-dashboard-debug-container-flex-row)}html .dashboard-widget-container.direction-row.widget-container-flex .widget-container-inner{display:flex;flex-direction:row;height:100%}html .dashboard-widget-container.direction-row.widget-container-flex .widget-container-inner .dashboard-widget{min-width:5%;max-width:100%}html .dashboard-widget-container.direction-column.widget-container-flex .widget-container-inner{display:flex;flex-direction:column;height:100%;outline:var(--bwj-dashboard-debug-container-flex-column)}html .dashboard-widget-container.direction-column.widget-container-flex .widget-container-inner .dashboard-widget{min-width:5%;max-width:100%}html .dashboard-widget-container.large-widget.widget-container-grid .widget-container-inner{display:grid;grid-template-columns:repeat(2,minmax(var(--bwj-widget-width),1fr));outline:var(--bwj-dashboard-debug-container-grid-large-inner)}html .dashboard-main-grid.responsive-grid .dashboard-widget-container:not(.large-widget):not(.xlarge-widget),html .dashboard-main-grid.responsive-grid .dashboard-widget:not(.large-widget):not(.xlarge-widget){min-width:20%;max-width:100%}html .dashboard-main-grid:not(.responsive-grid) .dashboard-widget-container:not(.widget-container-flex):not(.large-widget):not(.xlarge-widget),html .widget-container-flex:not(.direction-row) .dashboard-main-grid:not(.responsive-grid) .dashboard-widget:not(.large-widget):not(.xlarge-widget){min-width:var(--bwj-widget-width);max-width:var(--bwj-widget-width)}html .dashboard-widget-container.large-widget,html .dashboard-widget.large-widget{grid-column:span 2}html .dashboard-main-grid:not(.responsive-grid) .dashboard-widget-container.large-widget,html .dashboard-main-grid:not(.responsive-grid) .dashboard-widget.large-widget{max-width:calc(680px + var(--bwj-dashboard-gap, 1.5rem))}html .dashboard-widget-container.xlarge-widget,html .dashboard-widget.xlarge-widget{grid-column:span 3}html .dashboard-main-grid:not(.responsive-grid) .dashboard-widget-container.xlarge-widget,html .dashboard-main-grid:not(.responsive-grid) .dashboard-widget.xlarge-widget{max-width:calc(1020px + (var(--bwj-dashboard-gap, 1.5rem) * 2))}html .widget-header .actions-inner{display:none;align-items:center;gap:.25rem}html .widget-header .actions-inner .actions-buttons-container{align-items:center;gap:.25rem}html .dashboard-widget.editing:hover .actions-inner{display:flex!important}html .dashboard-widget-container.editing .widget-container-header .actions-inner{display:flex}html .actions-buttons-container{display:flex!important;align-items:center!important;gap:.25rem!important}html .dashboard-number{font-variant-numeric:tabular-nums;font-size:2.5rem;font-weight:700}html .dashboard-number.number-xl{font-size:3.5rem}html .dashboard-number.number-lg{font-size:2.5rem}html .dashboard-number.number-base{font-size:1.5rem}html .dashboard-progress-bar{padding:0;width:100%;height:1.5rem;border-radius:.75rem}html .dashboard-progress{padding:0;height:1.25rem;border-radius:.75rem}@media(max-width:769px){html .dashboard-main-grid{display:flex;flex-direction:column;width:100%;max-width:100%!important}html .dashboard-widget-container.widget-container-flex.direction-row{max-width:100%;grid-column:auto}html .dashboard-widget-container.widget-container-flex.direction-row .widget-container-inner{display:flex;flex-wrap:wrap;flex-direction:column!important;width:100%}}@media(min-width:770px){html .dashboard-main-grid{--bwj-dashboard-num-columns: calc(2 + var(--bwj-dashboard-add-cols))}}@media(max-width:1119px){html .dashboard-widget-container.widget-container-flex.direction-row{max-width:100%;grid-column:auto}html .dashboard-widget-container.widget-container-flex.direction-row .widget-container-inner{display:flex;flex-wrap:wrap;flex-direction:column!important;width:100%}}@media(min-width:1120px){html .dashboard-main-grid{--bwj-dashboard-num-columns: calc(3 + var(--bwj-dashboard-add-cols))}}@media(min-width:1480px){html .dashboard-main-grid{--bwj-dashboard-num-columns: calc(4 + var(--bwj-dashboard-add-cols))}}@media(min-width:1840px){html .dashboard-main-grid{--bwj-dashboard-num-columns: calc(5 + var(--bwj-dashboard-add-cols))}}@media(min-width:2220px){html .dashboard-main-grid{--bwj-dashboard-num-columns: calc(6 + var(--bwj-dashboard-add-cols))}}