{"name":"react-viewer","version":"3.2.4","keywords":["react","image","viewer"],"author":{"name":"infeng"},"license":"MIT","_id":"react-viewer@3.2.4","maintainers":[{"name":"infeng","email":"fzhihao@outlook.com"}],"homepage":"https://github.com/infeng/react-viewer#readme","bugs":{"url":"https://github.com/infeng/react-viewer/issues"},"dist":{"shasum":"85e6224c4dc28a1d638d050385521a3a7f0ff5a7","tarball":"http://registry-npm.ywwl.com/react-viewer/download/react-viewer-3.2.4.tgz","fileCount":14,"integrity":"sha512-Dm+zbDR2449UiOpAA2cfsWpOaq/2xSa1oj66t9Gpo50rHjVEkOqScW7FtAQycY3xqZtpJfVUti+psQUN/pHipA==","signatures":[{"sig":"MEUCICavFetqQSVyek5xaaVczFEynq0jBo7q8n70UFgBxK2YAiEAi2NgXAY3oMkPoHZXoShYI8QHjfEpUFyHMUwHQadxss4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":57945,"size":21596,"noattachment":false,"key":"/react-viewer/-/react-viewer-3.2.4.tgz"},"jest":{"globals":{"ts-jest":{"tsConfigFile":"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","gitHead":"b13d165e6129f8a8b987ada32cf765f7a37c2359","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","deploy":"gh-pages -d pages-build","verify":"npm test -- --runInBand && npm run lint && npm run build && npm run check:package-export && npm run doc && npm run build:ssr && npm pack --dry-run","build:ssr":"npm --prefix ssr-test ci --ignore-scripts && npm --prefix ssr-test run build","predeploy":"npm run doc","build:types":"node -e \"require('fs-extra').removeSync('lib')\" && tsc -p tsconfig.build.json","build:analyze":"ANALYZE=true webpack --config webpack.config.prop.js","prepublishOnly":"npm run build","check:package-export":"node scripts/check-package-export.js"},"typings":"lib/index.d.ts","_npmUser":{"name":"infeng","email":"fzhihao@outlook.com"},"pre-commit":["lint"],"repository":{"url":"git+https://github.com/infeng/react-viewer.git","type":"git"},"_npmVersion":"11.13.0","description":"react image viewer","directories":{},"_nodeVersion":"24.16.0","dependencies":{"classnames":"^2.2.5"},"_hasShrinkwrap":false,"devDependencies":{"antd":"^3.24.1","gulp":"^4.0.2","jest":"^23.5.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":"^23.1.3","webpack":"^4.47.0","fs-extra":"^8.1.0","gh-pages":"^2.1.1","through2":"^2.0.1","react-dom":"^16.10.2","ts-loader":"^6.2.0","babel-jest":"^23.4.2","css-loader":"^3.2.0","pre-commit":"^1.1.3","typescript":"^3.6.4","url-loader":"^2.2.0","@babel/core":"^7.6.4","@types/jest":"^23.3.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","react-test-render":"^1.1.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":"^23.4.0","enzyme-adapter-react-16":"^1.14.0","mini-css-extract-plugin":"^0.9.0","webpack-bundle-analyzer":"^3.6.0","jest-environment-jsdom-global":"^1.1.0","@babel/plugin-transform-object-assign":"^7.2.0","@babel/plugin-proposal-object-rest-spread":"^7.6.2"},"_npmOperationalInternal":{"tmp":"tmp/react-viewer_3.2.4_1787283526583_0.1286531075498314","host":"s3://npm-registry-packages-npm-production"},"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":1787283526739,"_cnpm_publish_time":1787283526739,"dist-tags":{"latest":"3.2.6"}}