myio-js-library 0.1.492 → 0.1.494
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/index.cjs +27 -22
- package/dist/index.js +27 -22
- package/dist/myio-js-library.umd.js +27 -22
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1162,7 +1162,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
1162
1162
|
// package.json
|
|
1163
1163
|
var package_default = {
|
|
1164
1164
|
name: "myio-js-library",
|
|
1165
|
-
version: "0.1.
|
|
1165
|
+
version: "0.1.494",
|
|
1166
1166
|
description: "A clean, standalone JS SDK for MYIO projects",
|
|
1167
1167
|
license: "MIT",
|
|
1168
1168
|
repository: "github:gh-myio/myio-js-library",
|
|
@@ -107685,17 +107685,19 @@ function injectStyles10(_container) {
|
|
|
107685
107685
|
|
|
107686
107686
|
// src/components/telemetry-grid-shopping/export.ts
|
|
107687
107687
|
var import_jspdf = require("jspdf");
|
|
107688
|
-
|
|
107689
|
-
|
|
107690
|
-
|
|
107691
|
-
|
|
107692
|
-
|
|
107693
|
-
|
|
107694
|
-
|
|
107695
|
-
|
|
107688
|
+
function makeCols(unit) {
|
|
107689
|
+
return [
|
|
107690
|
+
{ key: "idx", label: "#", pdfW: 10 },
|
|
107691
|
+
{ key: "nome", label: "Nome", pdfW: 100 },
|
|
107692
|
+
{ key: "identificador", label: "Identificador", pdfW: 60 },
|
|
107693
|
+
{ key: "consumo", label: unit ? `Consumo (${unit})` : "Consumo", pdfW: 50 },
|
|
107694
|
+
{ key: "perc", label: "%", pdfW: 20 }
|
|
107695
|
+
];
|
|
107696
|
+
}
|
|
107697
|
+
function buildRow(d, idx) {
|
|
107696
107698
|
const fmtVal = () => {
|
|
107697
107699
|
if (d.val === null || d.val === void 0) return "\u2014";
|
|
107698
|
-
return
|
|
107700
|
+
return Number(d.val).toLocaleString("pt-BR", { maximumFractionDigits: 3, useGrouping: false });
|
|
107699
107701
|
};
|
|
107700
107702
|
return {
|
|
107701
107703
|
idx: String(idx + 1),
|
|
@@ -107740,10 +107742,11 @@ function exportGridCsv(devices, label, unit, period) {
|
|
|
107740
107742
|
`"Gerado em";"${(/* @__PURE__ */ new Date()).toLocaleString("pt-BR")}"`,
|
|
107741
107743
|
""
|
|
107742
107744
|
].filter((v) => v !== null);
|
|
107743
|
-
const
|
|
107745
|
+
const cols = makeCols(unit);
|
|
107746
|
+
const header = cols.map((c) => `"${c.label}"`).join(";");
|
|
107744
107747
|
const rows = devices.map((d, i) => {
|
|
107745
|
-
const r = buildRow(d, i
|
|
107746
|
-
return
|
|
107748
|
+
const r = buildRow(d, i);
|
|
107749
|
+
return cols.map((c) => `"${String(r[c.key]).replace(/"/g, '""')}"`).join(";");
|
|
107747
107750
|
});
|
|
107748
107751
|
const csv = "\uFEFF" + [...metaRows, header, ...rows].join("\r\n");
|
|
107749
107752
|
triggerDownload(
|
|
@@ -107753,14 +107756,15 @@ function exportGridCsv(devices, label, unit, period) {
|
|
|
107753
107756
|
}
|
|
107754
107757
|
function exportGridXls(devices, label, unit, period) {
|
|
107755
107758
|
const periodLabel = fmtPeriod(period);
|
|
107756
|
-
const
|
|
107759
|
+
const cols = makeCols(unit);
|
|
107760
|
+
const span = cols.length - 1;
|
|
107757
107761
|
const metaRow = (key, val) => `<Row><Cell ss:StyleID="m"><Data ss:Type="String">${escXml(key)}</Data></Cell><Cell ss:MergeAcross="${span - 1}"><Data ss:Type="String">${escXml(val)}</Data></Cell></Row>`;
|
|
107758
|
-
const headerCells =
|
|
107762
|
+
const headerCells = cols.map(
|
|
107759
107763
|
(c) => `<Cell ss:StyleID="h"><Data ss:Type="String">${escXml(c.label)}</Data></Cell>`
|
|
107760
107764
|
).join("");
|
|
107761
107765
|
const dataRows = devices.map((d, i) => {
|
|
107762
|
-
const r = buildRow(d, i
|
|
107763
|
-
const cells =
|
|
107766
|
+
const r = buildRow(d, i);
|
|
107767
|
+
const cells = cols.map((c) => {
|
|
107764
107768
|
const v = escXml(String(r[c.key]));
|
|
107765
107769
|
return `<Cell><Data ss:Type="String">${v}</Data></Cell>`;
|
|
107766
107770
|
}).join("");
|
|
@@ -107807,9 +107811,10 @@ function exportGridPdf(devices, label, unit, period) {
|
|
|
107807
107811
|
const TABLE_Y = HDR_H + MARGIN;
|
|
107808
107812
|
const MAX_Y = PH - FTR_H - MARGIN;
|
|
107809
107813
|
const TABLE_W = PW - MARGIN * 2;
|
|
107810
|
-
const
|
|
107814
|
+
const cols = makeCols(unit);
|
|
107815
|
+
const rawTotal = cols.reduce((s, c) => s + c.pdfW, 0);
|
|
107811
107816
|
const scale = TABLE_W / rawTotal;
|
|
107812
|
-
const colWidths =
|
|
107817
|
+
const colWidths = cols.map((c) => c.pdfW * scale);
|
|
107813
107818
|
const colX = (ci) => MARGIN + colWidths.slice(0, ci).reduce((s, w) => s + w, 0);
|
|
107814
107819
|
function drawPageHeader(pageNo2) {
|
|
107815
107820
|
doc.setFillColor(62, 26, 125);
|
|
@@ -107831,7 +107836,7 @@ function exportGridPdf(devices, label, unit, period) {
|
|
|
107831
107836
|
doc.setTextColor(62, 26, 125);
|
|
107832
107837
|
doc.setFont("helvetica", "bold");
|
|
107833
107838
|
doc.setFontSize(7);
|
|
107834
|
-
|
|
107839
|
+
cols.forEach((c, ci) => {
|
|
107835
107840
|
const x = colX(ci) + 1.5;
|
|
107836
107841
|
doc.text(c.label, x, y + HEAD_H / 2 + 2.5);
|
|
107837
107842
|
});
|
|
@@ -107847,7 +107852,7 @@ function exportGridPdf(devices, label, unit, period) {
|
|
|
107847
107852
|
doc.setTextColor(40, 40, 40);
|
|
107848
107853
|
doc.setFont("helvetica", "normal");
|
|
107849
107854
|
doc.setFontSize(6.5);
|
|
107850
|
-
|
|
107855
|
+
cols.forEach((c, ci) => {
|
|
107851
107856
|
const x = colX(ci) + 1.5;
|
|
107852
107857
|
const maxChars = Math.floor(colWidths[ci] / 1.8);
|
|
107853
107858
|
const text = truncate(String(r[c.key]), maxChars);
|
|
@@ -107887,7 +107892,7 @@ function exportGridPdf(devices, label, unit, period) {
|
|
|
107887
107892
|
drawColumnHeaders(currentY);
|
|
107888
107893
|
currentY += HEAD_H;
|
|
107889
107894
|
}
|
|
107890
|
-
drawDataRow(buildRow(d, i
|
|
107895
|
+
drawDataRow(buildRow(d, i), currentY, i % 2 === 0);
|
|
107891
107896
|
currentY += ROW_H;
|
|
107892
107897
|
});
|
|
107893
107898
|
drawFooter2();
|
package/dist/index.js
CHANGED
|
@@ -546,7 +546,7 @@ var init_template_card = __esm({
|
|
|
546
546
|
// package.json
|
|
547
547
|
var package_default = {
|
|
548
548
|
name: "myio-js-library",
|
|
549
|
-
version: "0.1.
|
|
549
|
+
version: "0.1.494",
|
|
550
550
|
description: "A clean, standalone JS SDK for MYIO projects",
|
|
551
551
|
license: "MIT",
|
|
552
552
|
repository: "github:gh-myio/myio-js-library",
|
|
@@ -107069,17 +107069,19 @@ function injectStyles10(_container) {
|
|
|
107069
107069
|
|
|
107070
107070
|
// src/components/telemetry-grid-shopping/export.ts
|
|
107071
107071
|
import { jsPDF } from "jspdf";
|
|
107072
|
-
|
|
107073
|
-
|
|
107074
|
-
|
|
107075
|
-
|
|
107076
|
-
|
|
107077
|
-
|
|
107078
|
-
|
|
107079
|
-
|
|
107072
|
+
function makeCols(unit) {
|
|
107073
|
+
return [
|
|
107074
|
+
{ key: "idx", label: "#", pdfW: 10 },
|
|
107075
|
+
{ key: "nome", label: "Nome", pdfW: 100 },
|
|
107076
|
+
{ key: "identificador", label: "Identificador", pdfW: 60 },
|
|
107077
|
+
{ key: "consumo", label: unit ? `Consumo (${unit})` : "Consumo", pdfW: 50 },
|
|
107078
|
+
{ key: "perc", label: "%", pdfW: 20 }
|
|
107079
|
+
];
|
|
107080
|
+
}
|
|
107081
|
+
function buildRow(d, idx) {
|
|
107080
107082
|
const fmtVal = () => {
|
|
107081
107083
|
if (d.val === null || d.val === void 0) return "\u2014";
|
|
107082
|
-
return
|
|
107084
|
+
return Number(d.val).toLocaleString("pt-BR", { maximumFractionDigits: 3, useGrouping: false });
|
|
107083
107085
|
};
|
|
107084
107086
|
return {
|
|
107085
107087
|
idx: String(idx + 1),
|
|
@@ -107124,10 +107126,11 @@ function exportGridCsv(devices, label, unit, period) {
|
|
|
107124
107126
|
`"Gerado em";"${(/* @__PURE__ */ new Date()).toLocaleString("pt-BR")}"`,
|
|
107125
107127
|
""
|
|
107126
107128
|
].filter((v) => v !== null);
|
|
107127
|
-
const
|
|
107129
|
+
const cols = makeCols(unit);
|
|
107130
|
+
const header = cols.map((c) => `"${c.label}"`).join(";");
|
|
107128
107131
|
const rows = devices.map((d, i) => {
|
|
107129
|
-
const r = buildRow(d, i
|
|
107130
|
-
return
|
|
107132
|
+
const r = buildRow(d, i);
|
|
107133
|
+
return cols.map((c) => `"${String(r[c.key]).replace(/"/g, '""')}"`).join(";");
|
|
107131
107134
|
});
|
|
107132
107135
|
const csv = "\uFEFF" + [...metaRows, header, ...rows].join("\r\n");
|
|
107133
107136
|
triggerDownload(
|
|
@@ -107137,14 +107140,15 @@ function exportGridCsv(devices, label, unit, period) {
|
|
|
107137
107140
|
}
|
|
107138
107141
|
function exportGridXls(devices, label, unit, period) {
|
|
107139
107142
|
const periodLabel = fmtPeriod(period);
|
|
107140
|
-
const
|
|
107143
|
+
const cols = makeCols(unit);
|
|
107144
|
+
const span = cols.length - 1;
|
|
107141
107145
|
const metaRow = (key, val) => `<Row><Cell ss:StyleID="m"><Data ss:Type="String">${escXml(key)}</Data></Cell><Cell ss:MergeAcross="${span - 1}"><Data ss:Type="String">${escXml(val)}</Data></Cell></Row>`;
|
|
107142
|
-
const headerCells =
|
|
107146
|
+
const headerCells = cols.map(
|
|
107143
107147
|
(c) => `<Cell ss:StyleID="h"><Data ss:Type="String">${escXml(c.label)}</Data></Cell>`
|
|
107144
107148
|
).join("");
|
|
107145
107149
|
const dataRows = devices.map((d, i) => {
|
|
107146
|
-
const r = buildRow(d, i
|
|
107147
|
-
const cells =
|
|
107150
|
+
const r = buildRow(d, i);
|
|
107151
|
+
const cells = cols.map((c) => {
|
|
107148
107152
|
const v = escXml(String(r[c.key]));
|
|
107149
107153
|
return `<Cell><Data ss:Type="String">${v}</Data></Cell>`;
|
|
107150
107154
|
}).join("");
|
|
@@ -107191,9 +107195,10 @@ function exportGridPdf(devices, label, unit, period) {
|
|
|
107191
107195
|
const TABLE_Y = HDR_H + MARGIN;
|
|
107192
107196
|
const MAX_Y = PH - FTR_H - MARGIN;
|
|
107193
107197
|
const TABLE_W = PW - MARGIN * 2;
|
|
107194
|
-
const
|
|
107198
|
+
const cols = makeCols(unit);
|
|
107199
|
+
const rawTotal = cols.reduce((s, c) => s + c.pdfW, 0);
|
|
107195
107200
|
const scale = TABLE_W / rawTotal;
|
|
107196
|
-
const colWidths =
|
|
107201
|
+
const colWidths = cols.map((c) => c.pdfW * scale);
|
|
107197
107202
|
const colX = (ci) => MARGIN + colWidths.slice(0, ci).reduce((s, w) => s + w, 0);
|
|
107198
107203
|
function drawPageHeader(pageNo2) {
|
|
107199
107204
|
doc.setFillColor(62, 26, 125);
|
|
@@ -107215,7 +107220,7 @@ function exportGridPdf(devices, label, unit, period) {
|
|
|
107215
107220
|
doc.setTextColor(62, 26, 125);
|
|
107216
107221
|
doc.setFont("helvetica", "bold");
|
|
107217
107222
|
doc.setFontSize(7);
|
|
107218
|
-
|
|
107223
|
+
cols.forEach((c, ci) => {
|
|
107219
107224
|
const x = colX(ci) + 1.5;
|
|
107220
107225
|
doc.text(c.label, x, y + HEAD_H / 2 + 2.5);
|
|
107221
107226
|
});
|
|
@@ -107231,7 +107236,7 @@ function exportGridPdf(devices, label, unit, period) {
|
|
|
107231
107236
|
doc.setTextColor(40, 40, 40);
|
|
107232
107237
|
doc.setFont("helvetica", "normal");
|
|
107233
107238
|
doc.setFontSize(6.5);
|
|
107234
|
-
|
|
107239
|
+
cols.forEach((c, ci) => {
|
|
107235
107240
|
const x = colX(ci) + 1.5;
|
|
107236
107241
|
const maxChars = Math.floor(colWidths[ci] / 1.8);
|
|
107237
107242
|
const text = truncate(String(r[c.key]), maxChars);
|
|
@@ -107271,7 +107276,7 @@ function exportGridPdf(devices, label, unit, period) {
|
|
|
107271
107276
|
drawColumnHeaders(currentY);
|
|
107272
107277
|
currentY += HEAD_H;
|
|
107273
107278
|
}
|
|
107274
|
-
drawDataRow(buildRow(d, i
|
|
107279
|
+
drawDataRow(buildRow(d, i), currentY, i % 2 === 0);
|
|
107275
107280
|
currentY += ROW_H;
|
|
107276
107281
|
});
|
|
107277
107282
|
drawFooter2();
|
|
@@ -4070,7 +4070,7 @@
|
|
|
4070
4070
|
|
|
4071
4071
|
// package.json
|
|
4072
4072
|
var package_default = {
|
|
4073
|
-
version: "0.1.
|
|
4073
|
+
version: "0.1.494"};
|
|
4074
4074
|
|
|
4075
4075
|
// src/format/energy.ts
|
|
4076
4076
|
function formatPower(value, decimals = 2) {
|
|
@@ -110266,17 +110266,19 @@ Esta a\xE7\xE3o afeta todos os grupos que utilizam este canal.`
|
|
|
110266
110266
|
styleEl.textContent = TELEMETRY_GRID_SHOPPING_STYLES;
|
|
110267
110267
|
document.head.appendChild(styleEl);
|
|
110268
110268
|
}
|
|
110269
|
-
|
|
110270
|
-
|
|
110271
|
-
|
|
110272
|
-
|
|
110273
|
-
|
|
110274
|
-
|
|
110275
|
-
|
|
110276
|
-
|
|
110269
|
+
function makeCols(unit) {
|
|
110270
|
+
return [
|
|
110271
|
+
{ key: "idx", label: "#", pdfW: 10 },
|
|
110272
|
+
{ key: "nome", label: "Nome", pdfW: 100 },
|
|
110273
|
+
{ key: "identificador", label: "Identificador", pdfW: 60 },
|
|
110274
|
+
{ key: "consumo", label: unit ? `Consumo (${unit})` : "Consumo", pdfW: 50 },
|
|
110275
|
+
{ key: "perc", label: "%", pdfW: 20 }
|
|
110276
|
+
];
|
|
110277
|
+
}
|
|
110278
|
+
function buildRow(d, idx) {
|
|
110277
110279
|
const fmtVal = () => {
|
|
110278
110280
|
if (d.val === null || d.val === void 0) return "\u2014";
|
|
110279
|
-
return
|
|
110281
|
+
return Number(d.val).toLocaleString("pt-BR", { maximumFractionDigits: 3, useGrouping: false });
|
|
110280
110282
|
};
|
|
110281
110283
|
return {
|
|
110282
110284
|
idx: String(idx + 1),
|
|
@@ -110321,10 +110323,11 @@ Esta a\xE7\xE3o afeta todos os grupos que utilizam este canal.`
|
|
|
110321
110323
|
`"Gerado em";"${(/* @__PURE__ */ new Date()).toLocaleString("pt-BR")}"`,
|
|
110322
110324
|
""
|
|
110323
110325
|
].filter((v) => v !== null);
|
|
110324
|
-
const
|
|
110326
|
+
const cols = makeCols(unit);
|
|
110327
|
+
const header = cols.map((c) => `"${c.label}"`).join(";");
|
|
110325
110328
|
const rows = devices.map((d, i) => {
|
|
110326
|
-
const r = buildRow(d, i
|
|
110327
|
-
return
|
|
110329
|
+
const r = buildRow(d, i);
|
|
110330
|
+
return cols.map((c) => `"${String(r[c.key]).replace(/"/g, '""')}"`).join(";");
|
|
110328
110331
|
});
|
|
110329
110332
|
const csv = "\uFEFF" + [...metaRows, header, ...rows].join("\r\n");
|
|
110330
110333
|
triggerDownload(
|
|
@@ -110334,14 +110337,15 @@ Esta a\xE7\xE3o afeta todos os grupos que utilizam este canal.`
|
|
|
110334
110337
|
}
|
|
110335
110338
|
function exportGridXls(devices, label, unit, period) {
|
|
110336
110339
|
const periodLabel = fmtPeriod(period);
|
|
110337
|
-
const
|
|
110340
|
+
const cols = makeCols(unit);
|
|
110341
|
+
const span = cols.length - 1;
|
|
110338
110342
|
const metaRow = (key, val) => `<Row><Cell ss:StyleID="m"><Data ss:Type="String">${escXml(key)}</Data></Cell><Cell ss:MergeAcross="${span - 1}"><Data ss:Type="String">${escXml(val)}</Data></Cell></Row>`;
|
|
110339
|
-
const headerCells =
|
|
110343
|
+
const headerCells = cols.map(
|
|
110340
110344
|
(c) => `<Cell ss:StyleID="h"><Data ss:Type="String">${escXml(c.label)}</Data></Cell>`
|
|
110341
110345
|
).join("");
|
|
110342
110346
|
const dataRows = devices.map((d, i) => {
|
|
110343
|
-
const r = buildRow(d, i
|
|
110344
|
-
const cells =
|
|
110347
|
+
const r = buildRow(d, i);
|
|
110348
|
+
const cells = cols.map((c) => {
|
|
110345
110349
|
const v = escXml(String(r[c.key]));
|
|
110346
110350
|
return `<Cell><Data ss:Type="String">${v}</Data></Cell>`;
|
|
110347
110351
|
}).join("");
|
|
@@ -110388,9 +110392,10 @@ Esta a\xE7\xE3o afeta todos os grupos que utilizam este canal.`
|
|
|
110388
110392
|
const TABLE_Y = HDR_H + MARGIN;
|
|
110389
110393
|
const MAX_Y = PH - FTR_H - MARGIN;
|
|
110390
110394
|
const TABLE_W = PW - MARGIN * 2;
|
|
110391
|
-
const
|
|
110395
|
+
const cols = makeCols(unit);
|
|
110396
|
+
const rawTotal = cols.reduce((s, c) => s + c.pdfW, 0);
|
|
110392
110397
|
const scale = TABLE_W / rawTotal;
|
|
110393
|
-
const colWidths =
|
|
110398
|
+
const colWidths = cols.map((c) => c.pdfW * scale);
|
|
110394
110399
|
const colX = (ci) => MARGIN + colWidths.slice(0, ci).reduce((s, w) => s + w, 0);
|
|
110395
110400
|
function drawPageHeader(pageNo2) {
|
|
110396
110401
|
doc.setFillColor(62, 26, 125);
|
|
@@ -110412,7 +110417,7 @@ Esta a\xE7\xE3o afeta todos os grupos que utilizam este canal.`
|
|
|
110412
110417
|
doc.setTextColor(62, 26, 125);
|
|
110413
110418
|
doc.setFont("helvetica", "bold");
|
|
110414
110419
|
doc.setFontSize(7);
|
|
110415
|
-
|
|
110420
|
+
cols.forEach((c, ci) => {
|
|
110416
110421
|
const x = colX(ci) + 1.5;
|
|
110417
110422
|
doc.text(c.label, x, y + HEAD_H / 2 + 2.5);
|
|
110418
110423
|
});
|
|
@@ -110428,7 +110433,7 @@ Esta a\xE7\xE3o afeta todos os grupos que utilizam este canal.`
|
|
|
110428
110433
|
doc.setTextColor(40, 40, 40);
|
|
110429
110434
|
doc.setFont("helvetica", "normal");
|
|
110430
110435
|
doc.setFontSize(6.5);
|
|
110431
|
-
|
|
110436
|
+
cols.forEach((c, ci) => {
|
|
110432
110437
|
const x = colX(ci) + 1.5;
|
|
110433
110438
|
const maxChars = Math.floor(colWidths[ci] / 1.8);
|
|
110434
110439
|
const text = truncate(String(r[c.key]), maxChars);
|
|
@@ -110468,7 +110473,7 @@ Esta a\xE7\xE3o afeta todos os grupos que utilizam este canal.`
|
|
|
110468
110473
|
drawColumnHeaders(currentY);
|
|
110469
110474
|
currentY += HEAD_H;
|
|
110470
110475
|
}
|
|
110471
|
-
drawDataRow(buildRow(d, i
|
|
110476
|
+
drawDataRow(buildRow(d, i), currentY, i % 2 === 0);
|
|
110472
110477
|
currentY += ROW_H;
|
|
110473
110478
|
});
|
|
110474
110479
|
drawFooter2();
|