jenosize-ui 0.2.2 → 0.3.1
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/README.md +183 -63
- package/THIRD-PARTY-NOTICES.md +95 -0
- package/dist/GradientPicker-Bv3V3vL_.d.ts +144 -0
- package/dist/{PaymentInput-Dn5WVQVy.d.ts → PaymentInput-s7_s3UDi.d.ts} +1 -1
- package/dist/{Select-Dt5ARIH8.d.ts → Select-r233iMaU.d.ts} +15 -1
- package/dist/{TagInput-BaBeve6L.d.ts → TagInput-w_l9Fp5i.d.ts} +1 -1
- package/dist/area-chart.d.ts +2 -2
- package/dist/area-chart.js +8 -6
- package/dist/at-least-one-BZ2dsck-.d.ts +18 -0
- package/dist/avatar.d.ts +1 -1
- package/dist/avatar.js +12 -10
- package/dist/badge.d.ts +1 -1
- package/dist/badge.js +7 -6
- package/dist/bar-chart.d.ts +2 -2
- package/dist/bar-chart.js +8 -6
- package/dist/breadcrumb.d.ts +1 -1
- package/dist/breadcrumb.js +5 -4
- package/dist/button.d.ts +1 -1
- package/dist/button.js +12 -10
- package/dist/calendar.d.ts +1 -1
- package/dist/calendar.js +16 -14
- package/dist/callout.d.ts +4 -2
- package/dist/callout.js +13 -11
- package/dist/card.d.ts +59 -3
- package/dist/card.js +4 -3
- package/dist/carousel.d.ts +169 -0
- package/dist/carousel.js +10 -0
- package/dist/catalog.json +11976 -0
- package/dist/checkbox.js +9 -7
- package/dist/{chunk-AIARANKE.js → chunk-2EUVBRKG.js} +4 -4
- package/dist/{chunk-5ZEUTSCV.js → chunk-2RRPWOKT.js} +6 -6
- package/dist/{chunk-DD5KJVFV.js → chunk-3JFSKCVU.js} +19 -19
- package/dist/{chunk-OACWA4TC.js → chunk-3ZZZPT5G.js} +6 -6
- package/dist/{chunk-LQURV7HQ.js → chunk-47EOHGXM.js} +4 -4
- package/dist/{chunk-CGHYXWTT.js → chunk-4KRCT3Q2.js} +4 -4
- package/dist/chunk-4P3JA653.js +1129 -0
- package/dist/{chunk-FWRHBMWT.js → chunk-4Y32RIC7.js} +5 -19
- package/dist/{chunk-BBKE4W3B.js → chunk-5Z26DU23.js} +7 -7
- package/dist/{chunk-7QXOGAN6.js → chunk-6CJYVYVN.js} +87 -538
- package/dist/{chunk-3HOHLQVP.js → chunk-6FGLABYH.js} +3 -3
- package/dist/{chunk-GQRSABRN.js → chunk-6Q4VVBFO.js} +4 -4
- package/dist/{chunk-MCQG4H6T.js → chunk-6T3QAO5K.js} +12 -4
- package/dist/chunk-7JOW3LEH.js +4852 -0
- package/dist/{chunk-AFYXSZGW.js → chunk-7LSUUEAF.js} +7 -5
- package/dist/{chunk-7VLYQR4D.js → chunk-7OFGPDYJ.js} +3 -3
- package/dist/{chunk-7GUPNTAH.js → chunk-7RD5RTHU.js} +7 -7
- package/dist/{chunk-X2VMIBK5.js → chunk-A36W77MQ.js} +4 -4
- package/dist/chunk-AZFHRLYF.js +67 -0
- package/dist/{chunk-CFFWYXDW.js → chunk-B6LYO33Y.js} +5 -5
- package/dist/{chunk-P6CON2R2.js → chunk-BH32X25C.js} +3 -3
- package/dist/{chunk-KHGW72BM.js → chunk-CH2XMCWX.js} +3 -3
- package/dist/{chunk-FNQJJO63.js → chunk-D46OKHTH.js} +4 -4
- package/dist/{chunk-LE44X5GS.js → chunk-D4YGYNNY.js} +9 -9
- package/dist/{chunk-T5574MXM.js → chunk-D7WD4SUC.js} +8 -8
- package/dist/{chunk-33TOK7ES.js → chunk-DCKVNHV5.js} +5 -5
- package/dist/chunk-EBZNUQ6E.js +525 -0
- package/dist/{chunk-22M75A3N.js → chunk-ED5UCYAV.js} +14 -11
- package/dist/{chunk-IQNVSQRK.js → chunk-EDVYLO2N.js} +5 -5
- package/dist/{chunk-N3RVMBPX.js → chunk-EJKQGUUM.js} +4 -4
- package/dist/{chunk-POQTE7JI.js → chunk-EKQLIUV5.js} +7 -7
- package/dist/{chunk-ULGCGKOE.js → chunk-EKV3CVTY.js} +4 -4
- package/dist/{chunk-LCG34A5T.js → chunk-EVINS473.js} +5 -3
- package/dist/{chunk-ZZSNTCCL.js → chunk-G7B2QUQP.js} +4 -4
- package/dist/{chunk-SB3DG572.js → chunk-GHRZC5LS.js} +6 -6
- package/dist/{chunk-5YWH2ANQ.js → chunk-GIC6T647.js} +11 -10
- package/dist/{chunk-7ZM7SNCZ.js → chunk-GPHGPY6T.js} +3 -3
- package/dist/chunk-GV2KTRRP.js +325 -0
- package/dist/{chunk-4RBIWI2Q.js → chunk-GYL4KOPT.js} +3 -3
- package/dist/{chunk-5KSD4WKN.js → chunk-HB6UA6EF.js} +5 -5
- package/dist/{chunk-CGZXQ7PA.js → chunk-HNNNJP3A.js} +3 -3
- package/dist/chunk-HTWGTTSF.js +1011 -0
- package/dist/chunk-IH2F5UNQ.js +109 -0
- package/dist/{chunk-QNIKRB62.js → chunk-INYUL4DX.js} +4 -4
- package/dist/{chunk-SKRR3ZMP.js → chunk-IUB5TSSH.js} +3 -3
- package/dist/chunk-JGGSRKHW.js +344 -0
- package/dist/{chunk-ZR6HNKSN.js → chunk-JHHJNIW2.js} +3 -3
- package/dist/chunk-KBI442IB.js +113 -0
- package/dist/chunk-KBQJIVUB.js +33 -0
- package/dist/{chunk-3QXLIZIX.js → chunk-KNGJ3CSB.js} +3 -3
- package/dist/chunk-KNKR5TUM.js +183 -0
- package/dist/{chunk-KZP6B6B3.js → chunk-KTWTYK5U.js} +16 -5
- package/dist/{chunk-5XPMY2LF.js → chunk-LKUAVDWP.js} +5 -5
- package/dist/{chunk-YHBI52P2.js → chunk-LPWSP523.js} +3 -3
- package/dist/{chunk-GLKFFA7N.js → chunk-LY7IJOUF.js} +5 -5
- package/dist/{chunk-R4Z7BINC.js → chunk-LYWQD5KL.js} +8 -8
- package/dist/{chunk-LLPWQDF7.js → chunk-MTOTPAYZ.js} +3 -3
- package/dist/{chunk-AZ7DKRBY.js → chunk-MVF7FA4D.js} +5 -5
- package/dist/{chunk-AIGYMTCU.js → chunk-MVUNB43J.js} +3 -3
- package/dist/{chunk-T4ZFZTY6.js → chunk-N7DLNDER.js} +4 -4
- package/dist/{chunk-E2YZ7IMT.js → chunk-NDRQETOQ.js} +15 -11
- package/dist/{chunk-ZD3MOLIB.js → chunk-O7CPRU67.js} +4 -4
- package/dist/{chunk-OLLD2BZN.js → chunk-OEYKTHG7.js} +3 -3
- package/dist/{chunk-TX57TNJS.js → chunk-OG3H3RP2.js} +9 -9
- package/dist/{chunk-UGBNYSBN.js → chunk-PFKPKE6O.js} +20 -34
- package/dist/chunk-PRWPFBA5.js +619 -0
- package/dist/{chunk-QDKETK7D.js → chunk-S55JKMG7.js} +5 -5
- package/dist/{chunk-QDYE5LVT.js → chunk-SF3HCW4G.js} +45 -4
- package/dist/{chunk-6MMBQVRO.js → chunk-TDKKZA63.js} +9 -9
- package/dist/{chunk-HHYEAFCL.js → chunk-TDXHBS2C.js} +11 -11
- package/dist/{chunk-74AIU53R.js → chunk-THGGU64E.js} +3 -3
- package/dist/chunk-UHSGD4CD.js +364 -0
- package/dist/{chunk-HV2W6HUR.js → chunk-URAURI6G.js} +10 -10
- package/dist/{chunk-D6XO4JVM.js → chunk-UU6KUS5O.js} +42 -20
- package/dist/{chunk-NKG4N6HA.js → chunk-V7KEEDSF.js} +5 -4
- package/dist/{chunk-IEAWNA3V.js → chunk-VDFWWWLL.js} +3 -3
- package/dist/chunk-VHAA22YE.js +11 -0
- package/dist/chunk-WJB5GWAZ.js +20 -0
- package/dist/{chunk-KJ5JUS53.js → chunk-WM6DGNIA.js} +9 -9
- package/dist/{chunk-MFFA5MXY.js → chunk-WUXMLJEC.js} +5 -5
- package/dist/{chunk-YPNL2NBD.js → chunk-XNXBO44X.js} +33 -11
- package/dist/chunk-XPY3XT7L.js +5671 -0
- package/dist/{chunk-54SIZR63.js → chunk-XVFRDKZJ.js} +7 -7
- package/dist/{chunk-LYXPJERB.js → chunk-YDD46AX2.js} +5 -5
- package/dist/{chunk-NC63TYNW.js → chunk-YHQJGNXD.js} +7 -7
- package/dist/{chunk-I6WMNXC7.js → chunk-YKRE5NIH.js} +6 -6
- package/dist/{chunk-RJTVCA62.js → chunk-ZIEGUI25.js} +3 -3
- package/dist/{chunk-5DP7W5HX.js → chunk-ZLDWYTDA.js} +3 -3
- package/dist/color-input.d.ts +93 -0
- package/dist/color-input.js +36 -0
- package/dist/color-picker.d.ts +268 -0
- package/dist/color-picker.js +29 -0
- package/dist/color-value-DYzChVOW.d.ts +129 -0
- package/dist/combobox.d.ts +1 -1
- package/dist/combobox.js +14 -12
- package/dist/data-map.d.ts +1673 -0
- package/dist/data-map.js +36 -0
- package/dist/date-calendar.d.ts +49 -0
- package/dist/date-calendar.js +13 -0
- package/dist/date-input.d.ts +1 -1
- package/dist/date-input.js +12 -10
- package/dist/date-picker.d.ts +15 -131
- package/dist/date-picker.js +26 -21
- package/dist/date-types-CLZek3W2.d.ts +100 -0
- package/dist/dialog.d.ts +1 -1
- package/dist/dialog.js +10 -9
- package/dist/drawer.d.ts +1 -1
- package/dist/drawer.js +9 -8
- package/dist/dropdown-menu.d.ts +1 -1
- package/dist/dropdown-menu.js +5 -4
- package/dist/dropzone.d.ts +3 -3
- package/dist/dropzone.js +18 -16
- package/dist/file-trigger.js +1 -0
- package/dist/form.d.ts +15 -5
- package/dist/form.js +75 -35
- package/dist/header-navigation.d.ts +2 -2
- package/dist/header-navigation.js +20 -18
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +1 -0
- package/dist/illustration.js +1 -0
- package/dist/index.d.ts +26 -11
- package/dist/index.js +92 -77
- package/dist/indicator.js +5 -4
- package/dist/inline-banner.d.ts +68 -0
- package/dist/inline-banner.js +21 -0
- package/dist/input.d.ts +1 -1
- package/dist/input.js +11 -9
- package/dist/kanban-board.d.ts +2 -2
- package/dist/kanban-board.js +15 -13
- package/dist/labels-CuSlirP_.d.ts +1381 -0
- package/dist/line-chart.d.ts +2 -2
- package/dist/line-chart.js +8 -6
- package/dist/mcp.js +231 -0
- package/dist/number-input.d.ts +1 -1
- package/dist/number-input.js +11 -9
- package/dist/pagination.d.ts +1 -1
- package/dist/pagination.js +15 -13
- package/dist/{card-D56VxyAe.d.ts → panel-CUGm_Mxy.d.ts} +9 -57
- package/dist/payment-input.d.ts +3 -3
- package/dist/payment-input.js +11 -9
- package/dist/picker-draft-BPV3MUPY.d.ts +9 -0
- package/dist/pie-chart.d.ts +2 -2
- package/dist/pie-chart.js +8 -6
- package/dist/popover.d.ts +65 -4
- package/dist/popover.js +9 -8
- package/dist/progress-steps.js +5 -4
- package/dist/progress.js +4 -3
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +4 -3
- package/dist/qr-code.d.ts +227 -0
- package/dist/qr-code.js +20 -0
- package/dist/radar-chart.d.ts +2 -2
- package/dist/radar-chart.js +8 -6
- package/dist/radial-chart.d.ts +2 -2
- package/dist/radial-chart.js +8 -6
- package/dist/radio.js +9 -7
- package/dist/rich-text-editor.d.ts +624 -0
- package/dist/rich-text-editor.js +52 -0
- package/dist/rich-text-highlight.d.ts +11 -0
- package/dist/rich-text-highlight.js +65 -0
- package/dist/rich-text-sanitize.d.ts +17 -0
- package/dist/rich-text-sanitize.js +176 -0
- package/dist/scroll-area.js +1 -0
- package/dist/select.d.ts +2 -2
- package/dist/select.js +17 -15
- package/dist/separator.js +3 -2
- package/dist/shared-CGf2D8ZX.d.ts +20 -0
- package/dist/sidebar-navigation.d.ts +73 -32
- package/dist/sidebar-navigation.js +15 -13
- package/dist/sidebar-state.d.ts +76 -0
- package/dist/sidebar-state.js +27 -0
- package/dist/skeleton.js +3 -2
- package/dist/slider.d.ts +321 -0
- package/dist/slider.js +14 -0
- package/dist/styles.css +1 -1
- package/dist/switch.d.ts +1 -1
- package/dist/switch.js +3 -2
- package/dist/table.d.ts +3 -19
- package/dist/table.js +34 -32
- package/dist/tabs.js +3 -2
- package/dist/tag-input.d.ts +3 -3
- package/dist/tag-input.js +14 -12
- package/dist/tag.d.ts +1 -1
- package/dist/tag.js +5 -4
- package/dist/textarea.js +9 -7
- package/dist/theme.css +965 -0
- package/dist/theme.js +13 -11
- package/dist/toast.d.ts +1 -1
- package/dist/toast.js +13 -11
- package/dist/tooltip.js +5 -3
- package/dist/tree.d.ts +1 -1
- package/dist/tree.js +7 -6
- package/dist/{types-DR9rAEy1.d.ts → types-BoZ6XeLB.d.ts} +1 -1
- package/dist/{use-uploads-KaPqDklo.d.ts → use-uploads-cHo2p7Gn.d.ts} +1 -1
- package/dist/verification-code-input.js +11 -9
- package/package.json +105 -8
- package/dist/chunk-BLIZ3CL3.js +0 -49
- package/dist/labels-DPrh0se9.d.ts +0 -627
- package/dist/panel-El4oI68p.d.ts +0 -9
- package/dist/shared-BYXJPnsN.d.ts +0 -11
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
import { relativeLuminance, BLACK, parseColor } from './chunk-UHSGD4CD.js';
|
|
2
|
+
import { Button } from './chunk-3ZZZPT5G.js';
|
|
3
|
+
import { DownloadIcon } from './chunk-KBI442IB.js';
|
|
4
|
+
import { cn } from './chunk-ZSNJ6UA3.js';
|
|
5
|
+
import { useLabels } from './chunk-ZIEGUI25.js';
|
|
6
|
+
import { warnPositiveInt, devWarn, warnAspectOverflow } from './chunk-SF3HCW4G.js';
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { QrCodeDataType, encode } from 'uqr';
|
|
9
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
10
|
+
|
|
11
|
+
// src/lib/download.ts
|
|
12
|
+
function serializeSvg(svg, pixelSize) {
|
|
13
|
+
const clone = svg.cloneNode(true);
|
|
14
|
+
if (pixelSize !== void 0) {
|
|
15
|
+
clone.setAttribute("width", String(pixelSize));
|
|
16
|
+
clone.setAttribute("height", String(pixelSize));
|
|
17
|
+
}
|
|
18
|
+
clone.removeAttribute("class");
|
|
19
|
+
for (const el of clone.querySelectorAll("[class]")) el.removeAttribute("class");
|
|
20
|
+
for (const el of [clone, ...clone.querySelectorAll("[aria-labelledby]")]) {
|
|
21
|
+
const ids = el.getAttribute("aria-labelledby")?.split(/\s+/).filter(Boolean) ?? [];
|
|
22
|
+
if (ids.length > 0 && ids.every((id) => clone.querySelector(`[id="${CSS.escape(id)}"]`) === null)) {
|
|
23
|
+
el.removeAttribute("aria-labelledby");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const markup = new XMLSerializer().serializeToString(clone);
|
|
27
|
+
return markup.includes('xmlns="http://www.w3.org/2000/svg"') ? markup : markup.replace("<svg", '<svg xmlns="http://www.w3.org/2000/svg"');
|
|
28
|
+
}
|
|
29
|
+
async function rasterizeSvgMarkup(markup, pixelSize) {
|
|
30
|
+
const source = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(markup)}`;
|
|
31
|
+
const img = new Image();
|
|
32
|
+
img.src = source;
|
|
33
|
+
await img.decode();
|
|
34
|
+
const canvas = document.createElement("canvas");
|
|
35
|
+
canvas.width = pixelSize;
|
|
36
|
+
canvas.height = pixelSize;
|
|
37
|
+
const ctx = canvas.getContext("2d");
|
|
38
|
+
if (ctx === null) throw new Error("rasterizeSvgMarkup: no 2D canvas context.");
|
|
39
|
+
ctx.imageSmoothingEnabled = false;
|
|
40
|
+
ctx.drawImage(img, 0, 0, pixelSize, pixelSize);
|
|
41
|
+
return await new Promise((resolve, reject) => {
|
|
42
|
+
canvas.toBlob((blob) => blob === null ? reject(new Error("rasterizeSvgMarkup: toBlob returned null.")) : resolve(blob), "image/png");
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async function svgToPngBlob(svg, pixelSize) {
|
|
46
|
+
return await rasterizeSvgMarkup(serializeSvg(svg, pixelSize), pixelSize);
|
|
47
|
+
}
|
|
48
|
+
function saveBlob(blob, fileName) {
|
|
49
|
+
const url = URL.createObjectURL(blob);
|
|
50
|
+
const anchor = document.createElement("a");
|
|
51
|
+
anchor.href = url;
|
|
52
|
+
anchor.download = fileName;
|
|
53
|
+
anchor.rel = "noopener";
|
|
54
|
+
document.body.append(anchor);
|
|
55
|
+
anchor.click();
|
|
56
|
+
anchor.remove();
|
|
57
|
+
setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
58
|
+
}
|
|
59
|
+
var QUIET_ZONE = 4;
|
|
60
|
+
var EYE_SIZE = 7;
|
|
61
|
+
var LOGO_FRACTION = { sm: 0.18, md: 0.24, lg: 0.28 };
|
|
62
|
+
var DEFAULT_LOGO_SIZE = "md";
|
|
63
|
+
var DEFAULT_LOGO_SHAPE = "square";
|
|
64
|
+
var LOGO_BLEED = 1;
|
|
65
|
+
var LOGO_GRID = 24;
|
|
66
|
+
var LOGO_ASPECT_MIN = 0.5;
|
|
67
|
+
var LOGO_ASPECT_MAX = 2;
|
|
68
|
+
var LOGO_SHAPE_RADIUS = { square: 0, circle: 0.5 };
|
|
69
|
+
var MODULE_SHAPE = {
|
|
70
|
+
square: { size: 1, radius: 0 },
|
|
71
|
+
rounded: { size: 0.85, radius: 0.25 },
|
|
72
|
+
dot: { size: 1, radius: 0.5 }
|
|
73
|
+
};
|
|
74
|
+
var EYE_RADIUS = { square: 0, rounded: 2, circle: 3.5 };
|
|
75
|
+
var DEFAULT_QR_COLOR = "#000000";
|
|
76
|
+
var MIN_SYMBOL_CONTRAST = 0.45;
|
|
77
|
+
var LOCATOR_TYPES = /* @__PURE__ */ new Set([QrCodeDataType.Position, QrCodeDataType.Timing, QrCodeDataType.Function]);
|
|
78
|
+
var EMPTY = {
|
|
79
|
+
extent: 21 + QUIET_ZONE * 2,
|
|
80
|
+
path: "",
|
|
81
|
+
eyePath: "",
|
|
82
|
+
pupilPath: "",
|
|
83
|
+
hole: null,
|
|
84
|
+
logoBox: null,
|
|
85
|
+
logoTransform: null,
|
|
86
|
+
holeCoversLocator: false,
|
|
87
|
+
budgetExceeded: false,
|
|
88
|
+
unencodable: true
|
|
89
|
+
};
|
|
90
|
+
function buildQrGeometry(value, options = {}) {
|
|
91
|
+
if (value === "") {
|
|
92
|
+
devWarn("<QrCode> `value` is empty \u2014 there is nothing to encode. Render the code once you have a value.");
|
|
93
|
+
return EMPTY;
|
|
94
|
+
}
|
|
95
|
+
const ecc = options.ecc ?? "H";
|
|
96
|
+
const moduleShape = options.modules ?? "square";
|
|
97
|
+
const eyeShape = options.eyes ?? "square";
|
|
98
|
+
const rawAspect = options.logoAspect ?? null;
|
|
99
|
+
let result;
|
|
100
|
+
try {
|
|
101
|
+
result = encode(value, { ecc, border: QUIET_ZONE });
|
|
102
|
+
} catch {
|
|
103
|
+
devWarn(`<QrCode> \`value\` is too long to encode at error correction level "${ecc}" (${value.length} chars). Shorten it, or lower \`ecc\`.`);
|
|
104
|
+
return EMPTY;
|
|
105
|
+
}
|
|
106
|
+
let aspect = rawAspect === null ? null : clampAspect(rawAspect);
|
|
107
|
+
if (aspect !== null && (ecc === "L" || ecc === "M")) {
|
|
108
|
+
devWarn(
|
|
109
|
+
`<QrCode> \`ecc="${ecc}"\` cannot carry a \`logo\`, so the mark was DROPPED and the bare code rendered. The mark erases part of the code, and that erasure comes out of the same budget the level buys \u2014 level ${ecc} recovers ~${ecc === "L" ? 7 : 15}%, which a centre mark alone exhausts, and the failure is silent: the code renders perfectly and simply does not decode. Use "Q" or "H" (the default) whenever there is a mark.`
|
|
110
|
+
);
|
|
111
|
+
aspect = null;
|
|
112
|
+
}
|
|
113
|
+
const { size, data, types } = result;
|
|
114
|
+
const logoSize = options.logoSize ?? DEFAULT_LOGO_SIZE;
|
|
115
|
+
const logoShape = options.logoShape ?? DEFAULT_LOGO_SHAPE;
|
|
116
|
+
const hole = aspect === null ? null : centredHole(size, aspect, logoSize, logoShape);
|
|
117
|
+
const drawEyes = moduleShape !== "square" || eyeShape !== "square" || options.tintedEyes === true;
|
|
118
|
+
const box = hole === null || aspect === null ? null : markBox(hole, aspect);
|
|
119
|
+
const spend = hole === null ? null : codewordBudget(value, options);
|
|
120
|
+
return {
|
|
121
|
+
extent: size,
|
|
122
|
+
path: modulesToPath(data, types, hole, moduleShape, drawEyes),
|
|
123
|
+
eyePath: drawEyes ? eyeRingPath(size, eyeShape) : "",
|
|
124
|
+
pupilPath: drawEyes ? eyePupilPath(size, eyeShape) : "",
|
|
125
|
+
hole,
|
|
126
|
+
logoBox: box,
|
|
127
|
+
logoTransform: box === null ? null : `translate(${n(box.x)} ${n(box.y)}) scale(${box.h / LOGO_GRID})`,
|
|
128
|
+
holeCoversLocator: hole !== null && coversLocatorPattern(types, hole),
|
|
129
|
+
budgetExceeded: spend !== null && spend.destroyed > spend.budget,
|
|
130
|
+
unencodable: false
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
var ECC_BUDGET = { L: 0.07, M: 0.15, Q: 0.25, H: 0.3 };
|
|
134
|
+
function codewordBudget(value, options = {}) {
|
|
135
|
+
if (value === "") return null;
|
|
136
|
+
const ecc = options.ecc ?? "H";
|
|
137
|
+
let result;
|
|
138
|
+
try {
|
|
139
|
+
result = encode(value, { ecc, border: QUIET_ZONE });
|
|
140
|
+
} catch {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
const { size, types } = result;
|
|
144
|
+
const aspect = options.logoAspect ?? null;
|
|
145
|
+
const hole = aspect === null ? null : centredHole(
|
|
146
|
+
size,
|
|
147
|
+
Math.min(LOGO_ASPECT_MAX, Math.max(LOGO_ASPECT_MIN, aspect)),
|
|
148
|
+
options.logoSize ?? DEFAULT_LOGO_SIZE,
|
|
149
|
+
options.logoShape ?? DEFAULT_LOGO_SHAPE
|
|
150
|
+
);
|
|
151
|
+
const code = size - QUIET_ZONE * 2;
|
|
152
|
+
const destroyed = /* @__PURE__ */ new Set();
|
|
153
|
+
let bit = 0;
|
|
154
|
+
let upward = true;
|
|
155
|
+
for (let col = code - 1; col > 0; col -= 2) {
|
|
156
|
+
if (col === 6) col -= 1;
|
|
157
|
+
for (let i = 0; i < code; i++) {
|
|
158
|
+
const row = upward ? code - 1 - i : i;
|
|
159
|
+
for (const c of [col, col - 1]) {
|
|
160
|
+
const ir = row + QUIET_ZONE;
|
|
161
|
+
const ic = c + QUIET_ZONE;
|
|
162
|
+
if (types[ir]?.[ic] === QrCodeDataType.Data) {
|
|
163
|
+
if (inHole(hole, ir, ic)) destroyed.add(bit >> 3);
|
|
164
|
+
bit += 1;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
upward = !upward;
|
|
169
|
+
}
|
|
170
|
+
const total = bit >> 3;
|
|
171
|
+
return { destroyed: destroyed.size, budget: Math.floor(total * ECC_BUDGET[ecc]) };
|
|
172
|
+
}
|
|
173
|
+
var HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
174
|
+
function relativeLuminance2(hex) {
|
|
175
|
+
return relativeLuminance(parseColor(hex) ?? BLACK);
|
|
176
|
+
}
|
|
177
|
+
function symbolContrast(hex) {
|
|
178
|
+
return 1 - relativeLuminance2(hex);
|
|
179
|
+
}
|
|
180
|
+
function resolveQrColor(color, prop = "color") {
|
|
181
|
+
if (color === void 0) return DEFAULT_QR_COLOR;
|
|
182
|
+
if (!HEX.test(color)) {
|
|
183
|
+
devWarn(
|
|
184
|
+
`<QrCode> \`${prop}\` must be a 3- or 6-digit hex like "#06C755" \u2014 got "${color}". Falling back to ${DEFAULT_QR_COLOR}. An alpha channel is rejected too: a translucent module composites against whatever sits behind the plate, and a scanner has no way to threshold that.`
|
|
185
|
+
);
|
|
186
|
+
return DEFAULT_QR_COLOR;
|
|
187
|
+
}
|
|
188
|
+
const contrast = symbolContrast(color);
|
|
189
|
+
if (contrast < MIN_SYMBOL_CONTRAST) {
|
|
190
|
+
devWarn(
|
|
191
|
+
`<QrCode> \`${prop}="${color}"\` has ${(contrast * 100).toFixed(0)}% symbol contrast against the white plate, below the ${MIN_SYMBOL_CONTRAST * 100}% ISO/IEC 15415 wants for a printed symbol. It will still decode from a screen; what it loses is the margin a camera needs at an angle, under warm light, or on a matte label. Darken it. For reference, LINE's brand green (#06C755) measures 59%.`
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
return color;
|
|
195
|
+
}
|
|
196
|
+
function shapeRenderingFor(modules = "square", eyes = "square") {
|
|
197
|
+
return modules === "square" && eyes === "square" ? "crispEdges" : "geometricPrecision";
|
|
198
|
+
}
|
|
199
|
+
function n(value) {
|
|
200
|
+
return String(Math.round(value * 1e4) / 1e4);
|
|
201
|
+
}
|
|
202
|
+
function roundedRectPath(x, y, w, h, r) {
|
|
203
|
+
const rr = Math.min(r, w / 2, h / 2);
|
|
204
|
+
if (rr <= 0) return `M${n(x)} ${n(y)}h${n(w)}v${n(h)}h${n(-w)}z`;
|
|
205
|
+
const side = w - rr * 2;
|
|
206
|
+
const rise = h - rr * 2;
|
|
207
|
+
const arc = `a${n(rr)} ${n(rr)} 0 0 1 `;
|
|
208
|
+
return `M${n(x + rr)} ${n(y)}h${n(side)}${arc}${n(rr)} ${n(rr)}v${n(rise)}${arc}${n(-rr)} ${n(rr)}h${n(-side)}${arc}${n(-rr)} ${n(-rr)}v${n(-rise)}${arc}${n(rr)} ${n(-rr)}z`;
|
|
209
|
+
}
|
|
210
|
+
function centredHole(extent, aspect, size, shape) {
|
|
211
|
+
let inner = Math.round((extent - QUIET_ZONE * 2) * LOGO_FRACTION[size]);
|
|
212
|
+
if (inner % 2 === 0) inner += 1;
|
|
213
|
+
const area = inner * inner;
|
|
214
|
+
const wi0 = oddify(Math.sqrt(area * aspect));
|
|
215
|
+
const hi0 = oddBelow(area / wi0);
|
|
216
|
+
const fitH = Math.min(hi0, wi0 / aspect);
|
|
217
|
+
const wi = Math.min(wi0, oddAtLeast(fitH * aspect));
|
|
218
|
+
const hi = Math.min(hi0, oddAtLeast(fitH));
|
|
219
|
+
const w = wi + LOGO_BLEED * 2;
|
|
220
|
+
const h = hi + LOGO_BLEED * 2;
|
|
221
|
+
return { x: (extent - w) / 2, y: (extent - h) / 2, w, h, r: Math.min(w, h) * LOGO_SHAPE_RADIUS[shape] };
|
|
222
|
+
}
|
|
223
|
+
function oddify(value) {
|
|
224
|
+
return Math.max(1, 2 * Math.round((value - 1) / 2) + 1);
|
|
225
|
+
}
|
|
226
|
+
function oddBelow(value) {
|
|
227
|
+
const floored = Math.floor(value);
|
|
228
|
+
return Math.max(1, floored % 2 === 0 ? floored - 1 : floored);
|
|
229
|
+
}
|
|
230
|
+
function oddAtLeast(value) {
|
|
231
|
+
const ceiled = Math.ceil(value);
|
|
232
|
+
return Math.max(1, ceiled % 2 === 0 ? ceiled + 1 : ceiled);
|
|
233
|
+
}
|
|
234
|
+
function clampAspect(aspect) {
|
|
235
|
+
if (!Number.isFinite(aspect) || aspect <= 0) {
|
|
236
|
+
devWarn(`<QrCode> \`logo.aspect\` must be a positive number \u2014 got ${aspect}. Falling back to 1 (a square mark).`);
|
|
237
|
+
return 1;
|
|
238
|
+
}
|
|
239
|
+
if (aspect < LOGO_ASPECT_MIN || aspect > LOGO_ASPECT_MAX) {
|
|
240
|
+
const clamped = Math.min(LOGO_ASPECT_MAX, Math.max(LOGO_ASPECT_MIN, aspect));
|
|
241
|
+
devWarn(
|
|
242
|
+
`<QrCode> \`logo.aspect\` is ${aspect}, outside the ${LOGO_ASPECT_MIN}\u2013${LOGO_ASPECT_MAX} a code can carry \u2014 clamped to ${clamped}. The hole holds its area as it widens, but a codeword is taller than it is wide, so a wider hole still destroys more of them: past 2 a version-3 code at level H is over its recovery budget.`
|
|
243
|
+
);
|
|
244
|
+
return clamped;
|
|
245
|
+
}
|
|
246
|
+
return aspect;
|
|
247
|
+
}
|
|
248
|
+
function markBox(hole, aspect) {
|
|
249
|
+
const availW = hole.w - LOGO_BLEED * 2;
|
|
250
|
+
const availH = hole.h - LOGO_BLEED * 2;
|
|
251
|
+
const h = Math.min(availH, availW / aspect);
|
|
252
|
+
const w = h * aspect;
|
|
253
|
+
return { x: hole.x + (hole.w - w) / 2, y: hole.y + (hole.h - h) / 2, w, h };
|
|
254
|
+
}
|
|
255
|
+
function insideRoundedRect(hole, px, py) {
|
|
256
|
+
if (px < hole.x || px > hole.x + hole.w || py < hole.y || py > hole.y + hole.h) return false;
|
|
257
|
+
const rr = Math.min(hole.r, hole.w / 2, hole.h / 2);
|
|
258
|
+
if (rr <= 0) return true;
|
|
259
|
+
const dx = Math.max(hole.x + rr - px, px - (hole.x + hole.w - rr), 0);
|
|
260
|
+
const dy = Math.max(hole.y + rr - py, py - (hole.y + hole.h - rr), 0);
|
|
261
|
+
return dx * dx + dy * dy <= rr * rr;
|
|
262
|
+
}
|
|
263
|
+
function inHole(hole, r, c) {
|
|
264
|
+
if (hole === null) return false;
|
|
265
|
+
return insideRoundedRect(hole, c + 0.5, r + 0.5);
|
|
266
|
+
}
|
|
267
|
+
function modulesToPath(data, types, hole, shape, styledEyes) {
|
|
268
|
+
const { size, radius } = MODULE_SHAPE[shape];
|
|
269
|
+
const inset = (1 - size) / 2;
|
|
270
|
+
const parts = [];
|
|
271
|
+
for (const [r, row] of data.entries()) {
|
|
272
|
+
let run = 0;
|
|
273
|
+
for (let c = 0; c <= row.length; c++) {
|
|
274
|
+
const dark = row[c] === true && !inHole(hole, r, c) && !(styledEyes && types[r]?.[c] === QrCodeDataType.Position);
|
|
275
|
+
if (shape === "square") {
|
|
276
|
+
if (dark) {
|
|
277
|
+
run += 1;
|
|
278
|
+
} else if (run > 0) {
|
|
279
|
+
parts.push(`M${c - run} ${r}h${run}v1h-${run}z`);
|
|
280
|
+
run = 0;
|
|
281
|
+
}
|
|
282
|
+
} else if (dark) {
|
|
283
|
+
parts.push(roundedRectPath(c + inset, r + inset, size, size, size * radius));
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return parts.join("");
|
|
288
|
+
}
|
|
289
|
+
function eyeOrigins(extent) {
|
|
290
|
+
const far = extent - QUIET_ZONE - EYE_SIZE;
|
|
291
|
+
return [
|
|
292
|
+
[QUIET_ZONE, QUIET_ZONE],
|
|
293
|
+
[far, QUIET_ZONE],
|
|
294
|
+
[QUIET_ZONE, far]
|
|
295
|
+
];
|
|
296
|
+
}
|
|
297
|
+
function eyeRingPath(extent, shape) {
|
|
298
|
+
const outer = EYE_RADIUS[shape];
|
|
299
|
+
return eyeOrigins(extent).map(
|
|
300
|
+
([x, y]) => (
|
|
301
|
+
// `outer − 1` keeps the ring exactly one module thick all the way round. It falls out to 0 when
|
|
302
|
+
// the outer radius does.
|
|
303
|
+
roundedRectPath(x, y, EYE_SIZE, EYE_SIZE, outer) + roundedRectPath(x + 1, y + 1, 5, 5, Math.max(0, outer - 1))
|
|
304
|
+
)
|
|
305
|
+
).join("");
|
|
306
|
+
}
|
|
307
|
+
function eyePupilPath(extent, shape) {
|
|
308
|
+
const outer = EYE_RADIUS[shape];
|
|
309
|
+
return eyeOrigins(extent).map(([x, y]) => roundedRectPath(x + 2, y + 2, 3, 3, outer * 3 / EYE_SIZE)).join("");
|
|
310
|
+
}
|
|
311
|
+
function coversLocatorPattern(types, hole) {
|
|
312
|
+
for (let r = hole.y; r < hole.y + hole.h; r++) {
|
|
313
|
+
for (let c = hole.x; c < hole.x + hole.w; c++) {
|
|
314
|
+
const type = types[r]?.[c];
|
|
315
|
+
if (type !== void 0 && LOCATOR_TYPES.has(type) && inHole(hole, r, c)) return true;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// src/components/qr-code/labels.ts
|
|
322
|
+
var QR_CODE_LABELS = {
|
|
323
|
+
/** The `sr-only` text the `role="img"` svg is named by. */
|
|
324
|
+
name: (ctx) => `QR code for ${ctx.value}`,
|
|
325
|
+
/** Shown in place of the name when `value` did not encode. */
|
|
326
|
+
unavailable: "QR code unavailable",
|
|
327
|
+
downloadPng: "Download PNG",
|
|
328
|
+
downloadSvg: "Download SVG"
|
|
329
|
+
};
|
|
330
|
+
var DEFAULT_PIXEL_SIZE = 1024;
|
|
331
|
+
var DEFAULT_FILE_NAME = "qr-code";
|
|
332
|
+
var DEFAULT_FORMATS = ["png"];
|
|
333
|
+
var DOWNLOAD_LABEL = { png: "downloadPng", svg: "downloadSvg" };
|
|
334
|
+
function readLogo(logo) {
|
|
335
|
+
if (!logo) return null;
|
|
336
|
+
if (typeof logo === "object" && !React.isValidElement(logo) && "node" in logo) {
|
|
337
|
+
return { node: logo.node, aspect: logo.aspect ?? 1, size: logo.size ?? "md", shape: logo.shape ?? "square" };
|
|
338
|
+
}
|
|
339
|
+
return { node: logo, aspect: 1, size: "md", shape: "square" };
|
|
340
|
+
}
|
|
341
|
+
function QrCode({
|
|
342
|
+
value,
|
|
343
|
+
ecc = "H",
|
|
344
|
+
logo,
|
|
345
|
+
color,
|
|
346
|
+
eyeColor,
|
|
347
|
+
pupilColor,
|
|
348
|
+
modules = "square",
|
|
349
|
+
eyes = "square",
|
|
350
|
+
download = false,
|
|
351
|
+
"aria-label": ariaLabel,
|
|
352
|
+
labels,
|
|
353
|
+
className
|
|
354
|
+
}) {
|
|
355
|
+
const t = useLabels("qrCode", QR_CODE_LABELS, labels);
|
|
356
|
+
const nameId = React.useId();
|
|
357
|
+
const svgRef = React.useRef(null);
|
|
358
|
+
const logoRef = React.useRef(null);
|
|
359
|
+
const [rasterizing, setRasterizing] = React.useState(false);
|
|
360
|
+
const mark = readLogo(logo);
|
|
361
|
+
const logoAspect = mark?.aspect ?? null;
|
|
362
|
+
const logoSize = mark?.size ?? "md";
|
|
363
|
+
const logoShape = mark?.shape ?? "square";
|
|
364
|
+
const dark = React.useMemo(() => resolveQrColor(color), [color]);
|
|
365
|
+
const ring = React.useMemo(() => eyeColor === void 0 ? dark : resolveQrColor(eyeColor, "eyeColor"), [eyeColor, dark]);
|
|
366
|
+
const pupil = React.useMemo(() => pupilColor === void 0 ? ring : resolveQrColor(pupilColor, "pupilColor"), [pupilColor, ring]);
|
|
367
|
+
const tintedEyes = ring !== dark || pupil !== ring;
|
|
368
|
+
const geometry = React.useMemo(
|
|
369
|
+
() => buildQrGeometry(value, { ecc, modules, eyes, logoAspect, logoSize, logoShape, tintedEyes }),
|
|
370
|
+
[value, ecc, modules, eyes, logoAspect, logoSize, logoShape, tintedEyes]
|
|
371
|
+
);
|
|
372
|
+
const options = download === false ? null : download;
|
|
373
|
+
const fileName = options?.fileName ?? DEFAULT_FILE_NAME;
|
|
374
|
+
const formats = options?.formats ?? DEFAULT_FORMATS;
|
|
375
|
+
const pixelSize = options?.pixelSize ?? DEFAULT_PIXEL_SIZE;
|
|
376
|
+
warnPositiveInt("QrCode", "download.pixelSize", options?.pixelSize);
|
|
377
|
+
React.useEffect(() => {
|
|
378
|
+
if (geometry.holeCoversLocator) {
|
|
379
|
+
devWarn(
|
|
380
|
+
"<QrCode> the `logo` covers a finder, timing or format pattern. Those are read BEFORE error correction exists, so no `ecc` recovers them and the code will not scan. This code is too small to carry a centre mark \u2014 drop the `logo`, or encode a longer `value`."
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
}, [geometry.holeCoversLocator]);
|
|
384
|
+
React.useEffect(() => {
|
|
385
|
+
if (geometry.budgetExceeded && !geometry.holeCoversLocator) {
|
|
386
|
+
devWarn(
|
|
387
|
+
"<QrCode> the `logo` erases more of the code than `ecc` can recover, so the mark has spent the whole damage budget before the first scuff or bad angle. It may still decode from a clean screen and fail off a printed label. Three fixes, in order of how much they buy: a smaller `logo.size`, a longer `value` (a denser code has more codewords to spend), or a squarer `logo.aspect` \u2014 a wide mark shreds more codewords than a square one covering the same area."
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
}, [geometry.budgetExceeded, geometry.holeCoversLocator]);
|
|
391
|
+
React.useLayoutEffect(() => {
|
|
392
|
+
const g = logoRef.current;
|
|
393
|
+
const svg = svgRef.current;
|
|
394
|
+
const box = geometry.logoBox;
|
|
395
|
+
const base = geometry.logoTransform;
|
|
396
|
+
if (g === null || svg === null || box === null || base === null) return;
|
|
397
|
+
g.setAttribute("transform", base);
|
|
398
|
+
const frame = svg.getBoundingClientRect();
|
|
399
|
+
if (frame.width === 0) return;
|
|
400
|
+
const per = frame.width / geometry.extent;
|
|
401
|
+
const ink = g.getBoundingClientRect();
|
|
402
|
+
if (ink.width === 0 || ink.height === 0) return;
|
|
403
|
+
const inkW = ink.width / per;
|
|
404
|
+
const inkH = ink.height / per;
|
|
405
|
+
const fit = Math.min(box.w / inkW, box.h / inkH);
|
|
406
|
+
if (!Number.isFinite(fit) || fit <= 0) return;
|
|
407
|
+
const inkCx = (ink.left - frame.left) / per + inkW / 2;
|
|
408
|
+
const inkCy = (ink.top - frame.top) / per + inkH / 2;
|
|
409
|
+
const scale = box.h / LOGO_GRID;
|
|
410
|
+
const x = box.x + box.w / 2 + fit * (box.x - inkCx);
|
|
411
|
+
const y = box.y + box.h / 2 + fit * (box.y - inkCy);
|
|
412
|
+
g.setAttribute("transform", `translate(${x} ${y}) scale(${fit * scale})`);
|
|
413
|
+
}, [geometry.logoBox, geometry.logoTransform, geometry.extent, mark?.node]);
|
|
414
|
+
React.useEffect(() => {
|
|
415
|
+
if (logoAspect !== null) warnAspectOverflow("QrCode", "logo.aspect", logoAspect, logoRef.current);
|
|
416
|
+
}, [logoAspect, geometry.logoTransform]);
|
|
417
|
+
async function handleDownload(format) {
|
|
418
|
+
const svg = svgRef.current;
|
|
419
|
+
if (svg === null) return;
|
|
420
|
+
const edge = Math.max(1, Math.floor(pixelSize / geometry.extent)) * geometry.extent;
|
|
421
|
+
if (format === "svg") {
|
|
422
|
+
saveBlob(new Blob([serializeSvg(svg, edge)], { type: "image/svg+xml" }), `${fileName}.svg`);
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
setRasterizing(true);
|
|
426
|
+
try {
|
|
427
|
+
saveBlob(await svgToPngBlob(svg, edge), `${fileName}.png`);
|
|
428
|
+
} finally {
|
|
429
|
+
setRasterizing(false);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return (
|
|
433
|
+
/* NO gap, deliberately — the plate brings its own. Its FOUR-MODULE quiet zone is real padding
|
|
434
|
+
(18px at `max-w-56`, 9px at `w-32`, scaling with the render width), and any flex gap stacks on top
|
|
435
|
+
of it: `gap-3` measured 30px from the last dark module to the button. The quiet zone IS the
|
|
436
|
+
separation, so the layout adds none. */
|
|
437
|
+
/* @__PURE__ */ jsxs("div", { className: cn("flex w-full flex-col items-center", className), children: [
|
|
438
|
+
/* @__PURE__ */ jsxs(
|
|
439
|
+
"svg",
|
|
440
|
+
{
|
|
441
|
+
ref: svgRef,
|
|
442
|
+
role: "img",
|
|
443
|
+
"aria-label": ariaLabel,
|
|
444
|
+
"aria-labelledby": ariaLabel === void 0 ? nameId : void 0,
|
|
445
|
+
viewBox: `0 0 ${geometry.extent} ${geometry.extent}`,
|
|
446
|
+
shapeRendering: shapeRenderingFor(modules, eyes),
|
|
447
|
+
className: "aspect-square w-full max-w-full",
|
|
448
|
+
children: [
|
|
449
|
+
/* @__PURE__ */ jsx("rect", { width: geometry.extent, height: geometry.extent, fill: "#ffffff" }),
|
|
450
|
+
" ",
|
|
451
|
+
geometry.path !== "" && /* @__PURE__ */ jsx("path", { d: geometry.path, fill: dark }),
|
|
452
|
+
geometry.eyePath !== "" && /* @__PURE__ */ jsx("path", { d: geometry.eyePath, fill: ring, fillRule: "evenodd" }),
|
|
453
|
+
geometry.pupilPath !== "" && /* @__PURE__ */ jsx("path", { d: geometry.pupilPath, fill: pupil }),
|
|
454
|
+
geometry.hole !== null && /* @__PURE__ */ jsx(
|
|
455
|
+
"rect",
|
|
456
|
+
{
|
|
457
|
+
x: geometry.hole.x,
|
|
458
|
+
y: geometry.hole.y,
|
|
459
|
+
width: geometry.hole.w,
|
|
460
|
+
height: geometry.hole.h,
|
|
461
|
+
rx: geometry.hole.r === 0 ? void 0 : geometry.hole.r,
|
|
462
|
+
shapeRendering: geometry.hole.r === 0 ? void 0 : "geometricPrecision",
|
|
463
|
+
fill: "#ffffff"
|
|
464
|
+
}
|
|
465
|
+
),
|
|
466
|
+
geometry.logoTransform !== null && /* A `<g transform>`, NOT a nested `<svg width height>`: a lucide glyph carries its own
|
|
467
|
+
* `width="24" height="24"`, which inside a nested viewport would render at 24 MODULES and
|
|
468
|
+
* clip. A transform scales whatever arrives. And `style` rather than a class, because
|
|
469
|
+
* `currentColor` must resolve to the code's own dark once the file is opened standalone and a
|
|
470
|
+
* stylesheet does not travel with it — `serializeSvg` strips classes for exactly that reason.
|
|
471
|
+
* It takes `dark` rather than black so a green code gets a green mark.
|
|
472
|
+
*
|
|
473
|
+
* No `aria-hidden`: hiding the caller's node is a one-way door (AGENTS §Slots). A decorative
|
|
474
|
+
* mark hides itself. */
|
|
475
|
+
/* @__PURE__ */ jsx("g", { ref: logoRef, transform: geometry.logoTransform, style: { color: dark }, children: mark?.node })
|
|
476
|
+
]
|
|
477
|
+
}
|
|
478
|
+
),
|
|
479
|
+
ariaLabel === void 0 && /* @__PURE__ */ jsx("span", { id: nameId, className: "sr-only", children: geometry.unencodable ? t.unavailable : t.name({ value }) }),
|
|
480
|
+
options !== null && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap justify-center gap-2", children: formats.map((format) => /* @__PURE__ */ jsx(
|
|
481
|
+
Button,
|
|
482
|
+
{
|
|
483
|
+
variant: "secondary",
|
|
484
|
+
size: "sm",
|
|
485
|
+
leading: /* @__PURE__ */ jsx(DownloadIcon, {}),
|
|
486
|
+
loading: format === "png" && rasterizing,
|
|
487
|
+
disabled: geometry.unencodable,
|
|
488
|
+
onClick: () => void handleDownload(format),
|
|
489
|
+
children: t[DOWNLOAD_LABEL[format]]
|
|
490
|
+
},
|
|
491
|
+
format
|
|
492
|
+
)) })
|
|
493
|
+
] })
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// src/components/qr-code/to-file.ts
|
|
498
|
+
var DEFAULT_PIXEL_SIZE2 = 1024;
|
|
499
|
+
function snap(pixelSize, extent) {
|
|
500
|
+
return Math.max(1, Math.floor(pixelSize / extent)) * extent;
|
|
501
|
+
}
|
|
502
|
+
function qrToSvgString(value, options) {
|
|
503
|
+
const ecc = options?.ecc ?? "H";
|
|
504
|
+
const color = resolveQrColor(options?.color);
|
|
505
|
+
const ring = options?.eyeColor === void 0 ? color : resolveQrColor(options.eyeColor, "eyeColor");
|
|
506
|
+
const pupil = options?.pupilColor === void 0 ? ring : resolveQrColor(options.pupilColor, "pupilColor");
|
|
507
|
+
const { extent, path, eyePath, pupilPath, unencodable } = buildQrGeometry(value, {
|
|
508
|
+
ecc,
|
|
509
|
+
modules: options?.modules,
|
|
510
|
+
eyes: options?.eyes,
|
|
511
|
+
tintedEyes: ring !== color || pupil !== ring
|
|
512
|
+
});
|
|
513
|
+
if (unencodable) throw new RangeError(`qrToSvgString: "${value.slice(0, 32)}" does not encode at level ${ecc}.`);
|
|
514
|
+
const size = snap(options?.pixelSize ?? DEFAULT_PIXEL_SIZE2, extent);
|
|
515
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 ${extent} ${extent}" shape-rendering="${shapeRenderingFor(options?.modules, options?.eyes)}"><rect width="${extent}" height="${extent}" fill="#ffffff"/>` + (path === "" ? "" : `<path d="${path}" fill="${color}"/>`) + (eyePath === "" ? "" : `<path d="${eyePath}" fill="${ring}" fill-rule="evenodd"/>`) + (pupilPath === "" ? "" : `<path d="${pupilPath}" fill="${pupil}"/>`) + `</svg>`;
|
|
516
|
+
}
|
|
517
|
+
async function qrToPngBlob(value, options) {
|
|
518
|
+
const { extent } = buildQrGeometry(value, { ecc: options?.ecc ?? "H", modules: options?.modules, eyes: options?.eyes });
|
|
519
|
+
const size = snap(options?.pixelSize ?? DEFAULT_PIXEL_SIZE2, extent);
|
|
520
|
+
return await rasterizeSvgMarkup(qrToSvgString(value, { ...options, pixelSize: size }), size);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
export { QrCode, qrToPngBlob, qrToSvgString };
|
|
524
|
+
//# sourceMappingURL=chunk-EBZNUQ6E.js.map
|
|
525
|
+
//# sourceMappingURL=chunk-EBZNUQ6E.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { TOOLTIP_TONE, TOOLTIP_SWATCH } from './chunk-
|
|
1
|
+
import { TOOLTIP_TONE, TOOLTIP_SWATCH } from './chunk-7LSUUEAF.js';
|
|
2
2
|
import { cn } from './chunk-ZSNJ6UA3.js';
|
|
3
|
-
import { useLabels } from './chunk-
|
|
4
|
-
import { warnPositiveInt, devWarn } from './chunk-
|
|
3
|
+
import { useLabels } from './chunk-ZIEGUI25.js';
|
|
4
|
+
import { warnPositiveInt, devWarn } from './chunk-SF3HCW4G.js';
|
|
5
|
+
import { token } from './chunk-3ZEEGXYF.js';
|
|
5
6
|
import { ResponsiveContainer } from 'recharts';
|
|
6
7
|
export { Area, AreaChart, Bar, BarChart, CartesianGrid, Label, Line, LineChart, Pie, PieChart, PolarAngleAxis, PolarGrid, PolarRadiusAxis, Radar, RadarChart, RadialBar, RadialBarChart, ReferenceLine, Text, Tooltip, XAxis, YAxis } from 'recharts';
|
|
7
8
|
import * as React2 from 'react';
|
|
@@ -326,12 +327,14 @@ function ChartDataTable({ caption, rowHeader, columns, rows }) {
|
|
|
326
327
|
] }) });
|
|
327
328
|
}
|
|
328
329
|
var BRAND = [
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
"
|
|
332
|
-
"
|
|
333
|
-
"
|
|
334
|
-
"
|
|
330
|
+
// `token()` rather than the literal it returns: identical string, but the NAME is checked against the
|
|
331
|
+
// generated union, so a mistyped stop is a compile error instead of a series that paints nothing.
|
|
332
|
+
token("utility-brand-700"),
|
|
333
|
+
token("utility-brand-600"),
|
|
334
|
+
token("utility-brand-500"),
|
|
335
|
+
token("utility-brand-400"),
|
|
336
|
+
token("utility-brand-300"),
|
|
337
|
+
token("utility-brand-200")
|
|
335
338
|
];
|
|
336
339
|
BRAND.length;
|
|
337
340
|
var DEFAULT_PALETTE = [];
|
|
@@ -392,5 +395,5 @@ function useCartesianColors(component, series, palette) {
|
|
|
392
395
|
}
|
|
393
396
|
|
|
394
397
|
export { ACTIVE_DOT, AREA_BAND, AREA_FILL_OPACITY, AREA_GRADIENT_STOPS, AREA_SOLID_OPACITY, AXIS, AXIS_LABEL, AXIS_TICK, BAND_SEPARATOR, BAR_LAYOUT, BAR_RADIUS, BAR_RADIUS_HORIZONTAL, CHART_ROOT, ChartDataTable, ChartFrame, ChartLegendContent, ChartTooltipContent, DEFAULT_PALETTE, DOT, GRID, LINE_DASH, MARGIN, MAX_BAR_SIZE, NO_ANIMATION, PIE_DONUT, PIE_SIZE, POLAR_ANGLE_TICK, POLAR_ANGLE_TICK_LIFT, POLAR_HOVER, POLAR_RADIUS_PILL, POLAR_RADIUS_PILL_BASELINE, POLAR_RADIUS_PILL_HEIGHT, POLAR_RADIUS_PILL_PAD_X, POLAR_RADIUS_RINGS_DEFAULT, POLAR_ROOT, RADIAL_SIZE, RADIAL_TRACK, TOOLTIP_CURSOR, X_AXIS_PADDING, ZERO_LINE, formatNumber, paletteLength, seriesColor, useCartesianColors, useSeriesColors };
|
|
395
|
-
//# sourceMappingURL=chunk-
|
|
396
|
-
//# sourceMappingURL=chunk-
|
|
398
|
+
//# sourceMappingURL=chunk-ED5UCYAV.js.map
|
|
399
|
+
//# sourceMappingURL=chunk-ED5UCYAV.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { RULE_TONE, RULE_PAINT, RULE_TEXTURE } from './chunk-
|
|
2
|
-
import { SOLID, SOLID_BOX, SOLID_GLOSS, BOXED_BOX, BOX_RING } from './chunk-
|
|
1
|
+
import { RULE_TONE, RULE_PAINT, RULE_TEXTURE } from './chunk-EVINS473.js';
|
|
2
|
+
import { SOLID, SOLID_BOX, SOLID_GLOSS, BOXED_BOX, BOX_RING } from './chunk-6T3QAO5K.js';
|
|
3
3
|
import { overflowClasses } from './chunk-DWKILXHE.js';
|
|
4
|
-
import { CheckIcon, XIcon, MinusIcon } from './chunk-
|
|
4
|
+
import { CheckIcon, XIcon, MinusIcon } from './chunk-KBI442IB.js';
|
|
5
5
|
import { cn } from './chunk-ZSNJ6UA3.js';
|
|
6
6
|
import * as React3 from 'react';
|
|
7
7
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
@@ -601,5 +601,5 @@ function useSteps(options) {
|
|
|
601
601
|
}
|
|
602
602
|
|
|
603
603
|
export { ProgressSteps, StepPanel, buildStepMap, firstEnabledStep, resolveStepStatus, useSteps };
|
|
604
|
-
//# sourceMappingURL=chunk-
|
|
605
|
-
//# sourceMappingURL=chunk-
|
|
604
|
+
//# sourceMappingURL=chunk-EDVYLO2N.js.map
|
|
605
|
+
//# sourceMappingURL=chunk-EDVYLO2N.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FILL, SOLID } from './chunk-
|
|
2
|
-
import { SEAMLESS_DOT } from './chunk-
|
|
1
|
+
import { FILL, SOLID } from './chunk-6T3QAO5K.js';
|
|
2
|
+
import { SEAMLESS_DOT } from './chunk-GPHGPY6T.js';
|
|
3
3
|
import { cn } from './chunk-ZSNJ6UA3.js';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
@@ -108,5 +108,5 @@ function Indicator(props) {
|
|
|
108
108
|
Indicator.displayName = "Indicator";
|
|
109
109
|
|
|
110
110
|
export { Indicator };
|
|
111
|
-
//# sourceMappingURL=chunk-
|
|
112
|
-
//# sourceMappingURL=chunk-
|
|
111
|
+
//# sourceMappingURL=chunk-EJKQGUUM.js.map
|
|
112
|
+
//# sourceMappingURL=chunk-EJKQGUUM.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { DRAG_GHOST, DROP_LINE, DROP_LINE_Y, dragGhostProps, ghostPosition } from './chunk-5ZPUAGOP.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Skeleton } from './chunk-MTOTPAYZ.js';
|
|
3
|
+
import { useAutoScroll, useDrag } from './chunk-BH32X25C.js';
|
|
4
4
|
import { useDebounced } from './chunk-F6NLE6XJ.js';
|
|
5
5
|
import { useIsomorphicLayoutEffect } from './chunk-EDSK6FEH.js';
|
|
6
6
|
import { Slot } from './chunk-52IFGFTL.js';
|
|
7
|
-
import { LoaderCircleIcon, CircleAlertIcon, ChevronRightIcon, GripVerticalIcon, CheckIcon, MinusIcon } from './chunk-
|
|
7
|
+
import { LoaderCircleIcon, CircleAlertIcon, ChevronRightIcon, GripVerticalIcon, CheckIcon, MinusIcon } from './chunk-KBI442IB.js';
|
|
8
8
|
import { cn } from './chunk-ZSNJ6UA3.js';
|
|
9
|
-
import { useLabels } from './chunk-
|
|
10
|
-
import { devWarn, warnNonNegativeInt, warnNeedsName } from './chunk-
|
|
9
|
+
import { useLabels } from './chunk-ZIEGUI25.js';
|
|
10
|
+
import { devWarn, warnNonNegativeInt, warnNeedsName } from './chunk-SF3HCW4G.js';
|
|
11
11
|
import * as React from 'react';
|
|
12
12
|
import { mergeProps } from '@base-ui/react/merge-props';
|
|
13
13
|
import { useRender } from '@base-ui/react/use-render';
|
|
@@ -1373,5 +1373,5 @@ function Tree(props) {
|
|
|
1373
1373
|
Tree.displayName = "Tree";
|
|
1374
1374
|
|
|
1375
1375
|
export { Tree, ancestorIds, applyTreeMove, attachChildren, isBranch, isDescendant, useTree, walkTree };
|
|
1376
|
-
//# sourceMappingURL=chunk-
|
|
1377
|
-
//# sourceMappingURL=chunk-
|
|
1376
|
+
//# sourceMappingURL=chunk-EKQLIUV5.js.map
|
|
1377
|
+
//# sourceMappingURL=chunk-EKQLIUV5.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { usePolarData, resolveMax } from './chunk-
|
|
2
|
-
import { DEFAULT_PALETTE, RADIAL_SIZE, ChartDataTable, formatNumber, ChartFrame, RadialBarChart, MARGIN, PolarAngleAxis, Tooltip, NO_ANIMATION, ChartTooltipContent, RadialBar, RADIAL_TRACK, POLAR_ROOT, POLAR_HOVER, ChartLegendContent } from './chunk-
|
|
1
|
+
import { usePolarData, resolveMax } from './chunk-OEYKTHG7.js';
|
|
2
|
+
import { DEFAULT_PALETTE, RADIAL_SIZE, ChartDataTable, formatNumber, ChartFrame, RadialBarChart, MARGIN, PolarAngleAxis, Tooltip, NO_ANIMATION, ChartTooltipContent, RadialBar, RADIAL_TRACK, POLAR_ROOT, POLAR_HOVER, ChartLegendContent } from './chunk-ED5UCYAV.js';
|
|
3
3
|
import { cn } from './chunk-ZSNJ6UA3.js';
|
|
4
4
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -73,5 +73,5 @@ function RadialChart({
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
export { RadialChart };
|
|
76
|
-
//# sourceMappingURL=chunk-
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
//# sourceMappingURL=chunk-EKV3CVTY.js.map
|
|
77
|
+
//# sourceMappingURL=chunk-EKV3CVTY.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/lib/rule.ts
|
|
2
|
+
var RULE_TEXTURES = ["line", "dashed", "dot"];
|
|
2
3
|
var RULE_TEXTURE = {
|
|
3
4
|
line: {
|
|
4
5
|
y: "[--rule-image:initial] [--rule-size:auto]",
|
|
@@ -29,6 +30,7 @@ var RULE_WEIGHT_AFTER = {
|
|
|
29
30
|
dot: { y: "after:h-[3px]", x: "after:w-[3px]" },
|
|
30
31
|
dashed: { y: "after:h-px", x: "after:w-px" }
|
|
31
32
|
};
|
|
33
|
+
var RULE_WEIGHTS = ["hairline", "thick"];
|
|
32
34
|
var RULE_WEIGHT_THICK = {
|
|
33
35
|
line: { y: "h-0.5", x: "w-0.5" },
|
|
34
36
|
dot: { y: "h-[5px]", x: "w-[5px]" },
|
|
@@ -93,6 +95,6 @@ function ruleEdge(texture, edge, tone = "default") {
|
|
|
93
95
|
].join(" ");
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
export { RULE_PAINT, RULE_TEXTURE, RULE_TONE, RULE_WEIGHT, ruleBox, ruleEdge, rulePaint };
|
|
97
|
-
//# sourceMappingURL=chunk-
|
|
98
|
-
//# sourceMappingURL=chunk-
|
|
98
|
+
export { RULE_PAINT, RULE_TEXTURE, RULE_TEXTURES, RULE_TONE, RULE_WEIGHT, RULE_WEIGHTS, ruleBox, ruleEdge, rulePaint };
|
|
99
|
+
//# sourceMappingURL=chunk-EVINS473.js.map
|
|
100
|
+
//# sourceMappingURL=chunk-EVINS473.js.map
|