@react-pdf-viewer/full-screen
Advanced tools
Comparing version 3.11.0 to 3.12.0
@@ -66,61 +66,2 @@ 'use strict'; | ||
var Api; | ||
(function (Api) { | ||
Api[Api["ExitFullScreen"] = 0] = "ExitFullScreen"; | ||
Api[Api["FullScreenChange"] = 1] = "FullScreenChange"; | ||
Api[Api["FullScreenElement"] = 2] = "FullScreenElement"; | ||
Api[Api["FullScreenEnabled"] = 3] = "FullScreenEnabled"; | ||
Api[Api["RequestFullScreen"] = 4] = "RequestFullScreen"; | ||
})(Api || (Api = {})); | ||
var defaultVendor = { | ||
ExitFullScreen: 'exitFullscreen', | ||
FullScreenChange: 'fullscreenchange', | ||
FullScreenElement: 'fullscreenElement', | ||
FullScreenEnabled: 'fullscreenEnabled', | ||
RequestFullScreen: 'requestFullscreen', | ||
}; | ||
var webkitVendor = { | ||
ExitFullScreen: 'webkitExitFullscreen', | ||
FullScreenChange: 'webkitfullscreenchange', | ||
FullScreenElement: 'webkitFullscreenElement', | ||
FullScreenEnabled: 'webkitFullscreenEnabled', | ||
RequestFullScreen: 'webkitRequestFullscreen', | ||
}; | ||
var msVendor = { | ||
ExitFullScreen: 'msExitFullscreen', | ||
FullScreenChange: 'msFullscreenChange', | ||
FullScreenElement: 'msFullscreenElement', | ||
FullScreenEnabled: 'msFullscreenEnabled', | ||
RequestFullScreen: 'msRequestFullscreen', | ||
}; | ||
var isBrowser = typeof window !== 'undefined'; | ||
var vendor = isBrowser | ||
? (Api.FullScreenEnabled in document && defaultVendor) || | ||
(webkitVendor.FullScreenEnabled in document && webkitVendor) || | ||
(msVendor.FullScreenEnabled in document && msVendor) || | ||
defaultVendor | ||
: defaultVendor; | ||
var isFullScreenEnabled = function () { | ||
return isBrowser && vendor.FullScreenEnabled in document && document[vendor.FullScreenEnabled] === true; | ||
}; | ||
var addFullScreenChangeListener = function (handler) { | ||
if (isBrowser) { | ||
document.addEventListener(vendor.FullScreenChange, handler); | ||
} | ||
}; | ||
var exitFullScreenMode = function (element) { | ||
return isBrowser | ||
? | ||
element[vendor.ExitFullScreen]() | ||
: Promise.resolve({}); | ||
}; | ||
var getFullScreenElement = function () { | ||
return isBrowser ? document[vendor.FullScreenElement] : null; | ||
}; | ||
var requestFullScreen = function (element) { | ||
if (isBrowser) { | ||
element[vendor.RequestFullScreen](); | ||
} | ||
}; | ||
var TOOLTIP_OFFSET$1 = { left: 0, top: 8 }; | ||
@@ -132,3 +73,3 @@ var EnterFullScreenButton = function (_a) { | ||
var ariaKeyShortcuts = enableShortcuts ? (core.isMac() ? 'Meta+Ctrl+F' : 'F11') : ''; | ||
return (React__namespace.createElement(core.Tooltip, { ariaControlsSuffix: "full-screen-enter", position: core.Position.BottomCenter, target: React__namespace.createElement(core.MinimalButton, { ariaKeyShortcuts: ariaKeyShortcuts, ariaLabel: label, isDisabled: !isFullScreenEnabled(), testId: "full-screen__enter-button", onClick: onClick }, | ||
return (React__namespace.createElement(core.Tooltip, { ariaControlsSuffix: "full-screen-enter", position: core.Position.BottomCenter, target: React__namespace.createElement(core.MinimalButton, { ariaKeyShortcuts: ariaKeyShortcuts, ariaLabel: label, isDisabled: !core.isFullScreenEnabled(), testId: "full-screen__enter-button", onClick: onClick }, | ||
React__namespace.createElement(FullScreenIcon, null)), content: function () { return label; }, offset: TOOLTIP_OFFSET$1 })); | ||
@@ -146,66 +87,22 @@ }; | ||
var useEnterFullScreen = function (getFullScreenTarget, store, onEnterFullScreen, onExitFullScreen) { | ||
var _a = React__namespace.useState(false), isFullScreen = _a[0], setFullScreen = _a[1]; | ||
var pagesRef = React__namespace.useRef(store.get('getPagesContainer') ? store.get('getPagesContainer')() : null); | ||
var closeOtherFullScreen = function () { | ||
var pagesEle = pagesRef.current; | ||
if (!pagesEle) { | ||
return Promise.resolve(); | ||
} | ||
var ele = getFullScreenElement(); | ||
return ele && ele !== getFullScreenTarget(pagesEle) ? exitFullScreenMode(ele) : Promise.resolve(); | ||
}; | ||
var useEnterFullScreen = function (getFullScreenTarget, store) { | ||
var _a = React__namespace.useState(store.get('fullScreenMode')), fullScreenMode = _a[0], setFullScreenMode = _a[1]; | ||
var handleFullScreenMode = React__namespace.useCallback(function (fullScreenMode) { | ||
setFullScreenMode(fullScreenMode); | ||
}, []); | ||
var enterFullScreen = function () { | ||
if (!isFullScreenEnabled()) { | ||
var pagesContainer = store.get('getPagesContainer'); | ||
if (!pagesContainer) { | ||
return; | ||
} | ||
var pagesEle = pagesRef.current; | ||
if (!pagesEle) { | ||
return; | ||
} | ||
closeOtherFullScreen().then(function () { | ||
requestFullScreen(getFullScreenTarget(pagesEle)); | ||
}); | ||
var target = getFullScreenTarget(pagesContainer()); | ||
store.get('enterFullScreenMode')(target); | ||
}; | ||
var onFullScreenChange = function () { | ||
var ele = getFullScreenElement(); | ||
var pagesEle = pagesRef.current; | ||
var isFullScreenMode = ele === getFullScreenTarget(pagesEle); | ||
store.update('isFullScreen', isFullScreenMode); | ||
isFullScreenMode | ||
? pagesEle.classList.add('rpv-full-screen__pages') | ||
: pagesEle.classList.remove('rpv-full-screen__pages'); | ||
var zoom = store.get('zoom'); | ||
if (zoom) { | ||
isFullScreenMode ? onEnterFullScreen(zoom) : onExitFullScreen(zoom); | ||
} | ||
}; | ||
var handlePagesContainer = function (getPagesContainer) { | ||
pagesRef.current = getPagesContainer(); | ||
addFullScreenChangeListener(onFullScreenChange); | ||
}; | ||
var handleFullScreen = function (fullScreen) { | ||
setFullScreen(fullScreen); | ||
}; | ||
var exitFullScreen = function () { | ||
setFullScreen(false); | ||
var getPagesContainer = store.get('getPagesContainer'); | ||
if (!getPagesContainer) { | ||
return; | ||
} | ||
var pagesEle = getPagesContainer(); | ||
if (!pagesEle) { | ||
return; | ||
} | ||
var ele = getFullScreenElement(); | ||
if (ele && ele === getFullScreenTarget(pagesEle)) { | ||
exitFullScreenMode(document); | ||
} | ||
store.get('exitFullScreenMode')(); | ||
}; | ||
React__namespace.useEffect(function () { | ||
store.subscribe('isFullScreen', handleFullScreen); | ||
store.subscribe('getPagesContainer', handlePagesContainer); | ||
store.subscribe('fullScreenMode', handleFullScreenMode); | ||
return function () { | ||
store.unsubscribe('getPagesContainer', handlePagesContainer); | ||
store.unsubscribe('isFullScreen', handleFullScreen); | ||
store.unsubscribe('fullScreenMode', handleFullScreenMode); | ||
}; | ||
@@ -216,3 +113,3 @@ }, []); | ||
exitFullScreen: exitFullScreen, | ||
isFullScreen: isFullScreen, | ||
isFullScreen: fullScreenMode === core.FullScreenMode.Entering || fullScreenMode === core.FullScreenMode.EnteredCompletely, | ||
}; | ||
@@ -222,4 +119,4 @@ }; | ||
var EnterFullScreen = function (_a) { | ||
var children = _a.children, enableShortcuts = _a.enableShortcuts, getFullScreenTarget = _a.getFullScreenTarget, store = _a.store, onEnterFullScreen = _a.onEnterFullScreen, onExitFullScreen = _a.onExitFullScreen; | ||
var _b = useEnterFullScreen(getFullScreenTarget, store, onEnterFullScreen, onExitFullScreen), enterFullScreen = _b.enterFullScreen, exitFullScreen = _b.exitFullScreen, isFullScreen = _b.isFullScreen; | ||
var children = _a.children, enableShortcuts = _a.enableShortcuts, getFullScreenTarget = _a.getFullScreenTarget, store = _a.store; | ||
var _b = useEnterFullScreen(getFullScreenTarget, store), enterFullScreen = _b.enterFullScreen, exitFullScreen = _b.exitFullScreen, isFullScreen = _b.isFullScreen; | ||
var defaultChildren = function (props) { | ||
@@ -238,3 +135,3 @@ return isFullScreen ? (React__namespace.createElement(ExitFullScreenButtonWithTooltip, { onClick: props.onClick })) : (React__namespace.createElement(EnterFullScreenButton, { enableShortcuts: enableShortcuts, onClick: props.onClick })); | ||
var label = l10n && l10n.fullScreen ? l10n.fullScreen.enterFullScreen : 'Full screen'; | ||
return (React__namespace.createElement(core.MenuItem, { icon: React__namespace.createElement(FullScreenIcon, null), isDisabled: !isFullScreenEnabled(), testId: "full-screen__enter-menu", onClick: onClick }, label)); | ||
return (React__namespace.createElement(core.MenuItem, { icon: React__namespace.createElement(FullScreenIcon, null), isDisabled: !core.isFullScreenEnabled(), testId: "full-screen__enter-menu", onClick: onClick }, label)); | ||
}; | ||
@@ -258,4 +155,4 @@ | ||
var ExitFullScreen = function (_a) { | ||
var children = _a.children, getFullScreenTarget = _a.getFullScreenTarget, store = _a.store, onEnterFullScreen = _a.onEnterFullScreen, onExitFullScreen = _a.onExitFullScreen; | ||
var _b = useEnterFullScreen(getFullScreenTarget, store, onEnterFullScreen, onExitFullScreen), enterFullScreen = _b.enterFullScreen, exitFullScreen = _b.exitFullScreen, isFullScreen = _b.isFullScreen; | ||
var children = _a.children, getFullScreenTarget = _a.getFullScreenTarget, store = _a.store; | ||
var _b = useEnterFullScreen(getFullScreenTarget, store), enterFullScreen = _b.enterFullScreen, exitFullScreen = _b.exitFullScreen, isFullScreen = _b.isFullScreen; | ||
var defaultChildren = function (props) { return React__namespace.createElement(ExitFullScreenButton, { onClick: props.onClick }); }; | ||
@@ -269,5 +166,37 @@ var render = children || defaultChildren; | ||
var FullScreenModeTracker = function (_a) { | ||
var store = _a.store, onEnterFullScreen = _a.onEnterFullScreen, onExitFullScreen = _a.onExitFullScreen; | ||
var _b = React__namespace.useState(store.get('fullScreenMode')), fullScreenMode = _b[0], setFullScreenMode = _b[1]; | ||
var handleFullScreenMode = React__namespace.useCallback(function (fullScreenMode) { | ||
setFullScreenMode(fullScreenMode); | ||
}, []); | ||
var handleEnteredFullScreen = function () { | ||
onEnterFullScreen(store.get('zoom')); | ||
}; | ||
var handleExitedFullScreen = function () { | ||
onExitFullScreen(store.get('zoom')); | ||
}; | ||
React__namespace.useEffect(function () { | ||
switch (fullScreenMode) { | ||
case core.FullScreenMode.EnteredCompletely: | ||
handleEnteredFullScreen(); | ||
break; | ||
case core.FullScreenMode.Exited: | ||
handleExitedFullScreen(); | ||
break; | ||
} | ||
}, [fullScreenMode]); | ||
React__namespace.useEffect(function () { | ||
store.subscribe('fullScreenMode', handleFullScreenMode); | ||
return function () { | ||
store.unsubscribe('fullScreenMode', handleFullScreenMode); | ||
}; | ||
}, []); | ||
return ((fullScreenMode === core.FullScreenMode.Entering || fullScreenMode === core.FullScreenMode.Entered) && (React__namespace.createElement("div", { className: "rpv-full-screen__overlay" }, | ||
React__namespace.createElement(core.Spinner, null)))); | ||
}; | ||
var ShortcutHandler = function (_a) { | ||
var containerRef = _a.containerRef, getFullScreenTarget = _a.getFullScreenTarget, store = _a.store, onEnterFullScreen = _a.onEnterFullScreen, onExitFullScreen = _a.onExitFullScreen; | ||
var enterFullScreen = useEnterFullScreen(getFullScreenTarget, store, onEnterFullScreen, onExitFullScreen).enterFullScreen; | ||
var containerRef = _a.containerRef, getFullScreenTarget = _a.getFullScreenTarget, store = _a.store; | ||
var enterFullScreen = useEnterFullScreen(getFullScreenTarget, store).enterFullScreen; | ||
var keydownHandler = function (e) { | ||
@@ -307,4 +236,11 @@ if (e.shiftKey || e.altKey) { | ||
}, []); | ||
var store = React__namespace.useMemo(function () { return core.createStore({}); }, []); | ||
var EnterFullScreenDecorator = function (props) { return (React__namespace.createElement(EnterFullScreen, __assign({}, props, { enableShortcuts: fullScreenPluginProps.enableShortcuts, getFullScreenTarget: getFullScreenTarget, store: store, onEnterFullScreen: fullScreenPluginProps.onEnterFullScreen, onExitFullScreen: fullScreenPluginProps.onExitFullScreen }))); }; | ||
var store = React__namespace.useMemo(function () { | ||
return core.createStore({ | ||
enterFullScreenMode: function () { }, | ||
exitFullScreenMode: function () { }, | ||
fullScreenMode: core.FullScreenMode.Normal, | ||
zoom: function () { }, | ||
}); | ||
}, []); | ||
var EnterFullScreenDecorator = function (props) { return (React__namespace.createElement(EnterFullScreen, __assign({}, props, { enableShortcuts: fullScreenPluginProps.enableShortcuts, getFullScreenTarget: getFullScreenTarget, store: store }))); }; | ||
var EnterFullScreenButtonDecorator = function () { return (React__namespace.createElement(EnterFullScreenDecorator, null, function (renderProps) { return (React__namespace.createElement(EnterFullScreenButton, __assign({ enableShortcuts: fullScreenPluginProps.enableShortcuts }, renderProps))); })); }; | ||
@@ -315,3 +251,3 @@ var EnterFullScreenMenuItemDecorator = function (props) { return (React__namespace.createElement(EnterFullScreenDecorator, null, function (p) { return (React__namespace.createElement(EnterFullScreenMenuItem, { onClick: function () { | ||
} })); })); }; | ||
var ExitFullScreenDecorator = function () { return (React__namespace.createElement(ExitFullScreen, { getFullScreenTarget: getFullScreenTarget, store: store, onEnterFullScreen: fullScreenPluginProps.onEnterFullScreen, onExitFullScreen: fullScreenPluginProps.onExitFullScreen }, props === null || props === void 0 ? void 0 : props.renderExitFullScreenButton)); }; | ||
var ExitFullScreenDecorator = function () { return (React__namespace.createElement(ExitFullScreen, { getFullScreenTarget: getFullScreenTarget, store: store }, props === null || props === void 0 ? void 0 : props.renderExitFullScreenButton)); }; | ||
var renderViewer = function (props) { | ||
@@ -321,3 +257,4 @@ var currentSlot = props.slot; | ||
currentSlot.subSlot.children = (React__namespace.createElement(React__namespace.Fragment, null, | ||
fullScreenPluginProps.enableShortcuts && (React__namespace.createElement(ShortcutHandler, { containerRef: props.containerRef, getFullScreenTarget: getFullScreenTarget, store: store, onEnterFullScreen: fullScreenPluginProps.onEnterFullScreen, onExitFullScreen: fullScreenPluginProps.onExitFullScreen })), | ||
fullScreenPluginProps.enableShortcuts && (React__namespace.createElement(ShortcutHandler, { containerRef: props.containerRef, getFullScreenTarget: getFullScreenTarget, store: store })), | ||
React__namespace.createElement(FullScreenModeTracker, { store: store, onEnterFullScreen: fullScreenPluginProps.onEnterFullScreen, onExitFullScreen: fullScreenPluginProps.onExitFullScreen }), | ||
React__namespace.createElement(ExitFullScreenDecorator, null), | ||
@@ -330,5 +267,11 @@ currentSlot.subSlot.children)); | ||
install: function (pluginFunctions) { | ||
store.update('enterFullScreenMode', pluginFunctions.enterFullScreenMode); | ||
store.update('exitFullScreenMode', pluginFunctions.exitFullScreenMode); | ||
store.update('getPagesContainer', pluginFunctions.getPagesContainer); | ||
store.update('zoom', pluginFunctions.zoom); | ||
}, | ||
onViewerStateChange: function (viewerState) { | ||
store.update('fullScreenMode', viewerState.fullScreenMode); | ||
return viewerState; | ||
}, | ||
renderViewer: renderViewer, | ||
@@ -335,0 +278,0 @@ EnterFullScreen: EnterFullScreenDecorator, |
@@ -1,1 +0,1 @@ | ||
"use strict";var e=require("@react-pdf-viewer/core");function n(e){var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var l=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,l.get?l:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var t,l=n(require("react")),r=function(){return l.createElement(e.Icon,{size:16},l.createElement("path",{d:"M11.5 23.499L11.5 14.499"}),l.createElement("path",{d:"M7.5 18.499L11.5 14.499 15.5 18.499"}),l.createElement("path",{d:"M11.5 1.499L11.5 10.499"}),l.createElement("path",{d:"M7.5 6.499L11.5 10.499 15.5 6.499"}),l.createElement("path",{d:"M20.5 12.499L1.5 12.499"}))},c=function(){return l.createElement(e.Icon,{size:16},l.createElement("path",{d:"M0.5 12L23.5 12"}),l.createElement("path",{d:"M11.5 1L11.5 23"}),l.createElement("path",{d:"M8.5 4L11.5 1 14.5 4"}),l.createElement("path",{d:"M20.5 9L23.5 12 20.5 15"}),l.createElement("path",{d:"M3.5 15L0.5 12 3.5 9"}),l.createElement("path",{d:"M14.5 20L11.5 23 8.5 20"}))},u=function(){return u=Object.assign||function(e){for(var n,t=1,l=arguments.length;t<l;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},u.apply(this,arguments)};!function(e){e[e.ExitFullScreen=0]="ExitFullScreen",e[e.FullScreenChange=1]="FullScreenChange",e[e.FullScreenElement=2]="FullScreenElement",e[e.FullScreenEnabled=3]="FullScreenEnabled",e[e.RequestFullScreen=4]="RequestFullScreen"}(t||(t={}));var o={ExitFullScreen:"exitFullscreen",FullScreenChange:"fullscreenchange",FullScreenElement:"fullscreenElement",FullScreenEnabled:"fullscreenEnabled",RequestFullScreen:"requestFullscreen"},i={ExitFullScreen:"webkitExitFullscreen",FullScreenChange:"webkitfullscreenchange",FullScreenElement:"webkitFullscreenElement",FullScreenEnabled:"webkitFullscreenEnabled",RequestFullScreen:"webkitRequestFullscreen"},a={ExitFullScreen:"msExitFullscreen",FullScreenChange:"msFullscreenChange",FullScreenElement:"msFullscreenElement",FullScreenEnabled:"msFullscreenEnabled",RequestFullScreen:"msRequestFullscreen"},s="undefined"!=typeof window,f=s&&(t.FullScreenEnabled in document&&o||i.FullScreenEnabled in document&&i||a.FullScreenEnabled in document&&a)||o,S=function(){return s&&f.FullScreenEnabled in document&&!0===document[f.FullScreenEnabled]},E=function(e){return s?e[f.ExitFullScreen]():Promise.resolve({})},F=function(){return s?document[f.FullScreenElement]:null},m={left:0,top:8},d=function(n){var t=n.enableShortcuts,r=n.onClick,u=l.useContext(e.LocalizationContext).l10n,o=u&&u.fullScreen?u.fullScreen.enterFullScreen:"Full screen",i=t?e.isMac()?"Meta+Ctrl+F":"F11":"";return l.createElement(e.Tooltip,{ariaControlsSuffix:"full-screen-enter",position:e.Position.BottomCenter,target:l.createElement(e.MinimalButton,{ariaKeyShortcuts:i,ariaLabel:o,isDisabled:!S(),testId:"full-screen__enter-button",onClick:r},l.createElement(c,null)),content:function(){return o},offset:m})},b={left:0,top:8},g=function(n){var t=n.onClick,c=l.useContext(e.LocalizationContext).l10n,u=c&&c.fullScreen?c.fullScreen.exitFullScreen:"Exit full screen";return l.createElement(e.Tooltip,{ariaControlsSuffix:"full-screen-exit",position:e.Position.BottomCenter,target:l.createElement(e.MinimalButton,{ariaKeyShortcuts:"Esc",ariaLabel:u,testId:"full-screen__exit-button-with-tooltip",onClick:t},l.createElement(r,null)),content:function(){return u},offset:b})},x=function(e,n,t,r){var c=l.useState(!1),u=c[0],o=c[1],i=l.useRef(n.get("getPagesContainer")?n.get("getPagesContainer")():null),a=function(){var l=F(),c=i.current,u=l===e(c);n.update("isFullScreen",u),u?c.classList.add("rpv-full-screen__pages"):c.classList.remove("rpv-full-screen__pages");var o=n.get("zoom");o&&(u?t(o):r(o))},m=function(e){var n;i.current=e(),n=a,s&&document.addEventListener(f.FullScreenChange,n)},d=function(e){o(e)};return l.useEffect((function(){return n.subscribe("isFullScreen",d),n.subscribe("getPagesContainer",m),function(){n.unsubscribe("getPagesContainer",m),n.unsubscribe("isFullScreen",d)}}),[]),{enterFullScreen:function(){if(S()){var n=i.current;n&&function(){var n=i.current;if(!n)return Promise.resolve();var t=F();return t&&t!==e(n)?E(t):Promise.resolve()}().then((function(){var t;t=e(n),s&&t[f.RequestFullScreen]()}))}},exitFullScreen:function(){o(!1);var t=n.get("getPagesContainer");if(t){var l=t();if(l){var r=F();r&&r===e(l)&&E(document)}}},isFullScreen:u}},v=function(e){var n=e.children,t=e.enableShortcuts,r=e.getFullScreenTarget,c=e.store,u=e.onEnterFullScreen,o=e.onExitFullScreen,i=x(r,c,u,o),a=i.enterFullScreen,s=i.exitFullScreen,f=i.isFullScreen;return(n||function(e){return f?l.createElement(g,{onClick:e.onClick}):l.createElement(d,{enableShortcuts:t,onClick:e.onClick})})({onClick:f?s:a})},C=function(n){var t=n.onClick,r=l.useContext(e.LocalizationContext).l10n,u=r&&r.fullScreen?r.fullScreen.enterFullScreen:"Full screen";return l.createElement(e.MenuItem,{icon:l.createElement(c,null),isDisabled:!S(),testId:"full-screen__enter-menu",onClick:t},u)},h=function(n){var t=n.onClick,c=l.useContext(e.LocalizationContext).l10n,u=l.useContext(e.ThemeContext).direction===e.TextDirection.RightToLeft,o=c&&c.fullScreen?c.fullScreen.exitFullScreen:"Exit full screen";return l.createElement("div",{className:e.classNames({"rpv-full-screen__exit-button":!0,"rpv-full-screen__exit-button--ltr":!u,"rpv-full-screen__exit-button--rtl":u})},l.createElement(e.MinimalButton,{ariaLabel:o,testId:"full-screen__exit-button",onClick:t},l.createElement(r,null)))},p=function(e){var n=e.children,t=e.getFullScreenTarget,r=e.store,c=e.onEnterFullScreen,u=e.onExitFullScreen,o=x(t,r,c,u),i=o.enterFullScreen,a=o.exitFullScreen,s=o.isFullScreen;return s&&(n||function(e){return l.createElement(h,{onClick:e.onClick})})({onClick:s?a:i})},k=function(n){var t=n.containerRef,r=n.getFullScreenTarget,c=n.store,u=n.onEnterFullScreen,o=n.onExitFullScreen,i=x(r,c,u,o).enterFullScreen,a=function(n){if(!n.shiftKey&&!n.altKey&&(e.isMac()?n.metaKey&&n.ctrlKey&&"f"===n.key:"F11"===n.key)){var l=t.current;l&&document.activeElement&&l.contains(document.activeElement)&&(n.preventDefault(),i())}};return l.useEffect((function(){if(t.current)return document.addEventListener("keydown",a),function(){document.removeEventListener("keydown",a)}}),[t.current]),l.createElement(l.Fragment,null)};exports.ExitFullScreenIcon=r,exports.FullScreenIcon=c,exports.fullScreenPlugin=function(n){var t=(null==n?void 0:n.getFullScreenTarget)||function(e){return e},r=l.useMemo((function(){return Object.assign({},{enableShortcuts:!0,onEnterFullScreen:function(){},onExitFullScreen:function(){}},n)}),[]),c=l.useMemo((function(){return e.createStore({})}),[]),o=function(e){return l.createElement(v,u({},e,{enableShortcuts:r.enableShortcuts,getFullScreenTarget:t,store:c,onEnterFullScreen:r.onEnterFullScreen,onExitFullScreen:r.onExitFullScreen}))},i=function(){return l.createElement(p,{getFullScreenTarget:t,store:c,onEnterFullScreen:r.onEnterFullScreen,onExitFullScreen:r.onExitFullScreen},null==n?void 0:n.renderExitFullScreenButton)};return{install:function(e){c.update("getPagesContainer",e.getPagesContainer),c.update("zoom",e.zoom)},renderViewer:function(e){var n=e.slot;return n.subSlot&&(n.subSlot.children=l.createElement(l.Fragment,null,r.enableShortcuts&&l.createElement(k,{containerRef:e.containerRef,getFullScreenTarget:t,store:c,onEnterFullScreen:r.onEnterFullScreen,onExitFullScreen:r.onExitFullScreen}),l.createElement(i,null),n.subSlot.children)),n},EnterFullScreen:o,EnterFullScreenButton:function(){return l.createElement(o,null,(function(e){return l.createElement(d,u({enableShortcuts:r.enableShortcuts},e))}))},EnterFullScreenMenuItem:function(e){return l.createElement(o,null,(function(n){return l.createElement(C,{onClick:function(){n.onClick(),e.onClick()}})}))}}}; | ||
"use strict";var e=require("@react-pdf-viewer/core");function t(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var n=t(require("react")),r=function(){return n.createElement(e.Icon,{size:16},n.createElement("path",{d:"M11.5 23.499L11.5 14.499"}),n.createElement("path",{d:"M7.5 18.499L11.5 14.499 15.5 18.499"}),n.createElement("path",{d:"M11.5 1.499L11.5 10.499"}),n.createElement("path",{d:"M7.5 6.499L11.5 10.499 15.5 6.499"}),n.createElement("path",{d:"M20.5 12.499L1.5 12.499"}))},l=function(){return n.createElement(e.Icon,{size:16},n.createElement("path",{d:"M0.5 12L23.5 12"}),n.createElement("path",{d:"M11.5 1L11.5 23"}),n.createElement("path",{d:"M8.5 4L11.5 1 14.5 4"}),n.createElement("path",{d:"M20.5 9L23.5 12 20.5 15"}),n.createElement("path",{d:"M3.5 15L0.5 12 3.5 9"}),n.createElement("path",{d:"M14.5 20L11.5 23 8.5 20"}))},c=function(){return c=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var l in t=arguments[n])Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l]);return e},c.apply(this,arguments)},u={left:0,top:8},o=function(t){var r=t.enableShortcuts,c=t.onClick,o=n.useContext(e.LocalizationContext).l10n,i=o&&o.fullScreen?o.fullScreen.enterFullScreen:"Full screen",a=r?e.isMac()?"Meta+Ctrl+F":"F11":"";return n.createElement(e.Tooltip,{ariaControlsSuffix:"full-screen-enter",position:e.Position.BottomCenter,target:n.createElement(e.MinimalButton,{ariaKeyShortcuts:a,ariaLabel:i,isDisabled:!e.isFullScreenEnabled(),testId:"full-screen__enter-button",onClick:c},n.createElement(l,null)),content:function(){return i},offset:u})},i={left:0,top:8},a=function(t){var l=t.onClick,c=n.useContext(e.LocalizationContext).l10n,u=c&&c.fullScreen?c.fullScreen.exitFullScreen:"Exit full screen";return n.createElement(e.Tooltip,{ariaControlsSuffix:"full-screen-exit",position:e.Position.BottomCenter,target:n.createElement(e.MinimalButton,{ariaKeyShortcuts:"Esc",ariaLabel:u,testId:"full-screen__exit-button-with-tooltip",onClick:l},n.createElement(r,null)),content:function(){return u},offset:i})},f=function(t,r){var l=n.useState(r.get("fullScreenMode")),c=l[0],u=l[1],o=n.useCallback((function(e){u(e)}),[]);return n.useEffect((function(){return r.subscribe("fullScreenMode",o),function(){r.unsubscribe("fullScreenMode",o)}}),[]),{enterFullScreen:function(){var e=r.get("getPagesContainer");if(e){var n=t(e());r.get("enterFullScreenMode")(n)}},exitFullScreen:function(){r.get("exitFullScreenMode")()},isFullScreen:c===e.FullScreenMode.Entering||c===e.FullScreenMode.EnteredCompletely}},s=function(e){var t=e.children,r=e.enableShortcuts,l=e.getFullScreenTarget,c=e.store,u=f(l,c),i=u.enterFullScreen,s=u.exitFullScreen,S=u.isFullScreen;return(t||function(e){return S?n.createElement(a,{onClick:e.onClick}):n.createElement(o,{enableShortcuts:r,onClick:e.onClick})})({onClick:S?s:i})},S=function(t){var r=t.onClick,c=n.useContext(e.LocalizationContext).l10n,u=c&&c.fullScreen?c.fullScreen.enterFullScreen:"Full screen";return n.createElement(e.MenuItem,{icon:n.createElement(l,null),isDisabled:!e.isFullScreenEnabled(),testId:"full-screen__enter-menu",onClick:r},u)},d=function(t){var l=t.onClick,c=n.useContext(e.LocalizationContext).l10n,u=n.useContext(e.ThemeContext).direction===e.TextDirection.RightToLeft,o=c&&c.fullScreen?c.fullScreen.exitFullScreen:"Exit full screen";return n.createElement("div",{className:e.classNames({"rpv-full-screen__exit-button":!0,"rpv-full-screen__exit-button--ltr":!u,"rpv-full-screen__exit-button--rtl":u})},n.createElement(e.MinimalButton,{ariaLabel:o,testId:"full-screen__exit-button",onClick:l},n.createElement(r,null)))},m=function(e){var t=e.children,r=e.getFullScreenTarget,l=e.store,c=f(r,l),u=c.enterFullScreen,o=c.exitFullScreen,i=c.isFullScreen;return i&&(t||function(e){return n.createElement(d,{onClick:e.onClick})})({onClick:i?o:u})},E=function(t){var r=t.store,l=t.onEnterFullScreen,c=t.onExitFullScreen,u=n.useState(r.get("fullScreenMode")),o=u[0],i=u[1],a=n.useCallback((function(e){i(e)}),[]);return n.useEffect((function(){switch(o){case e.FullScreenMode.EnteredCompletely:l(r.get("zoom"));break;case e.FullScreenMode.Exited:c(r.get("zoom"))}}),[o]),n.useEffect((function(){return r.subscribe("fullScreenMode",a),function(){r.unsubscribe("fullScreenMode",a)}}),[]),(o===e.FullScreenMode.Entering||o===e.FullScreenMode.Entered)&&n.createElement("div",{className:"rpv-full-screen__overlay"},n.createElement(e.Spinner,null))},F=function(t){var r=t.containerRef,l=t.getFullScreenTarget,c=t.store,u=f(l,c).enterFullScreen,o=function(t){if(!t.shiftKey&&!t.altKey&&(e.isMac()?t.metaKey&&t.ctrlKey&&"f"===t.key:"F11"===t.key)){var n=r.current;n&&document.activeElement&&n.contains(document.activeElement)&&(t.preventDefault(),u())}};return n.useEffect((function(){if(r.current)return document.addEventListener("keydown",o),function(){document.removeEventListener("keydown",o)}}),[r.current]),n.createElement(n.Fragment,null)};exports.ExitFullScreenIcon=r,exports.FullScreenIcon=l,exports.fullScreenPlugin=function(t){var r=(null==t?void 0:t.getFullScreenTarget)||function(e){return e},l=n.useMemo((function(){return Object.assign({},{enableShortcuts:!0,onEnterFullScreen:function(){},onExitFullScreen:function(){}},t)}),[]),u=n.useMemo((function(){return e.createStore({enterFullScreenMode:function(){},exitFullScreenMode:function(){},fullScreenMode:e.FullScreenMode.Normal,zoom:function(){}})}),[]),i=function(e){return n.createElement(s,c({},e,{enableShortcuts:l.enableShortcuts,getFullScreenTarget:r,store:u}))},a=function(){return n.createElement(m,{getFullScreenTarget:r,store:u},null==t?void 0:t.renderExitFullScreenButton)};return{install:function(e){u.update("enterFullScreenMode",e.enterFullScreenMode),u.update("exitFullScreenMode",e.exitFullScreenMode),u.update("getPagesContainer",e.getPagesContainer),u.update("zoom",e.zoom)},onViewerStateChange:function(e){return u.update("fullScreenMode",e.fullScreenMode),e},renderViewer:function(e){var t=e.slot;return t.subSlot&&(t.subSlot.children=n.createElement(n.Fragment,null,l.enableShortcuts&&n.createElement(F,{containerRef:e.containerRef,getFullScreenTarget:r,store:u}),n.createElement(E,{store:u,onEnterFullScreen:l.onEnterFullScreen,onExitFullScreen:l.onExitFullScreen}),n.createElement(a,null),t.subSlot.children)),t},EnterFullScreen:i,EnterFullScreenButton:function(){return n.createElement(i,null,(function(e){return n.createElement(o,c({enableShortcuts:l.enableShortcuts},e))}))},EnterFullScreenMenuItem:function(e){return n.createElement(i,null,(function(t){return n.createElement(S,{onClick:function(){t.onClick(),e.onClick()}})}))}}}; |
{ | ||
"name": "@react-pdf-viewer/full-screen", | ||
"version": "3.11.0", | ||
"version": "3.12.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": "3.11.0" | ||
"@react-pdf-viewer/core": "3.12.0" | ||
}, | ||
@@ -52,3 +52,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "25039b7717eb30743eaaabbb4bb2eb75529b49e2" | ||
"gitHead": "ea84015146e8c5d4c78d7f10df2fba84567ef4aa" | ||
} |
Sorry, the diff of this file is not supported yet
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
25642
340
+ Added@react-pdf-viewer/core@3.12.0(transitive)
- Removed@react-pdf-viewer/core@3.11.0(transitive)