UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

1 lines 2.13 kB
System.register(["./p-c97dd66b.system.js","./p-17866377.system.js"],(function(e){"use strict";var t,n,r,i,s,a;return{setters:[function(e){t=e.r;n=e.c;r=e.h;i=e.H;s=e.g},function(e){a=e.S}],execute:function(){var o=e("calcite_sortable_list",function(){function e(e){var r=this;t(this,e);this.calciteListOrderChange=n(this,"calciteListOrderChange",7);this.handleSelector="calcite-handle";this.disabled=false;this.loading=false;this.handleActivated=false;this.items=[];this.observer=new MutationObserver((function(){r.cleanUpDragAndDrop();r.items=Array.from(r.el.children);r.setUpDragAndDrop()}))}e.prototype.connectedCallback=function(){this.items=Array.from(this.el.children);this.setUpDragAndDrop();this.beginObserving()};e.prototype.disconnectedCallback=function(){this.observer.disconnect();this.cleanUpDragAndDrop()};e.prototype.calciteHandleNudgeHandler=function(e){var t=this.items.find((function(t){return t.contains(e.detail.handle)||e.composedPath().includes(t)}));var n=this.items.length-1;var r=this.items.indexOf(t);var i=false;var s;switch(e.detail.direction){case"up":e.preventDefault();if(r===0){i=true}else{s=r-1}break;case"down":e.preventDefault();if(r===n){s=0}else if(r===n-1){i=true}else{s=r+2}break;default:return}this.observer.disconnect();if(i){t.parentElement.appendChild(t)}else{t.parentElement.insertBefore(t,this.items[s])}this.items=Array.from(this.el.children);e.detail.handle.activated=true;e.detail.handle.setFocus();this.beginObserving()};e.prototype.setUpDragAndDrop=function(){var e=this;this.sortable=a.create(this.el,{handle:this.handleSelector,onUpdate:function(){e.items=Array.from(e.el.children);e.calciteListOrderChange.emit()},onStart:function(){e.observer.disconnect()},onEnd:function(){e.beginObserving()}})};e.prototype.cleanUpDragAndDrop=function(){this.sortable.destroy();this.sortable=null};e.prototype.beginObserving=function(){this.observer.observe(this.el,{childList:true,subtree:true})};e.prototype.render=function(){return r(i,null,r("slot",null))};Object.defineProperty(e.prototype,"el",{get:function(){return s(this)},enumerable:false,configurable:true});return e}())}}}));