@ai-matrx/print 0.4.0 → 0.5.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.
- package/CHANGELOG.md +24 -0
- package/dist/booklet.cjs +4 -5
- package/dist/booklet.cjs.map +1 -1
- package/dist/booklet.js +4 -5
- package/dist/booklet.js.map +1 -1
- package/dist/certificate.cjs +32 -30
- package/dist/certificate.cjs.map +1 -1
- package/dist/certificate.js +32 -30
- package/dist/certificate.js.map +1 -1
- package/dist/core.cjs +2 -5
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +1 -2
- package/dist/core.d.ts +1 -2
- package/dist/core.js +1 -4
- package/dist/core.js.map +1 -1
- package/dist/education.cjs +21 -22
- package/dist/education.cjs.map +1 -1
- package/dist/education.js +20 -21
- package/dist/education.js.map +1 -1
- package/dist/exam.cjs +19 -20
- package/dist/exam.cjs.map +1 -1
- package/dist/exam.js +18 -19
- package/dist/exam.js.map +1 -1
- package/dist/flashcards.cjs +25 -26
- package/dist/flashcards.cjs.map +1 -1
- package/dist/flashcards.js +24 -25
- package/dist/flashcards.js.map +1 -1
- package/dist/labels.cjs +14 -13
- package/dist/labels.cjs.map +1 -1
- package/dist/labels.js +14 -13
- package/dist/labels.js.map +1 -1
- package/dist/markdown.cjs +6 -5
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.js +6 -5
- package/dist/markdown.js.map +1 -1
- package/dist/react.cjs +14 -13
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +14 -13
- package/dist/react.js.map +1 -1
- package/dist/zpl.cjs +14 -13
- package/dist/zpl.cjs.map +1 -1
- package/dist/zpl.js +14 -13
- package/dist/zpl.js.map +1 -1
- package/package.json +3 -2
package/dist/react.js
CHANGED
|
@@ -8,9 +8,7 @@ import { Drawer as DrawerPrimitive } from "vaul";
|
|
|
8
8
|
import { twMerge } from "tailwind-merge";
|
|
9
9
|
|
|
10
10
|
// src/core.ts
|
|
11
|
-
|
|
12
|
-
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
13
|
-
}
|
|
11
|
+
import { escapeHtml } from "@ai-matrx/kit/html-escape";
|
|
14
12
|
function openPrintWindow(htmlDocument, filename = "print", windowFeatures = "width=920,height=720,scrollbars=yes") {
|
|
15
13
|
const win = window.open("", "_blank", windowFeatures);
|
|
16
14
|
if (!win) {
|
|
@@ -31,6 +29,9 @@ function openPrintWindow(htmlDocument, filename = "print", windowFeatures = "wid
|
|
|
31
29
|
return "opened";
|
|
32
30
|
}
|
|
33
31
|
|
|
32
|
+
// src/labels.ts
|
|
33
|
+
import { escapeHtml as escapeHtml2 } from "@ai-matrx/kit/html-escape";
|
|
34
|
+
|
|
34
35
|
// src/qr.ts
|
|
35
36
|
var QR_MIN_QUIET_ZONE_MODULES = 4;
|
|
36
37
|
var DEFAULT_QR_EC_LEVEL = "M";
|
|
@@ -505,18 +506,18 @@ function buildLabelCellHtml(label, qrDataUri, t, layout, s) {
|
|
|
505
506
|
const badgeText = label.badge?.trim() ? label.badge.trim() : "";
|
|
506
507
|
if (layout.wide) {
|
|
507
508
|
const lines = s.showLines && label.lines?.length ? label.lines.filter((l) => l.trim()).map(
|
|
508
|
-
(l) => `<div class="lp-line" style="font-size:8pt;">${
|
|
509
|
+
(l) => `<div class="lp-line" style="font-size:8pt;">${escapeHtml2(l)}</div>`
|
|
509
510
|
).join("") : "";
|
|
510
|
-
const caption2 = captionText ? `<div class="lp-fit-wrap" style="max-height:${(t.labelHIn * 0.3).toFixed(3)}in;"><div class="lp-fit lp-caption" style="font-size:12pt;">${
|
|
511
|
-
const badge2 = badgeText ? `<div class="lp-fit-wrap" style="max-height:${layout.badgeZoneIn.toFixed(3)}in;"><div class="lp-fit lp-badge" style="font-size:24pt;">${
|
|
512
|
-
const image = isHttpUrl(label.imageUrl) ? `<img class="lp-img" src="${
|
|
511
|
+
const caption2 = captionText ? `<div class="lp-fit-wrap" style="max-height:${(t.labelHIn * 0.3).toFixed(3)}in;"><div class="lp-fit lp-caption" style="font-size:12pt;">${escapeHtml2(captionText)}</div></div>` : "";
|
|
512
|
+
const badge2 = badgeText ? `<div class="lp-fit-wrap" style="max-height:${layout.badgeZoneIn.toFixed(3)}in;"><div class="lp-fit lp-badge" style="font-size:24pt;">${escapeHtml2(badgeText)}</div></div>` : "";
|
|
513
|
+
const image = isHttpUrl(label.imageUrl) ? `<img class="lp-img" src="${escapeHtml2(label.imageUrl)}" alt="" style="height:${(t.labelHIn * 0.35).toFixed(3)}in;" />` : "";
|
|
513
514
|
return `<div class="lp-cell-wide" style="height:100%;padding:${layout.padIn}in;gap:${layout.padIn}in;">
|
|
514
515
|
${qr}
|
|
515
516
|
<div class="lp-text">${badge2}${caption2}${lines}${image}</div>
|
|
516
517
|
</div>`;
|
|
517
518
|
}
|
|
518
|
-
const caption = captionText ? `<div class="lp-fit-wrap lp-caption-stacked" style="height:${Math.min(0.28, t.labelHIn * 0.16).toFixed(3)}in;"><div class="lp-fit lp-caption" style="font-size:9pt;">${
|
|
519
|
-
const badge = badgeText ? `<div class="lp-fit-wrap lp-badge-stacked" style="height:${layout.badgeZoneIn.toFixed(3)}in;"><div class="lp-fit lp-badge" style="font-size:18pt;">${
|
|
519
|
+
const caption = captionText ? `<div class="lp-fit-wrap lp-caption-stacked" style="height:${Math.min(0.28, t.labelHIn * 0.16).toFixed(3)}in;"><div class="lp-fit lp-caption" style="font-size:9pt;">${escapeHtml2(captionText)}</div></div>` : "";
|
|
520
|
+
const badge = badgeText ? `<div class="lp-fit-wrap lp-badge-stacked" style="height:${layout.badgeZoneIn.toFixed(3)}in;"><div class="lp-fit lp-badge" style="font-size:18pt;">${escapeHtml2(badgeText)}</div></div>` : "";
|
|
520
521
|
return `<div class="lp-cell-stacked" style="height:100%;padding:${layout.padIn}in;">
|
|
521
522
|
${qr}
|
|
522
523
|
${badge}
|
|
@@ -537,12 +538,12 @@ function renderPages(t, cells) {
|
|
|
537
538
|
return pages.join("\n");
|
|
538
539
|
}
|
|
539
540
|
function openSheetWindow(t, bodyHtml, title, withFitScript, warning) {
|
|
540
|
-
const warningHtml = warning ? `<div class="screen-only lp-warning" style="font-family:sans-serif;font-size:12px;font-weight:600;padding:9px 16px;background:#fef2f2;color:#991b1b;border-bottom:1px solid #fecaca;">${
|
|
541
|
+
const warningHtml = warning ? `<div class="screen-only lp-warning" style="font-family:sans-serif;font-size:12px;font-weight:600;padding:9px 16px;background:#fef2f2;color:#991b1b;border-bottom:1px solid #fecaca;">${escapeHtml2(warning)}</div>` : "";
|
|
541
542
|
const html = `<!DOCTYPE html>
|
|
542
543
|
<html lang="en">
|
|
543
544
|
<head>
|
|
544
545
|
<meta charset="UTF-8">
|
|
545
|
-
<title>${
|
|
546
|
+
<title>${escapeHtml2(title)} \u2014 ${escapeHtml2(t.stockCode)}</title>
|
|
546
547
|
<style>${sheetStyles(t)}</style>
|
|
547
548
|
</head>
|
|
548
549
|
<body>
|
|
@@ -550,7 +551,7 @@ ${warningHtml}
|
|
|
550
551
|
<div class="screen-only" style="font-family:sans-serif;font-size:12px;padding:10px 16px;background:#f8fafc;border-bottom:1px solid #e2e8f0;display:flex;gap:10px;align-items:center;flex-wrap:wrap;">
|
|
551
552
|
<button onclick="window.print()" style="padding:7px 18px;background:#111;color:#fff;border:none;border-radius:6px;font-size:13px;font-weight:600;cursor:pointer;">Print / Save PDF</button>
|
|
552
553
|
<button onclick="window.close()" style="padding:7px 14px;background:#f1f5f9;border:1px solid #cbd5e1;border-radius:6px;font-size:13px;cursor:pointer;">Close</button>
|
|
553
|
-
<span style="color:#64748b;font-size:11px;">${
|
|
554
|
+
<span style="color:#64748b;font-size:11px;">${escapeHtml2(t.stockCode)} \xB7 ${escapeHtml2(t.name)} \xB7 set printer to <strong>100% scale (no "fit to page"), no margins, Portrait</strong></span>
|
|
554
555
|
</div>
|
|
555
556
|
${bodyHtml}
|
|
556
557
|
${withFitScript ? LP_FIT_SCRIPT : ""}
|
|
@@ -590,7 +591,7 @@ function buildCalibrationBody(t) {
|
|
|
590
591
|
mark(gridR, gridB - 0.0104, true),
|
|
591
592
|
mark(gridR - 0.0104, gridB, false)
|
|
592
593
|
].join("");
|
|
593
|
-
const banner = `<div style="position:absolute;left:0;right:0;top:${Math.max(0, t.marginTopIn - 0.3).toFixed(2)}in;text-align:center;font-size:7pt;color:#94a3b8;">Calibration \u2014 ${
|
|
594
|
+
const banner = `<div style="position:absolute;left:0;right:0;top:${Math.max(0, t.marginTopIn - 0.3).toFixed(2)}in;text-align:center;font-size:7pt;color:#94a3b8;">Calibration \u2014 ${escapeHtml2(t.stockCode)} \xB7 hold against your label sheet: every outline must sit on a label</div>`;
|
|
594
595
|
return `<div class="lp-page">${banner}${marks}${cells.join("\n")}</div>`;
|
|
595
596
|
}
|
|
596
597
|
function printCalibrationSheet(template) {
|