@xiping/react-components 1.0.12 → 1.0.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/dist/cjs/components/image-viewer/ImageViewer.d.ts +1 -0
- package/dist/cjs/components/image-viewer/ImageViewer.js +1 -1
- package/dist/cjs/components/pinch-content/PinchContent.d.ts +4 -1
- package/dist/cjs/components/pinch-content/PinchContent.js +1 -1
- package/dist/cjs/components/qr-code/index.d.ts +18 -31
- package/dist/es/components/image-viewer/ImageViewer.d.ts +1 -0
- package/dist/es/components/image-viewer/ImageViewer.js +38 -28
- package/dist/es/components/pinch-content/PinchContent.d.ts +4 -1
- package/dist/es/components/pinch-content/PinchContent.js +44 -36
- package/dist/es/components/qr-code/index.d.ts +18 -31
- package/package.json +12 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),m=require("@heroui/modal"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),m=require("@heroui/modal"),S=require("@heroui/spinner"),p=require("react-icons/io5"),z=require("../pinch-content/PinchContent.js"),L=require("@radix-ui/react-scroll-area"),f=require("react"),O=require("clsx");function q(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(o,s,a.get?a:{enumerable:!0,get:()=>t[s]})}}return o.default=t,Object.freeze(o)}const i=q(L),x=t=>{t.preventDefault()},I=t=>{const{isOpen:o,onClose:s,imgSrc:a,canDownload:g=!1,wrapperClassName:j}=t,c=Array.isArray(a)?a:[a],[d,w]=f.useState(0),[v,u]=f.useState(!0),h=()=>{u(!0),s()},N=async()=>{const r=c[d];try{const k=await(await fetch(r)).blob(),b=window.URL.createObjectURL(k),l=document.createElement("a");l.href=b,l.download=r.split("/").pop()||"image",document.body.appendChild(l),l.click(),window.URL.revokeObjectURL(b),document.body.removeChild(l)}catch(n){console.error("Error downloading image:",n)}},y=()=>{u(!1)},C=()=>{u(!1)};return f.useEffect(()=>{if(o)return document.addEventListener("touchmove",x,{passive:!1}),()=>{document.removeEventListener("touchmove",x)}},[o]),e.jsx(m.Modal,{isOpen:o,size:"full",onClose:h,classNames:{wrapper:O("",j)},className:"bg-black bg-opacity-70",hideCloseButton:!0,portalContainer:document.body,children:e.jsx(m.ModalContent,{className:"overflow-hidden",children:e.jsxs("div",{className:"w-screen h-screen relative flex flex-col pt-safe-offset-0",children:[e.jsxs("div",{className:"absolute top-2 right-2 flex gap-4 z-10",children:[g&&e.jsx(p.IoDownloadOutline,{size:24,className:"text-white cursor-pointer",onClick:N}),e.jsx(p.IoCloseSharp,{size:24,className:"text-white cursor-pointer",onClick:h})]}),e.jsxs("div",{className:"flex-1 min-h-0 relative flex items-center justify-center",children:[e.jsx(z.default,{canRotate:!1,className:"w-full h-full",children:e.jsx("img",{draggable:"false",src:c[d],alt:"",className:"w-screen h-full object-contain pointer-events-none",onLoad:y,onError:C})}),v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black bg-opacity-50",children:e.jsx(S.Spinner,{color:"white",size:"lg"})})]}),c.length>1&&e.jsx("div",{className:"h-24 bg-black bg-opacity-50 shrink-0 z-10 pb-safe-offset-0 pl-safe-offset-0 pr-safe-offset-0",children:e.jsxs(i.Root,{className:"h-24 w-screen",type:"auto",children:[e.jsx(i.Viewport,{className:"pppp h-full w-full",children:e.jsx("div",{className:"flex gap-2 p-2 h-24",children:c.map((r,n)=>e.jsx("div",{className:`h-full aspect-square flex-shrink-0 cursor-pointer border-2 transition-all ${n===d?"border-white":"border-transparent"}`,onClick:()=>w(n),children:e.jsx("img",{src:r,alt:"",className:"w-full h-full object-contain",draggable:"false"})},r))})}),e.jsx(i.Scrollbar,{className:"flex select-none touch-none p-0.5 bg-black/50 transition-colors duration-150 ease-out hover:bg-black/80 data-[orientation=horizontal]:h-2.5 data-[orientation=vertical]:w-2.5 data-[orientation=horizontal]:flex-col",orientation:"horizontal",children:e.jsx(i.Thumb,{className:"flex-1 bg-white/50 rounded-[10px] relative before:content-[''] before:absolute before:top-1/2 before:left-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:w-full before:h-full before:min-w-[44px] before:min-h-[44px]"})})]})})]})})})};exports.default=I;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
2
2
|
export interface PinchContentProps {
|
|
3
3
|
className?: string;
|
|
4
4
|
children?: ReactNode;
|
|
5
5
|
canDrag?: boolean;
|
|
6
6
|
canPinch?: boolean;
|
|
7
7
|
canRotate?: boolean;
|
|
8
|
+
pinchWithoutMove?: boolean;
|
|
8
9
|
scaleBounds?: {
|
|
9
10
|
min: number;
|
|
10
11
|
max: number;
|
|
11
12
|
};
|
|
12
13
|
wheelZoomFactor?: number;
|
|
14
|
+
rubberband?: boolean;
|
|
15
|
+
style?: CSSProperties;
|
|
13
16
|
}
|
|
14
17
|
declare const PinchContent: (props: PinchContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
18
|
export default PinchContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=require("react/jsx-runtime"),f=require("@react-spring/web"),l=require("@use-gesture/react"),G=require("react"),v=require("ahooks"),N=require("clsx"),U=l.createUseGesture([l.dragAction,l.pinchAction,l.wheelAction]),u=o=>o.preventDefault(),W=o=>{const{className:x,children:y,pinchWithoutMove:m=!1,canPinch:h=!0,canDrag:b=!0,canRotate:p=!0,scaleBounds:g={min:.3,max:10},wheelZoomFactor:S=.001,rubberband:q=!0}=o,r=G.useRef(null);v.useMount(()=>{var t,e,n;(t=r.current)==null||t.addEventListener("gesturestart",u),(e=r.current)==null||e.addEventListener("gesturechange",u),(n=r.current)==null||n.addEventListener("gestureend",u)}),v.useUnmount(()=>{var t,e,n;(t=r.current)==null||t.removeEventListener("gesturestart",u),(e=r.current)==null||e.removeEventListener("gesturechange",u),(n=r.current)==null||n.removeEventListener("gestureend",u)});const[s,d]=f.useSpring(()=>({x:0,y:0,scale:1,rotateZ:0}));return U({onWheel:({event:t,delta:[,e]})=>{if(!h)return;const c=s.scale.get()*(1-e*S),i=Math.min(Math.max(c,g.min),g.max);d.start({scale:i})},onDrag:({pinching:t,cancel:e,offset:[n,c],...i})=>{if(!b||t)return e();d.start({x:n,y:c})},onPinch:({origin:[t,e],first:n,movement:[c],offset:[i,w],memo:a,cancel:E})=>{if(!h)return E();if(n){const{width:P,height:Z,x:j,y:A}=r.current.getBoundingClientRect(),D=t-(j+P/2),B=e-(A+Z/2);a=[s.x.get(),s.y.get(),D,B]}const L=a[0]-(c-1)*a[2],M=a[1]-(c-1)*a[3],R={scale:i,rotateZ:p?w:s.rotateZ.get(),...m?{x:s.x.get(),y:s.y.get()}:{x:L,y:M}};return d.start(R),a}},{target:r,drag:{from:()=>[s.x.get(),s.y.get()]},pinch:{scaleBounds:g,rubberband:q},wheel:{enabled:!0}}),C.jsx(f.animated.div,{className:N("select-none",x),ref:r,style:{...o.style,...s},children:y})};exports.default=W;
|
|
@@ -44,71 +44,58 @@ type ImageSettings = {
|
|
|
44
44
|
* the attribute behaves differently than the empty string.
|
|
45
45
|
*/
|
|
46
46
|
crossOrigin?: CrossOrigin;
|
|
47
|
+
/**
|
|
48
|
+
* 图片渲染质量
|
|
49
|
+
* @defaultValue 'high'
|
|
50
|
+
*/
|
|
51
|
+
imageQuality?: 'low' | 'medium' | 'high';
|
|
47
52
|
};
|
|
48
53
|
export interface QRCodeProps {
|
|
49
54
|
/**
|
|
50
|
-
*
|
|
51
|
-
* to represent multiple segments to further optimize the QR Code.
|
|
55
|
+
* 要编码到二维码中的值
|
|
52
56
|
*/
|
|
53
|
-
value: string
|
|
57
|
+
value: string;
|
|
54
58
|
/**
|
|
55
|
-
*
|
|
59
|
+
* 二维码的渲染尺寸(像素)
|
|
56
60
|
* @defaultValue 128
|
|
57
61
|
*/
|
|
58
62
|
size?: number;
|
|
59
63
|
/**
|
|
60
|
-
*
|
|
61
|
-
* @
|
|
62
|
-
* @defaultValue L
|
|
64
|
+
* 错误纠正级别
|
|
65
|
+
* @defaultValue M
|
|
63
66
|
*/
|
|
64
67
|
level?: ErrorCorrectionLevel;
|
|
65
68
|
/**
|
|
66
|
-
*
|
|
67
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
|
|
69
|
+
* 二维码的背景颜色
|
|
68
70
|
* @defaultValue #FFFFFF
|
|
69
71
|
*/
|
|
70
72
|
bgColor?: string;
|
|
71
73
|
/**
|
|
72
|
-
*
|
|
73
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
|
|
74
|
+
* 二维码的前景颜色
|
|
74
75
|
* @defaultValue #000000
|
|
75
76
|
*/
|
|
76
77
|
fgColor?: string;
|
|
77
78
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* @deprecated Use `marginSize` instead.
|
|
81
|
-
* @defaultValue false
|
|
82
|
-
*/
|
|
83
|
-
includeMargin?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* The number of _modules_ to use for margin. The QR Code specification
|
|
86
|
-
* requires `4`, however you can specify any number. Values will be turned to
|
|
87
|
-
* integers with `Math.floor`. Overrides `includeMargin` when both are specified.
|
|
88
|
-
* @defaultValue 0
|
|
79
|
+
* 二维码边距的模块数量
|
|
80
|
+
* @defaultValue 4
|
|
89
81
|
*/
|
|
90
82
|
marginSize?: number;
|
|
91
83
|
/**
|
|
92
|
-
*
|
|
84
|
+
* 二维码的标题(用于无障碍访问)
|
|
93
85
|
*/
|
|
94
86
|
title?: string;
|
|
95
87
|
/**
|
|
96
|
-
*
|
|
97
|
-
* with higher values resulting in more complex QR Codes. The optimal
|
|
98
|
-
* (lowest) version is determined for the `value` provided, using `minVersion`
|
|
99
|
-
* as the lower bound.
|
|
88
|
+
* 编码二维码时使用的最小版本(1-40)
|
|
100
89
|
* @defaultValue 1
|
|
101
90
|
*/
|
|
102
91
|
minVersion?: number;
|
|
103
92
|
/**
|
|
104
|
-
*
|
|
105
|
-
* the specified Error Correction Level option if it can be done without
|
|
106
|
-
* increasing the version.
|
|
93
|
+
* 是否允许在可能的情况下提高错误纠正级别
|
|
107
94
|
* @defaultValue true
|
|
108
95
|
*/
|
|
109
96
|
boostLevel?: boolean;
|
|
110
97
|
/**
|
|
111
|
-
*
|
|
98
|
+
* 嵌入图片的设置
|
|
112
99
|
*/
|
|
113
100
|
imageSettings?: ImageSettings;
|
|
114
101
|
}
|
|
@@ -1,30 +1,37 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as e, jsxs as l } from "react/jsx-runtime";
|
|
3
|
-
import { Modal as
|
|
4
|
-
import { Spinner as
|
|
5
|
-
import { IoDownloadOutline as
|
|
6
|
-
import
|
|
3
|
+
import { Modal as L, ModalContent as z } from "@heroui/modal";
|
|
4
|
+
import { Spinner as j } from "@heroui/spinner";
|
|
5
|
+
import { IoDownloadOutline as I, IoCloseSharp as E } from "react-icons/io5";
|
|
6
|
+
import R from "../pinch-content/PinchContent.js";
|
|
7
7
|
import * as n from "@radix-ui/react-scroll-area";
|
|
8
|
-
import { useState as p, useEffect as
|
|
8
|
+
import { useState as p, useEffect as S } from "react";
|
|
9
|
+
import D from "clsx";
|
|
9
10
|
const u = (s) => {
|
|
10
11
|
s.preventDefault();
|
|
11
|
-
},
|
|
12
|
-
const {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
}, G = (s) => {
|
|
13
|
+
const {
|
|
14
|
+
isOpen: i,
|
|
15
|
+
onClose: b,
|
|
16
|
+
imgSrc: c,
|
|
17
|
+
canDownload: g = !1,
|
|
18
|
+
wrapperClassName: w
|
|
19
|
+
} = s, r = Array.isArray(c) ? c : [c], [f, v] = p(0), [x, d] = p(!0), m = () => {
|
|
20
|
+
d(!0), b();
|
|
21
|
+
}, N = async () => {
|
|
22
|
+
const o = r[f];
|
|
16
23
|
try {
|
|
17
|
-
const
|
|
24
|
+
const k = await (await fetch(o)).blob(), h = window.URL.createObjectURL(k), a = document.createElement("a");
|
|
18
25
|
a.href = h, a.download = o.split("/").pop() || "image", document.body.appendChild(a), a.click(), window.URL.revokeObjectURL(h), document.body.removeChild(a);
|
|
19
26
|
} catch (t) {
|
|
20
27
|
console.error("Error downloading image:", t);
|
|
21
28
|
}
|
|
22
|
-
}, N = () => {
|
|
23
|
-
f(!1);
|
|
24
29
|
}, C = () => {
|
|
25
|
-
|
|
30
|
+
d(!1);
|
|
31
|
+
}, y = () => {
|
|
32
|
+
d(!1);
|
|
26
33
|
};
|
|
27
|
-
return
|
|
34
|
+
return S(() => {
|
|
28
35
|
if (i)
|
|
29
36
|
return document.addEventListener("touchmove", u, {
|
|
30
37
|
passive: !1
|
|
@@ -32,26 +39,29 @@ const u = (s) => {
|
|
|
32
39
|
document.removeEventListener("touchmove", u);
|
|
33
40
|
};
|
|
34
41
|
}, [i]), /* @__PURE__ */ e(
|
|
35
|
-
|
|
42
|
+
L,
|
|
36
43
|
{
|
|
37
44
|
isOpen: i,
|
|
38
45
|
size: "full",
|
|
39
46
|
onClose: m,
|
|
47
|
+
classNames: {
|
|
48
|
+
wrapper: D("", w)
|
|
49
|
+
},
|
|
40
50
|
className: "bg-black bg-opacity-70",
|
|
41
51
|
hideCloseButton: !0,
|
|
42
52
|
portalContainer: document.body,
|
|
43
|
-
children: /* @__PURE__ */ e(
|
|
53
|
+
children: /* @__PURE__ */ e(z, { className: "overflow-hidden", children: /* @__PURE__ */ l("div", { className: "w-screen h-screen relative flex flex-col pt-safe-offset-0", children: [
|
|
44
54
|
/* @__PURE__ */ l("div", { className: "absolute top-2 right-2 flex gap-4 z-10", children: [
|
|
45
55
|
g && /* @__PURE__ */ e(
|
|
46
|
-
|
|
56
|
+
I,
|
|
47
57
|
{
|
|
48
58
|
size: 24,
|
|
49
59
|
className: "text-white cursor-pointer",
|
|
50
|
-
onClick:
|
|
60
|
+
onClick: N
|
|
51
61
|
}
|
|
52
62
|
),
|
|
53
63
|
/* @__PURE__ */ e(
|
|
54
|
-
|
|
64
|
+
E,
|
|
55
65
|
{
|
|
56
66
|
size: 24,
|
|
57
67
|
className: "text-white cursor-pointer",
|
|
@@ -60,25 +70,25 @@ const u = (s) => {
|
|
|
60
70
|
)
|
|
61
71
|
] }),
|
|
62
72
|
/* @__PURE__ */ l("div", { className: "flex-1 min-h-0 relative flex items-center justify-center", children: [
|
|
63
|
-
/* @__PURE__ */ e(
|
|
73
|
+
/* @__PURE__ */ e(R, { canRotate: !1, className: "w-full h-full", children: /* @__PURE__ */ e(
|
|
64
74
|
"img",
|
|
65
75
|
{
|
|
66
76
|
draggable: "false",
|
|
67
|
-
src: r[
|
|
77
|
+
src: r[f],
|
|
68
78
|
alt: "",
|
|
69
79
|
className: "w-screen h-full object-contain pointer-events-none",
|
|
70
|
-
onLoad:
|
|
71
|
-
onError:
|
|
80
|
+
onLoad: C,
|
|
81
|
+
onError: y
|
|
72
82
|
}
|
|
73
83
|
) }),
|
|
74
|
-
|
|
84
|
+
x && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black bg-opacity-50", children: /* @__PURE__ */ e(j, { color: "white", size: "lg" }) })
|
|
75
85
|
] }),
|
|
76
86
|
r.length > 1 && /* @__PURE__ */ e("div", { className: "h-24 bg-black bg-opacity-50 shrink-0 z-10 pb-safe-offset-0 pl-safe-offset-0 pr-safe-offset-0", children: /* @__PURE__ */ l(n.Root, { className: "h-24 w-screen", type: "auto", children: [
|
|
77
87
|
/* @__PURE__ */ e(n.Viewport, { className: "pppp h-full w-full", children: /* @__PURE__ */ e("div", { className: "flex gap-2 p-2 h-24", children: r.map((o, t) => /* @__PURE__ */ e(
|
|
78
88
|
"div",
|
|
79
89
|
{
|
|
80
|
-
className: `h-full aspect-square flex-shrink-0 cursor-pointer border-2 transition-all ${t ===
|
|
81
|
-
onClick: () =>
|
|
90
|
+
className: `h-full aspect-square flex-shrink-0 cursor-pointer border-2 transition-all ${t === f ? "border-white" : "border-transparent"}`,
|
|
91
|
+
onClick: () => v(t),
|
|
82
92
|
children: /* @__PURE__ */ e(
|
|
83
93
|
"img",
|
|
84
94
|
{
|
|
@@ -105,5 +115,5 @@ const u = (s) => {
|
|
|
105
115
|
);
|
|
106
116
|
};
|
|
107
117
|
export {
|
|
108
|
-
|
|
118
|
+
G as default
|
|
109
119
|
};
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
2
2
|
export interface PinchContentProps {
|
|
3
3
|
className?: string;
|
|
4
4
|
children?: ReactNode;
|
|
5
5
|
canDrag?: boolean;
|
|
6
6
|
canPinch?: boolean;
|
|
7
7
|
canRotate?: boolean;
|
|
8
|
+
pinchWithoutMove?: boolean;
|
|
8
9
|
scaleBounds?: {
|
|
9
10
|
min: number;
|
|
10
11
|
max: number;
|
|
11
12
|
};
|
|
12
13
|
wheelZoomFactor?: number;
|
|
14
|
+
rubberband?: boolean;
|
|
15
|
+
style?: CSSProperties;
|
|
13
16
|
}
|
|
14
17
|
declare const PinchContent: (props: PinchContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
18
|
export default PinchContent;
|
|
@@ -1,80 +1,88 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useSpring as
|
|
3
|
-
import { createUseGesture as
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { useMount as
|
|
6
|
-
import
|
|
7
|
-
const
|
|
1
|
+
import { jsx as B } from "react/jsx-runtime";
|
|
2
|
+
import { useSpring as C, animated as G } from "@react-spring/web";
|
|
3
|
+
import { createUseGesture as N, dragAction as U, pinchAction as W, wheelAction as j } from "@use-gesture/react";
|
|
4
|
+
import { useRef as F } from "react";
|
|
5
|
+
import { useMount as k, useUnmount as q } from "ahooks";
|
|
6
|
+
import z from "clsx";
|
|
7
|
+
const H = N([U, W, j]), o = (u) => u.preventDefault(), V = (u) => {
|
|
8
8
|
const {
|
|
9
|
-
className:
|
|
9
|
+
className: f,
|
|
10
10
|
children: h,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
pinchWithoutMove: m = !1,
|
|
12
|
+
canPinch: d = !0,
|
|
13
|
+
canDrag: x = !0,
|
|
13
14
|
canRotate: v = !0,
|
|
14
15
|
scaleBounds: l = { min: 0.3, max: 10 },
|
|
15
|
-
wheelZoomFactor:
|
|
16
|
-
|
|
17
|
-
F(
|
|
16
|
+
wheelZoomFactor: p = 1e-3,
|
|
17
|
+
rubberband: y = !0
|
|
18
|
+
} = u, n = F(null);
|
|
19
|
+
k(() => {
|
|
18
20
|
var t, e, r;
|
|
19
21
|
(t = n.current) == null || t.addEventListener("gesturestart", o), (e = n.current) == null || e.addEventListener("gesturechange", o), (r = n.current) == null || r.addEventListener("gestureend", o);
|
|
20
|
-
}),
|
|
22
|
+
}), q(() => {
|
|
21
23
|
var t, e, r;
|
|
22
24
|
(t = n.current) == null || t.removeEventListener("gesturestart", o), (e = n.current) == null || e.removeEventListener("gesturechange", o), (r = n.current) == null || r.removeEventListener("gestureend", o);
|
|
23
25
|
});
|
|
24
|
-
const [s,
|
|
26
|
+
const [s, g] = C(() => ({
|
|
25
27
|
x: 0,
|
|
26
28
|
y: 0,
|
|
27
29
|
scale: 1,
|
|
28
30
|
rotateZ: 0
|
|
29
31
|
}));
|
|
30
|
-
return
|
|
32
|
+
return H(
|
|
31
33
|
{
|
|
32
34
|
onWheel: ({ event: t, delta: [, e] }) => {
|
|
33
|
-
if (!
|
|
34
|
-
const a = s.scale.get() * (1 - e *
|
|
35
|
+
if (!d) return;
|
|
36
|
+
const a = s.scale.get() * (1 - e * p), i = Math.min(
|
|
35
37
|
Math.max(a, l.min),
|
|
36
38
|
l.max
|
|
37
39
|
);
|
|
38
|
-
|
|
40
|
+
g.start({ scale: i });
|
|
39
41
|
},
|
|
40
|
-
onDrag: ({ pinching: t, cancel: e, offset: [r, a], ...
|
|
41
|
-
if (!
|
|
42
|
-
|
|
42
|
+
onDrag: ({ pinching: t, cancel: e, offset: [r, a], ...i }) => {
|
|
43
|
+
if (!x || t) return e();
|
|
44
|
+
g.start({ x: r, y: a });
|
|
43
45
|
},
|
|
44
46
|
onPinch: ({
|
|
45
47
|
origin: [t, e],
|
|
46
48
|
first: r,
|
|
47
49
|
movement: [a],
|
|
48
|
-
offset: [
|
|
50
|
+
offset: [i, E],
|
|
49
51
|
memo: c,
|
|
50
|
-
cancel:
|
|
52
|
+
cancel: L
|
|
51
53
|
}) => {
|
|
52
|
-
if (!
|
|
54
|
+
if (!d) return L();
|
|
53
55
|
if (r) {
|
|
54
|
-
const { width:
|
|
55
|
-
c = [s.x.get(), s.y.get(),
|
|
56
|
+
const { width: M, height: Z, x: A, y: D } = n.current.getBoundingClientRect(), P = t - (A + M / 2), R = e - (D + Z / 2);
|
|
57
|
+
c = [s.x.get(), s.y.get(), P, R];
|
|
56
58
|
}
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
+
const w = c[0] - (a - 1) * c[2], S = c[1] - (a - 1) * c[3], b = {
|
|
60
|
+
scale: i,
|
|
61
|
+
rotateZ: v ? E : s.rotateZ.get(),
|
|
62
|
+
...m ? { x: s.x.get(), y: s.y.get() } : { x: w, y: S }
|
|
63
|
+
};
|
|
64
|
+
return g.start(b), c;
|
|
59
65
|
}
|
|
60
66
|
},
|
|
61
67
|
{
|
|
62
68
|
target: n,
|
|
63
69
|
drag: { from: () => [s.x.get(), s.y.get()] },
|
|
64
|
-
pinch: { scaleBounds: l, rubberband:
|
|
70
|
+
pinch: { scaleBounds: l, rubberband: y },
|
|
65
71
|
wheel: { enabled: !0 }
|
|
66
72
|
}
|
|
67
|
-
),
|
|
68
|
-
|
|
69
|
-
B.div,
|
|
73
|
+
), /* @__PURE__ */ B(
|
|
74
|
+
G.div,
|
|
70
75
|
{
|
|
71
|
-
className:
|
|
76
|
+
className: z("select-none", f),
|
|
72
77
|
ref: n,
|
|
73
|
-
style:
|
|
78
|
+
style: {
|
|
79
|
+
...u.style,
|
|
80
|
+
...s
|
|
81
|
+
},
|
|
74
82
|
children: h
|
|
75
83
|
}
|
|
76
84
|
);
|
|
77
85
|
};
|
|
78
86
|
export {
|
|
79
|
-
|
|
87
|
+
V as default
|
|
80
88
|
};
|
|
@@ -44,71 +44,58 @@ type ImageSettings = {
|
|
|
44
44
|
* the attribute behaves differently than the empty string.
|
|
45
45
|
*/
|
|
46
46
|
crossOrigin?: CrossOrigin;
|
|
47
|
+
/**
|
|
48
|
+
* 图片渲染质量
|
|
49
|
+
* @defaultValue 'high'
|
|
50
|
+
*/
|
|
51
|
+
imageQuality?: 'low' | 'medium' | 'high';
|
|
47
52
|
};
|
|
48
53
|
export interface QRCodeProps {
|
|
49
54
|
/**
|
|
50
|
-
*
|
|
51
|
-
* to represent multiple segments to further optimize the QR Code.
|
|
55
|
+
* 要编码到二维码中的值
|
|
52
56
|
*/
|
|
53
|
-
value: string
|
|
57
|
+
value: string;
|
|
54
58
|
/**
|
|
55
|
-
*
|
|
59
|
+
* 二维码的渲染尺寸(像素)
|
|
56
60
|
* @defaultValue 128
|
|
57
61
|
*/
|
|
58
62
|
size?: number;
|
|
59
63
|
/**
|
|
60
|
-
*
|
|
61
|
-
* @
|
|
62
|
-
* @defaultValue L
|
|
64
|
+
* 错误纠正级别
|
|
65
|
+
* @defaultValue M
|
|
63
66
|
*/
|
|
64
67
|
level?: ErrorCorrectionLevel;
|
|
65
68
|
/**
|
|
66
|
-
*
|
|
67
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
|
|
69
|
+
* 二维码的背景颜色
|
|
68
70
|
* @defaultValue #FFFFFF
|
|
69
71
|
*/
|
|
70
72
|
bgColor?: string;
|
|
71
73
|
/**
|
|
72
|
-
*
|
|
73
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
|
|
74
|
+
* 二维码的前景颜色
|
|
74
75
|
* @defaultValue #000000
|
|
75
76
|
*/
|
|
76
77
|
fgColor?: string;
|
|
77
78
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* @deprecated Use `marginSize` instead.
|
|
81
|
-
* @defaultValue false
|
|
82
|
-
*/
|
|
83
|
-
includeMargin?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* The number of _modules_ to use for margin. The QR Code specification
|
|
86
|
-
* requires `4`, however you can specify any number. Values will be turned to
|
|
87
|
-
* integers with `Math.floor`. Overrides `includeMargin` when both are specified.
|
|
88
|
-
* @defaultValue 0
|
|
79
|
+
* 二维码边距的模块数量
|
|
80
|
+
* @defaultValue 4
|
|
89
81
|
*/
|
|
90
82
|
marginSize?: number;
|
|
91
83
|
/**
|
|
92
|
-
*
|
|
84
|
+
* 二维码的标题(用于无障碍访问)
|
|
93
85
|
*/
|
|
94
86
|
title?: string;
|
|
95
87
|
/**
|
|
96
|
-
*
|
|
97
|
-
* with higher values resulting in more complex QR Codes. The optimal
|
|
98
|
-
* (lowest) version is determined for the `value` provided, using `minVersion`
|
|
99
|
-
* as the lower bound.
|
|
88
|
+
* 编码二维码时使用的最小版本(1-40)
|
|
100
89
|
* @defaultValue 1
|
|
101
90
|
*/
|
|
102
91
|
minVersion?: number;
|
|
103
92
|
/**
|
|
104
|
-
*
|
|
105
|
-
* the specified Error Correction Level option if it can be done without
|
|
106
|
-
* increasing the version.
|
|
93
|
+
* 是否允许在可能的情况下提高错误纠正级别
|
|
107
94
|
* @defaultValue true
|
|
108
95
|
*/
|
|
109
96
|
boostLevel?: boolean;
|
|
110
97
|
/**
|
|
111
|
-
*
|
|
98
|
+
* 嵌入图片的设置
|
|
112
99
|
*/
|
|
113
100
|
imageSettings?: ImageSettings;
|
|
114
101
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiping/react-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.14",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
7
7
|
"module": "./dist/es/index.js",
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"clsx": "^2.1.1",
|
|
49
49
|
"dayjs": "^1.11.13",
|
|
50
50
|
"lodash-es": "^4.17.21",
|
|
51
|
-
"motion": "^12.
|
|
51
|
+
"motion": "^12.18.1",
|
|
52
|
+
"qrcode": "^1.5.4",
|
|
52
53
|
"qrcode.react": "^4.2.0",
|
|
53
54
|
"react": "^18.3.1",
|
|
54
55
|
"react-dom": "^18.3.1",
|
|
@@ -64,10 +65,11 @@
|
|
|
64
65
|
"@eslint/js": "^9.29.0",
|
|
65
66
|
"@faker-js/faker": "^9.8.0",
|
|
66
67
|
"@storybook/addon-docs": "^9.0.10",
|
|
67
|
-
"@storybook/addon-onboarding": "^9.0.
|
|
68
|
-
"@storybook/react-vite": "^9.0.
|
|
68
|
+
"@storybook/addon-onboarding": "^9.0.10",
|
|
69
|
+
"@storybook/react-vite": "^9.0.10",
|
|
69
70
|
"@types/lodash-es": "^4.17.12",
|
|
70
|
-
"@types/node": "^22.15.
|
|
71
|
+
"@types/node": "^22.15.32",
|
|
72
|
+
"@types/qrcode": "^1.5.5",
|
|
71
73
|
"@types/react": "^18.3.23",
|
|
72
74
|
"@types/react-dom": "^18.3.7",
|
|
73
75
|
"@vitejs/plugin-react": "^4.5.2",
|
|
@@ -75,19 +77,19 @@
|
|
|
75
77
|
"eslint": "^9.29.0",
|
|
76
78
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
77
79
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
78
|
-
"eslint-plugin-storybook": "^9.0.
|
|
80
|
+
"eslint-plugin-storybook": "^9.0.11",
|
|
79
81
|
"globals": "^16.2.0",
|
|
80
|
-
"postcss": "^8.5.
|
|
82
|
+
"postcss": "^8.5.6",
|
|
81
83
|
"rollup-preserve-directives": "^1.1.3",
|
|
82
84
|
"sharp": "^0.34.2",
|
|
83
|
-
"storybook": "^9.0.
|
|
85
|
+
"storybook": "^9.0.10",
|
|
84
86
|
"svgo": "^3.3.2",
|
|
85
87
|
"tailwind-merge": "^2.6.0",
|
|
86
88
|
"tailwind-scrollbar": "^3.1.0",
|
|
87
89
|
"tailwindcss": "^3.4.17",
|
|
88
90
|
"tailwindcss-safe-area": "^0.6.0",
|
|
89
91
|
"typescript": "^5.8.3",
|
|
90
|
-
"typescript-eslint": "^8.34.
|
|
92
|
+
"typescript-eslint": "^8.34.1",
|
|
91
93
|
"vite": "^6.3.5",
|
|
92
94
|
"vite-plugin-dts": "^4.5.4",
|
|
93
95
|
"vite-plugin-image-optimizer": "^1.1.8",
|
|
@@ -102,5 +104,5 @@
|
|
|
102
104
|
"engines": {
|
|
103
105
|
"node": ">=20"
|
|
104
106
|
},
|
|
105
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "762cae9539bf1baba146a43651393fc3140bd4ad"
|
|
106
108
|
}
|