UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 1.43 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as t}from"tslib";import e from"../core/Collection.js";import{referenceSetter as r}from"../core/collectionUtils.js";import s from"../core/Logger.js";import{property as o,subclass as i}from"../core/accessorSupport/decorators.js";const a=new Set(["feature","subtype-group"]);function l(t,e,r){if(t)for(let s=0,o=t.length;s<o;s++){const o=t.at(s);if(o[e]===r)return o;if("group"===o?.type){const t=l(o.tables,e,r);if(t)return t}}}const n=n=>{const p=n;let d=class extends p{constructor(...t){super(...t),this.tables=new e,this.addHandles([this.tables.on("after-add",t=>{const e=t.item;e.parent&&e.parent!==this&&e.removeFromParent(),e.parent=this,a.has(e.type)||s.getLogger(this).error(`Layer 'title:${e.title}, id:${e.id}' of type '${e.type}' is not supported as a table and will therefore be ignored.`)}),this.tables.on("after-remove",t=>{t.item.parent=null})])}destroy(){const t=this.tables.toArray();for(const e of t)e.destroy();this.tables.destroy()}removeChildLayer(t){this.tables.remove(t),super.removeChildLayer?.(t)}get tables(){return this._get("tables")}set tables(t){this._set("tables",r(t,this._get("tables")))}findTableById(t){return l(this.tables,"id",t)}findTableByUid(t){return l(this.tables,"uid",t)}};return t([o()],d.prototype,"tables",null),d=t([i("esri.support.TablesMixin")],d),d};export{n as TablesMixin,a as allowedTableTypes};