{"_id":"react-viewer@3.2.6","bugs":{"url":"https://github.com/infeng/react-viewer/issues"},"dist":{"shasum":"a0124dc5cf6e67e8b025a208f4d72debbaa503a9","tarball":"http://registry-npm.ywwl.com/react-viewer/download/react-viewer-3.2.6.tgz","fileCount":14,"integrity":"sha512-yWulVU9p7JPbj+Ren6R9y8v5MWVyoyWf9HcWakEmD6ztZN6DeIXED1Ijk8xtPNlRqTATeENlRLsJbHvGSgjZ2Q==","signatures":[{"sig":"MEQCIGvWm4F5KYaAtbRsfEw3axZLQljJYHMCITNYUcBcr47mAiB1PY1EH1Y/RbJAekoPx9X72iMX2sk8efIQTPHzcE911g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCpV2fUTYr5aSvGx6/GL2IucdscVFYatg09a3GmF0GfUwIhAPVbcnNwxdHNQmnqZIe/WHj4nuATBPelXyqemIYVHDFb"}],"unpackedSize":64765,"size":23347,"noattachment":false,"key":"/react-viewer/-/react-viewer-3.2.6.tgz"},"jest":{"globals":{"ts-jest":{"tsConfig":"tsconfig.test.json"}},"testRegex":"(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$","transform":{"\\.js$":"babel-jest","^.+\\.tsx?$":"ts-jest"},"collectCoverage":true,"moduleNameMapper":{"\\.(css|less)$":"identity-obj-proxy","^.+\\.(jpg|jpeg)$":"jest-static-stubs/jpg"},"coverageDirectory":"./coverage/","moduleDirectories":["node_modules"],"snapshotSerializers":["enzyme-to-json/serializer"],"moduleFileExtensions":["ts","tsx","js","jsx"]},"main":"dist/index","name":"react-viewer","_from":"file:/tmp/react-viewer-release-326/react-viewer-3.2.6.tgz","author":{"name":"infeng"},"license":"MIT","scripts":{"doc":"webpack --config webpack.config.doc.js","pub":"npm publish","lint":"tslint -c tslint.json \"src/**/*.ts\" \"src/**/*.tsx\"","test":"jest","build":"webpack --config webpack.config.prop.js && npm run build:types","start":"webpack-dev-server","verify":"npm test -- --runInBand && npm run lint && npm run build && npm run check:package-export && npm run doc && npm run build:ssr && npm run check:ssr-hydration && npm run check:multipart && npm run audit:critical && npm pack --dry-run","build:ssr":"npm --prefix ssr-test ci --ignore-scripts && npm --prefix ssr-test run build","build:types":"node -e \"require('fs-extra').removeSync('lib')\" && tsc -p tsconfig.build.json","build:analyze":"ANALYZE=true webpack --config webpack.config.prop.js","audit:critical":"npm audit --audit-level=critical && npm --prefix ssr-test audit --audit-level=critical","prepublishOnly":"npm run build","check:multipart":"node scripts/check-multipart.js","check:ssr-hydration":"node scripts/check-ssr-hydration.js","check:package-export":"node scripts/check-package-export.js"},"typings":"lib/index.d.ts","version":"3.2.6","_npmUser":{"name":"infeng","email":"fzhihao@outlook.com"},"homepage":"https://github.com/infeng/react-viewer#readme","keywords":["react","image","viewer"],"_resolved":"/tmp/react-viewer-release-326/react-viewer-3.2.6.tgz","overrides":{"request":{"form-data":"2.5.6"}},"_integrity":"sha512-yWulVU9p7JPbj+Ren6R9y8v5MWVyoyWf9HcWakEmD6ztZN6DeIXED1Ijk8xtPNlRqTATeENlRLsJbHvGSgjZ2Q==","pre-commit":["lint"],"repository":{"url":"git+https://github.com/infeng/react-viewer.git","type":"git"},"_npmVersion":"11.13.0","description":"react image viewer","directories":{},"maintainers":[{"name":"infeng","email":"fzhihao@outlook.com"}],"_nodeVersion":"24.16.0","dependencies":{"classnames":"^2.2.5"},"_hasShrinkwrap":false,"devDependencies":{"antd":"^3.24.1","gulp":"^4.0.2","jest":"^24.9.0","less":"^3.10.3","jsdom":"^11.12.0","react":"^16.10.2","enzyme":"^3.10.0","merge2":"^1.3.0","tslint":"^5.18.0","ts-jest":"^24.3.0","webpack":"^4.47.0","fs-extra":"^8.1.0","through2":"^2.0.1","react-dom":"^16.10.2","ts-loader":"^6.2.0","babel-jest":"^24.9.0","css-loader":"^3.2.0","pre-commit":"^1.1.3","typescript":"^3.6.4","url-loader":"^2.2.0","@babel/core":"^7.29.7","@types/jest":"^24.9.1","@types/node":"^12.11.1","file-loader":"^4.2.0","less-loader":"^5.0.0","webpack-cli":"^3.3.9","@types/react":"^16.9.1","autoprefixer":"^9.6.5","babel-loader":"^8.0.6","style-loader":"^1.0.0","webpack-chain":"^6.0.0","enzyme-to-json":"^3.3.4","postcss-loader":"^3.0.0","gulp-typescript":"^5.0.1","@types/react-dom":"^16.8.5","@babel/preset-env":"^7.6.3","jest-static-stubs":"0.0.1","identity-obj-proxy":"^3.0.0","webpack-dev-server":"^3.8.2","@babel/preset-react":"^7.6.3","babel-plugin-import":"^1.2.1","html-webpack-plugin":"^4.5.2","wolfy87-eventemitter":"^5.2.5","jest-environment-jsdom":"^24.9.0","enzyme-adapter-react-16":"^1.14.0","mini-css-extract-plugin":"^0.9.0","webpack-bundle-analyzer":"^4.10.2","jest-environment-jsdom-global":"^2.0.4","@babel/plugin-transform-object-assign":"^7.2.0","@babel/plugin-proposal-object-rest-spread":"^7.6.2"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/react-viewer_3.2.6_1789722351389_0.3620169211952957"},"readme":"# react-viewer\n\n[![NPM version][npm-image]][npm-url] [![CI](https://github.com/infeng/react-viewer/actions/workflows/ci.yml/badge.svg)](https://github.com/infeng/react-viewer/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/infeng/react-viewer/branch/master/graph/badge.svg)](https://codecov.io/gh/infeng/react-viewer)\n> react image viewer.\n\n## Introduction\n\nBecause I can`t be comfortable using [viewerjs](https://github.com/fengyuanchen/viewerjs) in react, so I created react-viewer to replace it.\n\n## Installation\n\n> react >= 16.8.0 | react-dom >= 16.8.0\n\n```bash\nnpm install react-viewer --save\n```\n\n## Usage\n\n```javascript\nimport * as React from 'react';\nimport Viewer from 'react-viewer';\n\nfunction App() {\n  const [ visible, setVisible ] = React.useState(false);\n\n  return (\n    <div>\n      <button onClick={() => { setVisible(true); } }>show</button>\n      <Viewer\n      visible={visible}\n      onClose={() => { setVisible(false); } }\n      images={[{src: '', alt: ''}]}\n      />\n    </div>\n  );\n}\n```\n\n## Next.js (client-only)\n\n`react-viewer` uses browser DOM APIs and must be loaded with SSR disabled. In the\nNext.js App Router, put the dynamic import in a Client Component:\n\n```tsx\n'use client';\n\nimport dynamic from 'next/dynamic';\n\nconst ReactViewer = dynamic(\n  () => import('react-viewer').then((mod) => mod.default),\n  { ssr: false },\n);\n\nexport default function Viewer() {\n  return (\n    <ReactViewer\n      visible={true}\n      onClose={() => {}}\n      images={[{src: ''}]}\n    />\n  );\n}\n```\n\nThe Pages Router uses the same dynamic import but does not require the\n`'use client'` directive. Direct server rendering is not supported in `3.x`.\n\n## Props\n\n| props        | type         | default | description                 | required |\n|--------------|--------------|---------|-----------------------------|----------|\n| visible      | boolean      |  false  | Viewer visible             | true |\n| onClose      | function       |  -      | Specify a function that will be called when Visible close   | true |\n| images       | [ImageDecorator](#imagedecorator)[]     | []      | image source array | true  |\n| activeIndex  | number       | 0       | active image index | false |\n| zIndex       | number       | 1000    | Viewer css z-index | false |\n| container    | HTMLElement  | null    | set parent node(inline mode) | false |\n| drag         | boolean      | true    | whether to drag image | false |\n| attribute    | boolean      | true    | whether to show image attribute | false |\n| zoomable     | boolean      | true    | whether to show 'zoom' button | false |\n| rotatable    | boolean      | true    | whether to show 'rotate' button | false |\n| scalable     | boolean      | true    | whether to show 'scale' button | false |\n| onMaskClick  | (e) => void  |   -     | callback function when mask is clicked | false |\n| downloadable     | boolean      |  false  | whether to show 'download' | false |\n| noClose      | boolean      |  false  | to not render close button | false |\n| noNavbar     | boolean      |  false  | to not render the navbar | false |\n| noToolbar    | boolean      |  false  | to not render the toolbar | false |\n| noImgDetails | boolean      |  false  | to not render image detail (WxH) | false |\n| noFooter     | boolean      |  false  | to not render the entire footer | false |\n| changeable   | boolean      |  true   | whether to show change buttons  | false |\n| customToolbar | (defaultToolbarConfigs: [ToolbarConfig](#toolbarconfig)[]) => ToolbarConfig[] | - | customize the toolbar | false |\n| zoomSpeed    | number       | 0.05    | zoom speed | false |\n| defaultSize    | [ViewerImageSize](#viewerimagesize) | - | default image size | false |\n| defaultImg    | [ViewerDefaultImg](#viewerdefaultimg) | - | fallback shown when an image fails to load | false |\n| disableKeyboardSupport | boolean | false | disable keyboard support | false |\n| noResetZoomAfterChange | boolean | false | preserve zoom after image change | false |\n| noLimitInitializationSize | boolean | false | no limit image initialization size | false |\n| defaultScale | number | 1 | set default scale | false |\n| onChange | (activeImage: [ImageDecorator](#imagedecorator), index: number) => void | - | callback when image change | false |\n| loop         | boolean      |  true   | whether enable image loop | false |\n| disableMouseZoom   | boolean      |  false   | whether disable mouse zoom | false |\n| downloadInNewWindow | boolean | false | whether to download in a new window | false |\n| className   | string    |  -  | customized CSS class | false |\n| showTotal   | boolean    |  true  | whether to display the total number and range | false |\n| totalName | string | 'of' | total image separator name | false | \n| maxScale   | number    |  -  | maximum scaling | false |\n| minScale   | number    |  0.1  | minimum scaling | false |\n| exportFileName | string | 'exportFile' | customize download's filename | false |\n\n### ImageDecorator\n\n| props       | type         | default | description                 | required |\n|-------------|--------------|---------|-----------------------------|----------|\n| src  | string  |  -  | image source | true |\n| alt  | string  |  -  | image description | false |\n| downloadUrl  | string  |  -  | image download URL | false |\n| defaultSize  | [ViewerImageSize](#viewerimagesize)  |  -  | image size | false |\n\n### ViewerImageSize\n\n| props       | type         | default | description                 | required |\n|-------------|--------------|---------|-----------------------------|----------|\n| width  | number  |  -  | image width | true |\n| height  | number  |  -  | image height | true |\n\n### ViewerDefaultImg\n\n| props       | type         | default | description                 | required |\n|-------------|--------------|---------|-----------------------------|----------|\n| src  | string  |  -  | image source | true |\n| width  | number  |  -  | image width | false |\n| height  | number  |  -  | image height | false |\n\n### ToolbarConfig\n\n| props       | type         | default | description                 | required |\n|-------------|--------------|---------|-----------------------------|----------|\n| key  | string  |  -  | tool key | true |\n| render  | React.ReactNode  |  -  | tool render | false |\n| onClick  | function  |  -  | callback function when action is clicked | false |\n\nTo keep only selected built-in controls, filter the configurations passed to\n`customToolbar`. The `key` values are stable and avoid depending on numeric\n`actionType` values:\n\n```tsx\n<Viewer\n  visible={visible}\n  onClose={() => setVisible(false)}\n  images={images}\n  customToolbar={(toolbars) =>\n    toolbars.filter(({ key }) => key === 'zoomIn' || key === 'zoomOut')\n  }\n/>\n```\n\nThe returned array also controls the left-to-right order. For example, put\nzoom out before zoom in while preserving the remaining controls and their\nbuilt-in actions:\n\n```tsx\n<Viewer\n  visible={visible}\n  onClose={() => setVisible(false)}\n  images={images}\n  customToolbar={(toolbars) => [\n    ...toolbars.filter(({ key }) => key === 'zoomOut'),\n    ...toolbars.filter(({ key }) => key === 'zoomIn'),\n    ...toolbars.filter(({ key }) => key !== 'zoomOut' && key !== 'zoomIn'),\n  ]}\n/>\n```\n\nKeep the original configuration objects so their `actionType` values are\npreserved. Options such as `zoomable={false}` still hide the corresponding\ncontrols.\n\n### Localizing the image counter\n\nUse `totalName` to change the separator between the current image number and\nthe total. For example, this displays `1 / 3` for the first of three images:\n\n```tsx\n<Viewer\n  visible={visible}\n  onClose={() => setVisible(false)}\n  images={images}\n  totalName=\"/\"\n/>\n```\n\n`totalName=\"de\"` displays `1 de 3`. The counter is visible by default;\n`showTotal={false}` hides it. It is part of the image attribute row, so\n`attribute={false}`, `noToolbar`, or `noFooter` also hides it.\n\n## Keyboard support\n\n- `Esc`: Close viewer.\n- `←`: View the previous image.\n- `→`: View the next image.\n- `↑`: Zoom in the image.\n- `↓`: Zoom out the image.\n- `Ctrl + 1`: Reset the image.\n- `Ctrl + ←`: Rotate left the image.\n- `Ctrl + →`: Rotate right the image.\n\n## License\n\nMIT\n\n[npm-image]: https://badge.fury.io/js/react-viewer.svg\n[npm-url]: https://npmjs.org/package/react-viewer\n","publish_time":1789722351488,"_cnpm_publish_time":1789722351488,"dist-tags":{"latest":"3.2.6"}}