@zentauri-ui/zentauri-components 2.3.0 → 2.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 +7 -5
- package/cli/props.json +386 -0
- package/cli/registry.json +8 -0
- package/dist/chunk-4U6PVVST.mjs +15 -0
- package/dist/chunk-4U6PVVST.mjs.map +1 -0
- package/dist/{chunk-DIAA5VH4.mjs → chunk-CIZQQ32L.mjs} +3 -3
- package/dist/chunk-CIZQQ32L.mjs.map +1 -0
- package/dist/{chunk-PQ2XTY3M.js → chunk-G36ZV446.js} +13 -13
- package/dist/{chunk-PQ2XTY3M.js.map → chunk-G36ZV446.js.map} +1 -1
- package/dist/{chunk-H3BJOK22.js → chunk-HNAUUCR5.js} +3 -3
- package/dist/chunk-HNAUUCR5.js.map +1 -0
- package/dist/{chunk-YY7G4NV3.js → chunk-K7UU3K54.js} +27 -15
- package/dist/chunk-K7UU3K54.js.map +1 -0
- package/dist/chunk-MY3DQVNF.js +19 -0
- package/dist/{chunk-ENKXB2BA.js.map → chunk-MY3DQVNF.js.map} +1 -1
- package/dist/{chunk-ATE5SCTR.mjs → chunk-N6Q4ZLQR.mjs} +3 -3
- package/dist/{chunk-ATE5SCTR.mjs.map → chunk-N6Q4ZLQR.mjs.map} +1 -1
- package/dist/{chunk-ZB6C6CJQ.mjs → chunk-PJATBFEK.mjs} +18 -6
- package/dist/chunk-PJATBFEK.mjs.map +1 -0
- package/dist/chunk-PVVYOIU2.js +38 -0
- package/dist/chunk-PVVYOIU2.js.map +1 -0
- package/dist/chunk-PWEZB53R.js +90 -0
- package/dist/chunk-PWEZB53R.js.map +1 -0
- package/dist/chunk-PWYEC3KY.mjs +30 -0
- package/dist/chunk-PWYEC3KY.mjs.map +1 -0
- package/dist/{chunk-AARJLZXP.js → chunk-RBNZNWYQ.js} +6 -6
- package/dist/{chunk-AARJLZXP.js.map → chunk-RBNZNWYQ.js.map} +1 -1
- package/dist/{chunk-WZY32L6K.mjs → chunk-STWXN5EM.mjs} +3 -3
- package/dist/{chunk-WZY32L6K.mjs.map → chunk-STWXN5EM.mjs.map} +1 -1
- package/dist/{chunk-JKKF5DCF.mjs → chunk-TTKTPERV.mjs} +3 -3
- package/dist/{chunk-JKKF5DCF.mjs.map → chunk-TTKTPERV.mjs.map} +1 -1
- package/dist/chunk-UBQY572I.mjs +81 -0
- package/dist/chunk-UBQY572I.mjs.map +1 -0
- package/dist/{chunk-DSX6RUYI.js → chunk-UN5RRNPV.js} +12 -12
- package/dist/{chunk-DSX6RUYI.js.map → chunk-UN5RRNPV.js.map} +1 -1
- package/dist/{chunk-BFHJF4MV.mjs → chunk-VMVG2RVZ.mjs} +4 -4
- package/dist/{chunk-BFHJF4MV.mjs.map → chunk-VMVG2RVZ.mjs.map} +1 -1
- package/dist/chunk-XUK5P37Y.js +19 -0
- package/dist/chunk-XUK5P37Y.js.map +1 -0
- package/dist/design-system/facade.js +8 -6
- package/dist/design-system/facade.js.map +1 -1
- package/dist/design-system/facade.mjs +7 -5
- package/dist/design-system/facade.mjs.map +1 -1
- package/dist/design-system/index.d.ts +2 -0
- package/dist/design-system/index.d.ts.map +1 -1
- package/dist/design-system/qr-code.d.ts +4 -0
- package/dist/design-system/qr-code.d.ts.map +1 -0
- package/dist/design-system/qr-scanner.d.ts +11 -0
- package/dist/design-system/qr-scanner.d.ts.map +1 -0
- package/dist/design-system/secret-reveal.d.ts +1 -1
- package/dist/design-system/secret-reveal.d.ts.map +1 -1
- package/dist/ui/buttons/animated.js +10 -8
- package/dist/ui/buttons/animated.js.map +1 -1
- package/dist/ui/buttons/animated.mjs +8 -6
- package/dist/ui/buttons/animated.mjs.map +1 -1
- package/dist/ui/buttons.js +11 -9
- package/dist/ui/buttons.mjs +9 -7
- package/dist/ui/data-table.js +21 -19
- package/dist/ui/data-table.js.map +1 -1
- package/dist/ui/data-table.mjs +11 -9
- package/dist/ui/data-table.mjs.map +1 -1
- package/dist/ui/dynamic-stepper.js +20 -18
- package/dist/ui/dynamic-stepper.js.map +1 -1
- package/dist/ui/dynamic-stepper.mjs +9 -7
- package/dist/ui/dynamic-stepper.mjs.map +1 -1
- package/dist/ui/pagination.js +12 -10
- package/dist/ui/pagination.mjs +9 -7
- package/dist/ui/qr-code/animated/animations.d.ts +8 -0
- package/dist/ui/qr-code/animated/animations.d.ts.map +1 -0
- package/dist/ui/qr-code/animated/index.d.ts +4 -0
- package/dist/ui/qr-code/animated/index.d.ts.map +1 -0
- package/dist/ui/qr-code/animated/qr-code-animated.d.ts +6 -0
- package/dist/ui/qr-code/animated/qr-code-animated.d.ts.map +1 -0
- package/dist/ui/qr-code/animated/types.d.ts +9 -0
- package/dist/ui/qr-code/animated/types.d.ts.map +1 -0
- package/dist/ui/qr-code/animated.js +156 -0
- package/dist/ui/qr-code/animated.js.map +1 -0
- package/dist/ui/qr-code/animated.mjs +149 -0
- package/dist/ui/qr-code/animated.mjs.map +1 -0
- package/dist/ui/qr-code/index.d.ts +5 -0
- package/dist/ui/qr-code/index.d.ts.map +1 -0
- package/dist/ui/qr-code/qr-code-base.d.ts +47 -0
- package/dist/ui/qr-code/qr-code-base.d.ts.map +1 -0
- package/dist/ui/qr-code/qr-code.d.ts +2 -0
- package/dist/ui/qr-code/qr-code.d.ts.map +1 -0
- package/dist/ui/qr-code/types.d.ts +14 -0
- package/dist/ui/qr-code/types.d.ts.map +1 -0
- package/dist/ui/qr-code/variants.d.ts +4 -0
- package/dist/ui/qr-code/variants.d.ts.map +1 -0
- package/dist/ui/qr-code.js +35 -0
- package/dist/ui/qr-code.js.map +1 -0
- package/dist/ui/qr-code.mjs +17 -0
- package/dist/ui/qr-code.mjs.map +1 -0
- package/dist/ui/qr-scanner/index.d.ts +4 -0
- package/dist/ui/qr-scanner/index.d.ts.map +1 -0
- package/dist/ui/qr-scanner/qr-scanner-base.d.ts +62 -0
- package/dist/ui/qr-scanner/qr-scanner-base.d.ts.map +1 -0
- package/dist/ui/qr-scanner/qr-scanner.d.ts +2 -0
- package/dist/ui/qr-scanner/qr-scanner.d.ts.map +1 -0
- package/dist/ui/qr-scanner/types.d.ts +28 -0
- package/dist/ui/qr-scanner/types.d.ts.map +1 -0
- package/dist/ui/qr-scanner/variants.d.ts +9 -0
- package/dist/ui/qr-scanner/variants.d.ts.map +1 -0
- package/dist/ui/qr-scanner.js +316 -0
- package/dist/ui/qr-scanner.js.map +1 -0
- package/dist/ui/qr-scanner.mjs +308 -0
- package/dist/ui/qr-scanner.mjs.map +1 -0
- package/dist/ui/secret-reveal/animated/secret-reveal-animated.d.ts.map +1 -1
- package/dist/ui/secret-reveal/animated.js +10 -7
- package/dist/ui/secret-reveal/animated.js.map +1 -1
- package/dist/ui/secret-reveal/animated.mjs +6 -3
- package/dist/ui/secret-reveal/animated.mjs.map +1 -1
- package/dist/ui/secret-reveal/secret-reveal-base.d.ts.map +1 -1
- package/dist/ui/secret-reveal.js +14 -11
- package/dist/ui/secret-reveal.js.map +1 -1
- package/dist/ui/secret-reveal.mjs +7 -4
- package/dist/ui/secret-reveal.mjs.map +1 -1
- package/dist/ui/split-button.js +22 -20
- package/dist/ui/split-button.js.map +1 -1
- package/dist/ui/split-button.mjs +9 -7
- package/dist/ui/split-button.mjs.map +1 -1
- package/package.json +5 -2
- package/src/design-system/index.ts +2 -0
- package/src/design-system/qr-code.ts +13 -0
- package/src/design-system/qr-scanner.ts +32 -0
- package/src/design-system/secret-reveal.ts +1 -1
- package/src/ui/qr-code/animated/animations.ts +51 -0
- package/src/ui/qr-code/animated/index.ts +5 -0
- package/src/ui/qr-code/animated/qr-code-animated.tsx +111 -0
- package/src/ui/qr-code/animated/types.ts +10 -0
- package/src/ui/qr-code/index.ts +10 -0
- package/src/ui/qr-code/qr-code-base.tsx +149 -0
- package/src/ui/qr-code/qr-code.test.tsx +58 -0
- package/src/ui/qr-code/qr-code.tsx +2 -0
- package/src/ui/qr-code/types.ts +22 -0
- package/src/ui/qr-code/variants.ts +11 -0
- package/src/ui/qr-scanner/index.ts +17 -0
- package/src/ui/qr-scanner/qr-scanner-base.tsx +568 -0
- package/src/ui/qr-scanner/qr-scanner.test.tsx +61 -0
- package/src/ui/qr-scanner/qr-scanner.tsx +2 -0
- package/src/ui/qr-scanner/types.ts +32 -0
- package/src/ui/qr-scanner/variants.ts +26 -0
- package/src/ui/secret-reveal/animated/secret-reveal-animated.tsx +4 -1
- package/src/ui/secret-reveal/secret-reveal-base.tsx +4 -1
- package/dist/chunk-DIAA5VH4.mjs.map +0 -1
- package/dist/chunk-ENKXB2BA.js +0 -19
- package/dist/chunk-H3BJOK22.js.map +0 -1
- package/dist/chunk-YY7G4NV3.js.map +0 -1
- package/dist/chunk-ZB6C6CJQ.mjs.map +0 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunkPWEZB53R_js = require('../../chunk-PWEZB53R.js');
|
|
5
|
+
require('../../chunk-XUK5P37Y.js');
|
|
6
|
+
var chunkZS5756ZC_js = require('../../chunk-ZS5756ZC.js');
|
|
7
|
+
require('../../chunk-PZ5AY32C.js');
|
|
8
|
+
var react = require('react');
|
|
9
|
+
var framerMotion = require('framer-motion');
|
|
10
|
+
var QRCode = require('qrcode');
|
|
11
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
12
|
+
|
|
13
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
|
|
15
|
+
var QRCode__default = /*#__PURE__*/_interopDefault(QRCode);
|
|
16
|
+
|
|
17
|
+
// src/ui/qr-code/animated/animations.ts
|
|
18
|
+
var qrCodeAnimationPresets = {
|
|
19
|
+
none: {
|
|
20
|
+
transition: { duration: 0 },
|
|
21
|
+
variants: {
|
|
22
|
+
initial: { opacity: 1 },
|
|
23
|
+
animate: { opacity: 1 }
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"fade-in": {
|
|
27
|
+
transition: { duration: 0.3, ease: "easeOut" },
|
|
28
|
+
variants: {
|
|
29
|
+
initial: { opacity: 0 },
|
|
30
|
+
animate: { opacity: 1 }
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"zoom-in": {
|
|
34
|
+
transition: { type: "spring", stiffness: 300, damping: 24 },
|
|
35
|
+
variants: {
|
|
36
|
+
initial: { opacity: 0, scale: 0.85 },
|
|
37
|
+
animate: { opacity: 1, scale: 1 }
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"slide-up": {
|
|
41
|
+
transition: { type: "spring", stiffness: 280, damping: 22 },
|
|
42
|
+
variants: {
|
|
43
|
+
initial: { opacity: 0, y: 20 },
|
|
44
|
+
animate: { opacity: 1, y: 0 }
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"rotate-in": {
|
|
48
|
+
transition: { type: "spring", stiffness: 200, damping: 18 },
|
|
49
|
+
variants: {
|
|
50
|
+
initial: { opacity: 0, rotate: -90, scale: 0.8 },
|
|
51
|
+
animate: { opacity: 1, rotate: 0, scale: 1 }
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
function QrCodeAnimated({
|
|
56
|
+
animation = "none",
|
|
57
|
+
value,
|
|
58
|
+
canvasSize = 200,
|
|
59
|
+
level = "M",
|
|
60
|
+
bgColor = "#ffffff",
|
|
61
|
+
fgColor = "#000000",
|
|
62
|
+
margin = 2,
|
|
63
|
+
caption,
|
|
64
|
+
className,
|
|
65
|
+
...props
|
|
66
|
+
}) {
|
|
67
|
+
const canvasRef = react.useRef(null);
|
|
68
|
+
react.useEffect(() => {
|
|
69
|
+
const canvas = canvasRef.current;
|
|
70
|
+
if (!canvas || animation === "none") return;
|
|
71
|
+
if (!value) {
|
|
72
|
+
const ctx = canvas.getContext("2d");
|
|
73
|
+
if (ctx) {
|
|
74
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
75
|
+
}
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
QRCode__default.default.toCanvas(
|
|
79
|
+
canvas,
|
|
80
|
+
value,
|
|
81
|
+
{
|
|
82
|
+
width: canvasSize,
|
|
83
|
+
margin,
|
|
84
|
+
color: {
|
|
85
|
+
dark: fgColor,
|
|
86
|
+
light: bgColor
|
|
87
|
+
},
|
|
88
|
+
errorCorrectionLevel: level
|
|
89
|
+
},
|
|
90
|
+
(error) => {
|
|
91
|
+
if (error) {
|
|
92
|
+
console.error("QR Code generation error:", error);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
}, [value, canvasSize, level, bgColor, fgColor, margin, animation]);
|
|
97
|
+
if (animation === "none") {
|
|
98
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
99
|
+
chunkPWEZB53R_js.QrCodeBase,
|
|
100
|
+
{
|
|
101
|
+
value,
|
|
102
|
+
canvasSize,
|
|
103
|
+
level,
|
|
104
|
+
bgColor,
|
|
105
|
+
fgColor,
|
|
106
|
+
margin,
|
|
107
|
+
caption,
|
|
108
|
+
className,
|
|
109
|
+
...props
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
const preset = qrCodeAnimationPresets[animation];
|
|
114
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
115
|
+
framerMotion.motion.div,
|
|
116
|
+
{
|
|
117
|
+
"data-slot": "qr-code",
|
|
118
|
+
className: chunkZS5756ZC_js.cn(
|
|
119
|
+
"inline-flex flex-col items-center gap-3 rounded-2xl border p-6 border-[color:var(--zui-qr-code-border,var(--zui-border,#0000001a))] dark:border-[color:var(--zui-qr-code-border-dark,var(--zui-border-dark,#ffffff1a))] bg-[var(--zui-qr-code-bg,var(--zui-surface,oklch(98.4%_0.003_247.858)))] dark:bg-[var(--zui-qr-code-bg-dark,var(--zui-surface-dark,oklch(12.9%_0.042_264.695)))]",
|
|
120
|
+
className
|
|
121
|
+
),
|
|
122
|
+
variants: preset.variants,
|
|
123
|
+
initial: "initial",
|
|
124
|
+
animate: "animate",
|
|
125
|
+
transition: preset.transition,
|
|
126
|
+
...props,
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl bg-[var(--zui-qr-code-canvas-bg,var(--zui-surface-muted,oklch(92.9%_0.013_255.508)))] dark:bg-[var(--zui-qr-code-canvas-bg-dark,var(--zui-surface-muted-dark,oklch(27.9%_0.041_260.031)))]", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
129
|
+
"canvas",
|
|
130
|
+
{
|
|
131
|
+
ref: canvasRef,
|
|
132
|
+
width: canvasSize,
|
|
133
|
+
height: canvasSize,
|
|
134
|
+
"data-slot": "qr-code-canvas",
|
|
135
|
+
className: "block h-auto max-w-full",
|
|
136
|
+
"aria-label": `QR code for ${value}`
|
|
137
|
+
}
|
|
138
|
+
) }),
|
|
139
|
+
caption ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
140
|
+
"span",
|
|
141
|
+
{
|
|
142
|
+
"data-slot": "qr-code-caption",
|
|
143
|
+
className: "text-xs text-center text-[color:var(--zui-qr-code-caption-fg,var(--zui-fg-muted,oklch(55.2%_0.046_257.417)))] dark:text-[color:var(--zui-qr-code-caption-fg-dark,var(--zui-fg-muted-dark,oklch(70.8%_0.015_256.243)))] max-w-full truncate px-2",
|
|
144
|
+
children: caption
|
|
145
|
+
}
|
|
146
|
+
) : null
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
QrCodeAnimated.displayName = "QrCodeAnimated";
|
|
152
|
+
|
|
153
|
+
exports.QrCodeAnimated = QrCodeAnimated;
|
|
154
|
+
exports.qrCodeAnimationPresets = qrCodeAnimationPresets;
|
|
155
|
+
//# sourceMappingURL=animated.js.map
|
|
156
|
+
//# sourceMappingURL=animated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/qr-code/animated/animations.ts","../../../src/ui/qr-code/animated/qr-code-animated.tsx"],"names":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AAAA,QACC,OAAA,mBACCA,cAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,WAAA,EAAU,iBAAA;AAAA,YACV,SAAA,EAAU,iPAAA;AAAA,YAET,QAAA,EAAA;AAAA;AAAA,SACH,GACE;AAAA;AAAA;AAAA,GACN;AAEJ;AAEA,cAAA,CAAe,WAAA,GAAc,gBAAA","file":"animated.js","sourcesContent":["import type { Transition, Variants } from \"framer-motion\";\n\nexport type QrCodeAnimation =\n | \"none\"\n | \"fade-in\"\n | \"zoom-in\"\n | \"slide-up\"\n | \"rotate-in\";\n\nexport type QrCodeAnimationPresets = Record<\n QrCodeAnimation,\n { transition: Transition; variants: Variants }\n>;\n\nexport const qrCodeAnimationPresets: QrCodeAnimationPresets = {\n none: {\n transition: { duration: 0 },\n variants: {\n initial: { opacity: 1 },\n animate: { opacity: 1 },\n },\n },\n \"fade-in\": {\n transition: { duration: 0.3, ease: \"easeOut\" },\n variants: {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n },\n },\n \"zoom-in\": {\n transition: { type: \"spring\", stiffness: 300, damping: 24 },\n variants: {\n initial: { opacity: 0, scale: 0.85 },\n animate: { opacity: 1, scale: 1 },\n },\n },\n \"slide-up\": {\n transition: { type: \"spring\", stiffness: 280, damping: 22 },\n variants: {\n initial: { opacity: 0, y: 20 },\n animate: { opacity: 1, y: 0 },\n },\n },\n \"rotate-in\": {\n transition: { type: \"spring\", stiffness: 200, damping: 18 },\n variants: {\n initial: { opacity: 0, rotate: -90, scale: 0.8 },\n animate: { opacity: 1, rotate: 0, scale: 1 },\n },\n },\n};\n","\"use client\";\n\nimport { useEffect, useRef } from \"react\";\nimport { motion } from \"framer-motion\";\nimport QRCode from \"qrcode\";\n\nimport { cn } from \"../../../lib/utils\";\nimport { qrCodeAnimationPresets } from \"./animations\";\nimport type { QrCodeAnimatedProps } from \"./types\";\nimport { QrCodeBase } from \"../qr-code-base\";\n\nexport function QrCodeAnimated({\n animation = \"none\",\n value,\n canvasSize = 200,\n level = \"M\",\n bgColor = \"#ffffff\",\n fgColor = \"#000000\",\n margin = 2,\n caption,\n className,\n ...props\n}: QrCodeAnimatedProps) {\n const canvasRef = useRef<HTMLCanvasElement>(null);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas || animation === \"none\") return;\n\n if (!value) {\n const ctx = canvas.getContext(\"2d\");\n if (ctx) {\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n }\n return;\n }\n\n QRCode.toCanvas(\n canvas,\n value,\n {\n width: canvasSize,\n margin,\n color: {\n dark: fgColor,\n light: bgColor,\n },\n errorCorrectionLevel: level,\n },\n (error) => {\n if (error) {\n console.error(\"QR Code generation error:\", error);\n }\n },\n );\n }, [value, canvasSize, level, bgColor, fgColor, margin, animation]);\n\n if (animation === \"none\") {\n return (\n <QrCodeBase\n value={value}\n canvasSize={canvasSize}\n level={level}\n bgColor={bgColor}\n fgColor={fgColor}\n margin={margin}\n caption={caption}\n className={className}\n {...props}\n />\n );\n }\n\n const preset = qrCodeAnimationPresets[animation];\n\n return (\n <motion.div\n data-slot=\"qr-code\"\n className={cn(\n \"inline-flex flex-col items-center gap-3 rounded-2xl border p-6 border-[color:var(--zui-qr-code-border,var(--zui-border,#0000001a))] dark:border-[color:var(--zui-qr-code-border-dark,var(--zui-border-dark,#ffffff1a))] bg-[var(--zui-qr-code-bg,var(--zui-surface,oklch(98.4%_0.003_247.858)))] dark:bg-[var(--zui-qr-code-bg-dark,var(--zui-surface-dark,oklch(12.9%_0.042_264.695)))]\",\n className,\n )}\n variants={preset.variants}\n initial=\"initial\"\n animate=\"animate\"\n transition={preset.transition}\n {...(props as Record<string, unknown>)}\n >\n <div className=\"overflow-hidden rounded-xl bg-[var(--zui-qr-code-canvas-bg,var(--zui-surface-muted,oklch(92.9%_0.013_255.508)))] dark:bg-[var(--zui-qr-code-canvas-bg-dark,var(--zui-surface-muted-dark,oklch(27.9%_0.041_260.031)))]\">\n <canvas\n ref={canvasRef}\n width={canvasSize}\n height={canvasSize}\n data-slot=\"qr-code-canvas\"\n className=\"block h-auto max-w-full\"\n aria-label={`QR code for ${value}`}\n />\n </div>\n {caption ? (\n <span\n data-slot=\"qr-code-caption\"\n className=\"text-xs text-center text-[color:var(--zui-qr-code-caption-fg,var(--zui-fg-muted,oklch(55.2%_0.046_257.417)))] dark:text-[color:var(--zui-qr-code-caption-fg-dark,var(--zui-fg-muted-dark,oklch(70.8%_0.015_256.243)))] max-w-full truncate px-2\"\n >\n {caption}\n </span>\n ) : null}\n </motion.div>\n );\n}\n\nQrCodeAnimated.displayName = \"QrCodeAnimated\";\n"]}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { QrCodeBase } from '../../chunk-UBQY572I.mjs';
|
|
3
|
+
import '../../chunk-4U6PVVST.mjs';
|
|
4
|
+
import { cn } from '../../chunk-4D54YOL6.mjs';
|
|
5
|
+
import '../../chunk-J5LGTIGS.mjs';
|
|
6
|
+
import { useRef, useEffect } from 'react';
|
|
7
|
+
import { motion } from 'framer-motion';
|
|
8
|
+
import QRCode from 'qrcode';
|
|
9
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
10
|
+
|
|
11
|
+
// src/ui/qr-code/animated/animations.ts
|
|
12
|
+
var qrCodeAnimationPresets = {
|
|
13
|
+
none: {
|
|
14
|
+
transition: { duration: 0 },
|
|
15
|
+
variants: {
|
|
16
|
+
initial: { opacity: 1 },
|
|
17
|
+
animate: { opacity: 1 }
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"fade-in": {
|
|
21
|
+
transition: { duration: 0.3, ease: "easeOut" },
|
|
22
|
+
variants: {
|
|
23
|
+
initial: { opacity: 0 },
|
|
24
|
+
animate: { opacity: 1 }
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"zoom-in": {
|
|
28
|
+
transition: { type: "spring", stiffness: 300, damping: 24 },
|
|
29
|
+
variants: {
|
|
30
|
+
initial: { opacity: 0, scale: 0.85 },
|
|
31
|
+
animate: { opacity: 1, scale: 1 }
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"slide-up": {
|
|
35
|
+
transition: { type: "spring", stiffness: 280, damping: 22 },
|
|
36
|
+
variants: {
|
|
37
|
+
initial: { opacity: 0, y: 20 },
|
|
38
|
+
animate: { opacity: 1, y: 0 }
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"rotate-in": {
|
|
42
|
+
transition: { type: "spring", stiffness: 200, damping: 18 },
|
|
43
|
+
variants: {
|
|
44
|
+
initial: { opacity: 0, rotate: -90, scale: 0.8 },
|
|
45
|
+
animate: { opacity: 1, rotate: 0, scale: 1 }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function QrCodeAnimated({
|
|
50
|
+
animation = "none",
|
|
51
|
+
value,
|
|
52
|
+
canvasSize = 200,
|
|
53
|
+
level = "M",
|
|
54
|
+
bgColor = "#ffffff",
|
|
55
|
+
fgColor = "#000000",
|
|
56
|
+
margin = 2,
|
|
57
|
+
caption,
|
|
58
|
+
className,
|
|
59
|
+
...props
|
|
60
|
+
}) {
|
|
61
|
+
const canvasRef = useRef(null);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
const canvas = canvasRef.current;
|
|
64
|
+
if (!canvas || animation === "none") return;
|
|
65
|
+
if (!value) {
|
|
66
|
+
const ctx = canvas.getContext("2d");
|
|
67
|
+
if (ctx) {
|
|
68
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
QRCode.toCanvas(
|
|
73
|
+
canvas,
|
|
74
|
+
value,
|
|
75
|
+
{
|
|
76
|
+
width: canvasSize,
|
|
77
|
+
margin,
|
|
78
|
+
color: {
|
|
79
|
+
dark: fgColor,
|
|
80
|
+
light: bgColor
|
|
81
|
+
},
|
|
82
|
+
errorCorrectionLevel: level
|
|
83
|
+
},
|
|
84
|
+
(error) => {
|
|
85
|
+
if (error) {
|
|
86
|
+
console.error("QR Code generation error:", error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}, [value, canvasSize, level, bgColor, fgColor, margin, animation]);
|
|
91
|
+
if (animation === "none") {
|
|
92
|
+
return /* @__PURE__ */ jsx(
|
|
93
|
+
QrCodeBase,
|
|
94
|
+
{
|
|
95
|
+
value,
|
|
96
|
+
canvasSize,
|
|
97
|
+
level,
|
|
98
|
+
bgColor,
|
|
99
|
+
fgColor,
|
|
100
|
+
margin,
|
|
101
|
+
caption,
|
|
102
|
+
className,
|
|
103
|
+
...props
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
const preset = qrCodeAnimationPresets[animation];
|
|
108
|
+
return /* @__PURE__ */ jsxs(
|
|
109
|
+
motion.div,
|
|
110
|
+
{
|
|
111
|
+
"data-slot": "qr-code",
|
|
112
|
+
className: cn(
|
|
113
|
+
"inline-flex flex-col items-center gap-3 rounded-2xl border p-6 border-[color:var(--zui-qr-code-border,var(--zui-border,#0000001a))] dark:border-[color:var(--zui-qr-code-border-dark,var(--zui-border-dark,#ffffff1a))] bg-[var(--zui-qr-code-bg,var(--zui-surface,oklch(98.4%_0.003_247.858)))] dark:bg-[var(--zui-qr-code-bg-dark,var(--zui-surface-dark,oklch(12.9%_0.042_264.695)))]",
|
|
114
|
+
className
|
|
115
|
+
),
|
|
116
|
+
variants: preset.variants,
|
|
117
|
+
initial: "initial",
|
|
118
|
+
animate: "animate",
|
|
119
|
+
transition: preset.transition,
|
|
120
|
+
...props,
|
|
121
|
+
children: [
|
|
122
|
+
/* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-xl bg-[var(--zui-qr-code-canvas-bg,var(--zui-surface-muted,oklch(92.9%_0.013_255.508)))] dark:bg-[var(--zui-qr-code-canvas-bg-dark,var(--zui-surface-muted-dark,oklch(27.9%_0.041_260.031)))]", children: /* @__PURE__ */ jsx(
|
|
123
|
+
"canvas",
|
|
124
|
+
{
|
|
125
|
+
ref: canvasRef,
|
|
126
|
+
width: canvasSize,
|
|
127
|
+
height: canvasSize,
|
|
128
|
+
"data-slot": "qr-code-canvas",
|
|
129
|
+
className: "block h-auto max-w-full",
|
|
130
|
+
"aria-label": `QR code for ${value}`
|
|
131
|
+
}
|
|
132
|
+
) }),
|
|
133
|
+
caption ? /* @__PURE__ */ jsx(
|
|
134
|
+
"span",
|
|
135
|
+
{
|
|
136
|
+
"data-slot": "qr-code-caption",
|
|
137
|
+
className: "text-xs text-center text-[color:var(--zui-qr-code-caption-fg,var(--zui-fg-muted,oklch(55.2%_0.046_257.417)))] dark:text-[color:var(--zui-qr-code-caption-fg-dark,var(--zui-fg-muted-dark,oklch(70.8%_0.015_256.243)))] max-w-full truncate px-2",
|
|
138
|
+
children: caption
|
|
139
|
+
}
|
|
140
|
+
) : null
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
QrCodeAnimated.displayName = "QrCodeAnimated";
|
|
146
|
+
|
|
147
|
+
export { QrCodeAnimated, qrCodeAnimationPresets };
|
|
148
|
+
//# sourceMappingURL=animated.mjs.map
|
|
149
|
+
//# sourceMappingURL=animated.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/qr-code/animated/animations.ts","../../../src/ui/qr-code/animated/qr-code-animated.tsx"],"names":[],"mappings":";;;;;;;;;;AAcO,IAAM,sBAAA,GAAiD;AAAA,EAC5D,IAAA,EAAM;AAAA,IACJ,UAAA,EAAY,EAAE,QAAA,EAAU,CAAA,EAAE;AAAA,IAC1B,QAAA,EAAU;AAAA,MACR,OAAA,EAAS,EAAE,OAAA,EAAS,CAAA,EAAE;AAAA,MACtB,OAAA,EAAS,EAAE,OAAA,EAAS,CAAA;AAAE;AACxB,GACF;AAAA,EACA,SAAA,EAAW;AAAA,IACT,UAAA,EAAY,EAAE,QAAA,EAAU,GAAA,EA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A;AAAA,QACA,MAAA;AAAA,QACA,OAAA;AAAA,QACA,SAAA;AAAA,QACC,GAAG;AAAA;AAAA,KACN;AAAA,EAEJ;AAEA,EAAA,MAAM,MAAA,GAAS,uBAAuB,SAAS,CAAA;AAE/C,EAAA,uBACE,IAAA;AAAA,IAAC,MAAA,CAAO,GAAA;AAAA,IAAP;AAAA,MACC,WAAA,EAAU,SAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,0XAAA;AAAA,QACA;AAAA,OACF;AAAA,MACA,UAAU,MAAA,CAAO,QAAA;AAAA,MACjB,OAAA,EAAQ,SAAA;AAAA,MACR,OAAA,EAAQ,SAAA;AAAA,MACR,YAAY,MAAA,CAAO,UAAA;AAAA,MAClB,GAAI,KAAA;AAAA,MAEL,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,KAAA,EAAA,EAAI,WAAU,uNAAA,EACb,QAAA,kBAAA,GAAA;AAAA,UAAC,QAAA;AAAA,UAAA;AAAA,YACC,GAAA,EAAK,SAAA;AAAA,YACL,KAAA,EAAO,UAAA;AAAA,YACP,MAAA,EAAQ,UAAA;AAAA,YACR,WAAA,EAAU,gBAAA;AAAA,YACV,SAAA,EAAU,yBAAA;AAAA,YACV,YAAA,EAAY,eAAe,KAAK,CAAA;AAAA;AAAA,SAClC,EACF,CAAA;AAAA,QACC,OAAA,mBACC,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,WAAA,EAAU,iBAAA;AAAA,YACV,SAAA,EAAU,iPAAA;AAAA,YAET,QAAA,EAAA;AAAA;AAAA,SACH,GACE;AAAA;AAAA;AAAA,GACN;AAEJ;AAEA,cAAA,CAAe,WAAA,GAAc,gBAAA","file":"animated.mjs","sourcesContent":["import type { Transition, Variants } from \"framer-motion\";\n\nexport type QrCodeAnimation =\n | \"none\"\n | \"fade-in\"\n | \"zoom-in\"\n | \"slide-up\"\n | \"rotate-in\";\n\nexport type QrCodeAnimationPresets = Record<\n QrCodeAnimation,\n { transition: Transition; variants: Variants }\n>;\n\nexport const qrCodeAnimationPresets: QrCodeAnimationPresets = {\n none: {\n transition: { duration: 0 },\n variants: {\n initial: { opacity: 1 },\n animate: { opacity: 1 },\n },\n },\n \"fade-in\": {\n transition: { duration: 0.3, ease: \"easeOut\" },\n variants: {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n },\n },\n \"zoom-in\": {\n transition: { type: \"spring\", stiffness: 300, damping: 24 },\n variants: {\n initial: { opacity: 0, scale: 0.85 },\n animate: { opacity: 1, scale: 1 },\n },\n },\n \"slide-up\": {\n transition: { type: \"spring\", stiffness: 280, damping: 22 },\n variants: {\n initial: { opacity: 0, y: 20 },\n animate: { opacity: 1, y: 0 },\n },\n },\n \"rotate-in\": {\n transition: { type: \"spring\", stiffness: 200, damping: 18 },\n variants: {\n initial: { opacity: 0, rotate: -90, scale: 0.8 },\n animate: { opacity: 1, rotate: 0, scale: 1 },\n },\n },\n};\n","\"use client\";\n\nimport { useEffect, useRef } from \"react\";\nimport { motion } from \"framer-motion\";\nimport QRCode from \"qrcode\";\n\nimport { cn } from \"../../../lib/utils\";\nimport { qrCodeAnimationPresets } from \"./animations\";\nimport type { QrCodeAnimatedProps } from \"./types\";\nimport { QrCodeBase } from \"../qr-code-base\";\n\nexport function QrCodeAnimated({\n animation = \"none\",\n value,\n canvasSize = 200,\n level = \"M\",\n bgColor = \"#ffffff\",\n fgColor = \"#000000\",\n margin = 2,\n caption,\n className,\n ...props\n}: QrCodeAnimatedProps) {\n const canvasRef = useRef<HTMLCanvasElement>(null);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas || animation === \"none\") return;\n\n if (!value) {\n const ctx = canvas.getContext(\"2d\");\n if (ctx) {\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n }\n return;\n }\n\n QRCode.toCanvas(\n canvas,\n value,\n {\n width: canvasSize,\n margin,\n color: {\n dark: fgColor,\n light: bgColor,\n },\n errorCorrectionLevel: level,\n },\n (error) => {\n if (error) {\n console.error(\"QR Code generation error:\", error);\n }\n },\n );\n }, [value, canvasSize, level, bgColor, fgColor, margin, animation]);\n\n if (animation === \"none\") {\n return (\n <QrCodeBase\n value={value}\n canvasSize={canvasSize}\n level={level}\n bgColor={bgColor}\n fgColor={fgColor}\n margin={margin}\n caption={caption}\n className={className}\n {...props}\n />\n );\n }\n\n const preset = qrCodeAnimationPresets[animation];\n\n return (\n <motion.div\n data-slot=\"qr-code\"\n className={cn(\n \"inline-flex flex-col items-center gap-3 rounded-2xl border p-6 border-[color:var(--zui-qr-code-border,var(--zui-border,#0000001a))] dark:border-[color:var(--zui-qr-code-border-dark,var(--zui-border-dark,#ffffff1a))] bg-[var(--zui-qr-code-bg,var(--zui-surface,oklch(98.4%_0.003_247.858)))] dark:bg-[var(--zui-qr-code-bg-dark,var(--zui-surface-dark,oklch(12.9%_0.042_264.695)))]\",\n className,\n )}\n variants={preset.variants}\n initial=\"initial\"\n animate=\"animate\"\n transition={preset.transition}\n {...(props as Record<string, unknown>)}\n >\n <div className=\"overflow-hidden rounded-xl bg-[var(--zui-qr-code-canvas-bg,var(--zui-surface-muted,oklch(92.9%_0.013_255.508)))] dark:bg-[var(--zui-qr-code-canvas-bg-dark,var(--zui-surface-muted-dark,oklch(27.9%_0.041_260.031)))]\">\n <canvas\n ref={canvasRef}\n width={canvasSize}\n height={canvasSize}\n data-slot=\"qr-code-canvas\"\n className=\"block h-auto max-w-full\"\n aria-label={`QR code for ${value}`}\n />\n </div>\n {caption ? (\n <span\n data-slot=\"qr-code-caption\"\n className=\"text-xs text-center text-[color:var(--zui-qr-code-caption-fg,var(--zui-fg-muted,oklch(55.2%_0.046_257.417)))] dark:text-[color:var(--zui-qr-code-caption-fg-dark,var(--zui-fg-muted-dark,oklch(70.8%_0.015_256.243)))] max-w-full truncate px-2\"\n >\n {caption}\n </span>\n ) : null}\n </motion.div>\n );\n}\n\nQrCodeAnimated.displayName = \"QrCodeAnimated\";\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { QrCode } from "./qr-code";
|
|
2
|
+
export type { QrCodeBaseProps, QrCodeLevel, QrCodeProps } from "./types";
|
|
3
|
+
export { QR_CODE_LEVEL_LABELS } from "./types";
|
|
4
|
+
export { qrCodeCanvasWrapperVariants, qrCodeCaptionVariants, qrCodeVariants, } from "./variants";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/qr-code/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { QrCodeBaseProps } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* QrCodeBase renders a QR code onto a `<canvas>` element using the `qrcode`
|
|
4
|
+
* npm package. It is the static (non-animated) implementation of the public
|
|
5
|
+
* `QrCode` component.
|
|
6
|
+
*
|
|
7
|
+
* --- Props ---
|
|
8
|
+
*
|
|
9
|
+
* - `value` — The string to encode. When empty/falsy the canvas is cleared.
|
|
10
|
+
* - `canvasSize` — Pixel dimensions of the canvas (default: 200). Both width
|
|
11
|
+
* and height are set to this value, producing a square QR code.
|
|
12
|
+
* - `level` — Error correction level (`"L"` | `"M"` | `"Q"` | `"H"`). Higher
|
|
13
|
+
* levels survive more visual damage but hold less data.
|
|
14
|
+
* - `bgColor` / `fgColor` — Background and foreground colours passed to the
|
|
15
|
+
* underlying `QRCode.toCanvas` options.
|
|
16
|
+
* - `margin` — Quiet-zone width in QR modules (default: 2). Passed directly
|
|
17
|
+
* to the `qrcode` library.
|
|
18
|
+
* - `caption` — Optional label rendered below the QR code.
|
|
19
|
+
* - `ref` — React 19 ref forwarded to the root `<div>` element.
|
|
20
|
+
* - `className` / `...rest` — Spread onto the root `<div>` for layout or
|
|
21
|
+
* style overrides.
|
|
22
|
+
*
|
|
23
|
+
* --- Rendering lifecycle ---
|
|
24
|
+
*
|
|
25
|
+
* A `useEffect` watches `[value, canvasSize, level, bgColor, fgColor, margin]`.
|
|
26
|
+
* On every change it:
|
|
27
|
+
* 1. Grabs the canvas element from the ref.
|
|
28
|
+
* 2. If `value` is empty, clears the canvas with `ctx.clearRect` so a stale
|
|
29
|
+
* QR code doesn't persist.
|
|
30
|
+
* 3. Otherwise calls `QRCode.toCanvas()` which draws the QR pattern
|
|
31
|
+
* asynchronously (via callback) onto the canvas element.
|
|
32
|
+
*
|
|
33
|
+
* The outer `<div>` uses design-system variants (`qrCodeVariants`) for
|
|
34
|
+
* consistent theming and carries `data-slot="qr-code"` for scoped styling and
|
|
35
|
+
* testing.
|
|
36
|
+
*
|
|
37
|
+
* --- Accessibility ---
|
|
38
|
+
*
|
|
39
|
+
* The `<canvas>` has an `aria-label` describing it as a "QR code for {value}".
|
|
40
|
+
* Screen readers will announce the purpose, though the raw value is exposed
|
|
41
|
+
* (consider truncating for secrets).
|
|
42
|
+
*/
|
|
43
|
+
export declare function QrCodeBase({ value, canvasSize, level, bgColor, fgColor, margin, caption, className, ref, ...rest }: QrCodeBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export declare namespace QrCodeBase {
|
|
45
|
+
var displayName: string;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=qr-code-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-code-base.d.ts","sourceRoot":"","sources":["../../../src/ui/qr-code/qr-code-base.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAO/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,UAAgB,EAChB,KAAW,EACX,OAAmB,EACnB,OAAmB,EACnB,MAAU,EACV,OAAO,EACP,SAAS,EACT,GAAG,EACH,GAAG,IAAI,EACR,EAAE,eAAe,2CAgFjB;yBA3Fe,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-code.d.ts","sourceRoot":"","sources":["../../../src/ui/qr-code/qr-code.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
|
+
export type QrCodeLevel = "L" | "M" | "Q" | "H";
|
|
3
|
+
export interface QrCodeBaseProps extends ComponentPropsWithRef<"div"> {
|
|
4
|
+
value: string;
|
|
5
|
+
canvasSize?: number;
|
|
6
|
+
level?: QrCodeLevel;
|
|
7
|
+
bgColor?: string;
|
|
8
|
+
fgColor?: string;
|
|
9
|
+
margin?: number;
|
|
10
|
+
caption?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export type QrCodeProps = QrCodeBaseProps;
|
|
13
|
+
export declare const QR_CODE_LEVEL_LABELS: Record<QrCodeLevel, string>;
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/ui/qr-code/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,MAAM,MAAM,WAAW,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAEhD,MAAM,WAAW,eAAgB,SAAQ,qBAAqB,CAAC,KAAK,CAAC;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,MAAM,WAAW,GAAG,eAAe,CAAC;AAE1C,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAKnD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const qrCodeVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
2
|
+
export declare const qrCodeCanvasWrapperVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
3
|
+
export declare const qrCodeCaptionVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
4
|
+
//# sourceMappingURL=variants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../src/ui/qr-code/variants.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,cAAc,oFAAqB,CAAC;AACjD,eAAO,MAAM,2BAA2B,oFAA8B,CAAC;AACvE,eAAO,MAAM,qBAAqB,oFAA4B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunkPWEZB53R_js = require('../chunk-PWEZB53R.js');
|
|
5
|
+
require('../chunk-XUK5P37Y.js');
|
|
6
|
+
require('../chunk-ZS5756ZC.js');
|
|
7
|
+
require('../chunk-PZ5AY32C.js');
|
|
8
|
+
|
|
9
|
+
// src/ui/qr-code/types.ts
|
|
10
|
+
var QR_CODE_LEVEL_LABELS = {
|
|
11
|
+
L: "Low (7%)",
|
|
12
|
+
M: "Medium (15%)",
|
|
13
|
+
Q: "Quartile (25%)",
|
|
14
|
+
H: "High (30%)"
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
Object.defineProperty(exports, "QrCode", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return chunkPWEZB53R_js.QrCodeBase; }
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "qrCodeCanvasWrapperVariants", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return chunkPWEZB53R_js.qrCodeCanvasWrapperVariants; }
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "qrCodeCaptionVariants", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return chunkPWEZB53R_js.qrCodeCaptionVariants; }
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports, "qrCodeVariants", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return chunkPWEZB53R_js.qrCodeVariants; }
|
|
32
|
+
});
|
|
33
|
+
exports.QR_CODE_LEVEL_LABELS = QR_CODE_LEVEL_LABELS;
|
|
34
|
+
//# sourceMappingURL=qr-code.js.map
|
|
35
|
+
//# sourceMappingURL=qr-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/qr-code/types.ts"],"names":[],"mappings":";;;;;;;;AAgBO,IAAM,oBAAA,GAAoD;AAAA,EAC/D,CAAA,EAAG,UAAA;AAAA,EACH,CAAA,EAAG,cAAA;AAAA,EACH,CAAA,EAAG,gBAAA;AAAA,EACH,CAAA,EAAG;AACL","file":"qr-code.js","sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from \"react\";\n\nexport type QrCodeLevel = \"L\" | \"M\" | \"Q\" | \"H\";\n\nexport interface QrCodeBaseProps extends ComponentPropsWithRef<\"div\"> {\n value: string;\n canvasSize?: number;\n level?: QrCodeLevel;\n bgColor?: string;\n fgColor?: string;\n margin?: number;\n caption?: ReactNode;\n}\n\nexport type QrCodeProps = QrCodeBaseProps;\n\nexport const QR_CODE_LEVEL_LABELS: Record<QrCodeLevel, string> = {\n L: \"Low (7%)\",\n M: \"Medium (15%)\",\n Q: \"Quartile (25%)\",\n H: \"High (30%)\",\n} as const;\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
export { QrCodeBase as QrCode, qrCodeCanvasWrapperVariants, qrCodeCaptionVariants, qrCodeVariants } from '../chunk-UBQY572I.mjs';
|
|
3
|
+
import '../chunk-4U6PVVST.mjs';
|
|
4
|
+
import '../chunk-4D54YOL6.mjs';
|
|
5
|
+
import '../chunk-J5LGTIGS.mjs';
|
|
6
|
+
|
|
7
|
+
// src/ui/qr-code/types.ts
|
|
8
|
+
var QR_CODE_LEVEL_LABELS = {
|
|
9
|
+
L: "Low (7%)",
|
|
10
|
+
M: "Medium (15%)",
|
|
11
|
+
Q: "Quartile (25%)",
|
|
12
|
+
H: "High (30%)"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { QR_CODE_LEVEL_LABELS };
|
|
16
|
+
//# sourceMappingURL=qr-code.mjs.map
|
|
17
|
+
//# sourceMappingURL=qr-code.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/qr-code/types.ts"],"names":[],"mappings":";;;;;;AAgBO,IAAM,oBAAA,GAAoD;AAAA,EAC/D,CAAA,EAAG,UAAA;AAAA,EACH,CAAA,EAAG,cAAA;AAAA,EACH,CAAA,EAAG,gBAAA;AAAA,EACH,CAAA,EAAG;AACL","file":"qr-code.mjs","sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from \"react\";\n\nexport type QrCodeLevel = \"L\" | \"M\" | \"Q\" | \"H\";\n\nexport interface QrCodeBaseProps extends ComponentPropsWithRef<\"div\"> {\n value: string;\n canvasSize?: number;\n level?: QrCodeLevel;\n bgColor?: string;\n fgColor?: string;\n margin?: number;\n caption?: ReactNode;\n}\n\nexport type QrCodeProps = QrCodeBaseProps;\n\nexport const QR_CODE_LEVEL_LABELS: Record<QrCodeLevel, string> = {\n L: \"Low (7%)\",\n M: \"Medium (15%)\",\n Q: \"Quartile (25%)\",\n H: \"High (30%)\",\n} as const;\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { QrScanner } from "./qr-scanner";
|
|
2
|
+
export type { QrScannerBaseProps, QrScannerProps, QrScannerRef, QrScannerVariantProps, } from "./types";
|
|
3
|
+
export { qrScannerFallbackVariants, qrScannerOverlayVariants, qrScannerStatusVariants, qrScannerVariants, qrScannerVideoVariants, qrScannerViewfinderVariants, } from "./variants";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/qr-scanner/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,qBAAqB,GACtB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { QrScannerBaseProps } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* QrScannerBase uses the device camera (via `getUserMedia`) to decode QR
|
|
4
|
+
* codes in real time. It provides an imperative handle (`ref`) so parents
|
|
5
|
+
* can control the camera lifecycle and scan images without camera access.
|
|
6
|
+
*
|
|
7
|
+
* --- Architecture overview ---
|
|
8
|
+
*
|
|
9
|
+
* The component has three main async loops:
|
|
10
|
+
*
|
|
11
|
+
* 1. **Camera startup** (`startCamera`) — calls `getUserMedia`, attaches
|
|
12
|
+
* the stream to a `<video>` element, calls `video.play()`, then
|
|
13
|
+
* kicks off the scan loop via `requestAnimationFrame`.
|
|
14
|
+
*
|
|
15
|
+
* 2. **Scan loop** (`scanFrame`) — scheduled with `requestAnimationFrame`.
|
|
16
|
+
* Each frame draws the current video frame to an off-screen `<canvas>`,
|
|
17
|
+
* calls `jsQR` on the pixel data, and fires `onResult` when a QR code
|
|
18
|
+
* is detected. Respects `scanDelay` to avoid thrashing.
|
|
19
|
+
*
|
|
20
|
+
* 3. **Image scanning** (`scanImage` on the imperative handle) — decodes a
|
|
21
|
+
* QR code from a static `File` (e.g. an uploaded screenshot) without
|
|
22
|
+
* involving the camera at all.
|
|
23
|
+
*
|
|
24
|
+
* --- Race-condition guards ---
|
|
25
|
+
*
|
|
26
|
+
* Camera start/stop is inherently racy because `video.play()` returns a
|
|
27
|
+
* Promise that resolves asynchronously. If `stopCamera()` (or the
|
|
28
|
+
* `useEffect` cleanup) runs while `play()` is still pending, we must not
|
|
29
|
+
* operate on the new stream that may have been set up in the meantime.
|
|
30
|
+
*
|
|
31
|
+
* Both `stopCamera` and the effect cleanup capture `streamRef.current` into
|
|
32
|
+
* a local `streamToStop` variable at the time they are called. The actual
|
|
33
|
+
* stop/cleanup logic (which may run later via `playPromise.then(...)`)
|
|
34
|
+
* checks `video.srcObject === streamToStop` before pausing, ensuring it
|
|
35
|
+
* only affects the stream that was active at the time of the request.
|
|
36
|
+
*
|
|
37
|
+
* --- Callback ref pattern ---
|
|
38
|
+
*
|
|
39
|
+
* `onResult`, `onError`, `onStart`, `onStop` are stored in refs and kept
|
|
40
|
+
* current in the render body. The `useCallback` hooks for `scanFrame`,
|
|
41
|
+
* `startCamera`, and `stopCamera` read from these refs instead of listing
|
|
42
|
+
* the callbacks in their dependency arrays. This prevents the camera from
|
|
43
|
+
* restarting every time the parent passes a new inline function reference.
|
|
44
|
+
*
|
|
45
|
+
* --- Error classification ---
|
|
46
|
+
*
|
|
47
|
+
* `getUserMedia` throws `DOMException` with specific names:
|
|
48
|
+
* - `NotFoundError` → no camera hardware detected
|
|
49
|
+
* - `NotAllowedError` → user denied permission
|
|
50
|
+
* - `NotReadableError` → camera is busy (another app)
|
|
51
|
+
* - `AbortError` → `play()` was interrupted by unmount
|
|
52
|
+
*
|
|
53
|
+
* The first three set `status` to `"no-camera"` and render a fallback UI.
|
|
54
|
+
* `AbortError` is silently swallowed because it's a normal consequence of
|
|
55
|
+
* unmounting during startup. All other errors set `status` to `"error"` and
|
|
56
|
+
* display the error message.
|
|
57
|
+
*/
|
|
58
|
+
export declare function QrScannerBase({ onResult, onError, onStart, onStop, facingMode, constraints, scanDelay, continuous, fallbackText, loadingText, noCameraText, appearance, autoStart, className, ref, ...rest }: QrScannerBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
export declare namespace QrScannerBase {
|
|
60
|
+
var displayName: string;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=qr-scanner-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-scanner-base.d.ts","sourceRoot":"","sources":["../../../src/ui/qr-scanner/qr-scanner-base.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAkClD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,OAAO,EACP,OAAO,EACP,MAAM,EACN,UAA0B,EAC1B,WAAW,EACX,SAAe,EACf,UAAkB,EAClB,YAAqC,EACrC,WAAkC,EAClC,YAAmC,EACnC,UAAU,EACV,SAAgB,EAChB,SAAS,EACT,GAAG,EACH,GAAG,IAAI,EACR,EAAE,kBAAkB,2CA8bpB;yBA/ce,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-scanner.d.ts","sourceRoot":"","sources":["../../../src/ui/qr-scanner/qr-scanner.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { VariantProps } from "class-variance-authority";
|
|
2
|
+
import type { ComponentPropsWithoutRef, ReactNode, Ref } from "react";
|
|
3
|
+
import type { qrScannerVariants } from "./variants";
|
|
4
|
+
export type QrScannerVariantProps = VariantProps<typeof qrScannerVariants>;
|
|
5
|
+
export interface QrScannerBaseProps extends ComponentPropsWithoutRef<"div"> {
|
|
6
|
+
ref?: Ref<QrScannerRef>;
|
|
7
|
+
onResult: (data: string) => void;
|
|
8
|
+
onError?: (error: unknown) => void;
|
|
9
|
+
onStart?: () => void;
|
|
10
|
+
onStop?: () => void;
|
|
11
|
+
facingMode?: "user" | "environment";
|
|
12
|
+
constraints?: MediaTrackConstraints;
|
|
13
|
+
scanDelay?: number;
|
|
14
|
+
continuous?: boolean;
|
|
15
|
+
fallbackText?: ReactNode;
|
|
16
|
+
loadingText?: ReactNode;
|
|
17
|
+
noCameraText?: ReactNode;
|
|
18
|
+
appearance?: QrScannerVariantProps["appearance"];
|
|
19
|
+
autoStart?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export type QrScannerProps = QrScannerBaseProps;
|
|
22
|
+
export interface QrScannerRef {
|
|
23
|
+
start: () => Promise<void>;
|
|
24
|
+
stop: () => void;
|
|
25
|
+
scanImage: (file: File) => Promise<string | null>;
|
|
26
|
+
isScanning: boolean;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/ui/qr-scanner/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,MAAM,qBAAqB,GAAG,YAAY,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE3E,MAAM,WAAW,kBAAmB,SAAQ,wBAAwB,CAAC,KAAK,CAAC;IACzE,GAAG,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;IACxB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;IACpC,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,UAAU,CAAC,EAAE,qBAAqB,CAAC,YAAY,CAAC,CAAC;IACjD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAEhD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAClD,UAAU,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const qrScannerVariants: (props?: ({
|
|
2
|
+
appearance?: "default" | "muted" | null | undefined;
|
|
3
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
4
|
+
export declare const qrScannerVideoVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
5
|
+
export declare const qrScannerOverlayVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
6
|
+
export declare const qrScannerViewfinderVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
7
|
+
export declare const qrScannerStatusVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
8
|
+
export declare const qrScannerFallbackVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
9
|
+
//# sourceMappingURL=variants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../src/ui/qr-scanner/variants.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,iBAAiB;;8EAO5B,CAAC;AAEH,eAAO,MAAM,sBAAsB,oFAAyB,CAAC;AAC7D,eAAO,MAAM,wBAAwB,oFAA2B,CAAC;AACjE,eAAO,MAAM,2BAA2B,oFAA8B,CAAC;AACvE,eAAO,MAAM,uBAAuB,oFAA8B,CAAC;AACnE,eAAO,MAAM,yBAAyB,oFAAgC,CAAC"}
|