mediacms/static/js/_commons.js

2 lines
1.2 MiB
JavaScript
Raw Permalink Normal View History

2020-12-16 12:48:37 +01:00
/*! For license information please see _commons.js.LICENSE.txt */
2024-11-12 10:06:35 +01:00
(self.webpackChunkmediacms_frontend=self.webpackChunkmediacms_frontend||[]).push([[431],{27087:function(e,t,n){"use strict";function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,{Z:function(){return r}})},95458:function(e,t,n){"use strict";if(n.d(t,{Z:function(){return i}}),411==n.j)var r=n(27087);function i(e){if(Array.isArray(e))return(0,r.Z)(e)}},97692:function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{Z:function(){return r}})},57539:function(e,t,n){"use strict";function r(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}n.d(t,{Z:function(){return r}})},20303:function(e,t,n){"use strict";function r(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}n.d(t,{Z:function(){return r}})},89959:function(e,t,n){"use strict";if(n.d(t,{Z:function(){return s}}),411==n.j)var r=n(95458);if(411==n.j)var i=n(57539);if(411==n.j)var o=n(70299);if(411==n.j)var a=n(20303);function s(e){return(0,r.Z)(e)||(0,i.Z)(e)||(0,o.Z)(e)||(0,a.Z)()}},70299:function(e,t,n){"use strict";if(n.d(t,{Z:function(){return i}}),411==n.j)var r=n(27087);function i(e,t){if(e){if("string"==typeof e)return(0,r.Z)(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?(0,r.Z)(e,t):void 0}}},13506:function(e,t,n){"use strict";var r=n(12672),i=function(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)}(n(35466)),o=function(e){var t=e.files,n=i.useRef(),o=i.useContext(r.LocalizationContext).l10n,a=i.useContext(r.ThemeContext).direction===r.TextDirection.RightToLeft,s=i.useRef([]),l=o&&o.attachment?o.attachment.clickToDownload:"Click to download",u=function(e){var t=n.current,r=[].slice.call(t.getElementsByClassName("rpv-attachment__item"));if(0!==r.length){r.forEach((function(e){return e.setAttribute("tabindex","-1")}));var i=document.activeElement,o=r[Math.min(r.length-1,Math.max(0,e(r,i)))];o.setAttribute("tabindex","0"),o.focus()}};return r.useIsomorphicLayoutEffect((function(){var e=n.current;if(e){var t=[].slice.call(e.getElementsByClassName("rpv-attachment__item"));if(s.current=t,t.length>0){var r=t[0];r.focus(),r.setAttribute("tabindex","0")}}}),[]),i.createElement("div",{"data-testid":"attachment__list",className:r.classNames({"rpv-attachment__list":!0,"rpv-attachment__list--rtl":a}),ref:n,tabIndex:-1,onKeyDown:function(e){switch(e.key){case"ArrowDown":e.preventDefault(),u((function(e,t){return e.indexOf(t)+1}));break;case"ArrowUp":e.preventDefault(),u((function(e,t){return e.indexOf(t)-1}));break;case"End":e.preventDefault(),u((function(e,t){return e.length-1}));break;case"Home":e.preventDefault(),u((function(e,t){return 0}))}}},t.map((function(e){return i.createElement("button",{className:"rpv-attachment__item",key:e.fileName,tabIndex:-1,title:l,type:"button",onClick:function(){return t=e.fileName,r="string"==typeof(n=e.data)?"":URL.createObjectURL(new Blob([n],{type:""})),(i=document.createElement("a")).style.display="none",i.href=r||t,i.setAttribute("download",function(e){var t=e.split("/").pop();return t?t.split("#")[0].split("?")[0]:e}(t)),document.body.appendChild(i),i.click(),document.body.removeChild(i),void(r&&URL.revokeObjectURL(r));var t,n,r,i}},e.fileName)})))},a=function(e){var t=e.doc,n=i.useContext(r.LocalizationContext).l10n,a=i.useContext(r.ThemeContext).direction===r.TextDirection.RightToLeft,s=n&&n.attachment?n.attachment.noAttachment:"There is no attachment",l=i.useState({files:[],isLoaded:!1}),u=l[0],c=l[1];return i.useEffect((function(){t.getAttachments().then((fu