pixuireactcomponents 1.5.13 → 1.5.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixuireactcomponents",
3
- "version": "1.5.13",
3
+ "version": "1.5.14",
4
4
  "description": "pixui react components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -41,6 +41,7 @@
41
41
  "@types/jest": "25.2.1",
42
42
  "@types/node": "13.11.1",
43
43
  "ajv": "^8.14.0",
44
+ "arale-qrcode": "^3.0.5",
44
45
  "babel-loader": "^8.1.0",
45
46
  "babel-plugin-import": "^1.12.0",
46
47
  "babel-plugin-jsx-pragmatic": "^1.0.2",
@@ -0,0 +1,18 @@
1
+ import { h } from 'preact';
2
+ /**
3
+ *
4
+ * @param rootId 根节点id
5
+ * @param rootClassName 根节点className
6
+ * @param size 组件尺寸
7
+ * @param srcUrl url链接
8
+ */
9
+ export declare let QRCode: (props: {
10
+ rootId?: string;
11
+ rootClassName?: string;
12
+ size: number;
13
+ srcUrl: string;
14
+ background?: string;
15
+ foreground?: string;
16
+ image?: string;
17
+ imageSize?: number;
18
+ }) => h.JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { useEffect, useRef } from 'preact/hooks';
2
+ import { h } from 'preact';
3
+ import AraleQRCode from 'arale-qrcode';
4
+ /**
5
+ *
6
+ * @param rootId 根节点id
7
+ * @param rootClassName 根节点className
8
+ * @param size 组件尺寸
9
+ * @param srcUrl url链接
10
+ */
11
+ export var QRCode = function (props) {
12
+ var qrcodeRef = useRef(null);
13
+ useEffect(function () {
14
+ var qrcode = new AraleQRCode({
15
+ text: props.srcUrl,
16
+ size: props.size ? props.size : 100,
17
+ render: 'canvas',
18
+ background: props.background ? props.background : "#fff",
19
+ foreground: props.background ? props.foreground : "#000",
20
+ correctLevel: 1,
21
+ });
22
+ if (qrcodeRef.current) {
23
+ qrcodeRef.current.appendChild(qrcode);
24
+ }
25
+ }, []);
26
+ return (h("div", { id: props.rootId, className: props.rootClassName, ref: qrcodeRef }));
27
+ };