chore(deps): bump
- vite@6 - @bwip-js/browser - svelte-i18n@4 - migrate from csvtojson to papaparse
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import csv from "csvtojson";
|
||||
import { parse } from "papaparse";
|
||||
import { read as readXlsx, utils as xlsx_utils } from "xlsx";
|
||||
import { _ } from "svelte-i18n";
|
||||
import { clickOutside } from "../base/outsideclick";
|
||||
@@ -63,29 +63,31 @@
|
||||
let recent_processed = true;
|
||||
$: json_output = [];
|
||||
$: {
|
||||
if (files) {
|
||||
if (
|
||||
files[0].type ===
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||
) {
|
||||
const reader = new FileReader();
|
||||
reader.addEventListener("load", async (e) => {
|
||||
const data = new Uint8Array(e.target.result);
|
||||
const out = readXlsx(data, { type: "array" });
|
||||
json_output = xlsx_utils.sheet_to_json(
|
||||
out.Sheets[Object.keys(out.Sheets)[0]]
|
||||
);
|
||||
});
|
||||
reader.readAsArrayBuffer(files[0]);
|
||||
} else {
|
||||
const reader = new FileReader();
|
||||
reader.addEventListener("load", async (e) => {
|
||||
json_output = await csv({
|
||||
delimiter: [";", ","],
|
||||
trim: true,
|
||||
}).fromString(e.target.result);
|
||||
});
|
||||
reader.readAsText(files[0]);
|
||||
if (json_output.length === 0) {
|
||||
if (files) {
|
||||
if (
|
||||
files[0].type ===
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||
) {
|
||||
const reader = new FileReader();
|
||||
reader.addEventListener("loadend", (e) => {
|
||||
const data = new Uint8Array(e.target.result);
|
||||
const out = readXlsx(data, { type: "array" });
|
||||
json_output = xlsx_utils.sheet_to_json(
|
||||
out.Sheets[Object.keys(out.Sheets)[0]]
|
||||
);
|
||||
});
|
||||
reader.readAsArrayBuffer(files[0]);
|
||||
} else {
|
||||
const reader = new FileReader();
|
||||
reader.addEventListener("loadend", (e) => {
|
||||
json_output = parse(e.target.result, {
|
||||
delimitersToGuess: [";", ","],
|
||||
header: true,
|
||||
}).data;
|
||||
});
|
||||
reader.readAsText(files[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import { _ } from "svelte-i18n";
|
||||
import { tick } from "svelte";
|
||||
import bwipjs from "bwip-js";
|
||||
import { toCanvas } from "@bwip-js/browser";
|
||||
import toast from "svelte-french-toast";
|
||||
|
||||
export let copy_modal_open;
|
||||
@@ -51,7 +51,7 @@
|
||||
if (bcid == "code128") {
|
||||
codeconfig.height = 10;
|
||||
}
|
||||
bwipjs.toCanvas(canvas, codeconfig);
|
||||
toCanvas(canvas, codeconfig);
|
||||
return canvas.toDataURL("image/png");
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user