@esri/calcite-components
Version:
Web Components for Esri's Calcite Design System.
1 lines • 2.24 kB
JavaScript
System.register(["./p-1720b7a7.system.js","./p-17866377.system.js"],(function(e){"use strict";var t,r,i,n,s;return{setters:[function(e){t=e.r;r=e.c;i=e.h;n=e.g},function(e){s=e.S}],execute:function(){var a=e("calcite_sortable_list",function(){function e(e){var i=this;t(this,e);this.calciteListOrderChange=r(this,"calciteListOrderChange",7);this.handleSelector="calcite-handle";this.disabled=false;this.loading=false;this.handleActivated=false;this.items=[];this.observer=new MutationObserver((function(){i.items=Array.from(i.el.children);i.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 r=this.items.length-1;var i=this.items.indexOf(t);var n=false;var s;switch(e.detail.direction){case"up":e.preventDefault();if(i===0){n=true}else{s=i-1}break;case"down":e.preventDefault();if(i===r){s=0}else if(i===r-1){n=true}else{s=i+2}break;default:return}this.observer.disconnect();if(n){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.cleanUpDragAndDrop();var t={dataIdAttr:"id",group:this.group,handle:this.handleSelector,onUpdate:function(){e.items=Array.from(e.el.children);e.calciteListOrderChange.emit()},onStart:function(){e.observer.disconnect()},onEnd:function(){e.beginObserving()}};if(this.dragSelector){t.draggable=this.dragSelector}this.sortable=s.create(this.el,t)};e.prototype.cleanUpDragAndDrop=function(){var e;(e=this.sortable)===null||e===void 0?void 0:e.destroy();this.sortable=null};e.prototype.beginObserving=function(){this.observer.observe(this.el,{childList:true,subtree:true})};e.prototype.render=function(){return i("slot",null)};Object.defineProperty(e.prototype,"el",{get:function(){return n(this)},enumerable:false,configurable:true});return e}())}}}));