UNPKG

@rero/rero-ils-ui

Version:

User interface for RERO integrated library system (RERO ILS).

2 lines (1 loc) 11.1 kB
import{a as de}from"./chunk-32FZIPT5.js";import{ra as pe}from"./chunk-4GRLSOJZ.js";import{c as le}from"./chunk-WOV5KKTV.js";import{S as se}from"./chunk-MTJX6JRK.js";import{b as Y,c as ee}from"./chunk-GQ5FIRIY.js";import{k as ne}from"./chunk-4A4J5SA3.js";import{e as re,l as ae,x as oe}from"./chunk-L5BLWZD6.js";import{a as ie}from"./chunk-MR6TFYJD.js";import{A,y as te}from"./chunk-FRI676LD.js";import{ga as X}from"./chunk-WKOKZ3JO.js";import{$b as H,Aa as k,Ab as P,Ca as z,Cc as j,Eb as y,Ec as q,Fc as K,Ha as S,Hc as u,Jc as C,Mc as G,Nc as J,Oc as Q,Vb as E,Wc as x,Xb as w,Yb as O,Yc as N,_b as B,ac as m,bb as U,bc as r,cc as s,dc as Z,dd as h,ed as _,gb as l,jc as I,jd as L,kc as V,oa as v,pa as b,pb as M,qb as f,rc as g,sc as d,tc as $,uc as F,ud as R,va as c,vd as D,wa as T,yb as W}from"./chunk-3WD6XLXL.js";var me=class{static processRecipientSuggestions(a){let e={emails:[],recipients:[]};return a.map(t=>{e.emails.push(t.address),t.type&&t.type.map(n=>{e.recipients.push({address:t.address,type:n})})}),e.emails.sort(),e}};var ue=(()=>{class i{el;zone;renderer;scope;dragEffect;dragHandle;onDragStart=new c;onDragEnd=new c;onDrag=new c;handle;dragListener;mouseDownListener;mouseUpListener;_pDraggableDisabled=!1;constructor(e,t,n){this.el=e,this.zone=t,this.renderer=n}get pDraggableDisabled(){return this._pDraggableDisabled}set pDraggableDisabled(e){this._pDraggableDisabled=e,this._pDraggableDisabled?this.unbindMouseListeners():(this.el.nativeElement.draggable=!0,this.bindMouseListeners())}ngAfterViewInit(){this.pDraggableDisabled||(this.el.nativeElement.draggable=!0,this.bindMouseListeners())}bindDragListener(){this.dragListener||this.zone.runOutsideAngular(()=>{this.dragListener=this.renderer.listen(this.el.nativeElement,"drag",this.drag.bind(this))})}unbindDragListener(){this.dragListener&&this.zone.runOutsideAngular(()=>{this.dragListener&&this.dragListener(),this.dragListener=null})}bindMouseListeners(){!this.mouseDownListener&&!this.mouseUpListener&&this.zone.runOutsideAngular(()=>{this.mouseDownListener=this.renderer.listen(this.el.nativeElement,"mousedown",this.mousedown.bind(this)),this.mouseUpListener=this.renderer.listen(this.el.nativeElement,"mouseup",this.mouseup.bind(this))})}unbindMouseListeners(){this.mouseDownListener&&this.mouseUpListener&&this.zone.runOutsideAngular(()=>{this.mouseDownListener&&this.mouseDownListener(),this.mouseUpListener&&this.mouseUpListener(),this.mouseDownListener=null,this.mouseUpListener=null})}drag(e){this.onDrag.emit(e)}dragStart(e){this.allowDrag()&&!this.pDraggableDisabled?(this.dragEffect&&(e.dataTransfer.effectAllowed=this.dragEffect),e.dataTransfer.setData("text",this.scope),this.onDragStart.emit(e),this.bindDragListener()):e.preventDefault()}dragEnd(e){this.onDragEnd.emit(e),this.unbindDragListener()}mousedown(e){this.handle=e.target}mouseup(e){this.handle=null}allowDrag(){return this.dragHandle&&this.handle?ie.matches(this.handle,this.dragHandle):!0}ngOnDestroy(){this.unbindDragListener(),this.unbindMouseListeners()}static \u0275fac=function(t){return new(t||i)(f(S),f(T),f(M))};static \u0275dir=P({type:i,selectors:[["","pDraggable",""]],hostBindings:function(t,n){t&1&&g("dragstart",function(p){return n.dragStart(p)})("dragend",function(p){return n.dragEnd(p)})},inputs:{scope:[0,"pDraggable","scope"],dragEffect:"dragEffect",dragHandle:"dragHandle",pDraggableDisabled:"pDraggableDisabled"},outputs:{onDragStart:"onDragStart",onDragEnd:"onDragEnd",onDrag:"onDrag"}})}return i})(),ge=(()=>{class i{el;zone;renderer;scope;_pDroppableDisabled=!1;get pDroppableDisabled(){return this._pDroppableDisabled}set pDroppableDisabled(e){this._pDroppableDisabled=e,this._pDroppableDisabled?this.unbindDragOverListener():this.bindDragOverListener()}dropEffect;onDragEnter=new c;onDragLeave=new c;onDrop=new c;constructor(e,t,n){this.el=e,this.zone=t,this.renderer=n}dragOverListener;ngAfterViewInit(){this.pDroppableDisabled||this.bindDragOverListener()}bindDragOverListener(){this.dragOverListener||this.zone.runOutsideAngular(()=>{this.dragOverListener=this.renderer.listen(this.el.nativeElement,"dragover",this.dragOver.bind(this))})}unbindDragOverListener(){this.dragOverListener&&this.zone.runOutsideAngular(()=>{this.dragOverListener&&this.dragOverListener(),this.dragOverListener=null})}dragOver(e){e.preventDefault()}drop(e){this.allowDrop(e)&&(A(this.el.nativeElement,"p-draggable-enter"),e.preventDefault(),this.onDrop.emit(e))}dragEnter(e){e.preventDefault(),this.dropEffect&&(e.dataTransfer.dropEffect=this.dropEffect),te(this.el.nativeElement,"p-draggable-enter"),this.onDragEnter.emit(e)}dragLeave(e){e.preventDefault(),this.el.nativeElement.contains(e.relatedTarget)||(A(this.el.nativeElement,"p-draggable-enter"),this.onDragLeave.emit(e))}allowDrop(e){let t=e.dataTransfer.getData("text");if(typeof this.scope=="string"&&t==this.scope)return!0;if(Array.isArray(this.scope)){for(let n=0;n<this.scope.length;n++)if(t==this.scope[n])return!0}return!1}ngOnDestroy(){this.unbindDragOverListener()}static \u0275fac=function(t){return new(t||i)(f(S),f(T),f(M))};static \u0275dir=P({type:i,selectors:[["","pDroppable",""]],hostBindings:function(t,n){t&1&&g("drop",function(p){return n.drop(p)})("dragenter",function(p){return n.dragEnter(p)})("dragleave",function(p){return n.dragLeave(p)})},inputs:{scope:[0,"pDroppable","scope"],pDroppableDisabled:"pDroppableDisabled",dropEffect:"dropEffect"},outputs:{onDragEnter:"onDragEnter",onDragLeave:"onDragLeave",onDrop:"onDrop"}})}return i})();var he=[[["","headerMessage",""]],"*"],_e=["[headerMessage]","*"],De=["[select]","position"],ve=()=>["previewMessage"],ce=(i,a)=>({preview:i,position:a}),be=()=>({cursor:"grab"}),Ee=()=>["previewBottomMessage"];function we(i,a){if(i&1&&I(0,3),i&2){let e=d(),t=j(18);m("ngTemplateOutlet",t)("ngTemplateOutletContext",N(3,ce,e.preview,x(2,ve)))}}function ye(i,a){i&1&&(u(0),h(1,"translate")),i&2&&C(" ",_(1,1,"Suggested email address")," ")}function Ce(i,a){i&1&&(u(0),h(1,"translate")),i&2&&C(" ",_(1,1,"Suggested email addresses")," ")}function xe(i,a){if(i&1&&(r(0,"div",12),E(1,ye,2,3)(2,Ce,2,3),r(3,"small",13),u(4,"("),r(5,"span",14),u(6,"Drag and drop"),s(),u(7,")"),s()()),i&2){let e=d(2);l(),w(e.emails.length<2?1:2)}}function Le(i,a){if(i&1){let e=V();r(0,"p-tag",15),g("onDragStart",function(){let n=v(e).$implicit,o=d(2);return b(o.dragStart(n))})("onDragEnd",function(){v(e);let n=d(2);return b(n.dragEnd())}),s()}if(i&2){let e=a.$implicit;K(x(3,be)),m("value",e)}}function Te(i,a){if(i&1&&(r(0,"p-panel"),y(1,xe,8,1,"ng-template",null,1,L),r(3,"div",10),B(4,Le,1,4,"p-tag",11,O),s()()),i&2){let e=d();l(4),H(e.emails())}}function Se(i,a){if(i&1){let e=V();r(0,"div",16),u(1),h(2,"translate"),s(),r(3,"div",17)(4,"p-autocomplete",18),g("onDrop",function(n){v(e);let o=d();return b(o.drop(n))})("onBlur",function(n){v(e);let o=d();return b(o.onBlur(n))}),Q("ngModelChange",function(n){let o=v(e).$implicit,p=d();return J(p.recipients[o],n)||(p.recipients[o]=n),b(n)}),s()()}if(i&2){let e=a.$implicit,t=d();q("field-required",t.mandatoryEmailTypes().includes(e)),l(),C(" ",_(2,6,"email_"+e),"\xA0: "),l(3),m("typeahead",!1)("inputId",e),G("ngModel",t.recipients[e])}}function Me(i,a){if(i&1&&I(0,3),i&2){let e=d(),t=j(18);m("ngTemplateOutlet",t)("ngTemplateOutletContext",N(3,ce,e.preview,x(2,Ee)))}}function Pe(i,a){i&1&&(r(0,"div",20)(1,"div",21),u(2,"Message"),s(),r(3,"div",22),F(4,1,De),s()())}function Oe(i,a){if(i&1&&(r(0,"p-panel"),y(1,Pe,5,0,"ng-template",null,1,L),Z(3,"pre",19),s()),i&2){let e=a.preview;l(3),m("innerHTML",e().trim(),U)}}var nt=(()=>{class i{constructor(){this.emails=D(),this.preview=D(),this.previewPosition=D("top"),this.emailTypes=D(["to","cc","bcc","reply_to"]),this.mandatoryEmailTypes=D(["to"]),this.prePopulateRecipients=D(),this.data=R(),this.closeDialog=R(),this.isSending=k(!1),this.draggedEmail=null,this.recipients={to:[],cc:[],bcc:[],reply_to:[]},z(()=>{let e=this.prePopulateRecipients();if(e){let t=Object.keys(this.recipients);e.forEach(n=>{t.includes(n.type)&&this.recipients[n.type].push(n.address)})}})}dragStart(e){this.draggedEmail=e}dragEnd(){this.draggedEmail=null}drop(e){if(this.draggedEmail){let t=e.target.id;t&&!this.recipients[t].some(n=>n===this.draggedEmail)&&this.recipients[t].push(this.draggedEmail)}}close(){this.closeDialog.emit(!0)}confirm(){if(this.isSending())return;this.isSending.set(!0);let e=[];Object.keys(this.recipients).forEach(t=>this.recipients[t].every(n=>e.push({type:t,address:n}))),this.data.emit(e)}formValid(){return this.mandatoryEmailTypes().every(e=>this.recipients[e].length>0)?Object.keys(this.recipients).every(e=>this.recipients[e].every(t=>pe.validateEmail(t))):!1}onBlur(e){let t=e.target;t.value&&t?.dispatchEvent(new KeyboardEvent("keydown",{code:"Enter"}))}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275cmp=W({type:i,selectors:[["admin-preview-email"]],inputs:{emails:[1,"emails"],preview:[1,"preview"],previewPosition:[1,"previewPosition"],emailTypes:[1,"emailTypes"],mandatoryEmailTypes:[1,"mandatoryEmailTypes"],prePopulateRecipients:[1,"prePopulateRecipients"]},outputs:{data:"data",closeDialog:"closeDialog"},ngContentSelectors:_e,decls:19,vars:13,consts:[["messagePreview",""],["header",""],[1,"ui:flex","ui:flex-col","ui:gap-2"],[3,"ngTemplateOutlet","ngTemplateOutletContext"],["translate",""],[3,"header"],[1,"ui:grid","ui:grid-cols-12","ui:gap-4","ui:mt-2","ui:mb-4","ui:mx-4"],[1,"ui:flex","ui:justify-end","ui:gap-1","ui:mt-2"],["severity","danger","outlined","","aria-label","Close",3,"onClick","label"],[3,"onClick","label","disabled"],[1,"ui:flex","ui:gap-1","ui:mb-4","ui:mx-4"],["pDraggable","emails","icon","fa fa-user",3,"style","value"],[1,"p-panel-title"],[1,"ui:ml-1"],["translate","",1,"ui:italic"],["pDraggable","emails","icon","fa fa-user",3,"onDragStart","onDragEnd","value"],[1,"ui:col-span-2"],[1,"ui:col-span-10"],["multiple","","fluid","","pDroppable","emails",3,"onDrop","onBlur","ngModelChange","typeahead","inputId","ngModel"],[1,"ui:max-h-[25rem]","ui:text-sm","ui:overflow-auto","ui:px-5","ui:mb-4",3,"innerHTML"],[1,"ui:grid","ui:grid-flow-row","ui:auto-rows-max"],["translate","",1,"ui:font-bold"],[1,"ui:italic","ui:text-sm"]],template:function(t,n){t&1&&($(he),r(0,"div",2),F(1),E(2,we,1,6,"ng-container",3),r(3,"h5",4),u(4,"Who do you want to send the message to?"),s(),E(5,Te,6,0,"p-panel"),r(6,"p-panel",5),h(7,"translate"),r(8,"div",6),B(9,Se,5,8,null,null,O),s()(),E(11,Me,1,6,"ng-container",3),s(),r(12,"div",7)(13,"p-button",8),h(14,"translate"),g("onClick",function(){return n.close()}),s(),r(15,"p-button",9),h(16,"translate"),g("onClick",function(){return n.confirm()}),s()(),y(17,Oe,4,1,"ng-template",null,0,L)),t&2&&(l(2),w(n.previewPosition()==="top"?2:-1),l(3),w(n.emails().length>0?5:-1),l(),m("header",_(7,7,"Recipients")),l(3),H(n.emailTypes()),l(2),w(n.previewPosition()==="bottom"?11:-1),l(2),m("label",_(14,9,"Cancel")),l(2),m("label",_(16,11,"Confirm"))("disabled",!n.formValid()||n.isSending()))},dependencies:[X,Y,de,le,ue,se,ge,oe,re,ae,ne,ee],encapsulation:2,changeDetection:0})}}return i})();export{me as a,nt as b};