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 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.492",
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
- var COLS = [
107689
- { key: "idx", label: "#", pdfW: 10 },
107690
- { key: "nome", label: "Nome", pdfW: 100 },
107691
- { key: "identificador", label: "Identificador", pdfW: 60 },
107692
- { key: "consumo", label: "Consumo", pdfW: 50 },
107693
- { key: "perc", label: "%", pdfW: 20 }
107694
- ];
107695
- function buildRow(d, idx, unit) {
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 `${Number(d.val).toLocaleString("pt-BR", { maximumFractionDigits: 3 })} ${unit}`;
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 header = COLS.map((c) => `"${c.label}"`).join(";");
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, unit);
107746
- return COLS.map((c) => `"${String(r[c.key]).replace(/"/g, '""')}"`).join(";");
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 span = COLS.length - 1;
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 = COLS.map(
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, unit);
107763
- const cells = COLS.map((c) => {
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 rawTotal = COLS.reduce((s, c) => s + c.pdfW, 0);
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 = COLS.map((c) => c.pdfW * scale);
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
- COLS.forEach((c, ci) => {
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
- COLS.forEach((c, ci) => {
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, unit), currentY, i % 2 === 0);
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.492",
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
- var COLS = [
107073
- { key: "idx", label: "#", pdfW: 10 },
107074
- { key: "nome", label: "Nome", pdfW: 100 },
107075
- { key: "identificador", label: "Identificador", pdfW: 60 },
107076
- { key: "consumo", label: "Consumo", pdfW: 50 },
107077
- { key: "perc", label: "%", pdfW: 20 }
107078
- ];
107079
- function buildRow(d, idx, unit) {
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 `${Number(d.val).toLocaleString("pt-BR", { maximumFractionDigits: 3 })} ${unit}`;
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 header = COLS.map((c) => `"${c.label}"`).join(";");
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, unit);
107130
- return COLS.map((c) => `"${String(r[c.key]).replace(/"/g, '""')}"`).join(";");
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 span = COLS.length - 1;
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 = COLS.map(
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, unit);
107147
- const cells = COLS.map((c) => {
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 rawTotal = COLS.reduce((s, c) => s + c.pdfW, 0);
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 = COLS.map((c) => c.pdfW * scale);
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
- COLS.forEach((c, ci) => {
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
- COLS.forEach((c, ci) => {
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, unit), currentY, i % 2 === 0);
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.492"};
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
- var COLS = [
110270
- { key: "idx", label: "#", pdfW: 10 },
110271
- { key: "nome", label: "Nome", pdfW: 100 },
110272
- { key: "identificador", label: "Identificador", pdfW: 60 },
110273
- { key: "consumo", label: "Consumo", pdfW: 50 },
110274
- { key: "perc", label: "%", pdfW: 20 }
110275
- ];
110276
- function buildRow(d, idx, unit) {
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 `${Number(d.val).toLocaleString("pt-BR", { maximumFractionDigits: 3 })} ${unit}`;
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 header = COLS.map((c) => `"${c.label}"`).join(";");
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, unit);
110327
- return COLS.map((c) => `"${String(r[c.key]).replace(/"/g, '""')}"`).join(";");
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 span = COLS.length - 1;
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 = COLS.map(
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, unit);
110344
- const cells = COLS.map((c) => {
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 rawTotal = COLS.reduce((s, c) => s + c.pdfW, 0);
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 = COLS.map((c) => c.pdfW * scale);
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
- COLS.forEach((c, ci) => {
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
- COLS.forEach((c, ci) => {
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, unit), currentY, i % 2 === 0);
110476
+ drawDataRow(buildRow(d, i), currentY, i % 2 === 0);
110472
110477
  currentY += ROW_H;
110473
110478
  });
110474
110479
  drawFooter2();