qrdx 0.0.58 → 0.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.js +4 -4
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +4 -4
- package/dist/core.mjs.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/index.mjs.map +1 -1
- package/dist/src/qr-code-props.d.ts +10 -1
- package/dist/src/qr-code-props.d.ts.map +1 -1
- package/dist/src/qr-code.d.ts.map +1 -1
- package/dist/vanilla.browser.mjs +4 -4
- package/dist/vanilla.browser.mjs.map +1 -1
- package/package.json +1 -1
- package/src/qr-code-props.ts +38 -25
- package/src/qr-code.tsx +7 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qrdx",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.59",
|
|
4
4
|
"description": "Customizable QR code generator for React and plain JavaScript: SVG and canvas rendering, dot and eye patterns, gradients, logos, frames, Logo QR and Image QR art, PNG/JPG/WebP/SVG/PDF/EPS export, a scan score and QR scanning.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"qr-code",
|
package/src/qr-code-props.ts
CHANGED
|
@@ -87,32 +87,45 @@ function rootAttributes(props: QRCodeOptions): QRSVGAttributes {
|
|
|
87
87
|
|
|
88
88
|
type QRData = ReturnType<typeof getQRData>;
|
|
89
89
|
|
|
90
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* Every prop `getQRCodeData` lays the code out from, in one list. React's
|
|
92
|
+
* `QRCode` keeps its layout until one of these changes, so a prop the layout
|
|
93
|
+
* reads can't be left out of that check: the looks once were (the per-eye
|
|
94
|
+
* shapes, the eyes' gradient span, the rounded background and its backdrop,
|
|
95
|
+
* the halo and the shadow), and a code drawn without them stayed on screen
|
|
96
|
+
* after one was turned on.
|
|
97
|
+
*/
|
|
98
|
+
export const QR_CODE_DATA_KEYS = [
|
|
99
|
+
"value",
|
|
100
|
+
"fgColor",
|
|
101
|
+
"hideLogo",
|
|
102
|
+
"bgColor",
|
|
103
|
+
"eyeColor",
|
|
104
|
+
"dotColor",
|
|
105
|
+
"bodyPattern",
|
|
106
|
+
"cornerEyePattern",
|
|
107
|
+
"cornerEyeDotPattern",
|
|
108
|
+
"level",
|
|
109
|
+
"templateId",
|
|
110
|
+
"logo",
|
|
111
|
+
"logoOptions",
|
|
112
|
+
"margin",
|
|
113
|
+
"autoLevel",
|
|
114
|
+
"shape",
|
|
115
|
+
"eyeShapes",
|
|
116
|
+
"eyeGradient",
|
|
117
|
+
"bgRadius",
|
|
118
|
+
"backdrop",
|
|
119
|
+
"halo",
|
|
120
|
+
"shadow",
|
|
121
|
+
] as const satisfies readonly (keyof QRCodeProps)[];
|
|
122
|
+
|
|
123
|
+
/** What `getQRData` lays out for `QRCode`'s props (QR_CODE_DATA_KEYS). */
|
|
91
124
|
export function getQRCodeData(props: QRCodeProps): QRData {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
bgColor: props.bgColor,
|
|
97
|
-
eyeColor: props.eyeColor,
|
|
98
|
-
dotColor: props.dotColor,
|
|
99
|
-
bodyPattern: props.bodyPattern,
|
|
100
|
-
cornerEyePattern: props.cornerEyePattern,
|
|
101
|
-
cornerEyeDotPattern: props.cornerEyeDotPattern,
|
|
102
|
-
level: props.level,
|
|
103
|
-
templateId: props.templateId,
|
|
104
|
-
logo: props.logo,
|
|
105
|
-
logoOptions: props.logoOptions,
|
|
106
|
-
margin: props.margin ?? DEFAULT_MARGIN,
|
|
107
|
-
autoLevel: props.autoLevel,
|
|
108
|
-
shape: props.shape,
|
|
109
|
-
eyeShapes: props.eyeShapes,
|
|
110
|
-
eyeGradient: props.eyeGradient,
|
|
111
|
-
bgRadius: props.bgRadius,
|
|
112
|
-
backdrop: props.backdrop,
|
|
113
|
-
halo: props.halo,
|
|
114
|
-
shadow: props.shadow,
|
|
115
|
-
});
|
|
125
|
+
const read = Object.fromEntries(
|
|
126
|
+
QR_CODE_DATA_KEYS.map((key) => [key, props[key]])
|
|
127
|
+
) as Pick<QRCodeProps, (typeof QR_CODE_DATA_KEYS)[number]>;
|
|
128
|
+
return getQRData({ ...read, margin: props.margin ?? DEFAULT_MARGIN });
|
|
116
129
|
}
|
|
117
130
|
|
|
118
131
|
/**
|
package/src/qr-code.tsx
CHANGED
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
// on the server; only QRCodeCanvas needs a client boundary.
|
|
3
3
|
import { memo, useMemo } from "react";
|
|
4
4
|
import type { QRCodePropsSVG } from "../types/react";
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
getQRCodeData,
|
|
7
|
+
getQRCodeSVGProps,
|
|
8
|
+
QR_CODE_DATA_KEYS,
|
|
9
|
+
} from "./qr-code-props";
|
|
7
10
|
import { QRCodeSVG } from "./qr-code-svg";
|
|
8
11
|
|
|
9
12
|
/**
|
|
@@ -12,45 +15,10 @@ import { QRCodeSVG } from "./qr-code-svg";
|
|
|
12
15
|
* goes on the `<svg>`, as with `QRCodeSVG`.
|
|
13
16
|
*/
|
|
14
17
|
export const QRCode = memo((props: QRCodePropsSVG) => {
|
|
15
|
-
const {
|
|
16
|
-
value,
|
|
17
|
-
fgColor,
|
|
18
|
-
hideLogo,
|
|
19
|
-
logo,
|
|
20
|
-
logoOptions,
|
|
21
|
-
bgColor,
|
|
22
|
-
eyeColor,
|
|
23
|
-
dotColor,
|
|
24
|
-
bodyPattern,
|
|
25
|
-
cornerEyePattern,
|
|
26
|
-
cornerEyeDotPattern,
|
|
27
|
-
level,
|
|
28
|
-
margin = DEFAULT_MARGIN,
|
|
29
|
-
templateId,
|
|
30
|
-
autoLevel,
|
|
31
|
-
shape,
|
|
32
|
-
} = props;
|
|
33
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: the layout depends on exactly these props
|
|
34
18
|
const qrData = useMemo(
|
|
35
19
|
() => getQRCodeData(props),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
fgColor,
|
|
39
|
-
hideLogo,
|
|
40
|
-
logo,
|
|
41
|
-
logoOptions,
|
|
42
|
-
margin,
|
|
43
|
-
autoLevel,
|
|
44
|
-
shape,
|
|
45
|
-
bgColor,
|
|
46
|
-
eyeColor,
|
|
47
|
-
dotColor,
|
|
48
|
-
bodyPattern,
|
|
49
|
-
cornerEyePattern,
|
|
50
|
-
cornerEyeDotPattern,
|
|
51
|
-
level,
|
|
52
|
-
templateId,
|
|
53
|
-
]
|
|
20
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: the layout reads exactly these props (QR_CODE_DATA_KEYS, the list getQRCodeData lays out from)
|
|
21
|
+
QR_CODE_DATA_KEYS.map((key) => props[key])
|
|
54
22
|
);
|
|
55
23
|
|
|
56
24
|
return <QRCodeSVG {...getQRCodeSVGProps(props, qrData)} />;
|