@sth87/shadcn-design-system 0.0.23 → 0.0.24
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/ImageViewer/ImageViewer.cjs +1 -1
- package/dist/cjs/components/ImageViewer/ImageViewer.cjs.map +1 -1
- package/dist/cjs/components/Table/data-table-column-header.cjs +1 -1
- package/dist/cjs/components/Table/data-table-column-header.cjs.map +1 -1
- package/dist/cjs/components/Table/data-table.cjs +1 -1
- package/dist/cjs/components/Table/data-table.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/components/ImageViewer/ImageViewer.js +99 -69
- package/dist/esm/components/ImageViewer/ImageViewer.js.map +1 -1
- package/dist/esm/components/Table/data-table-column-header.js +40 -71
- package/dist/esm/components/Table/data-table-column-header.js.map +1 -1
- package/dist/esm/components/Table/data-table.js +51 -84
- package/dist/esm/components/Table/data-table.js.map +1 -1
- package/dist/esm/index.js +226 -255
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/packages/ui/src/components/select.js +1 -1
- package/dist/types/components/ImageViewer/ImageViewer.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/packages/ui/src/components/table.cjs +0 -2
- package/dist/cjs/packages/ui/src/components/table.cjs.map +0 -1
- package/dist/esm/packages/ui/src/components/table.js +0 -87
- package/dist/esm/packages/ui/src/components/table.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),T=/* empty css */D=require("lucide-react");;/* empty css */;/* empty css */require("@radix-ui/react-slot");require("../../packages/ui/src/components/button.cjs");require("../../packages/ui/src/components/button-group.cjs");require("../../packages/ui/src/components/input.cjs");require("../../packages/ui/src/components/textarea.cjs");require("@radix-ui/react-label");const I=require("../../packages/ui/src/lib/utils.cjs");require("../../packages/ui/src/components/select.cjs");require("../../packages/ui/src/components/combobox.cjs");require("@radix-ui/react-tooltip");require("react-day-picker");require("../../packages/ui/src/components/popover.cjs");require("@radix-ui/react-separator");require("../../packages/ui/src/components/switch.cjs");require("vaul");require("@radix-ui/react-scroll-area");require("../../packages/ui/src/components/tree-view.cjs");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-avatar");require("../../packages/ui/src/components/badge.cjs");require("../../packages/ui/src/components/checkbox.cjs");require("@radix-ui/react-collapsible");require("cmdk");require("@radix-ui/react-dialog");require("@radix-ui/react-dropdown-menu");require("../../packages/ui/src/components/input-otp.cjs");require("../../packages/ui/src/components/radio-group.cjs");require("../../packages/ui/src/components/sidebar.cjs");require("@radix-ui/react-slider");require("../../packages/ui/src/components/tabs.cjs");require("../../packages/ui/src/components/toggle.cjs");const q=({images:n,visible:d=!1,onClose:i,activeIndex:o=0,onIndexChange:l,zoomSpeed:w=.1,disableKeyboardSupport:u=!1,noNavbar:c=!1,noToolbar:h=!1,rotatable:b=!0,scalable:g=!0,changeable:y=!0,noClose:V=!1,minScale:x=.1,maxScale:f=50,defaultScale:v=1,className:p,downloadable:N=!1,noImgDetails:j=!1,noResetZoomAfterChange:L=!1,drag:P=!1})=>{const[m,k]=r.useState(o);r.useEffect(()=>{k(o)},[o]);const C=r.useCallback(()=>{i?.()},[i]),S=r.useCallback((t,s)=>{k(s),l?.(s)},[l]),U=r.useCallback(()=>{const t=n[m],s=t.downloadUrl||t.src,a=document.createElement("a");a.href=s,a.download=t.alt||`image-${m+1}`,fetch(s).then(E=>E.blob()).then(E=>{const O=window.URL.createObjectURL(E);a.href=O,document.body.appendChild(a),a.click(),document.body.removeChild(a),window.URL.revokeObjectURL(O)}).catch(()=>{})},[n,m]),R=n.map(t=>({src:t.src,alt:t.alt||"",downloadUrl:t.downloadUrl||t.src}));return e.jsx(T.default,{visible:d,onClose:C,onMaskClick:C,images:R,activeIndex:m,onChange:S,zoomSpeed:w,disableKeyboardSupport:u,noNavbar:c,noToolbar:h,rotatable:b,scalable:g,changeable:y,noClose:V,minScale:x,maxScale:f,defaultScale:v,className:I.cn("image-viewer-antd-style",p),downloadable:N,noImgDetails:j,noResetZoomAfterChange:L,showTotal:!0,drag:P,customToolbar:t=>t.map(s=>s.key==="download"?{...s,actionType:void 0,onClick:void 0,render:e.jsx("button",{type:"button",className:"react-viewer-icon react-viewer-download",title:"Download",style:{background:"none",border:"none",cursor:"pointer",padding:0},onClick:a=>{a.preventDefault(),a.stopPropagation(),U()},children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M10 3v10m0 0l-4-4m4 4l4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("rect",{x:"4",y:"17",width:"12",height:"2",rx:"1",fill:"currentColor"})]})})}:s)})};q.displayName="ImageViewer";const G=({src:n,alt:d="",width:i,height:o,preview:l=!0,previewSrc:w,fallback:u,placeholder:c,className:h,wrapperClassName:b,onPreviewClick:g,onError:y,...V})=>{const[x,f]=r.useState(!0),[v,p]=r.useState(!1),[N,j]=r.useState(!1),L=()=>{f(!1),p(!1)},P=R=>{f(!1),p(!0),y?.(R)},m=()=>{l&&(j(!0),g?.())},k=()=>{j(!1)},C=x&&c,S=v&&u,U=l&&!x&&!v;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:I.cn("ds-image-viewer-root relative inline-block",b),children:e.jsxs("div",{className:"relative inline-block",children:[C&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-muted animate-pulse",style:{width:i,height:o},children:c===!0?e.jsx("div",{className:"w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin"}):c}),e.jsx("img",{src:S?u:n,alt:d,width:i,height:o,className:I.cn("ds-image-viewer-img max-w-full h-auto align-middle",x&&"opacity-0",h),onLoad:L,onError:P,...V}),U&&e.jsx("div",{onClick:m,className:I.cn("ds-image-viewer-mask absolute inset-0 flex items-center justify-center opacity-0 hover:opacity-100 transition-opacity cursor-pointer","bg-black/50 backdrop-blur-sm"),children:e.jsxs("div",{className:"text-white text-sm flex items-center gap-2",children:[e.jsx(D.ZoomIn,{className:"w-5 h-5"}),e.jsx("span",{children:"Preview"})]})})]})}),e.jsx(q,{images:[{src:w||n,alt:d}],visible:N,onClose:k,rotatable:!0,scalable:!0,downloadable:!0})]})};G.displayName="ImageViewer.Image";const M=({children:n,images:d,preview:i=!0})=>{const[o,l]=r.useState(!1),[w,u]=r.useState(0),c=r.useCallback(g=>{u(g),l(!0)},[]),h=r.useCallback(()=>{l(!1)},[]),b=r.useMemo(()=>({handlePreview:c,preview:i}),[c,i]);return e.jsxs(e.Fragment,{children:[e.jsx(F.Provider,{value:b,children:n}),e.jsx(q,{images:d,visible:o,onClose:h,activeIndex:w,onIndexChange:u,rotatable:!0,scalable:!0,downloadable:!0})]})};M.displayName="ImageViewer.Group";const F=r.createContext(null);Object.assign(q,{Image:G,Group:M});exports.ImageViewer=q;exports.ImageViewerGroup=M;exports.ImageViewerImage=G;
|
|
2
2
|
//# sourceMappingURL=ImageViewer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageViewer.cjs","sources":["../../../../src/components/ImageViewer/ImageViewer.tsx"],"sourcesContent":["import React, { useState, useCallback, useEffect } from \"react\";\nimport Viewer from \"react-viewer\";\nimport { cn } from \"@dsui/ui/lib/utils\";\nimport { ZoomIn } from \"lucide-react\";\nimport \"viewerjs/dist/viewer.css\";\nimport \"./ImageViewer.css\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface ImageInfo {\n src: string;\n alt?: string;\n downloadUrl?: string;\n}\n\nexport interface ImageViewerProps {\n images: ImageInfo[];\n visible?: boolean;\n onClose?: () => void;\n activeIndex?: number;\n onIndexChange?: (_index: number) => void;\n zoomSpeed?: number;\n disableKeyboardSupport?: boolean;\n noNavbar?: boolean;\n noToolbar?: boolean;\n rotatable?: boolean;\n scalable?: boolean;\n changeable?: boolean;\n noClose?: boolean;\n minScale?: number;\n maxScale?: number;\n defaultScale?: number;\n className?: string;\n downloadable?: boolean;\n noImgDetails?: boolean;\n noResetZoomAfterChange?: boolean;\n drag?: boolean;\n}\n\nexport interface ImageViewerImageProps\n extends React.ImgHTMLAttributes<HTMLImageElement> {\n src: string;\n alt?: string;\n width?: string | number;\n height?: string | number;\n preview?: boolean;\n previewSrc?: string;\n fallback?: string;\n placeholder?: React.ReactNode | boolean;\n className?: string;\n wrapperClassName?: string;\n onPreviewClick?: () => void;\n}\n\n// ============================================================================\n// ImageViewer Component\n// ============================================================================\n\nexport const ImageViewer: React.FC<ImageViewerProps> = ({\n images,\n visible = false,\n onClose,\n activeIndex = 0,\n onIndexChange,\n zoomSpeed = 0.1,\n disableKeyboardSupport = false,\n noNavbar = false,\n noToolbar = false,\n rotatable = true,\n scalable = true,\n changeable = true,\n noClose = false,\n minScale = 0.1,\n maxScale = 50,\n defaultScale = 1,\n className,\n downloadable = false,\n noImgDetails = false,\n noResetZoomAfterChange = false,\n drag = false,\n}) => {\n const [currentIndex, setCurrentIndex] = useState(activeIndex);\n\n useEffect(() => {\n setCurrentIndex(activeIndex);\n }, [activeIndex]);\n\n const handleClose = useCallback(() => {\n onClose?.();\n }, [onClose]);\n\n const handleIndexChange = useCallback(\n (_activeImage: any, index: number) => {\n setCurrentIndex(index);\n onIndexChange?.(index);\n },\n [onIndexChange]\n );\n\n // Handle download to save file locally\n const handleDownload = useCallback(() => {\n const currentImage = images[currentIndex];\n const downloadUrl = currentImage.downloadUrl || currentImage.src;\n\n // Create a temporary anchor element to trigger download\n const link = document.createElement(\"a\");\n link.href = downloadUrl;\n link.download = currentImage.alt || `image-${currentIndex + 1}`;\n\n // For cross-origin images, try to download via fetch\n fetch(downloadUrl)\n .then((response) => response.blob())\n .then((blob) => {\n const url = window.URL.createObjectURL(blob);\n link.href = url;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n window.URL.revokeObjectURL(url);\n })\n .catch(() => {\n // Fallback: do nothing if fetch fails\n });\n }, [images, currentIndex]);\n\n // Transform images to include downloadUrl\n const viewerImages = images.map((img) => ({\n src: img.src,\n alt: img.alt || \"\",\n downloadUrl: img.downloadUrl || img.src,\n }));\n\n return (\n <Viewer\n visible={visible}\n onClose={handleClose}\n onMaskClick={handleClose}\n images={viewerImages}\n activeIndex={currentIndex}\n onChange={handleIndexChange}\n zoomSpeed={zoomSpeed}\n disableKeyboardSupport={disableKeyboardSupport}\n noNavbar={noNavbar}\n noToolbar={noToolbar}\n rotatable={rotatable}\n scalable={scalable}\n changeable={changeable}\n noClose={noClose}\n minScale={minScale}\n maxScale={maxScale}\n defaultScale={defaultScale}\n className={cn(\"image-viewer-antd-style\", className)}\n downloadable={downloadable}\n noImgDetails={noImgDetails}\n noResetZoomAfterChange={noResetZoomAfterChange}\n showTotal={true}\n drag={drag}\n customToolbar={(toolbars) => {\n // Replace download button with a custom-rendered button to prevent viewer state change\n return toolbars.map((toolbar) => {\n if (toolbar.key === \"download\") {\n return {\n ...toolbar,\n actionType: undefined, // Remove default action\n onClick: undefined,\n render: (\n <button\n type=\"button\"\n className=\"react-viewer-icon react-viewer-download\"\n title=\"Download\"\n style={{\n background: \"none\",\n border: \"none\",\n cursor: \"pointer\",\n padding: 0,\n }}\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n handleDownload();\n }}\n >\n {/* SVG icon for download (Ant Design style) */}\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M10 3v10m0 0l-4-4m4 4l4-4\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <rect\n x=\"4\"\n y=\"17\"\n width=\"12\"\n height=\"2\"\n rx=\"1\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n ),\n };\n }\n return toolbar;\n });\n }}\n />\n );\n};\n\nImageViewer.displayName = \"ImageViewer\";\n\n// ============================================================================\n// ImageViewerImage Component (Wrapper for single image with preview)\n// ============================================================================\n\nexport const ImageViewerImage: React.FC<ImageViewerImageProps> = ({\n src,\n alt = \"\",\n width,\n height,\n preview = true,\n previewSrc,\n fallback,\n placeholder,\n className,\n wrapperClassName,\n onPreviewClick,\n onError,\n ...props\n}) => {\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState(false);\n const [viewerVisible, setViewerVisible] = useState(false);\n\n const handleLoad = () => {\n setLoading(false);\n setError(false);\n };\n\n const handleError = (e: React.SyntheticEvent<HTMLImageElement, Event>) => {\n setLoading(false);\n setError(true);\n onError?.(e);\n };\n\n const handlePreview = () => {\n if (!preview) return;\n setViewerVisible(true);\n onPreviewClick?.();\n };\n\n const handleCloseViewer = () => {\n setViewerVisible(false);\n };\n\n const showPlaceholder = loading && placeholder;\n const showFallback = error && fallback;\n const showPreviewMask = preview && !loading && !error;\n\n return (\n <>\n <div\n className={cn(\n \"ds-image-viewer-root relative inline-block\",\n wrapperClassName\n )}\n >\n <div className=\"relative inline-block\">\n {showPlaceholder && (\n <div\n className=\"absolute inset-0 flex items-center justify-center bg-muted animate-pulse\"\n style={{ width, height }}\n >\n {placeholder === true ? (\n <div className=\"w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin\" />\n ) : (\n placeholder\n )}\n </div>\n )}\n\n <img\n src={showFallback ? fallback : src}\n alt={alt}\n width={width}\n height={height}\n className={cn(\n \"ds-image-viewer-img max-w-full h-auto align-middle\",\n loading && \"opacity-0\",\n className\n )}\n onLoad={handleLoad}\n onError={handleError}\n {...props}\n />\n\n {showPreviewMask && (\n <div\n onClick={handlePreview}\n className={cn(\n \"ds-image-viewer-mask absolute inset-0 flex items-center justify-center opacity-0 hover:opacity-100 transition-opacity cursor-pointer\",\n \"bg-black/50 backdrop-blur-sm\"\n )}\n >\n <div className=\"text-white text-sm flex items-center gap-2\">\n <ZoomIn className=\"w-5 h-5\" />\n <span>Preview</span>\n </div>\n </div>\n )}\n </div>\n </div>\n\n {/* Viewer Modal */}\n <ImageViewer\n images={[{ src: previewSrc || src, alt }]}\n visible={viewerVisible}\n onClose={handleCloseViewer}\n rotatable\n scalable\n downloadable\n />\n </>\n );\n};\n\nImageViewerImage.displayName = \"ImageViewer.Image\";\n\n// ============================================================================\n// ImageViewerGroup Component\n// ============================================================================\n\ninterface ImageViewerGroupProps {\n children: React.ReactNode;\n images: ImageInfo[];\n preview?: boolean;\n}\n\nexport const ImageViewerGroup: React.FC<ImageViewerGroupProps> = ({\n children,\n images,\n preview = true,\n}) => {\n const [viewerVisible, setViewerVisible] = useState(false);\n const [currentIndex, setCurrentIndex] = useState(0);\n\n const handlePreview = useCallback((index: number) => {\n setCurrentIndex(index);\n setViewerVisible(true);\n }, []);\n\n const handleClose = useCallback(() => {\n setViewerVisible(false);\n }, []);\n\n const contextValue = React.useMemo(\n () => ({\n handlePreview,\n preview,\n }),\n [handlePreview, preview]\n );\n\n return (\n <>\n <ImageViewerGroupContext.Provider value={contextValue}>\n {children}\n </ImageViewerGroupContext.Provider>\n\n <ImageViewer\n images={images}\n visible={viewerVisible}\n onClose={handleClose}\n activeIndex={currentIndex}\n onIndexChange={setCurrentIndex}\n rotatable\n scalable\n downloadable\n />\n </>\n );\n};\n\nImageViewerGroup.displayName = \"ImageViewer.Group\";\n\n// Context for Group\nconst ImageViewerGroupContext = React.createContext<{\n handlePreview?: (_index: number) => void;\n preview?: boolean;\n} | null>(null);\n\n// Export with namespace\nconst ImageViewerNamespace = Object.assign(ImageViewer, {\n Image: ImageViewerImage,\n Group: ImageViewerGroup,\n});\n\nexport default ImageViewerNamespace;\n"],"names":["ImageViewer","images","visible","onClose","activeIndex","onIndexChange","zoomSpeed","disableKeyboardSupport","noNavbar","noToolbar","rotatable","scalable","changeable","noClose","minScale","maxScale","defaultScale","className","downloadable","noImgDetails","noResetZoomAfterChange","drag","currentIndex","setCurrentIndex","useState","useEffect","handleClose","useCallback","handleIndexChange","_activeImage","index","handleDownload","currentImage","downloadUrl","link","response","blob","url","viewerImages","img","jsx","Viewer","cn","toolbars","toolbar","e","jsxs","ImageViewerImage","src","alt","width","height","preview","previewSrc","fallback","placeholder","wrapperClassName","onPreviewClick","onError","props","loading","setLoading","error","setError","viewerVisible","setViewerVisible","handleLoad","handleError","handlePreview","handleCloseViewer","showPlaceholder","showFallback","showPreviewMask","Fragment","ZoomIn","ImageViewerGroup","children","contextValue","React","ImageViewerGroupContext"],"mappings":"wXA4DO,MAAMA,EAA0C,CAAC,CACtD,OAAAC,EACA,QAAAC,EAAU,GACV,QAAAC,EACA,YAAAC,EAAc,EACd,cAAAC,EACA,UAAAC,EAAY,GACZ,uBAAAC,EAAyB,GACzB,SAAAC,EAAW,GACX,UAAAC,EAAY,GACZ,UAAAC,EAAY,GACZ,SAAAC,EAAW,GACX,WAAAC,EAAa,GACb,QAAAC,EAAU,GACV,SAAAC,EAAW,GACX,SAAAC,EAAW,GACX,aAAAC,EAAe,EACf,UAAAC,EACA,aAAAC,EAAe,GACf,aAAAC,EAAe,GACf,uBAAAC,EAAyB,GACzB,KAAAC,EAAO,EACT,IAAM,CACJ,KAAM,CAACC,EAAcC,CAAe,EAAIC,EAAAA,SAASpB,CAAW,EAE5DqB,EAAAA,UAAU,IAAM,CACdF,EAAgBnB,CAAW,CAC7B,EAAG,CAACA,CAAW,CAAC,EAEhB,MAAMsB,EAAcC,EAAAA,YAAY,IAAM,CACpCxB,IAAA,CACF,EAAG,CAACA,CAAO,CAAC,EAENyB,EAAoBD,EAAAA,YACxB,CAACE,EAAmBC,IAAkB,CACpCP,EAAgBO,CAAK,EACrBzB,IAAgByB,CAAK,CACvB,EACA,CAACzB,CAAa,CAAA,EAIV0B,EAAiBJ,EAAAA,YAAY,IAAM,CACvC,MAAMK,EAAe/B,EAAOqB,CAAY,EAClCW,EAAcD,EAAa,aAAeA,EAAa,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ACpCsC,EAAiB,EAAK,CACxB,EAAG,CAAA,CAAE,EAECY,EAAeC,EAAM,QACzB,KAAO,CACL,cAAAV,EACA,QAAAhB,CAAA,GAEF,CAACgB,EAAehB,CAAO,CAAA,EAGzB,OACEN,EAAAA,KAAA2B,WAAA,CACE,SAAA,CAAAjC,EAAAA,IAACuC,EAAwB,SAAxB,CAAiC,MAAOF,EACtC,SAAAD,EACH,EAEApC,EAAAA,IAACxC,EAAA,CACC,OAAAC,EACA,QAAS+D,EACT,QAAStC,EACT,YAAaJ,EACb,cAAeC,EACf,UAAS,GACT,SAAQ,GACR,aAAY,EAAA,CAAA,CACd,EACF,CAEJ,EAEAoD,EAAiB,YAAc,oBAG/B,MAAMI,EAA0BD,EAAM,cAG5B,IAAI,EAGe,OAAO,OAAO9E,EAAa,CACtD,MAAO+C,EACP,MAAO4B,CACT,CAAC"}
|
|
1
|
+
{"version":3,"file":"ImageViewer.cjs","sources":["../../../../src/components/ImageViewer/ImageViewer.tsx"],"sourcesContent":["import React, { useState, useCallback, useEffect } from \"react\";\nimport Viewer from \"react-viewer\";\nimport { ZoomIn } from \"lucide-react\";\nimport \"viewerjs/dist/viewer.css\";\nimport \"./ImageViewer.css\";\nimport { cn } from \"@dsui/ui/index\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface ImageInfo {\n src: string;\n alt?: string;\n downloadUrl?: string;\n}\n\nexport interface ImageViewerProps {\n images: ImageInfo[];\n visible?: boolean;\n onClose?: () => void;\n activeIndex?: number;\n onIndexChange?: (_index: number) => void;\n zoomSpeed?: number;\n disableKeyboardSupport?: boolean;\n noNavbar?: boolean;\n noToolbar?: boolean;\n rotatable?: boolean;\n scalable?: boolean;\n changeable?: boolean;\n noClose?: boolean;\n minScale?: number;\n maxScale?: number;\n defaultScale?: number;\n className?: string;\n downloadable?: boolean;\n noImgDetails?: boolean;\n noResetZoomAfterChange?: boolean;\n drag?: boolean;\n}\n\nexport interface ImageViewerImageProps\n extends React.ImgHTMLAttributes<HTMLImageElement> {\n src: string;\n alt?: string;\n width?: string | number;\n height?: string | number;\n preview?: boolean;\n previewSrc?: string;\n fallback?: string;\n placeholder?: React.ReactNode | boolean;\n className?: string;\n wrapperClassName?: string;\n onPreviewClick?: () => void;\n}\n\n// ============================================================================\n// ImageViewer Component\n// ============================================================================\n\nexport const ImageViewer: React.FC<ImageViewerProps> = ({\n images,\n visible = false,\n onClose,\n activeIndex = 0,\n onIndexChange,\n zoomSpeed = 0.1,\n disableKeyboardSupport = false,\n noNavbar = false,\n noToolbar = false,\n rotatable = true,\n scalable = true,\n changeable = true,\n noClose = false,\n minScale = 0.1,\n maxScale = 50,\n defaultScale = 1,\n className,\n downloadable = false,\n noImgDetails = false,\n noResetZoomAfterChange = false,\n drag = false,\n}) => {\n const [currentIndex, setCurrentIndex] = useState(activeIndex);\n\n useEffect(() => {\n setCurrentIndex(activeIndex);\n }, [activeIndex]);\n\n const handleClose = useCallback(() => {\n onClose?.();\n }, [onClose]);\n\n const handleIndexChange = useCallback(\n (_activeImage: any, index: number) => {\n setCurrentIndex(index);\n onIndexChange?.(index);\n },\n [onIndexChange]\n );\n\n // Handle download to save file locally\n const handleDownload = useCallback(() => {\n const currentImage = images[currentIndex];\n const downloadUrl = currentImage.downloadUrl || currentImage.src;\n\n // Create a temporary anchor element to trigger download\n const link = document.createElement(\"a\");\n link.href = downloadUrl;\n link.download = currentImage.alt || `image-${currentIndex + 1}`;\n\n // For cross-origin images, try to download via fetch\n fetch(downloadUrl)\n .then((response) => response.blob())\n .then((blob) => {\n const url = window.URL.createObjectURL(blob);\n link.href = url;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n window.URL.revokeObjectURL(url);\n })\n .catch(() => {\n // Fallback: do nothing if fetch fails\n });\n }, [images, currentIndex]);\n\n // Transform images to include downloadUrl\n const viewerImages = images.map((img) => ({\n src: img.src,\n alt: img.alt || \"\",\n downloadUrl: img.downloadUrl || img.src,\n }));\n\n return (\n <Viewer\n visible={visible}\n onClose={handleClose}\n onMaskClick={handleClose}\n images={viewerImages}\n activeIndex={currentIndex}\n onChange={handleIndexChange}\n zoomSpeed={zoomSpeed}\n disableKeyboardSupport={disableKeyboardSupport}\n noNavbar={noNavbar}\n noToolbar={noToolbar}\n rotatable={rotatable}\n scalable={scalable}\n changeable={changeable}\n noClose={noClose}\n minScale={minScale}\n maxScale={maxScale}\n defaultScale={defaultScale}\n className={cn(\"image-viewer-antd-style\", className)}\n downloadable={downloadable}\n noImgDetails={noImgDetails}\n noResetZoomAfterChange={noResetZoomAfterChange}\n showTotal={true}\n drag={drag}\n customToolbar={(toolbars) => {\n // Replace download button with a custom-rendered button to prevent viewer state change\n return toolbars.map((toolbar) => {\n if (toolbar.key === \"download\") {\n return {\n ...toolbar,\n actionType: undefined, // Remove default action\n onClick: undefined,\n render: (\n <button\n type=\"button\"\n className=\"react-viewer-icon react-viewer-download\"\n title=\"Download\"\n style={{\n background: \"none\",\n border: \"none\",\n cursor: \"pointer\",\n padding: 0,\n }}\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n handleDownload();\n }}\n >\n {/* SVG icon for download (Ant Design style) */}\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M10 3v10m0 0l-4-4m4 4l4-4\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <rect\n x=\"4\"\n y=\"17\"\n width=\"12\"\n height=\"2\"\n rx=\"1\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n ),\n };\n }\n return toolbar;\n });\n }}\n />\n );\n};\n\nImageViewer.displayName = \"ImageViewer\";\n\n// ============================================================================\n// ImageViewerImage Component (Wrapper for single image with preview)\n// ============================================================================\n\nexport const ImageViewerImage: React.FC<ImageViewerImageProps> = ({\n src,\n alt = \"\",\n width,\n height,\n preview = true,\n previewSrc,\n fallback,\n placeholder,\n className,\n wrapperClassName,\n onPreviewClick,\n onError,\n ...props\n}) => {\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState(false);\n const [viewerVisible, setViewerVisible] = useState(false);\n\n const handleLoad = () => {\n setLoading(false);\n setError(false);\n };\n\n const handleError = (e: React.SyntheticEvent<HTMLImageElement, Event>) => {\n setLoading(false);\n setError(true);\n onError?.(e);\n };\n\n const handlePreview = () => {\n if (!preview) return;\n setViewerVisible(true);\n onPreviewClick?.();\n };\n\n const handleCloseViewer = () => {\n setViewerVisible(false);\n };\n\n const showPlaceholder = loading && placeholder;\n const showFallback = error && fallback;\n const showPreviewMask = preview && !loading && !error;\n\n return (\n <>\n <div\n className={cn(\n \"ds-image-viewer-root relative inline-block\",\n wrapperClassName\n )}\n >\n <div className=\"relative inline-block\">\n {showPlaceholder && (\n <div\n className=\"absolute inset-0 flex items-center justify-center bg-muted animate-pulse\"\n style={{ width, height }}\n >\n {placeholder === true ? (\n <div className=\"w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin\" />\n ) : (\n placeholder\n )}\n </div>\n )}\n\n <img\n src={showFallback ? fallback : src}\n alt={alt}\n width={width}\n height={height}\n className={cn(\n \"ds-image-viewer-img max-w-full h-auto align-middle\",\n loading && \"opacity-0\",\n className\n )}\n onLoad={handleLoad}\n onError={handleError}\n {...props}\n />\n\n {showPreviewMask && (\n <div\n onClick={handlePreview}\n className={cn(\n \"ds-image-viewer-mask absolute inset-0 flex items-center justify-center opacity-0 hover:opacity-100 transition-opacity cursor-pointer\",\n \"bg-black/50 backdrop-blur-sm\"\n )}\n >\n <div className=\"text-white text-sm flex items-center gap-2\">\n <ZoomIn className=\"w-5 h-5\" />\n <span>Preview</span>\n </div>\n </div>\n )}\n </div>\n </div>\n\n {/* Viewer Modal */}\n <ImageViewer\n images={[{ src: previewSrc || src, alt }]}\n visible={viewerVisible}\n onClose={handleCloseViewer}\n rotatable\n scalable\n downloadable\n />\n </>\n );\n};\n\nImageViewerImage.displayName = \"ImageViewer.Image\";\n\n// ============================================================================\n// ImageViewerGroup Component\n// ============================================================================\n\ninterface ImageViewerGroupProps {\n children: React.ReactNode;\n images: ImageInfo[];\n preview?: boolean;\n}\n\nexport const ImageViewerGroup: React.FC<ImageViewerGroupProps> = ({\n children,\n images,\n preview = true,\n}) => {\n const [viewerVisible, setViewerVisible] = useState(false);\n const [currentIndex, setCurrentIndex] = useState(0);\n\n const handlePreview = useCallback((index: number) => {\n setCurrentIndex(index);\n setViewerVisible(true);\n }, []);\n\n const handleClose = useCallback(() => {\n setViewerVisible(false);\n }, []);\n\n const contextValue = React.useMemo(\n () => ({\n handlePreview,\n preview,\n }),\n [handlePreview, preview]\n );\n\n return (\n <>\n <ImageViewerGroupContext.Provider value={contextValue}>\n {children}\n </ImageViewerGroupContext.Provider>\n\n <ImageViewer\n images={images}\n visible={viewerVisible}\n onClose={handleClose}\n activeIndex={currentIndex}\n onIndexChange={setCurrentIndex}\n rotatable\n scalable\n downloadable\n />\n </>\n );\n};\n\nImageViewerGroup.displayName = \"ImageViewer.Group\";\n\n// Context for Group\nconst ImageViewerGroupContext = React.createContext<{\n handlePreview?: (_index: number) => void;\n preview?: boolean;\n} | null>(null);\n\n// Export with namespace\nconst ImageViewerNamespace = Object.assign(ImageViewer, {\n Image: ImageViewerImage,\n Group: ImageViewerGroup,\n});\n\nexport default ImageViewerNamespace;\n"],"names":["ImageViewer","images","visible","onClose","activeIndex","onIndexChange","zoomSpeed","disableKeyboardSupport","noNavbar","noToolbar","rotatable","scalable","changeable","noClose","minScale","maxScale","defaultScale","className","downloadable","noImgDetails","noResetZoomAfterChange","drag","currentIndex","setCurrentIndex","useState","useEffect","handleClose","useCallback","handleIndexChange","_activeImage","index","handleDownload","currentImage","downloadUrl","link","response","blob","url","viewerImages","img","jsx","Viewer","cn","toolbars","toolbar","e","jsxs","ImageViewerImage","src","alt","width","height","preview","previewSrc","fallback","placeholder","wrapperClassName","onPreviewClick","onError","props","loading","setLoading","error","setError","viewerVisible","setViewerVisible","handleLoad","handleError","handlePreview","handleCloseViewer","showPlaceholder","showFallback","showPreviewMask","Fragment","ZoomIn","ImageViewerGroup","children","contextValue","React","ImageViewerGroupContext"],"mappings":"6sDA4DO,MAAMA,EAA0C,CAAC,CACtD,OAAAC,EACA,QAAAC,EAAU,GACV,QAAAC,EACA,YAAAC,EAAc,EACd,cAAAC,EACA,UAAAC,EAAY,GACZ,uBAAAC,EAAyB,GACzB,SAAAC,EAAW,GACX,UAAAC,EAAY,GACZ,UAAAC,EAAY,GACZ,SAAAC,EAAW,GACX,WAAAC,EAAa,GACb,QAAAC,EAAU,GACV,SAAAC,EAAW,GACX,SAAAC,EAAW,GACX,aAAAC,EAAe,EACf,UAAAC,EACA,aAAAC,EAAe,GACf,aAAAC,EAAe,GACf,uBAAAC,EAAyB,GACzB,KAAAC,EAAO,EACT,IAAM,CACJ,KAAM,CAACC,EAAcC,CAAe,EAAIC,EAAAA,SAASpB,CAAW,EAE5DqB,EAAAA,UAAU,IAAM,CACdF,EAAgBnB,CAAW,CAC7B,EAAG,CAACA,CAAW,CAAC,EAEhB,MAAMsB,EAAcC,EAAAA,YAAY,IAAM,CACpCxB,IAAA,CACF,EAAG,CAACA,CAAO,CAAC,EAENyB,EAAoBD,EAAAA,YACxB,CAACE,EAAmBC,IAAkB,CACpCP,EAAgBO,CAAK,EACrBzB,IAAgByB,CAAK,CACvB,EACA,CAACzB,CAAa,CAAA,EAIV0B,EAAiBJ,EAAAA,YAAY,IAAM,CACvC,MAAMK,EAAe/B,EAAOqB,CAAY,EAClCW,EAAcD,EAAa,aAAeA,EAAa,IAGvDE,EAAO,SAAS,cAAc,GAAG,EACvCA,EAAK,KAAOD,EACZC,EAAK,SAAWF,EAAa,KAAO,SAASV,EAAe,CAAC,GAG7D,MAAMW,CAAW,EACd,KAAME,GAAaA,EAAS,MAAM,EAClC,KAAMC,GAAS,CACd,MAAMC,EAAM,OAAO,IAAI,gBAAgBD,CAAI,EAC3CF,EAAK,KA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F,EACtC,SAAAD,EACH,EAEApC,EAAAA,IAACxC,EAAA,CACC,OAAAC,EACA,QAAS+D,EACT,QAAStC,EACT,YAAaJ,EACb,cAAeC,EACf,UAAS,GACT,SAAQ,GACR,aAAY,EAAA,CAAA,CACd,EACF,CAEJ,EAEAoD,EAAiB,YAAc,oBAG/B,MAAMI,EAA0BD,EAAM,cAG5B,IAAI,EAGe,OAAO,OAAO9E,EAAa,CACtD,MAAO+C,EACP,MAAO4B,CACT,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),s=require("lucide-react"),i=require("@dsui/ui"),g=require("../DropdownMenu/DropdownMenu.cjs"),d=require("./TableFilter/data-table-filter-popover.cjs"),h=require("../Button/Button.cjs");function p({column:e,label:o,className:a}){const n=o||(typeof e.columnDef.header=="string"?e.columnDef.header:null);if(!(e.getCanSort()||e.getCanHide()||e.getCanFilter()))return t.jsx("div",{className:i.cn(a),children:n});const c=t.jsxs("button",{className:"-ml-1.5 flex h-8 items-center gap-1.5 rounded-md px-2 py-1.5 hover:bg-accent focus:outline-none focus:ring-1 focus:ring-ring data-[state=open]:bg-accent [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground",children:[n,e.getCanSort()&&(e.getIsSorted()==="desc"?t.jsx(s.ChevronDown,{}):e.getIsSorted()==="asc"?t.jsx(s.ChevronUp,{}):t.jsx(s.ChevronsUpDown,{}))]}),l=e.getCanFilter()&&e.columnDef.meta?.variant?t.jsx(d.DataTableFilterPopover,{column:e,trigger:t.jsx(h.default,{variant:"ghost",className:i.cn("hover:bg-accent rounded p-1",e.getFilterValue()?"text-primary":""),children:t.jsx(s.Filter,{className:"size-4"})})}):null,r=[];return e.getCanSort()&&(r.push({key:"asc",type:"checkbox",label:"Asc",icon:t.jsx(s.ChevronUp,{}),checked:e.getIsSorted()==="asc",onClick:()=>e.toggleSorting(!1),className:"relative pr-8 pl-2 [&>span:first-child]:right-2 [&>span:first-child]:left-auto [&_svg]:text-muted-foreground"}),r.push({key:"desc",type:"checkbox",label:"Desc",icon:t.jsx(s.ChevronDown,{}),checked:e.getIsSorted()==="desc",onClick:()=>e.toggleSorting(!0),className:"relative pr-8 pl-2 [&>span:first-child]:right-2 [&>span:first-child]:left-auto [&_svg]:text-muted-foreground"}),e.getIsSorted()&&r.push({key:"reset",type:"item",label:"Reset",icon:t.jsx(s.X,{}),onClick:()=>e.clearSorting(),className:"pl-2 [&_svg]:text-muted-foreground"})),e.getCanHide()&&r.push({key:"hide",type:"checkbox",label:"Hide",icon:t.jsx(s.EyeOff,{}),checked:!e.getIsVisible(),onClick:()=>e.toggleVisibility(!1),className:"relative pr-8 pl-2 [&>span:first-child]:right-2 [&>span:first-child]:left-auto [&_svg]:text-muted-foreground"}),t.jsxs("div",{className:i.cn("flex items-center gap-1.5",a),children:[t.jsx(g.default,{trigger:c,items:r,align:"start",contentClassName:"w-28"}),l]})}exports.DataTableColumnHeader=p;
|
|
2
2
|
//# sourceMappingURL=data-table-column-header.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-column-header.cjs","sources":["../../../../src/components/Table/data-table-column-header.tsx"],"sourcesContent":["\"use client\";\n\nimport type { Column } from \"@tanstack/react-table\";\nimport {\n ChevronDown,\n ChevronsUpDown,\n ChevronUp,\n EyeOff,\n Filter,\n X,\n} from \"lucide-react\";\n\nimport { cn } from \"@dsui/ui\";\nimport DropdownMenu, {\n type DropdownMenuItem,\n} from \"../DropdownMenu/DropdownMenu\";\nimport { DataTableFilterPopover } from \"./TableFilter/data-table-filter-popover\";\nimport { Button } from \"../Button\";\n\ninterface DataTableColumnHeaderProps<TData, TValue> {\n column: Column<TData, TValue>;\n label?: string;\n className?: string;\n}\n\nexport function DataTableColumnHeader<TData, TValue>({\n column,\n label,\n className,\n}: DataTableColumnHeaderProps<TData, TValue>) {\n const displayLabel =\n label ||\n (typeof column.columnDef.header === \"string\"\n ? column.columnDef.header\n : null);\n\n const hasActions =\n column.getCanSort() || column.getCanHide() || column.getCanFilter();\n\n if (!hasActions) {\n return <div className={cn(className)}>{displayLabel}</div>;\n }\n\n const sortTrigger = (\n <button className=\"-ml-1.5 flex h-8 items-center gap-1.5 rounded-md px-2 py-1.5 hover:bg-accent focus:outline-none focus:ring-1 focus:ring-ring data-[state=open]:bg-accent [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground\">\n {displayLabel}\n {column.getCanSort() &&\n (column.getIsSorted() === \"desc\" ? (\n <ChevronDown />\n ) : column.getIsSorted() === \"asc\" ? (\n <ChevronUp />\n ) : (\n <ChevronsUpDown />\n ))}\n </button>\n );\n\n const filterButton =\n column.getCanFilter() && column.columnDef.meta?.variant ? (\n <DataTableFilterPopover\n column={column}\n trigger={\n <Button\n variant=\"ghost\"\n className={cn(\n \"hover:bg-accent rounded p-1\",\n column.getFilterValue() ? \"text-primary\" : \"\"\n )}\n >\n <Filter className=\"size-4\" />\n </Button>\n }\n />\n ) : null;\n\n const items: DropdownMenuItem[] = [];\n\n if (column.getCanSort()) {\n items.push({\n key: \"asc\",\n type: \"checkbox\",\n label: \"Asc\",\n icon: <ChevronUp />,\n checked: column.getIsSorted() === \"asc\",\n onClick: () => column.toggleSorting(false),\n className:\n \"relative pr-8 pl-2 [&>span:first-child]:right-2 [&>span:first-child]:left-auto [&_svg]:text-muted-foreground\",\n });\n items.push({\n key: \"desc\",\n type: \"checkbox\",\n label: \"Desc\",\n icon: <ChevronDown />,\n checked: column.getIsSorted() === \"desc\",\n onClick: () => column.toggleSorting(true),\n className:\n \"relative pr-8 pl-2 [&>span:first-child]:right-2 [&>span:first-child]:left-auto [&_svg]:text-muted-foreground\",\n });\n if (column.getIsSorted()) {\n items.push({\n key: \"reset\",\n type: \"item\",\n label: \"Reset\",\n icon: <X />,\n onClick: () => column.clearSorting(),\n className: \"pl-2 [&_svg]:text-muted-foreground\",\n });\n }\n }\n\n if (column.getCanHide()) {\n items.push({\n key: \"hide\",\n type: \"checkbox\",\n label: \"Hide\",\n icon: <EyeOff />,\n checked: !column.getIsVisible(),\n onClick: () => column.toggleVisibility(false),\n className:\n \"relative pr-8 pl-2 [&>span:first-child]:right-2 [&>span:first-child]:left-auto [&_svg]:text-muted-foreground\",\n });\n }\n\n return (\n <div className={cn(\"flex items-center gap-1.5\", className)}>\n <DropdownMenu\n trigger={sortTrigger}\n items={items}\n align=\"start\"\n contentClassName=\"w-28\"\n />\n {filterButton}\n </div>\n );\n}\n"],"names":["DataTableColumnHeader","column","label","className","displayLabel","cn","sortTrigger","jsxs","jsx","ChevronDown","ChevronUp","ChevronsUpDown","filterButton","DataTableFilterPopover","Button","Filter","items","X","EyeOff","DropdownMenu"],"mappings":"
|
|
1
|
+
{"version":3,"file":"data-table-column-header.cjs","sources":["../../../../src/components/Table/data-table-column-header.tsx"],"sourcesContent":["\"use client\";\n\nimport type { Column } from \"@tanstack/react-table\";\nimport {\n ChevronDown,\n ChevronsUpDown,\n ChevronUp,\n EyeOff,\n Filter,\n X,\n} from \"lucide-react\";\n\nimport { cn } from \"@dsui/ui\";\nimport DropdownMenu, {\n type DropdownMenuItem,\n} from \"../DropdownMenu/DropdownMenu\";\nimport { DataTableFilterPopover } from \"./TableFilter/data-table-filter-popover\";\nimport { Button } from \"../Button\";\n\ninterface DataTableColumnHeaderProps<TData, TValue> {\n column: Column<TData, TValue>;\n label?: string;\n className?: string;\n}\n\nexport function DataTableColumnHeader<TData, TValue>({\n column,\n label,\n className,\n}: DataTableColumnHeaderProps<TData, TValue>) {\n const displayLabel =\n label ||\n (typeof column.columnDef.header === \"string\"\n ? column.columnDef.header\n : null);\n\n const hasActions =\n column.getCanSort() || column.getCanHide() || column.getCanFilter();\n\n if (!hasActions) {\n return <div className={cn(className)}>{displayLabel}</div>;\n }\n\n const sortTrigger = (\n <button className=\"-ml-1.5 flex h-8 items-center gap-1.5 rounded-md px-2 py-1.5 hover:bg-accent focus:outline-none focus:ring-1 focus:ring-ring data-[state=open]:bg-accent [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground\">\n {displayLabel}\n {column.getCanSort() &&\n (column.getIsSorted() === \"desc\" ? (\n <ChevronDown />\n ) : column.getIsSorted() === \"asc\" ? (\n <ChevronUp />\n ) : (\n <ChevronsUpDown />\n ))}\n </button>\n );\n\n const filterButton =\n column.getCanFilter() && column.columnDef.meta?.variant ? (\n <DataTableFilterPopover\n column={column}\n trigger={\n <Button\n variant=\"ghost\"\n className={cn(\n \"hover:bg-accent rounded p-1\",\n column.getFilterValue() ? \"text-primary\" : \"\"\n )}\n >\n <Filter className=\"size-4\" />\n </Button>\n }\n />\n ) : null;\n\n const items: DropdownMenuItem[] = [];\n\n if (column.getCanSort()) {\n items.push({\n key: \"asc\",\n type: \"checkbox\",\n label: \"Asc\",\n icon: <ChevronUp />,\n checked: column.getIsSorted() === \"asc\",\n onClick: () => column.toggleSorting(false),\n className:\n \"relative pr-8 pl-2 [&>span:first-child]:right-2 [&>span:first-child]:left-auto [&_svg]:text-muted-foreground\",\n });\n items.push({\n key: \"desc\",\n type: \"checkbox\",\n label: \"Desc\",\n icon: <ChevronDown />,\n checked: column.getIsSorted() === \"desc\",\n onClick: () => column.toggleSorting(true),\n className:\n \"relative pr-8 pl-2 [&>span:first-child]:right-2 [&>span:first-child]:left-auto [&_svg]:text-muted-foreground\",\n });\n if (column.getIsSorted()) {\n items.push({\n key: \"reset\",\n type: \"item\",\n label: \"Reset\",\n icon: <X />,\n onClick: () => column.clearSorting(),\n className: \"pl-2 [&_svg]:text-muted-foreground\",\n });\n }\n }\n\n if (column.getCanHide()) {\n items.push({\n key: \"hide\",\n type: \"checkbox\",\n label: \"Hide\",\n icon: <EyeOff />,\n checked: !column.getIsVisible(),\n onClick: () => column.toggleVisibility(false),\n className:\n \"relative pr-8 pl-2 [&>span:first-child]:right-2 [&>span:first-child]:left-auto [&_svg]:text-muted-foreground\",\n });\n }\n\n return (\n <div className={cn(\"flex items-center gap-1.5\", className)}>\n <DropdownMenu\n trigger={sortTrigger}\n items={items}\n align=\"start\"\n contentClassName=\"w-28\"\n />\n {filterButton}\n </div>\n );\n}\n"],"names":["DataTableColumnHeader","column","label","className","displayLabel","cn","sortTrigger","jsxs","jsx","ChevronDown","ChevronUp","ChevronsUpDown","filterButton","DataTableFilterPopover","Button","Filter","items","X","EyeOff","DropdownMenu"],"mappings":"8SAyBO,SAASA,EAAqC,CACnD,OAAAC,EACA,MAAAC,EACA,UAAAC,CACF,EAA8C,CAC5C,MAAMC,EACJF,IACC,OAAOD,EAAO,UAAU,QAAW,SAChCA,EAAO,UAAU,OACjB,MAKN,GAAI,EAFFA,EAAO,WAAA,GAAgBA,EAAO,WAAA,GAAgBA,EAAO,aAAA,GAGrD,aAAQ,MAAA,CAAI,UAAWI,EAAAA,GAAGF,CAAS,EAAI,SAAAC,EAAa,EAGtD,MAAME,EACJC,EAAAA,KAAC,SAAA,CAAO,UAAU,yNACf,SAAA,CAAAH,EACAH,EAAO,WAAA,IACLA,EAAO,YAAA,IAAkB,OACxBO,EAAAA,IAACC,EAAAA,YAAA,EAAY,EACXR,EAAO,gBAAkB,YAC1BS,EAAAA,UAAA,CAAA,CAAU,QAEVC,EAAAA,eAAA,EAAe,EAAA,EAEtB,EAGIC,EACJX,EAAO,aAAA,GAAkBA,EAAO,UAAU,MAAM,QAC9CO,EAAAA,IAACK,EAAAA,uBAAA,CACC,OAAAZ,EACA,QACEO,EAAAA,IAACM,EAAAA,QAAA,CACC,QAAQ,QACR,UAAWT,EAAAA,GACT,8BACAJ,EAAO,eAAA,EAAmB,eAAiB,EAAA,EAG7C,SAAAO,EAAAA,IAACO,EAAAA,OAAA,CAAO,UAAU,QAAA,CAAS,CAAA,CAAA,CAC7B,CAAA,EAGF,KAEAC,EAA4B,CAAA,EAElC,OAAIf,EAAO,eACTe,EAAM,KAAK,CACT,IAAK,MACL,KAAM,WACN,MAAO,MACP,WAAON,EAAAA,UAAA,EAAU,EACjB,QAAST,EAAO,YAAA,IAAkB,MAClC,QAAS,IAAMA,EAAO,cAAc,EAAK,EACzC,UACE,8GAAA,CACH,EACDe,EAAM,KAAK,CACT,IAAK,OACL,KAAM,WACN,MAAO,OACP,WAAOP,EAAAA,YAAA,EAAY,EACnB,QAASR,EAAO,YAAA,IAAkB,OAClC,QAAS,IAAMA,EAAO,cAAc,EAAI,EACxC,UACE,8GAAA,CACH,EACGA,EAAO,eACTe,EAAM,KAAK,CACT,IAAK,QACL,KAAM,OACN,MAAO,QACP,WAAOC,EAAAA,EAAA,EAAE,EACT,QAAS,IAAMhB,EAAO,aAAA,EACtB,UAAW,oCAAA,CACZ,GAIDA,EAAO,cACTe,EAAM,KAAK,CACT,IAAK,OACL,KAAM,WACN,MAAO,OACP,WAAOE,EAAAA,OAAA,EAAO,EACd,QAAS,CAACjB,EAAO,aAAA,EACjB,QAAS,IAAMA,EAAO,iBAAiB,EAAK,EAC5C,UACE,8GAAA,CACH,SAIA,MAAA,CAAI,UAAWI,EAAAA,GAAG,4BAA6BF,CAAS,EACvD,SAAA,CAAAK,EAAAA,IAACW,EAAAA,QAAA,CACC,QAASb,EACT,MAAAU,EACA,MAAM,QACN,iBAAiB,MAAA,CAAA,EAElBJ,CAAA,EACH,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("@tanstack/react-table"),g=require("./data-table-pagination.cjs"),n=require("@dsui/ui"),d=require("../../utils/data-table.cjs"),b=require("./data-table-column-header.cjs");function j({table:o,actionBar:c,children:u,className:m,pagination:t=!0,sticky:T,bordered:f,loading:a,footer:r,...x}){return e.jsxs("div",{className:n.cn("flex w-full flex-col gap-2.5 relative",m),...x,children:[u,a&&e.jsx("div",{className:"absolute inset-0 bg-background/50 flex items-center justify-center z-20",children:"Loading..."}),e.jsx("div",{className:n.cn("overflow-auto rounded-md border",a&&"blur-sm"),children:e.jsxs(n.Table,{children:[e.jsx(n.TableHeader,{children:o.getHeaderGroups().map(s=>e.jsx(n.TableRow,{children:s.headers.map(l=>e.jsx(n.TableHead,{colSpan:l.colSpan,style:{...d.getCommonPinningStyles({column:l.column})},children:l.isPlaceholder?null:l.column.columnDef.header?typeof l.column.columnDef.header=="function"?i.flexRender(l.column.columnDef.header,l.getContext()):e.jsx(b.DataTableColumnHeader,{column:l.column}):null},l.id))},s.id))}),e.jsx(n.TableBody,{children:o.getRowModel().rows?.length?o.getRowModel().rows.map(s=>e.jsx(n.TableRow,{"data-state":s.getIsSelected()&&"selected",children:s.getVisibleCells().map(l=>e.jsx(n.TableCell,{style:{...d.getCommonPinningStyles({column:l.column})},children:i.flexRender(l.column.columnDef.cell,l.getContext())},l.id))},s.id)):e.jsx(n.TableRow,{children:e.jsx(n.TableCell,{colSpan:o.getAllColumns().length,className:"h-24 text-center",children:"No results."})})}),r&&e.jsx("tfoot",{children:e.jsx(n.TableRow,{children:e.jsx(n.TableCell,{colSpan:o.getAllColumns().length,children:r(o.getRowModel().rows.map(s=>s.original))})})})]})}),e.jsxs("div",{className:"flex flex-col gap-2.5",children:[t&&e.jsx(g.DataTablePagination,{table:o,...t===!0?{}:t}),c&&o.getFilteredSelectedRowModel().rows.length>0&&c]})]})}exports.DataTable=j;
|
|
2
2
|
//# sourceMappingURL=data-table.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table.cjs","sources":["../../../../src/components/Table/data-table.tsx"],"sourcesContent":["import { flexRender, type Table as TanstackTable } from \"@tanstack/react-table\";\nimport type * as React from \"react\";\n\nimport { DataTablePagination } from \"./data-table-pagination\";\nimport {\n cn,\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from \"@dsui/ui\";\nimport { getCommonPinningStyles } from \"@/utils/data-table\";\nimport { DataTableColumnHeader } from \"./data-table-column-header\";\n\nexport interface DataTableProps<TData> extends React.ComponentProps<\"div\"> {\n table: TanstackTable<TData>;\n actionBar?: React.ReactNode;\n pagination?:\n | boolean\n | Omit<React.ComponentProps<typeof DataTablePagination<TData>>, \"table\">;\n sticky?: boolean | { offsetHeader?: number; offsetScroll?: number };\n bordered?: boolean;\n loading?: boolean;\n footer?: (currentPageData: TData[]) => React.ReactNode;\n}\n\nexport function DataTable<TData>({\n table,\n actionBar,\n children,\n className,\n pagination = true,\n sticky,\n bordered,\n loading,\n footer,\n ...props\n}: DataTableProps<TData>) {\n return (\n <div\n className={cn(\"flex w-full flex-col gap-2.5 relative\", className)}\n {...props}\n >\n {children}\n {loading && (\n <div className=\"absolute inset-0 bg-background/50 flex items-center justify-center z-20\">\n Loading...\n </div>\n )}\n <div\n className={cn(\"overflow-auto rounded-md border\", loading && \"blur-sm\")}\n >\n <Table>\n <TableHeader>\n {table.getHeaderGroups().map((headerGroup) => (\n <TableRow key={headerGroup.id}>\n {headerGroup.headers.map((header) => (\n <TableHead\n key={header.id}\n colSpan={header.colSpan}\n style={{\n ...getCommonPinningStyles({ column: header.column }),\n }}\n >\n {header.isPlaceholder ? null : header.column.columnDef\n .header ? (\n typeof header.column.columnDef.header === \"function\" ? (\n flexRender(\n header.column.columnDef.header,\n header.getContext()\n )\n ) : (\n <DataTableColumnHeader column={header.column} />\n )\n ) : null}\n </TableHead>\n ))}\n </TableRow>\n ))}\n </TableHeader>\n <TableBody>\n {table.getRowModel().rows?.length ? (\n table.getRowModel().rows.map((row) => (\n <TableRow\n key={row.id}\n data-state={row.getIsSelected() && \"selected\"}\n >\n {row.getVisibleCells().map((cell) => (\n <TableCell\n key={cell.id}\n style={{\n ...getCommonPinningStyles({ column: cell.column }),\n }}\n >\n {flexRender(\n cell.column.columnDef.cell,\n cell.getContext()\n )}\n </TableCell>\n ))}\n </TableRow>\n ))\n ) : (\n <TableRow>\n <TableCell\n colSpan={table.getAllColumns().length}\n className=\"h-24 text-center\"\n >\n No results.\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n {footer && (\n <tfoot>\n <TableRow>\n <TableCell colSpan={table.getAllColumns().length}>\n {footer(table.getRowModel().rows.map((row) => row.original))}\n </TableCell>\n </TableRow>\n </tfoot>\n )}\n </Table>\n </div>\n <div className=\"flex flex-col gap-2.5\">\n {pagination && (\n <DataTablePagination\n table={table}\n {...(pagination === true ? {} : pagination)}\n />\n )}\n {actionBar &&\n table.getFilteredSelectedRowModel().rows.length > 0 &&\n actionBar}\n </div>\n </div>\n );\n}\n"],"names":["DataTable","table","actionBar","children","className","pagination","sticky","bordered","loading","footer","props","jsxs","cn","jsx","Table","TableHeader","headerGroup","TableRow","header","TableHead","getCommonPinningStyles","flexRender","DataTableColumnHeader","TableBody","row","cell","TableCell","DataTablePagination"],"mappings":"
|
|
1
|
+
{"version":3,"file":"data-table.cjs","sources":["../../../../src/components/Table/data-table.tsx"],"sourcesContent":["import { flexRender, type Table as TanstackTable } from \"@tanstack/react-table\";\nimport type * as React from \"react\";\n\nimport { DataTablePagination } from \"./data-table-pagination\";\nimport {\n cn,\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from \"@dsui/ui\";\nimport { getCommonPinningStyles } from \"@/utils/data-table\";\nimport { DataTableColumnHeader } from \"./data-table-column-header\";\n\nexport interface DataTableProps<TData> extends React.ComponentProps<\"div\"> {\n table: TanstackTable<TData>;\n actionBar?: React.ReactNode;\n pagination?:\n | boolean\n | Omit<React.ComponentProps<typeof DataTablePagination<TData>>, \"table\">;\n sticky?: boolean | { offsetHeader?: number; offsetScroll?: number };\n bordered?: boolean;\n loading?: boolean;\n footer?: (currentPageData: TData[]) => React.ReactNode;\n}\n\nexport function DataTable<TData>({\n table,\n actionBar,\n children,\n className,\n pagination = true,\n sticky,\n bordered,\n loading,\n footer,\n ...props\n}: DataTableProps<TData>) {\n return (\n <div\n className={cn(\"flex w-full flex-col gap-2.5 relative\", className)}\n {...props}\n >\n {children}\n {loading && (\n <div className=\"absolute inset-0 bg-background/50 flex items-center justify-center z-20\">\n Loading...\n </div>\n )}\n <div\n className={cn(\"overflow-auto rounded-md border\", loading && \"blur-sm\")}\n >\n <Table>\n <TableHeader>\n {table.getHeaderGroups().map((headerGroup) => (\n <TableRow key={headerGroup.id}>\n {headerGroup.headers.map((header) => (\n <TableHead\n key={header.id}\n colSpan={header.colSpan}\n style={{\n ...getCommonPinningStyles({ column: header.column }),\n }}\n >\n {header.isPlaceholder ? null : header.column.columnDef\n .header ? (\n typeof header.column.columnDef.header === \"function\" ? (\n flexRender(\n header.column.columnDef.header,\n header.getContext()\n )\n ) : (\n <DataTableColumnHeader column={header.column} />\n )\n ) : null}\n </TableHead>\n ))}\n </TableRow>\n ))}\n </TableHeader>\n <TableBody>\n {table.getRowModel().rows?.length ? (\n table.getRowModel().rows.map((row) => (\n <TableRow\n key={row.id}\n data-state={row.getIsSelected() && \"selected\"}\n >\n {row.getVisibleCells().map((cell) => (\n <TableCell\n key={cell.id}\n style={{\n ...getCommonPinningStyles({ column: cell.column }),\n }}\n >\n {flexRender(\n cell.column.columnDef.cell,\n cell.getContext()\n )}\n </TableCell>\n ))}\n </TableRow>\n ))\n ) : (\n <TableRow>\n <TableCell\n colSpan={table.getAllColumns().length}\n className=\"h-24 text-center\"\n >\n No results.\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n {footer && (\n <tfoot>\n <TableRow>\n <TableCell colSpan={table.getAllColumns().length}>\n {footer(table.getRowModel().rows.map((row) => row.original))}\n </TableCell>\n </TableRow>\n </tfoot>\n )}\n </Table>\n </div>\n <div className=\"flex flex-col gap-2.5\">\n {pagination && (\n <DataTablePagination\n table={table}\n {...(pagination === true ? {} : pagination)}\n />\n )}\n {actionBar &&\n table.getFilteredSelectedRowModel().rows.length > 0 &&\n actionBar}\n </div>\n </div>\n );\n}\n"],"names":["DataTable","table","actionBar","children","className","pagination","sticky","bordered","loading","footer","props","jsxs","cn","jsx","Table","TableHeader","headerGroup","TableRow","header","TableHead","getCommonPinningStyles","flexRender","DataTableColumnHeader","TableBody","row","cell","TableCell","DataTablePagination"],"mappings":"2SA4BO,SAASA,EAAiB,CAC/B,MAAAC,EACA,UAAAC,EACA,SAAAC,EACA,UAAAC,EACA,WAAAC,EAAa,GACb,OAAAC,EACA,SAAAC,EACA,QAAAC,EACA,OAAAC,EACA,GAAGC,CACL,EAA0B,CACxB,OACEC,EAAAA,KAAC,MAAA,CACC,UAAWC,EAAAA,GAAG,wCAAyCR,CAAS,EAC/D,GAAGM,EAEH,SAAA,CAAAP,EACAK,GACCK,EAAAA,IAAC,MAAA,CAAI,UAAU,0EAA0E,SAAA,aAEzF,EAEFA,EAAAA,IAAC,MAAA,CACC,UAAWD,EAAAA,GAAG,kCAAmCJ,GAAW,SAAS,EAErE,gBAACM,QAAA,CACC,SAAA,CAAAD,EAAAA,IAACE,EAAAA,YAAA,CACE,SAAAd,EAAM,gBAAA,EAAkB,IAAKe,GAC5BH,EAAAA,IAACI,EAAAA,SAAA,CACE,SAAAD,EAAY,QAAQ,IAAKE,GACxBL,EAAAA,IAACM,EAAAA,UAAA,CAEC,QAASD,EAAO,QAChB,MAAO,CACL,GAAGE,yBAAuB,CAAE,OAAQF,EAAO,OAAQ,CAAA,EAGpD,SAAAA,EAAO,cAAgB,KAAOA,EAAO,OAAO,UACxC,OACH,OAAOA,EAAO,OAAO,UAAU,QAAW,WACxCG,EAAAA,WACEH,EAAO,OAAO,UAAU,OACxBA,EAAO,WAAA,CAAW,EAGpBL,EAAAA,IAACS,EAAAA,sBAAA,CAAsB,OAAQJ,EAAO,OAAQ,EAE9C,IAAA,EAhBCA,EAAO,EAAA,CAkBf,GArBYF,EAAY,EAsB3B,CACD,CAAA,CACH,EACAH,EAAAA,IAACU,EAAAA,UAAA,CACE,SAAAtB,EAAM,YAAA,EAAc,MAAM,OACzBA,EAAM,YAAA,EAAc,KAAK,IAAKuB,GAC5BX,EAAAA,IAACI,EAAAA,SAAA,CAEC,aAAYO,EAAI,cAAA,GAAmB,WAElC,SAAAA,EAAI,gBAAA,EAAkB,IAAKC,GAC1BZ,EAAAA,IAACa,EAAAA,UAAA,CAEC,MAAO,CACL,GAAGN,yBAAuB,CAAE,OAAQK,EAAK,OAAQ,CAAA,EAGlD,SAAAJ,EAAAA,WACCI,EAAK,OAAO,UAAU,KACtBA,EAAK,WAAA,CAAW,CAClB,EARKA,EAAK,EAAA,CAUb,CAAA,EAfID,EAAI,EAAA,CAiBZ,EAEDX,EAAAA,IAACI,WAAA,CACC,SAAAJ,EAAAA,IAACa,EAAAA,UAAA,CACC,QAASzB,EAAM,cAAA,EAAgB,OAC/B,UAAU,mBACX,SAAA,aAAA,CAAA,EAGH,CAAA,CAEJ,EACCQ,GACCI,EAAAA,IAAC,QAAA,CACC,SAAAA,EAAAA,IAACI,EAAAA,SAAA,CACC,eAACS,EAAAA,UAAA,CAAU,QAASzB,EAAM,cAAA,EAAgB,OACvC,WAAOA,EAAM,YAAA,EAAc,KAAK,IAAKuB,GAAQA,EAAI,QAAQ,CAAC,CAAA,CAC7D,CAAA,CACF,CAAA,CACF,CAAA,CAAA,CAEJ,CAAA,CAAA,EAEFb,EAAAA,KAAC,MAAA,CAAI,UAAU,wBACZ,SAAA,CAAAN,GACCQ,EAAAA,IAACc,EAAAA,oBAAA,CACC,MAAA1B,EACC,GAAII,IAAe,GAAO,GAAKA,CAAA,CAAA,EAGnCH,GACCD,EAAM,4BAAA,EAA8B,KAAK,OAAS,GAClDC,CAAA,CAAA,CACJ,CAAA,CAAA,CAAA,CAGN"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("./components/Command/index.cjs"),C=require("./components/Popover/index.cjs"),g=require("./components/Tour/index.cjs"),c=require("./components/QrCode/index.cjs"),m=require("./components/Stepper/index.cjs"),x=require("./components/Pagination/index.cjs"),f=require("./components/DropdownMenu/index.cjs"),R=require("./components/ContextMenu/index.cjs"),I=require("./components/FloatLabel.cjs"),M=require("./components/TimeGridView.cjs"),P=require("./components/WheelColumn.cjs"),G=require("./components/Marquee/index.cjs");require("@radix-ui/react-slot");require("./packages/ui/src/components/button.cjs");const d=require("./packages/ui/src/components/button-group.cjs");require("./packages/ui/src/components/input.cjs");require("./packages/ui/src/components/textarea.cjs");const k=require("./packages/ui/src/components/label.cjs");require("./packages/ui/src/components/select.cjs");require("./packages/ui/src/components/combobox.cjs");require("react/jsx-runtime");require("@radix-ui/react-tooltip");const w=require("./packages/ui/src/lib/utils.cjs");require("react");require("lucide-react");require("react-day-picker");require("./packages/ui/src/components/popover.cjs");require("@radix-ui/react-separator");require("./packages/ui/src/components/switch.cjs");require("vaul");require("@radix-ui/react-scroll-area");const B=require("./packages/ui/src/components/tree-view.cjs");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-avatar");require("./packages/ui/src/components/badge.cjs");require("./packages/ui/src/components/checkbox.cjs");require("@radix-ui/react-collapsible");require("cmdk");require("@radix-ui/react-dialog");require("@radix-ui/react-dropdown-menu");require("./packages/ui/src/components/input-otp.cjs");require("./packages/ui/src/components/radio-group.cjs");const A=require("./packages/ui/src/components/sidebar.cjs");require("@radix-ui/react-slider");require("./packages/ui/src/components/tabs.cjs");require("./packages/ui/src/components/toggle.cjs");const D=require("./hooks/use-callback-ref.cjs"),v=require("./hooks/use-debounced-callback.cjs"),y=require("./hooks/use-debounced-value.cjs"),V=require("./hooks/use-intersection-observer.cjs"),F=require("./hooks/use-script.cjs"),E=require("./hooks/use-scroll-lock.cjs"),O=require("./hooks/use-on-click-outside.cjs"),z=require("./hooks/use-event-listener.cjs"),L=require("./hooks/use-media-query.cjs"),h=require("./hooks/use-data-table.cjs"),W=require("./components/Badge/Badge.cjs"),Q=require("./components/Breadcrumb/Breadcrumb.cjs"),H=require("./components/Button/Button.cjs"),$=require("./components/Button/ButtonGroup.cjs"),N=require("./components/Checkbox/Checkbox.cjs"),U=require("./components/Collapsible/Collapsible.cjs"),_=require("./components/Dialog/Dialog.cjs"),j=require("./components/Glass/Glass.cjs"),J=require("./components/Input/Input.cjs"),K=require("./components/InputOTP/InputOTP.cjs"),X=require("./components/Radio/Radio.cjs"),Y=require("./components/ScrollArea/ScrollArea.cjs"),Z=require("./components/Select/Select.cjs"),ee=require("./components/Separator/Separator.cjs"),re=require("./components/Sheet/Sheet.cjs"),oe=require("./components/Skeleton/Skeleton.cjs"),te=require("./components/Slider/Slider.cjs"),ie=require("./components/Switch/Switch.cjs"),ue=require("./components/Tabs/Tabs.cjs"),ae=require("./components/Textarea/Textarea.cjs"),ne=require("./components/Toggle/Toggle.cjs"),se=require("./components/Rate/Rate.cjs"),i=require("./components/Resizable/Resizable.cjs"),le=require("./components/Accordion/Accordion.cjs"),ce=require("./lib/TextAnimation/BlurText.cjs"),de=require("./lib/TextAnimation/CircularText.cjs"),qe=require("./lib/TextAnimation/TextPressureEffect.cjs"),be=require("./lib/TextAnimation/TypingText.cjs"),Se=require("./components/Avatar/Avatar.cjs"),q=require("./components/Calendar/Calendar.cjs"),pe=require("./components/DatePicker/DatePicker.cjs"),Te=require("./components/DatePicker/RangePicker.cjs"),Ce=require("./components/DatePicker/TimePicker.cjs"),e=require("./components/Sidebar/Sidebar.cjs"),a=require("./components/Toast/Toast.cjs"),ge=require("./components/Tooltip/Tooltip.cjs"),me=require("./components/Upload/Upload.cjs"),xe=require("./components/QrCode/QrCode.cjs"),fe=require("./components/Stepper/Stepper.cjs"),Re=require("./components/Table/data-table.cjs"),Ie=require("./components/Table/data-table-pagination.cjs"),n=require("./packages/ui/src/components/resizable.cjs"),s=require("./packages/ui/src/components/accordion.cjs"),l=require("./components/ImageViewer/ImageViewer.cjs"),b=require("./components/Carousel/Carousel.cjs"),o=require("./components/Cropper/Cropper.cjs"),S=require("./components/Cropper/CropperTool.cjs"),t=require("./components/Cropper/utils.cjs"),r=require("./components/Interactive/CursorFollow.cjs"),u=require("./components/Masonry/Masonry.cjs"),p=require("./components/Masonry/MasonryWrapper.cjs"),Me=require("./lib/TextAnimation/RotatingText.cjs"),Pe=require("./lib/TextAnimation/FlipWords.cjs"),Ge=require("./lib/TextAnimation/GradientText.cjs"),ke=require("./lib/TextAnimation/RollingText.cjs"),we=require("./lib/TextAnimation/ShimmeringText.cjs"),Be=require("./lib/TextAnimation/SplittingText.cjs"),Ae=require("./lib/TextAnimation/TextGenerateEffect.cjs"),De=require("./lib/TextAnimation/TextHoverEffect.cjs"),ve=require("./lib/TextAnimation/WritingText.cjs");exports.Command=T.Command;exports.Popover=C.Popover;exports.Tour=g.Tour;exports.QRCode=c.QRCode;exports.QrCode=c.QRCode;exports.Stepper=m.Stepper;exports.Pagination=x.Pagination;exports.DropdownMenu=f.DropdownMenu;exports.ContextMenu=R.ContextMenu;exports.FloatingLabel=I.FloatingLabel;exports.TimeGridView=M.TimeGridView;exports.WheelColumn=P.TimeColumnwheel;exports.Marquee=G.Marquee;exports.ButtonGroupSeparator=d.ButtonGroupSeparator;exports.ButtonGroupText=d.ButtonGroupText;exports.Label=k.Label;exports.cn=w.cn;exports.TreeView=B.TreeView;exports.useSidebar=A.useSidebar;exports.useCallbackRef=D.useCallbackRef;exports.useDebouncedCallback=v.useDebouncedCallback;exports.useDebounceValue=y.useDebounceValue;exports.useIntersectionObserver=V.useIntersectionObserver;exports.useScript=F.useScript;exports.useScrollLock=E.useScrollLock;exports.useOnClickOutside=O.useOnClickOutside;exports.useEventListener=z.useEventListener;exports.useMediaQuery=L.useMediaQuery;exports.useDataTable=h.useDataTable;exports.Badge=W.default;exports.Breadcrumb=Q.default;exports.Button=H.default;exports.ButtonGroup=$.default;exports.Checkbox=N.default;exports.Collapsible=U.default;exports.Dialog=_.default;exports.Glass=j.default;exports.Input=J.default;exports.InputOTP=K.default;exports.Radio=X.default;exports.ScrollArea=Y.ScrollArea;exports.Select=Z.default;exports.Separator=ee.default;exports.Sheet=re.default;exports.Skeleton=oe.default;exports.Slider=te.default;exports.Switch=ie.default;exports.Tabs=ue.default;exports.Textarea=ae.default;exports.Toggle=ne.default;exports.Rate=se.default;exports.Handle=i.Handle;exports.Panel=i.Panel;exports.Resizable=i.default;exports.ResizableWrapper=i.ResizableWrapper;exports.Accordion=le.default;exports.BlurText=ce.default;exports.CircularText=de.default;exports.TextPressure=qe.default;exports.TypingText=be.default;exports.Avatar=Se.Avatar;exports.Calendar=q.Calendar;exports.CalendarDayButton=q.CalendarDayButton;exports.DatePicker=pe.DatePicker;exports.RangePicker=Te.RangePicker;exports.TimePicker=Ce.TimePicker;exports.Sidebar=e.Sidebar;exports.SidebarContent=e.SidebarContent;exports.SidebarFooter=e.SidebarFooter;exports.SidebarGroup=e.SidebarGroup;exports.SidebarGroupAction=e.SidebarGroupAction;exports.SidebarGroupContent=e.SidebarGroupContent;exports.SidebarGroupLabel=e.SidebarGroupLabel;exports.SidebarHeader=e.SidebarHeader;exports.SidebarInput=e.SidebarInput;exports.SidebarInset=e.SidebarInset;exports.SidebarMenu=e.SidebarMenu;exports.SidebarMenuAction=e.SidebarMenuAction;exports.SidebarMenuBadge=e.SidebarMenuBadge;exports.SidebarMenuButton=e.SidebarMenuButton;exports.SidebarMenuItem=e.SidebarMenuItem;exports.SidebarMenuSkeleton=e.SidebarMenuSkeleton;exports.SidebarMenuSub=e.SidebarMenuSub;exports.SidebarMenuSubButton=e.SidebarMenuSubButton;exports.SidebarMenuSubItem=e.SidebarMenuSubItem;exports.SidebarProvider=e.SidebarProvider;exports.SidebarRail=e.SidebarRail;exports.SidebarSeparator=e.SidebarSeparator;exports.SidebarTrigger=e.SidebarTrigger;exports.Toast=a.toast;exports.Toaster=a.Toaster;exports.toast=a.toast;exports.Tooltip=ge.Tooltip;exports.Upload=me.Upload;exports.useQRCode=xe.useQRCode;exports.useStepper=fe.useStepper;exports.DataTable=Re.DataTable;exports.DataTablePagination=Ie.DataTablePagination;exports.ResizableHandle=n.ResizableHandle;exports.ResizablePanel=n.ResizablePanel;exports.ResizablePanelGroup=n.ResizablePanelGroup;exports.AccordionContent=s.AccordionContent;exports.AccordionItem=s.AccordionItem;exports.AccordionTrigger=s.AccordionTrigger;exports.ImageViewer=l.ImageViewer;exports.ImageViewerGroup=l.ImageViewerGroup;exports.ImageViewerImage=l.ImageViewerImage;exports.Carousel=b.Carousel;exports.CarouselSlide=b.CarouselSlide;exports.Cropper=o.Root;exports.CropperArea=o.Area;exports.CropperImage=o.Image;exports.CropperVideo=o.Video;exports.useCropper=o.useCropper;exports.CropperTool=S.CropperTool;exports.useCropperTool=S.useCropperTool;exports.base64ToBlob=t.base64ToBlob;exports.base64ToFile=t.base64ToFile;exports.downloadImage=t.downloadImage;exports.getCroppedImg=t.getCroppedImg;exports.rotateSize=t.rotateSize;exports.Cursor=r.Cursor;exports.CursorFollow=r.CursorFollow;exports.CursorProvider=r.CursorProvider;exports.TRANSITION_PRESETS=r.TRANSITION_PRESETS;exports.useCursor=r.useCursor;exports.useCursorFollow=r.useCursorFollow;exports.Item=u.Item;exports.MasonryItem=u.MasonryItem;exports.MasonryRoot=u.MasonryRoot;exports.Root=u.Root;exports.Masonry=p.Masonry;exports.MasonryComponent=p.MasonryComponent;exports.RotatingText=Me.RotatingText;exports.FlipWords=Pe.FlipWords;exports.GradientText=Ge.GradientText;exports.RollingText=ke.RollingText;exports.ShimmeringText=we.ShimmeringText;exports.SplittingText=Be.SplittingText;exports.TextGenerateEffect=Ae.TextGenerateEffect;exports.TextHoverEffect=De.TextHoverEffect;exports.WritingText=ve.WritingText;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("./components/Command/index.cjs"),C=require("./components/Popover/index.cjs"),g=require("./components/Tour/index.cjs"),c=require("./components/QrCode/index.cjs"),m=require("./components/Stepper/index.cjs"),x=require("./components/Pagination/index.cjs"),f=require("./components/DropdownMenu/index.cjs"),R=require("./components/ContextMenu/index.cjs"),I=require("./components/FloatLabel.cjs"),M=require("./components/TimeGridView.cjs"),P=require("./components/WheelColumn.cjs"),G=require("./components/Marquee/index.cjs"),k=require("@dsui/ui"),w=require("./hooks/use-callback-ref.cjs"),B=require("./hooks/use-debounced-callback.cjs"),A=require("./hooks/use-debounced-value.cjs"),D=require("./hooks/use-intersection-observer.cjs"),y=require("./hooks/use-script.cjs"),v=require("./hooks/use-scroll-lock.cjs"),V=require("./hooks/use-on-click-outside.cjs"),F=require("./hooks/use-event-listener.cjs"),O=require("./hooks/use-media-query.cjs"),E=require("./hooks/use-data-table.cjs"),z=require("./components/Badge/Badge.cjs"),L=require("./components/Breadcrumb/Breadcrumb.cjs"),h=require("./components/Button/Button.cjs"),W=require("./components/Button/ButtonGroup.cjs"),Q=require("./components/Checkbox/Checkbox.cjs"),H=require("./components/Collapsible/Collapsible.cjs"),$=require("./components/Dialog/Dialog.cjs"),N=require("./components/Glass/Glass.cjs"),U=require("./components/Input/Input.cjs"),j=require("./components/InputOTP/InputOTP.cjs"),_=require("./components/Radio/Radio.cjs"),J=require("./components/ScrollArea/ScrollArea.cjs"),K=require("./components/Select/Select.cjs"),X=require("./components/Separator/Separator.cjs"),Y=require("./components/Sheet/Sheet.cjs"),Z=require("./components/Skeleton/Skeleton.cjs"),ee=require("./components/Slider/Slider.cjs"),re=require("./components/Switch/Switch.cjs"),te=require("./components/Tabs/Tabs.cjs"),oe=require("./components/Textarea/Textarea.cjs"),ie=require("./components/Toggle/Toggle.cjs"),ae=require("./components/Rate/Rate.cjs"),i=require("./components/Resizable/Resizable.cjs"),ue=require("./components/Accordion/Accordion.cjs"),ne=require("./lib/TextAnimation/BlurText.cjs"),se=require("./lib/TextAnimation/CircularText.cjs"),le=require("./lib/TextAnimation/TextPressureEffect.cjs"),ce=require("./lib/TextAnimation/TypingText.cjs"),de=require("./components/Avatar/Avatar.cjs"),d=require("./packages/ui/src/components/button-group.cjs"),b=require("./components/Calendar/Calendar.cjs"),be=require("./components/DatePicker/DatePicker.cjs"),Se=require("./components/DatePicker/RangePicker.cjs"),pe=require("./components/DatePicker/TimePicker.cjs"),Te=require("./packages/ui/src/components/label.cjs"),qe=require("./packages/ui/src/components/sidebar.cjs"),e=require("./components/Sidebar/Sidebar.cjs"),u=require("./components/Toast/Toast.cjs"),Ce=require("./components/Tooltip/Tooltip.cjs"),ge=require("./components/Upload/Upload.cjs"),me=require("./components/QrCode/QrCode.cjs"),xe=require("./components/Stepper/Stepper.cjs"),fe=require("./components/Table/data-table.cjs"),Re=require("./components/Table/data-table-pagination.cjs"),Ie=require("./packages/ui/src/components/tree-view.cjs"),n=require("./packages/ui/src/components/resizable.cjs"),s=require("./packages/ui/src/components/accordion.cjs"),l=require("./components/ImageViewer/ImageViewer.cjs"),S=require("./components/Carousel/Carousel.cjs"),t=require("./components/Cropper/Cropper.cjs"),p=require("./components/Cropper/CropperTool.cjs"),o=require("./components/Cropper/utils.cjs"),r=require("./components/Interactive/CursorFollow.cjs"),a=require("./components/Masonry/Masonry.cjs"),T=require("./components/Masonry/MasonryWrapper.cjs"),Me=require("./lib/TextAnimation/RotatingText.cjs"),Pe=require("./lib/TextAnimation/FlipWords.cjs"),Ge=require("./lib/TextAnimation/GradientText.cjs"),ke=require("./lib/TextAnimation/RollingText.cjs"),we=require("./lib/TextAnimation/ShimmeringText.cjs"),Be=require("./lib/TextAnimation/SplittingText.cjs"),Ae=require("./lib/TextAnimation/TextGenerateEffect.cjs"),De=require("./lib/TextAnimation/TextHoverEffect.cjs"),ye=require("./lib/TextAnimation/WritingText.cjs");exports.Command=q.Command;exports.Popover=C.Popover;exports.Tour=g.Tour;exports.QRCode=c.QRCode;exports.QrCode=c.QRCode;exports.Stepper=m.Stepper;exports.Pagination=x.Pagination;exports.DropdownMenu=f.DropdownMenu;exports.ContextMenu=R.ContextMenu;exports.FloatingLabel=I.FloatingLabel;exports.TimeGridView=M.TimeGridView;exports.WheelColumn=P.TimeColumnwheel;exports.Marquee=G.Marquee;Object.defineProperty(exports,"cn",{enumerable:!0,get:()=>k.cn});exports.useCallbackRef=w.useCallbackRef;exports.useDebouncedCallback=B.useDebouncedCallback;exports.useDebounceValue=A.useDebounceValue;exports.useIntersectionObserver=D.useIntersectionObserver;exports.useScript=y.useScript;exports.useScrollLock=v.useScrollLock;exports.useOnClickOutside=V.useOnClickOutside;exports.useEventListener=F.useEventListener;exports.useMediaQuery=O.useMediaQuery;exports.useDataTable=E.useDataTable;exports.Badge=z.default;exports.Breadcrumb=L.default;exports.Button=h.default;exports.ButtonGroup=W.default;exports.Checkbox=Q.default;exports.Collapsible=H.default;exports.Dialog=$.default;exports.Glass=N.default;exports.Input=U.default;exports.InputOTP=j.default;exports.Radio=_.default;exports.ScrollArea=J.ScrollArea;exports.Select=K.default;exports.Separator=X.default;exports.Sheet=Y.default;exports.Skeleton=Z.default;exports.Slider=ee.default;exports.Switch=re.default;exports.Tabs=te.default;exports.Textarea=oe.default;exports.Toggle=ie.default;exports.Rate=ae.default;exports.Handle=i.Handle;exports.Panel=i.Panel;exports.Resizable=i.default;exports.ResizableWrapper=i.ResizableWrapper;exports.Accordion=ue.default;exports.BlurText=ne.default;exports.CircularText=se.default;exports.TextPressure=le.default;exports.TypingText=ce.default;exports.Avatar=de.Avatar;exports.ButtonGroupSeparator=d.ButtonGroupSeparator;exports.ButtonGroupText=d.ButtonGroupText;exports.Calendar=b.Calendar;exports.CalendarDayButton=b.CalendarDayButton;exports.DatePicker=be.DatePicker;exports.RangePicker=Se.RangePicker;exports.TimePicker=pe.TimePicker;exports.Label=Te.Label;exports.useSidebar=qe.useSidebar;exports.Sidebar=e.Sidebar;exports.SidebarContent=e.SidebarContent;exports.SidebarFooter=e.SidebarFooter;exports.SidebarGroup=e.SidebarGroup;exports.SidebarGroupAction=e.SidebarGroupAction;exports.SidebarGroupContent=e.SidebarGroupContent;exports.SidebarGroupLabel=e.SidebarGroupLabel;exports.SidebarHeader=e.SidebarHeader;exports.SidebarInput=e.SidebarInput;exports.SidebarInset=e.SidebarInset;exports.SidebarMenu=e.SidebarMenu;exports.SidebarMenuAction=e.SidebarMenuAction;exports.SidebarMenuBadge=e.SidebarMenuBadge;exports.SidebarMenuButton=e.SidebarMenuButton;exports.SidebarMenuItem=e.SidebarMenuItem;exports.SidebarMenuSkeleton=e.SidebarMenuSkeleton;exports.SidebarMenuSub=e.SidebarMenuSub;exports.SidebarMenuSubButton=e.SidebarMenuSubButton;exports.SidebarMenuSubItem=e.SidebarMenuSubItem;exports.SidebarProvider=e.SidebarProvider;exports.SidebarRail=e.SidebarRail;exports.SidebarSeparator=e.SidebarSeparator;exports.SidebarTrigger=e.SidebarTrigger;exports.Toast=u.toast;exports.Toaster=u.Toaster;exports.toast=u.toast;exports.Tooltip=Ce.Tooltip;exports.Upload=ge.Upload;exports.useQRCode=me.useQRCode;exports.useStepper=xe.useStepper;exports.DataTable=fe.DataTable;exports.DataTablePagination=Re.DataTablePagination;exports.TreeView=Ie.TreeView;exports.ResizableHandle=n.ResizableHandle;exports.ResizablePanel=n.ResizablePanel;exports.ResizablePanelGroup=n.ResizablePanelGroup;exports.AccordionContent=s.AccordionContent;exports.AccordionItem=s.AccordionItem;exports.AccordionTrigger=s.AccordionTrigger;exports.ImageViewer=l.ImageViewer;exports.ImageViewerGroup=l.ImageViewerGroup;exports.ImageViewerImage=l.ImageViewerImage;exports.Carousel=S.Carousel;exports.CarouselSlide=S.CarouselSlide;exports.Cropper=t.Root;exports.CropperArea=t.Area;exports.CropperImage=t.Image;exports.CropperVideo=t.Video;exports.useCropper=t.useCropper;exports.CropperTool=p.CropperTool;exports.useCropperTool=p.useCropperTool;exports.base64ToBlob=o.base64ToBlob;exports.base64ToFile=o.base64ToFile;exports.downloadImage=o.downloadImage;exports.getCroppedImg=o.getCroppedImg;exports.rotateSize=o.rotateSize;exports.Cursor=r.Cursor;exports.CursorFollow=r.CursorFollow;exports.CursorProvider=r.CursorProvider;exports.TRANSITION_PRESETS=r.TRANSITION_PRESETS;exports.useCursor=r.useCursor;exports.useCursorFollow=r.useCursorFollow;exports.Item=a.Item;exports.MasonryItem=a.MasonryItem;exports.MasonryRoot=a.MasonryRoot;exports.Root=a.Root;exports.Masonry=T.Masonry;exports.MasonryComponent=T.MasonryComponent;exports.RotatingText=Me.RotatingText;exports.FlipWords=Pe.FlipWords;exports.GradientText=Ge.GradientText;exports.RollingText=ke.RollingText;exports.ShimmeringText=we.ShimmeringText;exports.SplittingText=Be.SplittingText;exports.TextGenerateEffect=Ae.TextGenerateEffect;exports.TextHoverEffect=De.TextHoverEffect;exports.WritingText=ye.WritingText;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,22 +1,52 @@
|
|
|
1
1
|
import { jsx as e, jsxs as g, Fragment as _ } from "react/jsx-runtime";
|
|
2
|
-
import F, { useState as
|
|
2
|
+
import F, { useState as p, useEffect as W, useCallback as v } from "react";
|
|
3
3
|
import Z from "../../_virtual/index.js";
|
|
4
|
-
import { cn as N } from "../../packages/ui/src/lib/utils.js";
|
|
5
4
|
import { ZoomIn as $ } from "lucide-react";
|
|
6
5
|
/* empty css */
|
|
7
6
|
/* empty css */
|
|
7
|
+
import "@radix-ui/react-slot";
|
|
8
|
+
import "../../packages/ui/src/components/button.js";
|
|
9
|
+
import "../../packages/ui/src/components/button-group.js";
|
|
10
|
+
import "../../packages/ui/src/components/input.js";
|
|
11
|
+
import "../../packages/ui/src/components/textarea.js";
|
|
12
|
+
import "@radix-ui/react-label";
|
|
13
|
+
import { cn as N } from "../../packages/ui/src/lib/utils.js";
|
|
14
|
+
import "../../packages/ui/src/components/select.js";
|
|
15
|
+
import "../../packages/ui/src/components/combobox.js";
|
|
16
|
+
import "@radix-ui/react-tooltip";
|
|
17
|
+
import "react-day-picker";
|
|
18
|
+
import "../../packages/ui/src/components/popover.js";
|
|
19
|
+
import "@radix-ui/react-separator";
|
|
20
|
+
import "../../packages/ui/src/components/switch.js";
|
|
21
|
+
import "vaul";
|
|
22
|
+
import "@radix-ui/react-scroll-area";
|
|
23
|
+
import "../../packages/ui/src/components/tree-view.js";
|
|
24
|
+
import "@radix-ui/react-alert-dialog";
|
|
25
|
+
import "@radix-ui/react-avatar";
|
|
26
|
+
import "../../packages/ui/src/components/badge.js";
|
|
27
|
+
import "../../packages/ui/src/components/checkbox.js";
|
|
28
|
+
import "@radix-ui/react-collapsible";
|
|
29
|
+
import "cmdk";
|
|
30
|
+
import "@radix-ui/react-dialog";
|
|
31
|
+
import "@radix-ui/react-dropdown-menu";
|
|
32
|
+
import "../../packages/ui/src/components/input-otp.js";
|
|
33
|
+
import "../../packages/ui/src/components/radio-group.js";
|
|
34
|
+
import "../../packages/ui/src/components/sidebar.js";
|
|
35
|
+
import "@radix-ui/react-slider";
|
|
36
|
+
import "../../packages/ui/src/components/tabs.js";
|
|
37
|
+
import "../../packages/ui/src/components/toggle.js";
|
|
8
38
|
const L = ({
|
|
9
|
-
images:
|
|
10
|
-
visible:
|
|
11
|
-
onClose:
|
|
12
|
-
activeIndex:
|
|
13
|
-
onIndexChange:
|
|
14
|
-
zoomSpeed:
|
|
39
|
+
images: i,
|
|
40
|
+
visible: m = !1,
|
|
41
|
+
onClose: a,
|
|
42
|
+
activeIndex: n = 0,
|
|
43
|
+
onIndexChange: s,
|
|
44
|
+
zoomSpeed: u = 0.1,
|
|
15
45
|
disableKeyboardSupport: c = !1,
|
|
16
|
-
noNavbar:
|
|
17
|
-
noToolbar:
|
|
18
|
-
rotatable:
|
|
19
|
-
scalable:
|
|
46
|
+
noNavbar: l = !1,
|
|
47
|
+
noToolbar: w = !1,
|
|
48
|
+
rotatable: h = !0,
|
|
49
|
+
scalable: f = !0,
|
|
20
50
|
changeable: j = !0,
|
|
21
51
|
noClose: U = !1,
|
|
22
52
|
minScale: b = 0.1,
|
|
@@ -28,25 +58,25 @@ const L = ({
|
|
|
28
58
|
noResetZoomAfterChange: E = !1,
|
|
29
59
|
drag: R = !1
|
|
30
60
|
}) => {
|
|
31
|
-
const [
|
|
61
|
+
const [d, I] = p(n);
|
|
32
62
|
W(() => {
|
|
33
|
-
I(
|
|
34
|
-
}, [
|
|
63
|
+
I(n);
|
|
64
|
+
}, [n]);
|
|
35
65
|
const V = v(() => {
|
|
36
|
-
|
|
37
|
-
}, [
|
|
66
|
+
a?.();
|
|
67
|
+
}, [a]), G = v(
|
|
38
68
|
(r, t) => {
|
|
39
|
-
I(t),
|
|
69
|
+
I(t), s?.(t);
|
|
40
70
|
},
|
|
41
|
-
[
|
|
71
|
+
[s]
|
|
42
72
|
), M = v(() => {
|
|
43
|
-
const r =
|
|
44
|
-
o.href = t, o.download = r.alt || `image-${
|
|
73
|
+
const r = i[d], t = r.downloadUrl || r.src, o = document.createElement("a");
|
|
74
|
+
o.href = t, o.download = r.alt || `image-${d + 1}`, fetch(t).then((O) => O.blob()).then((O) => {
|
|
45
75
|
const T = window.URL.createObjectURL(O);
|
|
46
76
|
o.href = T, document.body.appendChild(o), o.click(), document.body.removeChild(o), window.URL.revokeObjectURL(T);
|
|
47
77
|
}).catch(() => {
|
|
48
78
|
});
|
|
49
|
-
}, [
|
|
79
|
+
}, [i, d]), D = i.map((r) => ({
|
|
50
80
|
src: r.src,
|
|
51
81
|
alt: r.alt || "",
|
|
52
82
|
downloadUrl: r.downloadUrl || r.src
|
|
@@ -54,18 +84,18 @@ const L = ({
|
|
|
54
84
|
return /* @__PURE__ */ e(
|
|
55
85
|
Z,
|
|
56
86
|
{
|
|
57
|
-
visible:
|
|
87
|
+
visible: m,
|
|
58
88
|
onClose: V,
|
|
59
89
|
onMaskClick: V,
|
|
60
90
|
images: D,
|
|
61
|
-
activeIndex:
|
|
91
|
+
activeIndex: d,
|
|
62
92
|
onChange: G,
|
|
63
|
-
zoomSpeed:
|
|
93
|
+
zoomSpeed: u,
|
|
64
94
|
disableKeyboardSupport: c,
|
|
65
|
-
noNavbar:
|
|
66
|
-
noToolbar:
|
|
67
|
-
rotatable:
|
|
68
|
-
scalable:
|
|
95
|
+
noNavbar: l,
|
|
96
|
+
noToolbar: w,
|
|
97
|
+
rotatable: h,
|
|
98
|
+
scalable: f,
|
|
69
99
|
changeable: j,
|
|
70
100
|
noClose: U,
|
|
71
101
|
minScale: b,
|
|
@@ -138,57 +168,57 @@ const L = ({
|
|
|
138
168
|
};
|
|
139
169
|
L.displayName = "ImageViewer";
|
|
140
170
|
const B = ({
|
|
141
|
-
src:
|
|
142
|
-
alt:
|
|
143
|
-
width:
|
|
144
|
-
height:
|
|
145
|
-
preview:
|
|
146
|
-
previewSrc:
|
|
171
|
+
src: i,
|
|
172
|
+
alt: m = "",
|
|
173
|
+
width: a,
|
|
174
|
+
height: n,
|
|
175
|
+
preview: s = !0,
|
|
176
|
+
previewSrc: u,
|
|
147
177
|
fallback: c,
|
|
148
|
-
placeholder:
|
|
149
|
-
className:
|
|
150
|
-
wrapperClassName:
|
|
151
|
-
onPreviewClick:
|
|
178
|
+
placeholder: l,
|
|
179
|
+
className: w,
|
|
180
|
+
wrapperClassName: h,
|
|
181
|
+
onPreviewClick: f,
|
|
152
182
|
onError: j,
|
|
153
183
|
...U
|
|
154
184
|
}) => {
|
|
155
|
-
const [b, k] =
|
|
185
|
+
const [b, k] = p(!0), [x, C] = p(!1), [P, y] = p(!1), E = () => {
|
|
156
186
|
k(!1), C(!1);
|
|
157
187
|
}, R = (D) => {
|
|
158
188
|
k(!1), C(!0), j?.(D);
|
|
159
|
-
},
|
|
160
|
-
|
|
189
|
+
}, d = () => {
|
|
190
|
+
s && (y(!0), f?.());
|
|
161
191
|
}, I = () => {
|
|
162
192
|
y(!1);
|
|
163
|
-
}, V = b &&
|
|
193
|
+
}, V = b && l, G = x && c, M = s && !b && !x;
|
|
164
194
|
return /* @__PURE__ */ g(_, { children: [
|
|
165
195
|
/* @__PURE__ */ e(
|
|
166
196
|
"div",
|
|
167
197
|
{
|
|
168
198
|
className: N(
|
|
169
199
|
"ds-image-viewer-root relative inline-block",
|
|
170
|
-
|
|
200
|
+
h
|
|
171
201
|
),
|
|
172
202
|
children: /* @__PURE__ */ g("div", { className: "relative inline-block", children: [
|
|
173
203
|
V && /* @__PURE__ */ e(
|
|
174
204
|
"div",
|
|
175
205
|
{
|
|
176
206
|
className: "absolute inset-0 flex items-center justify-center bg-muted animate-pulse",
|
|
177
|
-
style: { width:
|
|
178
|
-
children:
|
|
207
|
+
style: { width: a, height: n },
|
|
208
|
+
children: l === !0 ? /* @__PURE__ */ e("div", { className: "w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin" }) : l
|
|
179
209
|
}
|
|
180
210
|
),
|
|
181
211
|
/* @__PURE__ */ e(
|
|
182
212
|
"img",
|
|
183
213
|
{
|
|
184
|
-
src: G ? c :
|
|
185
|
-
alt:
|
|
186
|
-
width:
|
|
187
|
-
height:
|
|
214
|
+
src: G ? c : i,
|
|
215
|
+
alt: m,
|
|
216
|
+
width: a,
|
|
217
|
+
height: n,
|
|
188
218
|
className: N(
|
|
189
219
|
"ds-image-viewer-img max-w-full h-auto align-middle",
|
|
190
220
|
b && "opacity-0",
|
|
191
|
-
|
|
221
|
+
w
|
|
192
222
|
),
|
|
193
223
|
onLoad: E,
|
|
194
224
|
onError: R,
|
|
@@ -198,7 +228,7 @@ const B = ({
|
|
|
198
228
|
M && /* @__PURE__ */ e(
|
|
199
229
|
"div",
|
|
200
230
|
{
|
|
201
|
-
onClick:
|
|
231
|
+
onClick: d,
|
|
202
232
|
className: N(
|
|
203
233
|
"ds-image-viewer-mask absolute inset-0 flex items-center justify-center opacity-0 hover:opacity-100 transition-opacity cursor-pointer",
|
|
204
234
|
"bg-black/50 backdrop-blur-sm"
|
|
@@ -215,7 +245,7 @@ const B = ({
|
|
|
215
245
|
/* @__PURE__ */ e(
|
|
216
246
|
L,
|
|
217
247
|
{
|
|
218
|
-
images: [{ src:
|
|
248
|
+
images: [{ src: u || i, alt: m }],
|
|
219
249
|
visible: P,
|
|
220
250
|
onClose: I,
|
|
221
251
|
rotatable: !0,
|
|
@@ -227,30 +257,30 @@ const B = ({
|
|
|
227
257
|
};
|
|
228
258
|
B.displayName = "ImageViewer.Image";
|
|
229
259
|
const S = ({
|
|
230
|
-
children:
|
|
231
|
-
images:
|
|
232
|
-
preview:
|
|
260
|
+
children: i,
|
|
261
|
+
images: m,
|
|
262
|
+
preview: a = !0
|
|
233
263
|
}) => {
|
|
234
|
-
const [
|
|
235
|
-
c(
|
|
236
|
-
}, []),
|
|
237
|
-
|
|
238
|
-
}, []),
|
|
264
|
+
const [n, s] = p(!1), [u, c] = p(0), l = v((f) => {
|
|
265
|
+
c(f), s(!0);
|
|
266
|
+
}, []), w = v(() => {
|
|
267
|
+
s(!1);
|
|
268
|
+
}, []), h = F.useMemo(
|
|
239
269
|
() => ({
|
|
240
|
-
handlePreview:
|
|
241
|
-
preview:
|
|
270
|
+
handlePreview: l,
|
|
271
|
+
preview: a
|
|
242
272
|
}),
|
|
243
|
-
[
|
|
273
|
+
[l, a]
|
|
244
274
|
);
|
|
245
275
|
return /* @__PURE__ */ g(_, { children: [
|
|
246
|
-
/* @__PURE__ */ e(q.Provider, { value:
|
|
276
|
+
/* @__PURE__ */ e(q.Provider, { value: h, children: i }),
|
|
247
277
|
/* @__PURE__ */ e(
|
|
248
278
|
L,
|
|
249
279
|
{
|
|
250
|
-
images:
|
|
251
|
-
visible:
|
|
252
|
-
onClose:
|
|
253
|
-
activeIndex:
|
|
280
|
+
images: m,
|
|
281
|
+
visible: n,
|
|
282
|
+
onClose: w,
|
|
283
|
+
activeIndex: u,
|
|
254
284
|
onIndexChange: c,
|
|
255
285
|
rotatable: !0,
|
|
256
286
|
scalable: !0,
|