@react-pdf-viewer/properties
Advanced tools
Comparing version 2.6.1 to 2.7.0
@@ -30,7 +30,2 @@ 'use strict'; | ||
var InfoIcon = function () { | ||
return (React__namespace.createElement(core.Icon, { size: 16 }, | ||
React__namespace.createElement("path", { d: "M12,1.001c6.075,0,11,4.925,11,11s-4.925,11-11,11s-11-4.925-11-11S5.925,1.001,12,1.001z\n M14.5,17.005H13\n c-0.552,0-1-0.448-1-1v-6.5c0-0.276-0.224-0.5-0.5-0.5H10\n M11.745,6.504L11.745,6.504\n M11.745,6.5c-0.138,0-0.25,0.112-0.25,0.25\n S11.607,7,11.745,7s0.25-0.112,0.25-0.25S11.883,6.5,11.745,6.5" }))); | ||
}; | ||
/*! ***************************************************************************** | ||
@@ -139,3 +134,3 @@ Copyright (c) Microsoft Corporation. | ||
var fileName = function (url) { | ||
var getFileName = function (url) { | ||
var str = url.split('/').pop(); | ||
@@ -145,3 +140,3 @@ return str ? str.split('#')[0].split('?')[0] : url; | ||
var fileSize = function (bytes) { | ||
var getFileSize = function (bytes) { | ||
var sufixes = ['B', 'kB', 'MB', 'GB', 'TB']; | ||
@@ -153,3 +148,3 @@ var i = Math.floor(Math.log(bytes) / Math.log(1024)); | ||
var PropertiesModal = function (_a) { | ||
var doc = _a.doc, fileName$1 = _a.fileName, onToggle = _a.onToggle; | ||
var doc = _a.doc, fileName = _a.fileName, onToggle = _a.onToggle; | ||
var l10n = React__namespace.useContext(core.LocalizationContext); | ||
@@ -162,4 +157,4 @@ var formatDate = function (input) { | ||
React__namespace.createElement("div", { className: "rpv-properties__modal-section" }, | ||
React__namespace.createElement(PropertyItem, { label: (l10n && l10n.properties ? l10n.properties.fileName : 'File name'), value: data.fileName || fileName(fileName$1) }), | ||
React__namespace.createElement(PropertyItem, { label: (l10n && l10n.properties ? l10n.properties.fileSize : 'File size'), value: fileSize(data.length) })), | ||
React__namespace.createElement(PropertyItem, { label: (l10n && l10n.properties ? l10n.properties.fileName : 'File name'), value: data.fileName || getFileName(fileName) }), | ||
React__namespace.createElement(PropertyItem, { label: (l10n && l10n.properties ? l10n.properties.fileSize : 'File size'), value: getFileSize(data.length) })), | ||
React__namespace.createElement(core.Separator, null), | ||
@@ -185,2 +180,5 @@ React__namespace.createElement("div", { className: "rpv-properties__modal-section" }, | ||
var InfoIcon = function () { return (React__namespace.createElement(core.Icon, { size: 16 }, | ||
React__namespace.createElement("path", { d: "M12,1.001c6.075,0,11,4.925,11,11s-4.925,11-11,11s-11-4.925-11-11S5.925,1.001,12,1.001z\n M14.5,17.005H13\n c-0.552,0-1-0.448-1-1v-6.5c0-0.276-0.224-0.5-0.5-0.5H10\n M11.745,6.504L11.745,6.504\n M11.745,6.5c-0.138,0-0.25,0.112-0.25,0.25\n S11.607,7,11.745,7s0.25-0.112,0.25-0.25S11.883,6.5,11.745,6.5" }))); }; | ||
var TOOLTIP_OFFSET = { left: 0, top: 8 }; | ||
@@ -191,3 +189,3 @@ var ShowPropertiesButton = function (_a) { | ||
var label = l10n && l10n.properties ? l10n.properties.showProperties : 'Show properties'; | ||
return (React__namespace.createElement(core.Tooltip, { position: core.Position.BottomCenter, target: React__namespace.createElement(core.MinimalButton, { onClick: onClick }, | ||
return (React__namespace.createElement(core.Tooltip, { ariaControlsSuffix: "properties", position: core.Position.BottomCenter, target: React__namespace.createElement(core.MinimalButton, { ariaLabel: label, onClick: onClick }, | ||
React__namespace.createElement(InfoIcon, null)), content: function () { return label; }, offset: TOOLTIP_OFFSET })); | ||
@@ -216,3 +214,3 @@ }; | ||
var render = children || defaultChildren; | ||
return currentDoc ? (React__namespace.createElement(core.Modal, { target: function (toggle) { | ||
return currentDoc ? (React__namespace.createElement(core.Modal, { ariaControlsSuffix: "properties", target: function (toggle) { | ||
return render({ | ||
@@ -219,0 +217,0 @@ onClick: toggle, |
@@ -1,1 +0,15 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@react-pdf-viewer/core");function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(e),o=function(){return n.createElement(t.Icon,{size:16},n.createElement("path",{d:"M12,1.001c6.075,0,11,4.925,11,11s-4.925,11-11,11s-11-4.925-11-11S5.925,1.001,12,1.001z\n M14.5,17.005H13\n c-0.552,0-1-0.448-1-1v-6.5c0-0.276-0.224-0.5-0.5-0.5H10\n M11.745,6.504L11.745,6.504\n M11.745,6.5c-0.138,0-0.25,0.112-0.25,0.25\n S11.607,7,11.745,7s0.25-0.112,0.25-0.25S11.883,6.5,11.745,6.5"}))},a=function(){return(a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},i=function(e){var r=e.doc,o=e.render,a=n.useState(),i=a[0],l=a[1];return n.useEffect((function(){r.getMetadata().then((function(e){return Promise.resolve(e)})).then((function(e){return r.getDownloadInfo().then((function(t){return Promise.resolve({fileName:e.contentDispositionFilename||"",info:e.info,length:t.length})}))})).then((function(e){l(e)}))}),[]),i?o(i):n.createElement("div",{className:"rpv-properties__loader"},n.createElement(t.Spinner,null))},l=function(e){var t=e.label,r=e.value;return n.createElement("dl",{className:"rpv-properties__item"},n.createElement("dt",{className:"rpv-properties__item-label"},t,":"),n.createElement("dd",{className:"rpv-properties__item-value"},r||"-"))},c=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"),u=function(e,t,r,n){var o=parseInt(e,10);return o>=t&&o<=r?o:n},p=function(e){var r=e.doc,o=e.fileName,a=e.onToggle,p=n.useContext(t.LocalizationContext),s=function(e){var t=function(e){var t=c.exec(e);if(!t)return null;var r=parseInt(t[1],10),n=u(t[2],1,12,1)-1,o=u(t[3],1,31,1),a=u(t[4],0,23,0),i=u(t[5],0,59,0),l=u(t[6],0,59,0),p=t[7]||"Z",s=u(t[8],0,23,0),f=u(t[9],0,59,0);switch(p){case"-":a+=s,i+=f;break;case"+":a-=s,i-=f}return new Date(Date.UTC(r,n,o,a,i,l))}(e);return t?t.toLocaleDateString()+", "+t.toLocaleTimeString():""};return n.createElement("div",{className:"rpv-properties__modal"},n.createElement(i,{doc:r,render:function(e){return n.createElement(n.Fragment,null,n.createElement("div",{className:"rpv-properties__modal-section"},n.createElement(l,{label:p&&p.properties?p.properties.fileName:"File name",value:e.fileName||(c=o,u=c.split("/").pop(),u?u.split("#")[0].split("?")[0]:c)}),n.createElement(l,{label:p&&p.properties?p.properties.fileSize:"File size",value:(a=e.length,i=Math.floor(Math.log(a)/Math.log(1024)),(a/Math.pow(1024,i)).toFixed(2)+" "+["B","kB","MB","GB","TB"][i])})),n.createElement(t.Separator,null),n.createElement("div",{className:"rpv-properties__modal-section"},n.createElement(l,{label:p&&p.properties?p.properties.title:"Title",value:e.info.Title}),n.createElement(l,{label:p&&p.properties?p.properties.author:"Author",value:e.info.Author}),n.createElement(l,{label:p&&p.properties?p.properties.subject:"Subject",value:e.info.Subject}),n.createElement(l,{label:p&&p.properties?p.properties.keywords:"Keywords",value:e.info.Keywords}),n.createElement(l,{label:p&&p.properties?p.properties.creator:"Creator",value:e.info.Creator}),n.createElement(l,{label:p&&p.properties?p.properties.creationDate:"Creation date",value:s(e.info.CreationDate)}),n.createElement(l,{label:p&&p.properties?p.properties.modificationDate:"Modification date",value:s(e.info.ModDate)})),n.createElement(t.Separator,null),n.createElement("div",{className:"rpv-properties__modal-section"},n.createElement(l,{label:p&&p.properties?p.properties.pdfProducer:"PDF producer",value:e.info.Producer}),n.createElement(l,{label:p&&p.properties?p.properties.pdfVersion:"PDF version",value:e.info.PDFFormatVersion}),n.createElement(l,{label:p&&p.properties?p.properties.pageCount:"Page count",value:""+r.numPages})));var a,i,c,u}}),n.createElement("div",{className:"rpv-properties__modal-footer"},n.createElement(t.Button,{onClick:a},p&&p.properties?p.properties.close:"Close")))},s={left:0,top:8},f=function(e){var r=e.onClick,a=n.useContext(t.LocalizationContext),i=a&&a.properties?a.properties.showProperties:"Show properties";return n.createElement(t.Tooltip,{position:t.Position.BottomCenter,target:n.createElement(t.MinimalButton,{onClick:r},n.createElement(o,null)),content:function(){return i},offset:s})},m=function(e){var r=e.children,o=e.store,i=function(e){var t=n.useState(e.get("doc")),r=t[0],o=t[1],a=function(e){o(e)};return n.useEffect((function(){return e.subscribe("doc",a),function(){e.unsubscribe("doc",a)}}),[]),{currentDoc:r}}(o).currentDoc,l=o.get("fileName")||"",c=r||function(e){return n.createElement(f,a({},e))};return i?n.createElement(t.Modal,{target:function(e){return c({onClick:e})},content:function(e){return n.createElement(p,{doc:i,fileName:l,onToggle:e})},closeOnClickOutside:!0,closeOnEscape:!0}):n.createElement(n.Fragment,null)},d=function(e){var r=e.onClick,a=n.useContext(t.LocalizationContext),i=a&&a.properties?a.properties.showProperties:"Show properties";return n.createElement(t.MenuItem,{icon:n.createElement(o,null),onClick:r},i)};exports.InfoIcon=o,exports.propertiesPlugin=function(){var e=n.useMemo((function(){return t.createStore({fileName:""})}),[]),r=function(t){return n.createElement(m,a({},t,{store:e}))};return{onDocumentLoad:function(t){e.update("doc",t.doc)},onViewerStateChange:function(t){return e.update("fileName",t.file.name),t},ShowProperties:r,ShowPropertiesButton:function(){return n.createElement(m,{store:e})},ShowPropertiesMenuItem:function(e){return n.createElement(r,null,(function(e){return n.createElement(d,a({},e))}))}}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@react-pdf-viewer/core");function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(e),o=function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},a=function(e){var r=e.doc,o=e.render,a=n.useState(),i=a[0],l=a[1];return n.useEffect((function(){r.getMetadata().then((function(e){return Promise.resolve(e)})).then((function(e){return r.getDownloadInfo().then((function(t){return Promise.resolve({fileName:e.contentDispositionFilename||"",info:e.info,length:t.length})}))})).then((function(e){l(e)}))}),[]),i?o(i):n.createElement("div",{className:"rpv-properties__loader"},n.createElement(t.Spinner,null))},i=function(e){var t=e.label,r=e.value;return n.createElement("dl",{className:"rpv-properties__item"},n.createElement("dt",{className:"rpv-properties__item-label"},t,":"),n.createElement("dd",{className:"rpv-properties__item-value"},r||"-"))},l=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"),c=function(e,t,r,n){var o=parseInt(e,10);return o>=t&&o<=r?o:n},u=function(e){var r=e.doc,o=e.fileName,u=e.onToggle,p=n.useContext(t.LocalizationContext),s=function(e){var t=function(e){var t=l.exec(e);if(!t)return null;var r=parseInt(t[1],10),n=c(t[2],1,12,1)-1,o=c(t[3],1,31,1),a=c(t[4],0,23,0),i=c(t[5],0,59,0),u=c(t[6],0,59,0),p=t[7]||"Z",s=c(t[8],0,23,0),f=c(t[9],0,59,0);switch(p){case"-":a+=s,i+=f;break;case"+":a-=s,i-=f}return new Date(Date.UTC(r,n,o,a,i,u))}(e);return t?t.toLocaleDateString()+", "+t.toLocaleTimeString():""};return n.createElement("div",{className:"rpv-properties__modal"},n.createElement(a,{doc:r,render:function(e){return n.createElement(n.Fragment,null,n.createElement("div",{className:"rpv-properties__modal-section"},n.createElement(i,{label:p&&p.properties?p.properties.fileName:"File name",value:e.fileName||(c=o,u=c.split("/").pop(),u?u.split("#")[0].split("?")[0]:c)}),n.createElement(i,{label:p&&p.properties?p.properties.fileSize:"File size",value:(a=e.length,l=Math.floor(Math.log(a)/Math.log(1024)),(a/Math.pow(1024,l)).toFixed(2)+" "+["B","kB","MB","GB","TB"][l])})),n.createElement(t.Separator,null),n.createElement("div",{className:"rpv-properties__modal-section"},n.createElement(i,{label:p&&p.properties?p.properties.title:"Title",value:e.info.Title}),n.createElement(i,{label:p&&p.properties?p.properties.author:"Author",value:e.info.Author}),n.createElement(i,{label:p&&p.properties?p.properties.subject:"Subject",value:e.info.Subject}),n.createElement(i,{label:p&&p.properties?p.properties.keywords:"Keywords",value:e.info.Keywords}),n.createElement(i,{label:p&&p.properties?p.properties.creator:"Creator",value:e.info.Creator}),n.createElement(i,{label:p&&p.properties?p.properties.creationDate:"Creation date",value:s(e.info.CreationDate)}),n.createElement(i,{label:p&&p.properties?p.properties.modificationDate:"Modification date",value:s(e.info.ModDate)})),n.createElement(t.Separator,null),n.createElement("div",{className:"rpv-properties__modal-section"},n.createElement(i,{label:p&&p.properties?p.properties.pdfProducer:"PDF producer",value:e.info.Producer}),n.createElement(i,{label:p&&p.properties?p.properties.pdfVersion:"PDF version",value:e.info.PDFFormatVersion}),n.createElement(i,{label:p&&p.properties?p.properties.pageCount:"Page count",value:""+r.numPages})));var a,l,c,u}}),n.createElement("div",{className:"rpv-properties__modal-footer"},n.createElement(t.Button,{onClick:u},p&&p.properties?p.properties.close:"Close")))},p=function(){return n.createElement(t.Icon,{size:16},n.createElement("path",{d:"M12,1.001c6.075,0,11,4.925,11,11s-4.925,11-11,11s-11-4.925-11-11S5.925,1.001,12,1.001z\n M14.5,17.005H13\n c-0.552,0-1-0.448-1-1v-6.5c0-0.276-0.224-0.5-0.5-0.5H10\n M11.745,6.504L11.745,6.504\n M11.745,6.5c-0.138,0-0.25,0.112-0.25,0.25\n S11.607,7,11.745,7s0.25-0.112,0.25-0.25S11.883,6.5,11.745,6.5"}))},s={left:0,top:8},f=function(e){var r=e.onClick,o=n.useContext(t.LocalizationContext),a=o&&o.properties?o.properties.showProperties:"Show properties";return n.createElement(t.Tooltip,{ariaControlsSuffix:"properties",position:t.Position.BottomCenter,target:n.createElement(t.MinimalButton,{ariaLabel:a,onClick:r},n.createElement(p,null)),content:function(){return a},offset:s})},m=function(e){var r=e.children,a=e.store,i=function(e){var t=n.useState(e.get("doc")),r=t[0],o=t[1],a=function(e){o(e)};return n.useEffect((function(){return e.subscribe("doc",a),function(){e.unsubscribe("doc",a)}}),[]),{currentDoc:r}}(a).currentDoc,l=a.get("fileName")||"",c=r||function(e){return n.createElement(f,o({},e))};return i?n.createElement(t.Modal,{ariaControlsSuffix:"properties",target:function(e){return c({onClick:e})},content:function(e){return n.createElement(u,{doc:i,fileName:l,onToggle:e})},closeOnClickOutside:!0,closeOnEscape:!0}):n.createElement(n.Fragment,null)},d=function(e){var r=e.onClick,o=n.useContext(t.LocalizationContext),a=o&&o.properties?o.properties.showProperties:"Show properties";return n.createElement(t.MenuItem,{icon:n.createElement(p,null),onClick:r},a)}; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */exports.InfoIcon=p,exports.propertiesPlugin=function(){var e=n.useMemo((function(){return t.createStore({fileName:""})}),[]),r=function(t){return n.createElement(m,o({},t,{store:e}))};return{onDocumentLoad:function(t){e.update("doc",t.doc)},onViewerStateChange:function(t){return e.update("fileName",t.file.name),t},ShowProperties:r,ShowPropertiesButton:function(){return n.createElement(m,{store:e})},ShowPropertiesMenuItem:function(e){return n.createElement(r,null,(function(e){return n.createElement(d,o({},e))}))}}}; |
@@ -10,4 +10,5 @@ /** | ||
import * as React from 'react'; | ||
import { Plugin } from '@react-pdf-viewer/core'; | ||
import type { Plugin } from '@react-pdf-viewer/core'; | ||
// Types | ||
export interface ShowPropertiesMenuItemProps { | ||
@@ -17,2 +18,6 @@ onClick: () => void; | ||
export interface ShowPropertiesProps { | ||
children?: (props: RenderShowPropertiesProps) => React.ReactElement; | ||
} | ||
export interface RenderShowPropertiesProps { | ||
@@ -22,6 +27,3 @@ onClick(): void; | ||
export interface ShowPropertiesProps { | ||
children?: (props: RenderShowPropertiesProps) => React.ReactElement; | ||
} | ||
// Plugin | ||
export interface PropertiesPlugin extends Plugin { | ||
@@ -35,2 +37,3 @@ ShowProperties: (props: ShowPropertiesProps) => React.ReactElement; | ||
// Components | ||
export class InfoIcon extends React.Component {} |
{ | ||
"name": "@react-pdf-viewer/properties", | ||
"version": "2.6.1", | ||
"version": "2.7.0", | ||
"description": "A React component to view a PDF document", | ||
@@ -36,3 +36,3 @@ "license": "https://react-pdf-viewer.dev/license", | ||
"dependencies": { | ||
"@react-pdf-viewer/core": "2.6.1" | ||
"@react-pdf-viewer/core": "2.7.0" | ||
}, | ||
@@ -52,3 +52,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "500247f24514da033bf92266f6903decaffebb68" | ||
"gitHead": "331789d286847ac1c8a272c9df82bdab63ba4406" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22640
302
+ Added@react-pdf-viewer/core@2.7.0(transitive)
- Removed@react-pdf-viewer/core@2.6.1(transitive)
Updated@react-pdf-viewer/core@2.7.0