@aurigma/ui-framework
Version:
A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.
1 lines • 2.45 kB
JavaScript
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[25],{906:function(e,t,i){i.r(t),i.d(t,"AuWidgetDndController",function(){return a}),i.d(t,"widget",function(){return a});var t=i(0),d=i(160),s=i(2),o=i(17),n=i(1);let a=class extends d.c{constructor(){super(...arguments),this.toggle=!1}valueChanged(){this.toggle?this.hide(this.hideWidget,this.showWidget):this.show(this.hideWidget,this.showWidget)}updateParams(e){this.hideWidgetName=e.hideWidget,this.showWidgetName=e.showWidget,this.findWidget(this.showWidgetName,"showWidget"),this.findWidget(this.hideWidgetName,"hideWidget"),this.toggle=e.hide||!1,this.subscribeWidget(),this.handleDrop()}handleDrop(){let t=this;["dragenter","dragover","dragleave","dragend","dragexit","drop"].forEach(e=>{this.hideWidget.addEventListener(e,function(e){e.preventDefault(),e.stopPropagation()},!1)}),["dragenter","dragover","drop"].forEach(e=>{this.hideWidget.addEventListener(e,function(e){t.toggle=!0},!1)}),["dragend","dragexit","dragleave"].forEach(e=>{this.hideWidget.addEventListener(e,function(e){t.toggle=!1},!1)})}findWidget(t,i){this.observe(o.a.WIDGET_CONNECTED_CALLBACK).subscribe(e=>{e.name===t&&(e=e.sender,this[i]=e)}).unsubscribe()}subscribeWidget(){this.subscriber=this.observe(o.a.CLOSE_DISPLAYED_WIDGET).subscribe(e=>{e.name===this.showWidgetName&&(this.toggle=!1)})}disconnectedCallback(){this.subscriber.unsubscribe()}hide(e,t){n.a.isNotNullOrUndefined(e)&&n.a.isNotNullOrUndefined(t)&&(e.shadowRoot.contains(t)||e.shadowRoot.appendChild(t),t.setAttribute("style","position:absolute; top:0; left:0; width:100%; height:100%; opacity:1; transition: all 0.1s ease-out; z-index:100000;"))}show(e,t){n.a.isNotNullOrUndefined(e)&&n.a.isNotNullOrUndefined(t)&&t.setAttribute("style","position:absolute; top:0; left:0;pointer-events: none; width:100%; height:100%; opacity:0; transition: all 0.1s ease-in; z-index:-1;")}};Object(t.a)([Object(s.c)(),Object(t.b)("design:type",Object)],a.prototype,"params",void 0),Object(t.a)([Object(s.c)(),Object(t.b)("design:type",String)],a.prototype,"hideWidgetName",void 0),Object(t.a)([Object(s.c)(),Object(t.b)("design:type",String)],a.prototype,"showWidgetName",void 0),Object(t.a)([Object(s.b)("toggle"),Object(t.b)("design:type",Function),Object(t.b)("design:paramtypes",[]),Object(t.b)("design:returntype",void 0)],a.prototype,"valueChanged",null),a=Object(t.a)([Object(s.a)("au-widget-dnd-controller")],a)}}]);