@xiping/react-components 1.0.12 → 1.0.13

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.
@@ -3,6 +3,7 @@ interface ImageViewerProps {
3
3
  imgSrc: string | string[];
4
4
  onClose: () => void;
5
5
  canDownload?: boolean;
6
+ wrapperClassName?: string;
6
7
  }
7
8
  declare const ImageViewer: (props: ImageViewerProps) => import("react/jsx-runtime").JSX.Element;
8
9
  export default ImageViewer;
@@ -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"),k=require("@heroui/spinner"),p=require("react-icons/io5"),S=require("../pinch-content/PinchContent.js"),z=require("@radix-ui/react-scroll-area"),f=require("react");function L(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(o,n,a.get?a:{enumerable:!0,get:()=>t[n]})}}return o.default=t,Object.freeze(o)}const i=L(z),x=t=>{t.preventDefault()},O=t=>{const{isOpen:o,onClose:n,imgSrc:a,canDownload:g=!1}=t,c=Array.isArray(a)?a:[a],[d,j]=f.useState(0),[w,u]=f.useState(!0),h=()=>{u(!0),n()},v=async()=>{const r=c[d];try{const C=await(await fetch(r)).blob(),b=window.URL.createObjectURL(C),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(s){console.error("Error downloading image:",s)}},N=()=>{u(!1)},y=()=>{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,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:v}),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(S.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:N,onError:y})}),w&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black bg-opacity-50",children:e.jsx(k.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,s)=>e.jsx("div",{className:`h-full aspect-square flex-shrink-0 cursor-pointer border-2 transition-all ${s===d?"border-white":"border-transparent"}`,onClick:()=>j(s),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=O;
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;
@@ -3,6 +3,7 @@ interface ImageViewerProps {
3
3
  imgSrc: string | string[];
4
4
  onClose: () => void;
5
5
  canDownload?: boolean;
6
+ wrapperClassName?: string;
6
7
  }
7
8
  declare const ImageViewer: (props: ImageViewerProps) => import("react/jsx-runtime").JSX.Element;
8
9
  export default ImageViewer;
@@ -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 k, ModalContent as L } from "@heroui/modal";
4
- import { Spinner as z } from "@heroui/spinner";
5
- import { IoDownloadOutline as j, IoCloseSharp as I } from "react-icons/io5";
6
- import E from "../pinch-content/PinchContent.js";
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 R } from "react";
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
- }, V = (s) => {
12
- const { isOpen: i, onClose: b, imgSrc: c, canDownload: g = !1 } = s, r = Array.isArray(c) ? c : [c], [d, w] = p(0), [v, f] = p(!0), m = () => {
13
- f(!0), b();
14
- }, x = async () => {
15
- const o = r[d];
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 y = await (await fetch(o)).blob(), h = window.URL.createObjectURL(y), a = document.createElement("a");
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
- f(!1);
30
+ d(!1);
31
+ }, y = () => {
32
+ d(!1);
26
33
  };
27
- return R(() => {
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
- k,
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(L, { className: "overflow-hidden", children: /* @__PURE__ */ l("div", { className: "w-screen h-screen relative flex flex-col pt-safe-offset-0", children: [
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
- j,
56
+ I,
47
57
  {
48
58
  size: 24,
49
59
  className: "text-white cursor-pointer",
50
- onClick: x
60
+ onClick: N
51
61
  }
52
62
  ),
53
63
  /* @__PURE__ */ e(
54
- I,
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(E, { canRotate: !1, className: "w-full h-full", children: /* @__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[d],
77
+ src: r[f],
68
78
  alt: "",
69
79
  className: "w-screen h-full object-contain pointer-events-none",
70
- onLoad: N,
71
- onError: C
80
+ onLoad: C,
81
+ onError: y
72
82
  }
73
83
  ) }),
74
- v && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black bg-opacity-50", children: /* @__PURE__ */ e(z, { color: "white", size: "lg" }) })
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 === d ? "border-white" : "border-transparent"}`,
81
- onClick: () => w(t),
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
- V as default
118
+ G as default
109
119
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xiping/react-components",
3
3
  "private": false,
4
- "version": "1.0.12",
4
+ "version": "1.0.13",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
7
7
  "module": "./dist/es/index.js",
@@ -102,5 +102,5 @@
102
102
  "engines": {
103
103
  "node": ">=20"
104
104
  },
105
- "gitHead": "94b9351a8cb37cbfca40d528f06e1513243fe6b8"
105
+ "gitHead": "2241fd579443d54339afba75c192a73d68f9043e"
106
106
  }