qrcode-alipay 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { A as AlipayQRCodeOptions } from './types-Bdh_dniH.cjs';
3
+
4
+ interface AlipayQRCodeProps extends AlipayQRCodeOptions, Omit<React.SVGAttributes<SVGSVGElement>, 'children' | 'className' | 'dangerouslySetInnerHTML'> {
5
+ value: string;
6
+ className?: string;
7
+ [dataAttribute: `data-${string}`]: unknown;
8
+ }
9
+ declare function AlipayQRCode({ value, size, margin, title, ariaLabel, className, ...svgProps }: AlipayQRCodeProps): React.ReactElement;
10
+
11
+ export { AlipayQRCode, type AlipayQRCodeProps };
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { A as AlipayQRCodeOptions } from './types-Bdh_dniH.js';
3
+
4
+ interface AlipayQRCodeProps extends AlipayQRCodeOptions, Omit<React.SVGAttributes<SVGSVGElement>, 'children' | 'className' | 'dangerouslySetInnerHTML'> {
5
+ value: string;
6
+ className?: string;
7
+ [dataAttribute: `data-${string}`]: unknown;
8
+ }
9
+ declare function AlipayQRCode({ value, size, margin, title, ariaLabel, className, ...svgProps }: AlipayQRCodeProps): React.ReactElement;
10
+
11
+ export { AlipayQRCode, type AlipayQRCodeProps };
package/dist/react.js ADDED
@@ -0,0 +1,54 @@
1
+ import {
2
+ createAlipayQRCode
3
+ } from "./chunk-BECJ3Y2B.js";
4
+
5
+ // src/react.ts
6
+ import * as React from "react";
7
+ var REACT_ATTRS = {
8
+ class: "className",
9
+ "clip-rule": "clipRule",
10
+ "fill-rule": "fillRule",
11
+ focusable: "focusable",
12
+ "shape-rendering": "shapeRendering",
13
+ "stroke-linecap": "strokeLinecap",
14
+ "stroke-linejoin": "strokeLinejoin",
15
+ "stroke-width": "strokeWidth"
16
+ };
17
+ function reactAttrs(attrs = {}) {
18
+ return Object.fromEntries(
19
+ Object.entries(attrs).filter(([, value]) => value !== void 0 && value !== null && value !== false).map(([name, value]) => [REACT_ATTRS[name] ?? name, value])
20
+ );
21
+ }
22
+ function renderReactNode(node, key, rootProps) {
23
+ if (typeof node === "string") return node;
24
+ const props = {
25
+ ...reactAttrs(node.attrs),
26
+ ...rootProps ?? {},
27
+ key
28
+ };
29
+ const children = node.children?.map(
30
+ (child, index) => renderReactNode(child, index)
31
+ );
32
+ return React.createElement(node.tag, props, children);
33
+ }
34
+ function AlipayQRCode({
35
+ value,
36
+ size,
37
+ margin,
38
+ title,
39
+ ariaLabel,
40
+ className,
41
+ ...svgProps
42
+ }) {
43
+ const descriptor = createAlipayQRCode(value, {
44
+ size,
45
+ margin,
46
+ title,
47
+ ariaLabel,
48
+ className
49
+ });
50
+ return renderReactNode(descriptor, "root", svgProps);
51
+ }
52
+ export {
53
+ AlipayQRCode
54
+ };
@@ -0,0 +1,51 @@
1
+ type SvgAttributeValue = string | number | boolean | null | undefined;
2
+ interface SvgElementDescriptor {
3
+ tag: string;
4
+ attrs?: Record<string, SvgAttributeValue>;
5
+ children?: SvgNodeDescriptor[];
6
+ }
7
+ type SvgNodeDescriptor = SvgElementDescriptor | string;
8
+ interface AlipayQRCodeOptions {
9
+ /**
10
+ * Rendered SVG width and height. Numbers are emitted as px-like SVG units;
11
+ * strings can be used for responsive values such as "100%".
12
+ */
13
+ size?: number | string;
14
+ /**
15
+ * QR quiet zone in module units. Defaults to 0. If the QR code is rendered
16
+ * without a white padded container, pass 1 or more for scanner safety.
17
+ */
18
+ margin?: number;
19
+ /**
20
+ * Optional accessible title element inside the SVG.
21
+ */
22
+ title?: string;
23
+ /**
24
+ * Accessible label for the root SVG. Defaults to title, then a generic label.
25
+ */
26
+ ariaLabel?: string;
27
+ /**
28
+ * CSS class attached to the root SVG.
29
+ */
30
+ className?: string;
31
+ }
32
+ interface AlipayQRCodeMetadata {
33
+ moduleCount: number;
34
+ margin: number;
35
+ viewBoxSize: number;
36
+ logo?: {
37
+ frameX: number;
38
+ frameY: number;
39
+ frameSize: number;
40
+ iconX: number;
41
+ iconY: number;
42
+ iconSize: number;
43
+ };
44
+ }
45
+ interface AlipayQRCodeDescriptor extends SvgElementDescriptor {
46
+ tag: 'svg';
47
+ attrs: Record<string, SvgAttributeValue>;
48
+ metadata: AlipayQRCodeMetadata;
49
+ }
50
+
51
+ export type { AlipayQRCodeOptions as A, SvgAttributeValue as S, AlipayQRCodeDescriptor as a, AlipayQRCodeMetadata as b, SvgElementDescriptor as c, SvgNodeDescriptor as d };
@@ -0,0 +1,51 @@
1
+ type SvgAttributeValue = string | number | boolean | null | undefined;
2
+ interface SvgElementDescriptor {
3
+ tag: string;
4
+ attrs?: Record<string, SvgAttributeValue>;
5
+ children?: SvgNodeDescriptor[];
6
+ }
7
+ type SvgNodeDescriptor = SvgElementDescriptor | string;
8
+ interface AlipayQRCodeOptions {
9
+ /**
10
+ * Rendered SVG width and height. Numbers are emitted as px-like SVG units;
11
+ * strings can be used for responsive values such as "100%".
12
+ */
13
+ size?: number | string;
14
+ /**
15
+ * QR quiet zone in module units. Defaults to 0. If the QR code is rendered
16
+ * without a white padded container, pass 1 or more for scanner safety.
17
+ */
18
+ margin?: number;
19
+ /**
20
+ * Optional accessible title element inside the SVG.
21
+ */
22
+ title?: string;
23
+ /**
24
+ * Accessible label for the root SVG. Defaults to title, then a generic label.
25
+ */
26
+ ariaLabel?: string;
27
+ /**
28
+ * CSS class attached to the root SVG.
29
+ */
30
+ className?: string;
31
+ }
32
+ interface AlipayQRCodeMetadata {
33
+ moduleCount: number;
34
+ margin: number;
35
+ viewBoxSize: number;
36
+ logo?: {
37
+ frameX: number;
38
+ frameY: number;
39
+ frameSize: number;
40
+ iconX: number;
41
+ iconY: number;
42
+ iconSize: number;
43
+ };
44
+ }
45
+ interface AlipayQRCodeDescriptor extends SvgElementDescriptor {
46
+ tag: 'svg';
47
+ attrs: Record<string, SvgAttributeValue>;
48
+ metadata: AlipayQRCodeMetadata;
49
+ }
50
+
51
+ export type { AlipayQRCodeOptions as A, SvgAttributeValue as S, AlipayQRCodeDescriptor as a, AlipayQRCodeMetadata as b, SvgElementDescriptor as c, SvgNodeDescriptor as d };