@arcgis/core 4.30.0-next.20240606 → 4.30.0-next.20240607
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0062b5fc83fc67d813e0.js +1 -0
- package/assets/esri/core/workers/chunks/{288fdc4a4746d6b81687.js → 4468c2c3b489782faa5c.js} +1 -1
- package/assets/esri/core/workers/chunks/6ad7b5817a9594689716.js +1 -0
- package/assets/esri/core/workers/chunks/888ad3cf5eaa472731be.js +1 -0
- package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core-simd.wasm +0 -0
- package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core.wasm +0 -0
- package/interfaces.d.ts +64 -0
- package/layers/CatalogLayer.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/arcgisLayers.js +1 -1
- package/package.json +1 -1
- package/support/elevationInfoUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/3d/interactive/editingTools/manipulatorUtils.js +1 -1
- package/views/3d/interactive/editingTools/originGeometryVisualElementUtils.js +1 -1
- package/views/3d/layers/TiledLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ElevationAgnosticBVH.js +1 -1
- package/webdoc/support/webdocSaveUtils.js +1 -1
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/FeatureTable/support/tableUtils.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/assets/esri/core/workers/chunks/9f2d8940da48c864b2ca.js +0 -1
- package/assets/esri/core/workers/chunks/d03ada1212b13e76bff4.js +0 -1
- package/assets/esri/core/workers/chunks/e21d72debf45c5a33520.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import{IdentifiableMixin as s}from"../core/Identifiable.js";import o from"../core/Logger.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as a,getActionStyles as r}from"../support/actions/actionUtils.js";import c from"./Widget.js";import d from"./BasemapLayerList/BasemapLayerListViewModel.js";import m from"./BasemapLayerList/BasemapLayerListVisibleElements.js";import{css as p}from"./BasemapLayerList/css.js";import u from"./LayerList/ListItem.js";import{minFilterItems as h,getItem as g,getLayerType as f,getStatusIcon as y,sortLayersToIds as b,sortChildLayersToIds as _,listItemHasChildren as v,areChildrenHidden as I,canSortSublayers as L,getVisibilityIcon as w}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as E}from"./support/componentsUtils.js";import{globalCss as F}from"./support/globalCss.js";import{incrementHeadingLevel as C}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as T}from"./support/decorators/messageBundle.js";import{vmEvent as M}from"./support/decorators/vmEvent.js";import{tsx as A}from"./support/jsxFactory.js";const k=t.ofType(u),S=".*\\S+.*";let x=class extends(s(c)){constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new Map,this._editTitleInput=null,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusEditingFlowItem=!1,this._focusCatalogFlowItem=!1,this._catalogFlowItem=null,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`basemap-${this.uid}`,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.editingTitle=!1,this.filterPlaceholder="",this.baseFilterText="",this.referenceFilterText="",this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.minFilterItems=h,this.selectedItems=new k,this.selectionMode="none",this.viewModel=new d,this.visibilityAppearance="default",this.visibleElements=new m,this._canMove=({dragEl:e,fromEl:t,toEl:i},s)=>{const o="pull"===s?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,l=g(e);if(!l?.sortable)return!1;const n=g(t),a=f(t),r=g(i),c=f(i),d=!!a&&!!c&&a===c,m={selected:l,from:n,to:r},p=t.group,u=i.group,h=n?.layer?.type??"",y=r?.layer?.type??"",b=new Set(["map-image","catalog","knowledge-graph"]),_="sublayer";return p&&u&&"function"==typeof o?o.call(null,m):d&&!b.has(h)&&!b.has(y)&&l?.layer?.type!==_},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(p.item)));this._activeItem=g(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:s,dragEl:o,newIndex:l}=e;if(!s||!i||t?.newIndex===l&&t?.dragEl===o&&t?.toEl===i&&t?.fromEl===s)return;this._lastDragDetail=e;const n=s,a=i;if(n!==a)this._moveLayerFromChildList({toEl:a,fromEl:n,dragEl:o,newIndex:l});else{const e=Array.from(s.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(n,e)}}}normalizeCtorArgs(e){return null!=e?.editingEnabled&&null!=e.visibleElements?{...e,visibleElements:new m({...e.visibleElements,editTitleButton:e.editingEnabled})}:e}loadDependencies(){return E({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._tooltipReferenceMap.clear()}get _totalBaseItems(){return this.viewModel.baseItems.flatten((e=>e.children.filter((e=>"catalog-dynamic-group"!==e.layer.type)))).length}get _totalReferenceItems(){return this.viewModel.referenceItems.flatten((e=>e.children.filter((e=>"catalog-dynamic-group"!==e.layer.type)))).length}get _baseFilterEnabled(){return this._totalBaseItems>=this.minFilterItems&&this.visibleElements.filter}get _referenceFilterEnabled(){return this._totalReferenceItems>=this.minFilterItems&&this.visibleElements.filter}get basemapTitle(){return this.viewModel.basemapTitle}set basemapTitle(e){this.viewModel.basemapTitle=e}get baseListItemCreatedFunction(){return this.viewModel.baseListItemCreatedFunction}set baseListItemCreatedFunction(e){this.viewModel.baseListItemCreatedFunction=e}get editingEnabled(){return i(o.getLogger(this),"editingEnabled",{replacement:"selectionMode, dragEnabled, visibleElements.editTitleButton",version:"4.29",warnOnce:!0}),"none"!==this.selectionMode&&this.dragEnabled&&this.visibleElements.editTitleButton}set editingEnabled(e){i(o.getLogger(this),"editingEnabled",{replacement:"selectionMode, dragEnabled, visibleElements.editTitleButton",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.visibleElements.editTitleButton=e,this.selectionMode=e?this.multipleSelectionEnabled?"multiple":"single":"none"}get icon(){return"layers"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multipleSelectionEnabled(){return i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),this.selectionMode=e?"multiple":this.editingEnabled?"single":"none"}get referenceListItemCreatedFunction(){return this.viewModel.referenceListItemCreatedFunction}set referenceListItemCreatedFunction(e){this.viewModel.referenceListItemCreatedFunction=e}get baseItems(){return this.viewModel.baseItems}get referenceItems(){return this.viewModel.referenceItems}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const{state:e}=this.viewModel,t={[F.hidden]:"loading"===e,[F.disabled]:"disabled"===e};return A("div",{class:this.classes(p.base,F.widget,F.panel,t)},this._renderItems())}_renderItemTooltip(e){return e?A("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,referenceElement:this._tooltipReferenceMap.get(e.layer.uid)},this.messages.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}async _createCatalog(e){const{default:t}=await import("./CatalogLayerList.js"),{headingLevel:i,catalogOptions:s,view:o,filterPlaceholder:l,baseListItemCreatedFunction:n,referenceListItemCreatedFunction:a,minFilterItems:r,selectionMode:c,visibilityAppearance:d}=this,m=this._catalogFlowItem?.layer;this._set("catalogLayerList",new t({headingLevel:i,view:o,filterPlaceholder:l,minFilterItems:r,selectionMode:c,listItemCreatedFunction:"base"===e?n:a,visibilityAppearance:d,...s,catalogLayer:m}))}_destroyCatalog(){this._catalogFlowItem=null,this._focusRootFlowItem=!0,this.catalogLayerList?.destroy(),this._set("catalogLayerList",null)}_renderCatalogFlowItem(){const{_catalogFlowItem:e,messages:t}=this;if(!e)return null;const i=this._getLayerTitle(e);return A("calcite-flow-item",{afterCreate:this._focusCatalogFlowItemNode,afterUpdate:this._focusCatalogFlowItemNode,bind:this,description:i,heading:t.catalogLayers,headingLevel:this.headingLevel,key:`flow-catalog-${e.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),this._destroyCatalog()}},this.catalogLayerList?.render())}_focusCatalogFlowItemNode(e){this._focusCatalogFlowItem&&(this._focusCatalogFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled)).toArray().map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return A("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),A("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusEditingFlowItemNode(e){this._focusEditingFlowItem&&(this._focusEditingFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItemMessage(e){return e.error?A("div",{class:p.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},A("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},A("div",{slot:"message"},this.messages.layerError))):e.incompatible?A("div",{class:p.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},A("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},A("div",{slot:"message"},this.messages.layerIncompatible))):null}_getLayerTitle(e){return e.title||this.messages.untitledLayer}_renderItem(e,t,i,s,o){const{_activeItem:l,_selectedDragItemLayerUid:n,selectionMode:a,selectedItems:r,messages:c,visibleElements:d}=this,m=this._getLayerTitle(e),u=e.visibleAtCurrentTimeExtent?e.visibleAtCurrentScale?m:`${m} (${c.layerInvisibleAtScale})`:`${m} (${c.layerInvisibleAtTime})`,h=this._filterActions(e.actionsSections),g=this._countActions(h),f="catalog"===e.parent?.layer?.type,y="catalog-footprint"===e.layer?.type,b="catalog-dynamic-group"===e.layer?.type,_=y?A("calcite-icon",{class:p.itemCatalogIcon,icon:"footprint",key:"footprint",scale:"s",slot:"content-start"}):null,v=d.catalogLayerList&&b?A("calcite-icon",{class:p.itemCatalogIcon,icon:"catalog-dataset",key:"catalog-dataset",scale:"s",slot:"content-start"}):null,I=b?A("calcite-action",{appearance:"transparent",icon:"chevron-right",iconFlipRtl:!0,onclick:()=>{this._catalogFlowItem=s,this._focusCatalogFlowItem=!0,this._createCatalog(t)},scale:"s",slot:"actions-end",text:m}):null;return A("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes(p.item,{[p.itemActive]:l===e}),"data-item":e,"data-layer-id":e.layer.id,dragDisabled:!e.sortable||i||f,dragSelected:e.layer.uid===n,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:m,metadata:{parentTitles:o,title:m},open:e.open,selected:"none"!==a&&r.includes(e),title:u,value:e.layer.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:t=>this._handleCalciteListItemSelect(t,e,s),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},_,v,A("div",{class:this.classes({[p.itemContent]:!0,[p.itemInvisible]:!e.visibleAtCurrentScale||!e.visibleAtCurrentTimeExtent}),slot:"content"},m),this._renderItemStatus(e,s),this._renderItemToggle(e,s),I,this._renderItemTemporaryIcon(e),this._renderChildList(e,t,o),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),g>1?this._renderActionsSections(e,h):1===g?this._renderAction({item:e,action:this._getSingleAction(h),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:s,publishing:o,updating:l}=e,n=l&&!t,a=!!s;return A("calcite-icon",{class:this.classes({[p.statusIndicator]:!0,[p.publishing]:o,[p.updating]:n,[p.connectionStatus]:a,[p.connectionStatusConnected]:a&&"connected"===s}),icon:y({connectionStatus:s,publishing:o}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryLayerIndicators&&"persistenceEnabled"in e.layer&&!e.layer.persistenceEnabled?A("calcite-icon",{class:p.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messages.temporary}):null}_renderItemToggle(e,t){const{messages:i,visibilityAppearance:s}=this,{visible:o}=e,l=t?.visibilityMode;if("inherited"===l)return null;const n=w({visible:o,exclusive:"exclusive"===l,visibilityAppearance:s}),a="checkbox"===s,r=i.layerVisibility;return A("calcite-action",{appearance:"transparent",class:p.visibleToggle,icon:a?n:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:a?"actions-start":"actions-end",text:r,title:r},a?null:A("calcite-icon",{class:this.classes({[p.visibleIcon]:"exclusive"!==l&&o}),icon:n,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:A("div",{class:p.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:s}=e;return A("calcite-action",{active:t,appearance:"transparent",disabled:s,icon:a(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){const i=this.messagesCommon.options;return A("calcite-action-menu",{appearance:"transparent",class:p.actionMenu,key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},A("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:i,title:i}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return A("calcite-action-group",{class:p.actionGroup,key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const s="image"in e?e.image:void 0,o={[p.itemActionIcon]:!!t,[p.itemActionImage]:!!s};return t&&(o[t]=!0),s||t?A("span",{"aria-hidden":"true",class:this.classes(p.itemActionIcon,o),key:"icon",styles:r(s)}):null}_renderAction(e){const{item:t,action:i,textEnabled:s}=e;if(!i)return null;const{active:o,disabled:l,title:n,type:r,indicator:c}=i;return A("calcite-action",{active:"toggle"===r&&i.value,appearance:"transparent",disabled:l,icon:a(i),indicator:c,key:`action-${i.uid}`,loading:o,onclick:()=>this._triggerAction(t,i),scale:"s",slot:s?void 0:"actions-end",text:n??"",textEnabled:s,title:n??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.layer.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.layer.uid)}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:s}){const o=g(i),l=g(e),n=g(t),a=j(t),r=j(e);a&&r&&this.viewModel.moveListItem({targetItem:o,fromParentItem:n,toParentItem:l,newIndex:s,from:a,to:r})}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:s}=e;t.insertBefore(i,t.children[s])}_sortLayers(e,t){if(e)if(e.group===this._rootGroupUid){const i=j(e),s="base"===i?this.view?.map?.basemap?.baseLayers:"reference"===i?this.view?.map?.basemap?.referenceLayers:null;b(s,t)}else{const i=g(e);if(!i)return;_(i,t)}}_getSingleAction(e){return e.reduce((e=>e)).find((e=>e&&("button"===e.type||"toggle"===e.type)))}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const s=e.target.selectedItems.map((e=>g(e))).filter(Boolean);i.removeAll(),i.addMany(s)}_handleCalciteListItemToggle(e,t){e.stopPropagation(),t.open=e.target.open}_focusSelectedDragEl(e,t){this._selectedDragItemLayerUid===t.layer.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const i=e.target.dragSelected;this._selectedDragItemLayerUid=i?t.layer.uid:null}_handleCalciteListItemSelect(e,t,i){g(e.target)===t&&"none"===this.selectionMode&&"inherited"!==i?.visibilityMode&&this._toggleVisibility(t,i)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}_renderEditingInput(){const{messages:e}=this,{basemapTitle:t}=this.viewModel;return A("div",{class:p.editing},A("calcite-label",null,e.basemapTitle,A("calcite-input",{afterCreate:e=>this._editTitleInput=e,label:e.basemapTitle,name:"basemaptitle",pattern:S,placeholder:e.basemapTitle,required:!0,title:e.basemapTitle,type:"text",value:t??void 0})))}_renderCancelButton(){const{messagesCommon:{cancel:e}}=this;return A("calcite-button",{appearance:"outline",bind:this,label:e,onclick:this._toggleEditingTitle,slot:"footer",title:e,width:"half"},e)}_renderSubmitButton(){const{messagesCommon:e}=this;return A("calcite-button",{label:e.form.submit,slot:"footer",title:e.form.submit,type:"submit",width:"half"},e.form.ok)}_renderEditingForm(){return this.editingTitle?A("form",{bind:this,onsubmit:this._formSubmit},A("calcite-flow-item",{afterCreate:this._focusEditingFlowItemNode,afterUpdate:this._focusEditingFlowItemNode,bind:this,heading:this.visibleElements.heading?this.messages.basemapTitle:void 0,headingLevel:this.headingLevel,onCalciteFlowItemBack:e=>{e.preventDefault(),this._toggleEditingTitle()}},this._renderEditingInput(),this._renderCancelButton(),this._renderSubmitButton())):null}_renderEditTitleButton(){const{editingTitle:e,visibleElements:t,messagesCommon:i}=this,s=i.edit;return t.editTitleButton&&!e?A("calcite-action",{bind:this,icon:"pencil",onclick:this._toggleEditingTitle,slot:"header-actions-end",text:s,title:s}):null}_renderNoLayersInfoMessage(e){return A("div",{slot:"message"},e)}_renderNoLayersInfo(e,t){return A("div",{class:p.itemMessage},A("calcite-notice",{icon:"information",key:t,kind:"info",open:!0,width:"full"},this._renderNoLayersInfoMessage(e)))}_getFilteredItems(e){return e?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}_renderItems(){const{collapsed:e,visible:t,visibleElements:{closeButton:i,collapseButton:s,heading:o,flow:l},messages:n,viewModel:a,referenceItems:r,baseItems:c}=this,d=this.visibleElements.referenceLayers?this._getFilteredItems(r):null,m=this.visibleElements.baseLayers?this._getFilteredItems(c):null,p=[A("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:i,closed:!t,collapsed:e,collapsible:s,heading:o?a.basemapTitle??n.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},this._renderEditTitleButton(),this._renderReferenceSection(d),this._renderBaseSection(m,1===m?.length)),this._renderEditingForm(),this._renderPanelFlowItems(m),this._renderPanelFlowItems(d),this._renderCatalogFlowItem()];return t?[l?A("calcite-flow",{key:"root-flow"},p):p,this._renderItemTooltips(d),this._renderItemTooltips(m)]:null}_renderChildList(e,t,i=[]){const{_rootGroupUid:s,dragEnabled:o,viewModel:{listModeDisabled:l},selectionMode:n}=this,{children:a}=e,r="catalog-dynamic-group"!==e.layer?.type&&v(e),c=!(!l&&I(e.layer))&&!r&&o&&"group"===e.layer?.type;return r||c?A("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-basemap-layer-type":t,"data-item":e,"data-layer-type":s,dragEnabled:!!o&&(e.childrenSortable&&L(e)),group:`${s}-${e.layer.uid}`,key:`child-list-${e.layer.uid}`,selectionAppearance:"border",selectionMode:n},a?.filter((e=>!e.hidden)).toArray().map((s=>this._renderItem(s,t,!1,e,[...i,e.title])))):null}_renderList(e,t,i){const{messages:s,dragEnabled:o,selectionMode:l,filterPlaceholder:n,baseFilterText:a,referenceFilterText:r,_baseFilterEnabled:c,_referenceFilterEnabled:d,_rootGroupUid:m}=this,u="reference"===t?s.noReferenceLayers:s.noBaseLayers,h="reference"===t?d:c;return A("calcite-block",{class:p.section,collapsible:!0,heading:"reference"===t?s.referenceHeading:s.baseHeading,headingLevel:C(this.headingLevel),key:`block-${t}`,open:!0},0===e?.length?this._renderNoLayersInfo(u,t):null,A("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-basemap-layer-type":t,"data-layer-type":m,dragEnabled:o,filterEnabled:h,filterPlaceholder:n,filterText:h?"reference"===t?r:a:"",group:m,key:`list-${t}`,label:s.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:l,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this["reference"===t?"referenceFilterText":"baseFilterText"]=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e,t,i))),e?.length&&h?A("div",{class:p.filterNoResults,slot:"filter-no-results"},A("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoLayersInfoMessage(u))):null))}_renderBaseSection(e,t){return this.visibleElements.baseLayers?this._renderList(e,"base",t):null}_renderReferenceSection(e){return this.visibleElements.referenceLayers?this._renderList(e,"reference",!1):null}_toggleEditingTitle(){const{editingTitle:e}=this,t=!e;this.editingTitle=t,t?this._focusEditingFlowItem=!0:this._focusRootFlowItem=!0}_formSubmit(e){e.preventDefault();const t=this._editTitleInput?.value;t?.trim()&&(this.basemapTitle=t),this._toggleEditingTitle()}};function j(e){return e?.getAttribute("data-basemap-layer-type")}e([l()],x.prototype,"_activeItem",void 0),e([l()],x.prototype,"_tooltipReferenceMap",void 0),e([l()],x.prototype,"_focusRootFlowItem",void 0),e([l()],x.prototype,"_focusPanelFlowItem",void 0),e([l()],x.prototype,"_focusEditingFlowItem",void 0),e([l()],x.prototype,"_focusCatalogFlowItem",void 0),e([l()],x.prototype,"_catalogFlowItem",void 0),e([l()],x.prototype,"_totalBaseItems",null),e([l()],x.prototype,"_totalReferenceItems",null),e([l()],x.prototype,"_baseFilterEnabled",null),e([l()],x.prototype,"_referenceFilterEnabled",null),e([l()],x.prototype,"basemapTitle",null),e([l({readOnly:!0})],x.prototype,"catalogLayerList",void 0),e([l()],x.prototype,"catalogOptions",void 0),e([l()],x.prototype,"collapsed",void 0),e([l()],x.prototype,"dragEnabled",void 0),e([l()],x.prototype,"editingTitle",void 0),e([l()],x.prototype,"filterPlaceholder",void 0),e([l()],x.prototype,"baseFilterText",void 0),e([l()],x.prototype,"referenceFilterText",void 0),e([l()],x.prototype,"listItemCanGiveFunction",void 0),e([l()],x.prototype,"listItemCanReceiveFunction",void 0),e([l()],x.prototype,"baseListItemCreatedFunction",null),e([l()],x.prototype,"editingEnabled",null),e([l()],x.prototype,"headingLevel",void 0),e([l()],x.prototype,"icon",null),e([l()],x.prototype,"label",null),e([l(),T("esri/widgets/BasemapLayerList/t9n/BasemapLayerList")],x.prototype,"messages",void 0),e([l(),T("esri/t9n/common")],x.prototype,"messagesCommon",void 0),e([l()],x.prototype,"minFilterItems",void 0),e([l()],x.prototype,"multipleSelectionEnabled",null),e([l()],x.prototype,"referenceListItemCreatedFunction",null),e([l({readOnly:!0})],x.prototype,"baseItems",null),e([l({readOnly:!0})],x.prototype,"referenceItems",null),e([l()],x.prototype,"selectedItems",void 0),e([l()],x.prototype,"selectionMode",void 0),e([l()],x.prototype,"view",null),e([M("trigger-action"),l({type:d})],x.prototype,"viewModel",void 0),e([l()],x.prototype,"visibilityAppearance",void 0),e([l({type:m,nonNullable:!0})],x.prototype,"visibleElements",void 0),x=e([n("esri.widgets.BasemapLayerList")],x);const B=x;export{B as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import{IdentifiableMixin as s}from"../core/Identifiable.js";import o from"../core/Logger.js";import{watch as l}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as r,getActionStyles as c}from"../support/actions/actionUtils.js";import d from"./Widget.js";import m from"./BasemapLayerList/BasemapLayerListViewModel.js";import p from"./BasemapLayerList/BasemapLayerListVisibleElements.js";import{css as u}from"./BasemapLayerList/css.js";import h from"./LayerList/ListItem.js";import{minFilterItems as g,getItem as f,getLayerType as y,getStatusIcon as b,sortLayersToIds as _,sortChildLayersToIds as v,listItemHasChildren as I,areChildrenHidden as L,canSortSublayers as w,getVisibilityIcon as E}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{globalCss as F}from"./support/globalCss.js";import{incrementHeadingLevel as T}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as A}from"./support/decorators/vmEvent.js";import{tsx as k}from"./support/jsxFactory.js";const S=t.ofType(h),x=".*\\S+.*";let j=class extends(s(d)){constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new Map,this._editTitleInput=null,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusEditingFlowItem=!1,this._focusCatalogFlowItem=!1,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`basemap-${this.uid}`,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.editingTitle=!1,this.filterPlaceholder="",this.baseFilterText="",this.referenceFilterText="",this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.minFilterItems=g,this.openCatalogItem=null,this.selectedItems=new S,this.selectionMode="none",this.viewModel=new m,this.visibilityAppearance="default",this.visibleElements=new p,this._canMove=({dragEl:e,fromEl:t,toEl:i},s)=>{const o="pull"===s?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,l=f(e);if(!l?.sortable)return!1;const n=f(t),a=y(t),r=f(i),c=y(i),d=!!a&&!!c&&a===c,m={selected:l,from:n,to:r},p=t.group,u=i.group,h=n?.layer?.type??"",g=r?.layer?.type??"",b=new Set(["map-image","catalog","knowledge-graph"]),_="sublayer";return p&&u&&"function"==typeof o?o.call(null,m):d&&!b.has(h)&&!b.has(g)&&l?.layer?.type!==_},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(u.item)));this._activeItem=f(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:s,dragEl:o,newIndex:l}=e;if(!s||!i||t?.newIndex===l&&t?.dragEl===o&&t?.toEl===i&&t?.fromEl===s)return;this._lastDragDetail=e;const n=s,a=i;if(n!==a)this._moveLayerFromChildList({toEl:a,fromEl:n,dragEl:o,newIndex:l});else{const e=Array.from(s.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(n,e)}}}initialize(){this.addHandles([l((()=>this.openCatalogItem),(e=>e?this._createCatalog():this._destroyCatalog()))])}normalizeCtorArgs(e){return null!=e?.editingEnabled&&null!=e.visibleElements?{...e,visibleElements:new p({...e.visibleElements,editTitleButton:e.editingEnabled})}:e}loadDependencies(){return C({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._tooltipReferenceMap.clear()}get _totalBaseItems(){return this.viewModel.baseItems.flatten((e=>e.children.filter((e=>"catalog-dynamic-group"!==e.layer.type)))).length}get _totalReferenceItems(){return this.viewModel.referenceItems.flatten((e=>e.children.filter((e=>"catalog-dynamic-group"!==e.layer.type)))).length}get _baseFilterEnabled(){return this._totalBaseItems>=this.minFilterItems&&this.visibleElements.filter}get _referenceFilterEnabled(){return this._totalReferenceItems>=this.minFilterItems&&this.visibleElements.filter}get basemapTitle(){return this.viewModel.basemapTitle}set basemapTitle(e){this.viewModel.basemapTitle=e}get baseListItemCreatedFunction(){return this.viewModel.baseListItemCreatedFunction}set baseListItemCreatedFunction(e){this.viewModel.baseListItemCreatedFunction=e}get editingEnabled(){return i(o.getLogger(this),"editingEnabled",{replacement:"selectionMode, dragEnabled, visibleElements.editTitleButton",version:"4.29",warnOnce:!0}),"none"!==this.selectionMode&&this.dragEnabled&&this.visibleElements.editTitleButton}set editingEnabled(e){i(o.getLogger(this),"editingEnabled",{replacement:"selectionMode, dragEnabled, visibleElements.editTitleButton",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.visibleElements.editTitleButton=e,this.selectionMode=e?this.multipleSelectionEnabled?"multiple":"single":"none"}get icon(){return"layers"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multipleSelectionEnabled(){return i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),this.selectionMode=e?"multiple":this.editingEnabled?"single":"none"}get referenceListItemCreatedFunction(){return this.viewModel.referenceListItemCreatedFunction}set referenceListItemCreatedFunction(e){this.viewModel.referenceListItemCreatedFunction=e}get baseItems(){return this.viewModel.baseItems}get referenceItems(){return this.viewModel.referenceItems}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const{state:e}=this.viewModel,t={[F.hidden]:"loading"===e,[F.disabled]:"disabled"===e};return k("div",{class:this.classes(u.base,F.widget,F.panel,t)},this._renderItems())}_renderItemTooltip(e){return e?k("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,referenceElement:this._tooltipReferenceMap.get(e.layer.uid)},this.messages.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}async _createCatalog(){this._destroyCatalog();const{default:e}=await import("./CatalogLayerList.js"),{headingLevel:t,catalogOptions:i,view:s,filterPlaceholder:o,baseListItemCreatedFunction:l,referenceListItemCreatedFunction:n,minFilterItems:a,selectionMode:r,visibilityAppearance:c,openCatalogItem:d,referenceItems:m}=this,p=d&&m.flatten((e=>e.children)).includes(d)?"reference":"base",u=this.openCatalogItem?.layer;this._set("catalogLayerList",new e({headingLevel:t,view:s,filterPlaceholder:o,minFilterItems:a,selectionMode:r,listItemCreatedFunction:"base"===p?l:n,visibilityAppearance:c,...i,catalogLayer:u}))}_destroyCatalog(){this.catalogLayerList?.destroy(),this._set("catalogLayerList",null)}_renderCatalogFlowItem(){const{openCatalogItem:e,messages:t}=this;if(!e)return null;const i=this._getLayerTitle(e);return k("calcite-flow-item",{afterCreate:this._focusCatalogFlowItemNode,afterUpdate:this._focusCatalogFlowItemNode,bind:this,description:i,heading:t.catalogLayers,headingLevel:this.headingLevel,key:`flow-catalog-${e.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),this.openCatalogItem=null,this._focusRootFlowItem=!0}},this.catalogLayerList?.render())}_focusCatalogFlowItemNode(e){this._focusCatalogFlowItem&&(this._focusCatalogFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled)).toArray().map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return k("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),k("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusEditingFlowItemNode(e){this._focusEditingFlowItem&&(this._focusEditingFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItemMessage(e){return e.error?k("div",{class:u.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},k("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},k("div",{slot:"message"},this.messages.layerError))):e.incompatible?k("div",{class:u.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},k("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},k("div",{slot:"message"},this.messages.layerIncompatible))):null}_getLayerTitle(e){return e.title||this.messages.untitledLayer}_renderItem(e,t,i,s,o){const{_activeItem:l,_selectedDragItemLayerUid:n,selectionMode:a,selectedItems:r,messages:c,visibleElements:d}=this,m=this._getLayerTitle(e),p=e.visibleAtCurrentTimeExtent?e.visibleAtCurrentScale?m:`${m} (${c.layerInvisibleAtScale})`:`${m} (${c.layerInvisibleAtTime})`,h=this._filterActions(e.actionsSections),g=this._countActions(h),f="catalog"===e.parent?.layer?.type,y="catalog-footprint"===e.layer?.type,b="catalog-dynamic-group"===e.layer?.type,_=y?k("calcite-icon",{class:u.itemCatalogIcon,icon:"footprint",key:"footprint",scale:"s",slot:"content-start"}):null,v=d.catalogLayerList&&b?k("calcite-icon",{class:u.itemCatalogIcon,icon:"catalog-dataset",key:"catalog-dataset",scale:"s",slot:"content-start"}):null,I=b?k("calcite-action",{appearance:"transparent",icon:"chevron-right",iconFlipRtl:!0,onclick:()=>{this.openCatalogItem=s,this._focusCatalogFlowItem=!0},scale:"s",slot:"actions-end",text:m}):null;return k("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes(u.item,{[u.itemActive]:l===e}),"data-item":e,"data-layer-id":e.layer.id,dragDisabled:!e.sortable||i||f,dragSelected:e.layer.uid===n,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:m,metadata:{parentTitles:o,title:m},open:e.open,selected:"none"!==a&&r.includes(e),title:p,value:e.layer.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:t=>this._handleCalciteListItemSelect(t,e,s),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},_,v,k("div",{class:this.classes({[u.itemContent]:!0,[u.itemInvisible]:!e.visibleAtCurrentScale||!e.visibleAtCurrentTimeExtent}),slot:"content"},m),this._renderItemStatus(e,s),this._renderItemToggle(e,s),I,this._renderItemTemporaryIcon(e),this._renderChildList(e,t,o),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),g>1?this._renderActionsSections(e,h):1===g?this._renderAction({item:e,action:this._getSingleAction(h),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:s,publishing:o,updating:l}=e,n=l&&!t,a=!!s;return k("calcite-icon",{class:this.classes({[u.statusIndicator]:!0,[u.publishing]:o,[u.updating]:n,[u.connectionStatus]:a,[u.connectionStatusConnected]:a&&"connected"===s}),icon:b({connectionStatus:s,publishing:o}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryLayerIndicators&&"persistenceEnabled"in e.layer&&!e.layer.persistenceEnabled?k("calcite-icon",{class:u.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messages.temporary}):null}_renderItemToggle(e,t){const{messages:i,visibilityAppearance:s}=this,{visible:o}=e,l=t?.visibilityMode;if("inherited"===l)return null;const n=E({visible:o,exclusive:"exclusive"===l,visibilityAppearance:s}),a="checkbox"===s,r=i.layerVisibility;return k("calcite-action",{appearance:"transparent",class:u.visibleToggle,icon:a?n:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:a?"actions-start":"actions-end",text:r,title:r},a?null:k("calcite-icon",{class:this.classes({[u.visibleIcon]:"exclusive"!==l&&o}),icon:n,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:k("div",{class:u.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:s}=e;return k("calcite-action",{active:t,appearance:"transparent",disabled:s,icon:r(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){const i=this.messagesCommon.options;return k("calcite-action-menu",{appearance:"transparent",class:u.actionMenu,key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},k("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:i,title:i}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return k("calcite-action-group",{class:u.actionGroup,key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const s="image"in e?e.image:void 0,o={[u.itemActionIcon]:!!t,[u.itemActionImage]:!!s};return t&&(o[t]=!0),s||t?k("span",{"aria-hidden":"true",class:this.classes(u.itemActionIcon,o),key:"icon",styles:c(s)}):null}_renderAction(e){const{item:t,action:i,textEnabled:s}=e;if(!i)return null;const{active:o,disabled:l,title:n,type:a,indicator:c}=i;return k("calcite-action",{active:"toggle"===a&&i.value,appearance:"transparent",disabled:l,icon:r(i),indicator:c,key:`action-${i.uid}`,loading:o,onclick:()=>this._triggerAction(t,i),scale:"s",slot:s?void 0:"actions-end",text:n??"",textEnabled:s,title:n??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.layer.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.layer.uid)}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:s}){const o=f(i),l=f(e),n=f(t),a=B(t),r=B(e);a&&r&&this.viewModel.moveListItem({targetItem:o,fromParentItem:n,toParentItem:l,newIndex:s,from:a,to:r})}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:s}=e;t.insertBefore(i,t.children[s])}_sortLayers(e,t){if(e)if(e.group===this._rootGroupUid){const i=B(e),s="base"===i?this.view?.map?.basemap?.baseLayers:"reference"===i?this.view?.map?.basemap?.referenceLayers:null;_(s,t)}else{const i=f(e);if(!i)return;v(i,t)}}_getSingleAction(e){return e.reduce((e=>e)).find((e=>e&&("button"===e.type||"toggle"===e.type)))}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const s=e.target.selectedItems.map((e=>f(e))).filter(Boolean);i.removeAll(),i.addMany(s)}_handleCalciteListItemToggle(e,t){e.stopPropagation(),t.open=e.target.open}_focusSelectedDragEl(e,t){this._selectedDragItemLayerUid===t.layer.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const i=e.target.dragSelected;this._selectedDragItemLayerUid=i?t.layer.uid:null}_handleCalciteListItemSelect(e,t,i){f(e.target)===t&&"none"===this.selectionMode&&"inherited"!==i?.visibilityMode&&this._toggleVisibility(t,i)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}_renderEditingInput(){const{messages:e}=this,{basemapTitle:t}=this.viewModel;return k("div",{class:u.editing},k("calcite-label",null,e.basemapTitle,k("calcite-input",{afterCreate:e=>this._editTitleInput=e,label:e.basemapTitle,name:"basemaptitle",pattern:x,placeholder:e.basemapTitle,required:!0,title:e.basemapTitle,type:"text",value:t??void 0})))}_renderCancelButton(){const{messagesCommon:{cancel:e}}=this;return k("calcite-button",{appearance:"outline",bind:this,label:e,onclick:this._toggleEditingTitle,slot:"footer",title:e,width:"half"},e)}_renderSubmitButton(){const{messagesCommon:e}=this;return k("calcite-button",{label:e.form.submit,slot:"footer",title:e.form.submit,type:"submit",width:"half"},e.form.ok)}_renderEditingForm(){return this.editingTitle?k("form",{bind:this,onsubmit:this._formSubmit},k("calcite-flow-item",{afterCreate:this._focusEditingFlowItemNode,afterUpdate:this._focusEditingFlowItemNode,bind:this,heading:this.visibleElements.heading?this.messages.basemapTitle:void 0,headingLevel:this.headingLevel,onCalciteFlowItemBack:e=>{e.preventDefault(),this._toggleEditingTitle()}},this._renderEditingInput(),this._renderCancelButton(),this._renderSubmitButton())):null}_renderEditTitleButton(){const{editingTitle:e,visibleElements:t,messagesCommon:i}=this,s=i.edit;return t.editTitleButton&&!e?k("calcite-action",{bind:this,icon:"pencil",onclick:this._toggleEditingTitle,slot:"header-actions-end",text:s,title:s}):null}_renderNoLayersInfoMessage(e){return k("div",{slot:"message"},e)}_renderNoLayersInfo(e,t){return k("div",{class:u.itemMessage},k("calcite-notice",{icon:"information",key:t,kind:"info",open:!0,width:"full"},this._renderNoLayersInfoMessage(e)))}_getFilteredItems(e){return e?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}_renderItems(){const{collapsed:e,visible:t,visibleElements:{closeButton:i,collapseButton:s,heading:o,flow:l},messages:n,viewModel:a,referenceItems:r,baseItems:c}=this,d=this.visibleElements.referenceLayers?this._getFilteredItems(r):null,m=this.visibleElements.baseLayers?this._getFilteredItems(c):null,p=[k("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:i,closed:!t,collapsed:e,collapsible:s,heading:o?a.basemapTitle??n.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},this._renderEditTitleButton(),this._renderReferenceSection(d),this._renderBaseSection(m,1===m?.length)),this._renderEditingForm(),this._renderPanelFlowItems(m),this._renderPanelFlowItems(d),this._renderCatalogFlowItem()];return t?[l?k("calcite-flow",{key:"root-flow"},p):p,this._renderItemTooltips(d),this._renderItemTooltips(m)]:null}_renderChildList(e,t,i=[]){const{_rootGroupUid:s,dragEnabled:o,viewModel:{listModeDisabled:l},selectionMode:n}=this,{children:a}=e,r="catalog-dynamic-group"!==e.layer?.type&&I(e),c=!(!l&&L(e.layer))&&!r&&o&&"group"===e.layer?.type;return r||c?k("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-basemap-layer-type":t,"data-item":e,"data-layer-type":s,dragEnabled:!!o&&(e.childrenSortable&&w(e)),group:`${s}-${e.layer.uid}`,key:`child-list-${e.layer.uid}`,selectionAppearance:"border",selectionMode:n},a?.filter((e=>!e.hidden)).toArray().map((s=>this._renderItem(s,t,!1,e,[...i,e.title])))):null}_renderList(e,t,i){const{messages:s,dragEnabled:o,selectionMode:l,filterPlaceholder:n,baseFilterText:a,referenceFilterText:r,_baseFilterEnabled:c,_referenceFilterEnabled:d,_rootGroupUid:m}=this,p="reference"===t?s.noReferenceLayers:s.noBaseLayers,h="reference"===t?d:c;return k("calcite-block",{class:u.section,collapsible:!0,heading:"reference"===t?s.referenceHeading:s.baseHeading,headingLevel:T(this.headingLevel),key:`block-${t}`,open:!0},0===e?.length?this._renderNoLayersInfo(p,t):null,k("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-basemap-layer-type":t,"data-layer-type":m,dragEnabled:o,filterEnabled:h,filterPlaceholder:n,filterText:h?"reference"===t?r:a:"",group:m,key:`list-${t}`,label:s.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:l,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this["reference"===t?"referenceFilterText":"baseFilterText"]=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e,t,i))),e?.length&&h?k("div",{class:u.filterNoResults,slot:"filter-no-results"},k("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoLayersInfoMessage(p))):null))}_renderBaseSection(e,t){return this.visibleElements.baseLayers?this._renderList(e,"base",t):null}_renderReferenceSection(e){return this.visibleElements.referenceLayers?this._renderList(e,"reference",!1):null}_toggleEditingTitle(){const{editingTitle:e}=this,t=!e;this.editingTitle=t,t?this._focusEditingFlowItem=!0:this._focusRootFlowItem=!0}_formSubmit(e){e.preventDefault();const t=this._editTitleInput?.value;t?.trim()&&(this.basemapTitle=t),this._toggleEditingTitle()}};function B(e){return e?.getAttribute("data-basemap-layer-type")}e([n()],j.prototype,"_activeItem",void 0),e([n()],j.prototype,"_tooltipReferenceMap",void 0),e([n()],j.prototype,"_focusRootFlowItem",void 0),e([n()],j.prototype,"_focusPanelFlowItem",void 0),e([n()],j.prototype,"_focusEditingFlowItem",void 0),e([n()],j.prototype,"_focusCatalogFlowItem",void 0),e([n()],j.prototype,"_totalBaseItems",null),e([n()],j.prototype,"_totalReferenceItems",null),e([n()],j.prototype,"_baseFilterEnabled",null),e([n()],j.prototype,"_referenceFilterEnabled",null),e([n()],j.prototype,"basemapTitle",null),e([n({readOnly:!0})],j.prototype,"catalogLayerList",void 0),e([n()],j.prototype,"catalogOptions",void 0),e([n()],j.prototype,"collapsed",void 0),e([n()],j.prototype,"dragEnabled",void 0),e([n()],j.prototype,"editingTitle",void 0),e([n()],j.prototype,"filterPlaceholder",void 0),e([n()],j.prototype,"baseFilterText",void 0),e([n()],j.prototype,"referenceFilterText",void 0),e([n()],j.prototype,"listItemCanGiveFunction",void 0),e([n()],j.prototype,"listItemCanReceiveFunction",void 0),e([n()],j.prototype,"baseListItemCreatedFunction",null),e([n()],j.prototype,"editingEnabled",null),e([n()],j.prototype,"headingLevel",void 0),e([n()],j.prototype,"icon",null),e([n()],j.prototype,"label",null),e([n(),M("esri/widgets/BasemapLayerList/t9n/BasemapLayerList")],j.prototype,"messages",void 0),e([n(),M("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([n()],j.prototype,"minFilterItems",void 0),e([n()],j.prototype,"multipleSelectionEnabled",null),e([n()],j.prototype,"referenceListItemCreatedFunction",null),e([n({readOnly:!0})],j.prototype,"baseItems",null),e([n()],j.prototype,"openCatalogItem",void 0),e([n({readOnly:!0})],j.prototype,"referenceItems",null),e([n()],j.prototype,"selectedItems",void 0),e([n()],j.prototype,"selectionMode",void 0),e([n()],j.prototype,"view",null),e([A("trigger-action"),n({type:m})],j.prototype,"viewModel",void 0),e([n()],j.prototype,"visibilityAppearance",void 0),e([n({type:p,nonNullable:!0})],j.prototype,"visibleElements",void 0),j=e([a("esri.widgets.BasemapLayerList")],j);const P=j;export{P as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{convertDateFormatToIntlOptions as n,formatDate as r}from"../../../intl/date.js";import{formatNumber as i,convertNumberFormatToIntlOptions as o}from"../../../intl/number.js";import{isRasterPixelValueField as a,featureHasFields as l,isTimeOnlyField as u}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as s}from"../../../layers/support/layerUtils.js";import{formatAnyDate as f,isAnyDateField as c}from"../../../smartMapping/support/utils.js";import{loadArcade as d}from"../../../support/arcadeOnDemand.js";import{getTimeZoneFormattingOptions as p}from"../../../time/timeZoneUtils.js";const y="esri.widgets.Feature.support.featureUtils",m=()=>e.getLogger(y),g=/href=(""|'')/gi,h=/(\{([^{\r\n]+)\})/g,I=/'/g,b=/^\s*expression\//i,T=/(\n)/gi,w=/[\u00A0-\u9999<>&]/gim,F=/href\s*=\s*(?:"([^"]+)"|'([^']+)')/gi,N=/^(?:mailto:|tel:)/,j="relationships/",Z=n("short-date-short-time");function L(e){if(null!=e)return(e.sourceLayer||e.layer)??void 0}async function E({type:e,value:t,event:n}){try{return"function"==typeof t?t(n):t}catch(r){return void m().error("error",`An error occurred when calling the "${e}" function`,{error:r,graphic:n.graphic,value:t})}}function v(e=""){if(e)return!N.test(e.trim().toLowerCase())}function x(e){return!!e&&b.test(e)}function A(e,t){if(!t||!x(t)||!e)return;const n=t.replace(b,"").toLowerCase();return e.find((({name:e})=>e.toLowerCase()===n))}function C(e,t){const n=A(t,e?.fieldName);return n?n.title||null:e?e.label||e.fieldName:null}function M(e,t){const n=t.get(e.toLowerCase());return`{${n?.fieldName||e}}`}function U(e){return e.replaceAll(g,"")}function q(e,t){const n=$(t,e);return n?n.name:e}function R(e,t){return e&&e.map((e=>q(e,t)))}function $(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function k(e){return`${e}`.trim()}function D({attributes:e,globalAttributes:t,layer:n,text:r,expressionAttributes:i,fieldInfoMap:o}){return r?z({formattedAttributes:t,template:Q(r,{...t,...i,...e},n),fieldInfoMap:o}):""}function z({formattedAttributes:e,template:n,fieldInfoMap:r}){return k(U(t(t(n,(e=>M(e,r))),e)))}function O(e,t,n=!1){const r=t[e];if("string"==typeof r){const i="%27",o=(n?encodeURIComponent(r):r).replaceAll(I,i);t[e]=o}}function G(e,t=!1){const n={...e};return Object.keys(n).forEach((e=>O(e,n,t))),n}function S(e,n,r){const i=(n=k(n))&&"{"!==n[0];return t(e,G(r,i||!1))}function P(e,t){return e.replaceAll(h,((e,n,r)=>{const i=$(t,r);return i?`{${i.name}}`:n}))}function Q(e,t,n){const r=P(e,n);return r?r.replaceAll(F,((e,n,r)=>S(e,n||r,t))):r}function _(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function H(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&("feature"===e.type||"scene"===e.type||"sublayer"===e.type)&&"when"in e}function B(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function J(e){return H(e)&&B(e)}function K(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&J(e.sourceLayer)}function V(e,t){const{fieldInfos:n,fieldName:r,preventPlacesFormatting:l,layer:u,timeZone:s}=t,c=Y(n,r),d=$(u,r);if(c&&!a(r)){const t=d?.type,n=c.format?.dateFormat;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t||n)return f(e,{format:n,fieldType:t,timeZoneOptions:{layerTimeZone:u&&"preferredTimeZone"in u?u.preferredTimeZone:null,viewTimeZone:s,datesInUnknownTimezone:!(!u||!("datesInUnknownTimezone"in u))&&!!u.datesInUnknownTimezone}})}const p=c?.format;return"string"==typeof e&&a(r)&&p?W(e,p):"string"==typeof(e=_(e,p))||null==e||null==p?ae(e):i(e,l?{...o(p),minimumFractionDigits:0,maximumFractionDigits:20}:o(p))}function W(e,t){return e=e.trim(),/\d{2}-\d{2}/.test(e)?e:e.includes(",")?X(e,",",", ",t):e.includes(";")?X(e,";","; ",t):e.includes(" ")?X(e," "," ",t):i(Number(e),o(t))}function X(e,t,n,r){return e.trim().split(t).map((e=>i(Number(e),o(r)))).join(n)}function Y(e,t){if(e?.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function ee({fieldName:e,graphic:t,layer:n}){if(de(e))return null;if(!n||"function"!=typeof n.getFeatureType)return null;const{typeIdField:r}=n;if(!r||e!==r)return null;const i=n.getFeatureType(t);return i?i.name:null}function te({fieldName:e,value:t,graphic:n,layer:r}){if(de(e))return null;if(!r||"function"!=typeof r.getFieldDomain)return null;const i=n&&r.getFieldDomain(e,{feature:n});return i&&"coded-value"===i.type?i.getName(t):null}function ne(e,t,n,i){const{creatorField:o,creationDateField:a,editorField:l,editDateField:u}=e;if(!t)return;const s=p(i&&"preferredTimeZone"in i?i.preferredTimeZone:null,!(!i||!("datesInUnknownTimezone"in i))&&!!i.datesInUnknownTimezone,n,Z,"date"),f={...Z,...s},c=t[u];if("number"==typeof c){const e=t[l];return{type:"edit",date:r(c,f),user:e}}const d=t[a];if("number"==typeof d){const e=t[o];return{type:"create",date:r(d,f),user:e}}return null}function re(e,t){const n=new Map;if(!e)return n;for(const r of e){if(!r.fieldName)continue;const e=q(r.fieldName,t);r.fieldName=e,n.set(e.toLowerCase(),r)}return n}function ie(e){const t=[];if(!e)return t;const{fieldInfos:n,content:r}=e;return n&&t.push(...n),r&&Array.isArray(r)?(r.forEach((e=>{if("fields"===e.type){const n=e?.fieldInfos;n&&t.push(...n)}})),t):t}function oe(e){return e.replaceAll(w,(e=>`&#${e.charCodeAt(0)};`))}function ae(e){return"string"==typeof e?e.replaceAll(T,'<br class="esri-text-new-line" />'):e}function le(e){const{value:t,fieldName:n,fieldInfos:r,fieldInfoMap:i,layer:o,graphic:a,timeZone:l}=e;if(null==t)return"";const s=te({fieldName:n,value:t,graphic:a,layer:o});if(s)return s;const d=ee({fieldName:n,graphic:a,layer:o});if(d)return d;if(i.get(n.toLowerCase()))return V(t,{fieldInfos:r||Array.from(i.values()),fieldName:n,layer:o,timeZone:l});const p=o?.fieldsIndex?.get(n);return p&&(c(p)||u(p))?f(t,{fieldType:p.type,timeZoneOptions:{layerTimeZone:o&&"preferredTimeZone"in o?o.preferredTimeZone:null,viewTimeZone:l,datesInUnknownTimezone:!(!o||!("datesInUnknownTimezone"in o))&&!!o.datesInUnknownTimezone}}):ae(t)}function ue({fieldInfos:e,attributes:t,layer:n,graphic:r,fieldInfoMap:i,relatedInfos:o,timeZone:a}){const l={};return o?.forEach((t=>me({attributes:l,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:n,timeZone:a}))),t&&Object.keys(t).forEach((o=>{const u=t[o];l[o]=le({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:n,value:u,graphic:r,timeZone:a})})),l}async function se(e,t){const{layer:n,graphic:r,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:n,graphic:r,objectId:u,requiredFields:i};return m().warn(e,t),null}if(!s(n)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:n,graphic:r,requiredFields:i,returnGeometry:a};return m().warn(e,t),null}const f=n.createQuery();f.objectIds=o,f.outFields=i?.length?i:[n.objectIdField],f.returnGeometry=!!a,f.returnZ=!!a,f.returnM=!!a,f.outSpatialReference=l;return(await n.queryFeatures(f,t)).features[0]}async function fe(e){if(!e.expressionInfos?.length)return!1;const t=await d(),{arcadeUtils:{hasGeometryFunctions:n}}=t;return n(e)}async function ce({graphic:e,popupTemplate:t,layer:n,spatialReference:r},i){if(!n||!t)return;if("function"==typeof n.load&&await n.load(i),!e.attributes)return;const o=n.objectIdField,a=e.attributes[o];if(null==a)return;const u=[a],s=await t.getRequiredFields(n.fieldsIndex),f=l(s,e),c=f?[]:s.includes(o)?s:[...s,o],d=t.returnGeometry||await fe(t);if(f&&!d)return;const p=await se({layer:n,graphic:e,outFields:c,objectIds:u,returnGeometry:d,spatialReference:r},i);p&&(p.geometry&&(e.geometry=p.geometry),p.attributes&&(e.attributes={...e.attributes,...p.attributes}))}function de(e=""){return!!e&&e.includes(j)}function pe(e){return e?`${j}${e.layerId}/${e.fieldName}`:""}function ye({attributes:e,graphic:t,relatedInfo:n,fieldInfos:r,fieldInfoMap:i,layer:o,timeZone:a}){e&&t&&n&&Object.keys(t.attributes).forEach((l=>{const u=pe({layerId:n.relation.id.toString(),fieldName:l}),s=t.attributes[l];e[u]=le({fieldName:u,fieldInfos:r,fieldInfoMap:i,layer:o,value:s,graphic:t,timeZone:a})}))}function me({attributes:e,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}){e&&t&&(t.relatedFeatures?.forEach((a=>ye({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}))),t.relatedStatsFeatures?.forEach((a=>ye({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}))))}const ge=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},he=({layer:e,method:t,query:n,definitionExpression:r})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=n.where?n.where:null,o=null!=n.geometry?n.geometry:null;ge(r)||ge(i)||"extent"===o?.type||"tile"===n.resultType||(n.cacheHint=!0)},Ie=({query:e,layer:t,method:n})=>{he({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})},be=({queryPayload:e,layer:t,method:n})=>{he({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})};function Te(e,t,n){return e&&t&&n?"sublayer"===t.type?we({layers:t.layer?.sublayers,relatedLayer:t,relationship:n})||we({layers:t.layer?.subtables,relatedLayer:t,relationship:n}):we({layers:e.allLayers,relatedLayer:t,relationship:n})||we({layers:e.allTables,relatedLayer:t,relationship:n}):null}function we({relationship:e,relationship:{relatedTableId:t},relatedLayer:n,layers:r}){if(!r)return null;for(const i of r){if("map-image"===i.type){const t=we({layers:i.sublayers,relatedLayer:n,relationship:e})||we({layers:i.subtables,relatedLayer:n,relationship:e});if(t)return t;continue}if(!J(i))continue;if("sublayer"===n.type){if(i!==n&&i.id===t)return i;continue}const r="scene"===n.type&&n.associatedLayer?n.associatedLayer.url:n.url;if(!r)return null;if("sublayer"!==i.type){if(i!==n&&i.url===r&&i.layerId===t)return i}else if(i!==n&&i.layer?.url===r&&i.id===t)return i}return null}function Fe(e){const t=e.getObjectId();return null!=t?`oid:${t}`:`uid:${e.uid}`}export{ae as applyTextFormattingHTML,re as createFieldInfoMap,Te as findRelatedLayer,P as fixTokens,ue as formatAttributes,ne as formatEditInfo,V as formatValueToFieldInfo,ie as getAllFieldInfos,Y as getFieldInfo,C as getFieldInfoLabel,q as getFixedFieldName,R as getFixedFieldNames,Fe as getHighlightKeyForFeature,L as getSourceLayer,E as graphicCallback,oe as htmlEntities,x as isExpressionField,H as isFeatureSupportedLayer,K as isGraphicForRelatableFeatureSupportedLayer,J as isRelatableFeatureSupportedLayer,B as isRelatableLayer,de as isRelatedField,Ie as preLayerQueryCallback,be as preRequestCallback,se as querySourceLayer,ce as queryUpdatedFeature,v as shouldOpenInNewTab,z as substituteAttributes,D as substituteFieldsInLinksAndAttributes};
|
|
5
|
+
import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{convertDateFormatToIntlOptions as r,formatDate as n}from"../../../intl/date.js";import{formatNumber as i,convertNumberFormatToIntlOptions as o}from"../../../intl/number.js";import{isRasterPixelValueField as a,featureHasFields as l,isTimeOnlyField as u}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as s}from"../../../layers/support/layerUtils.js";import{formatAnyDate as f,isAnyDateField as c}from"../../../smartMapping/support/utils.js";import{loadArcade as d}from"../../../support/arcadeOnDemand.js";import{getTimeZoneFormattingOptions as p}from"../../../time/timeZoneUtils.js";const y="esri.widgets.Feature.support.featureUtils",m=()=>e.getLogger(y),g=/href=(""|'')/gi,h=/(\{([^{\r\n]+)\})/g,b=/'/g,I=/^\s*expression\//i,T=/(\n)/gi,w=/[\u00A0-\u9999<>&]/gim,F=/href\s*=\s*(?:"([^"]+)"|'([^']+)')/gi,N=/^(?:mailto:|tel:)/,j="relationships/",Z=r("short-date-short-time");function L(e){if(null!=e)return(e.sourceLayer||e.layer)??void 0}async function E({type:e,value:t,event:r}){try{return"function"==typeof t?t(r):t}catch(n){return void m().error("error",`An error occurred when calling the "${e}" function`,{error:n,graphic:r.graphic,value:t})}}function v(e=""){if(e)return!N.test(e.trim().toLowerCase())}function x(e){return!!e&&I.test(e)}function A(e,t){if(!t||!x(t)||!e)return;const r=t.replace(I,"").toLowerCase();return e.find((({name:e})=>e.toLowerCase()===r))}function C(e,t){const r=A(t,e?.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function M(e,t){const r=t.get(e.toLowerCase());return`{${r?.fieldName||e}}`}function U(e){return e.replaceAll(g,"")}function q(e,t){const r=$(t,e);return r?r.name:e}function R(e,t){return e&&e.map((e=>q(e,t)))}function $(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function k(e){return`${e}`.trim()}function D({attributes:e,globalAttributes:t,layer:r,text:n,expressionAttributes:i,fieldInfoMap:o}){return n?O({formattedAttributes:t,template:Q(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function O({formattedAttributes:e,template:r,fieldInfoMap:n}){return k(U(t(t(r,(e=>M(e,n))),e)))}function z(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replaceAll(b,i);t[e]=o}}function G(e,t=!1){const r={...e};return Object.keys(r).forEach((e=>z(e,r,t))),r}function S(e,r,n){const i=(r=k(r))&&"{"!==r[0];return t(e,G(n,i||!1))}function P(e,t){return e.replaceAll(h,((e,r,n)=>{const i=$(t,n);return i?`{${i.name}}`:r}))}function Q(e,t,r){const n=P(e,r);return n?n.replaceAll(F,((e,r,n)=>S(e,r||n,t))):n}function _(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function H(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&("feature"===e.type||"scene"===e.type||"sublayer"===e.type)&&"when"in e}function J(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function B(e){return H(e)&&J(e)}function K(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&B(e.sourceLayer)}function V(e,t){const{fieldInfos:r,fieldName:n,preventPlacesFormatting:l,layer:u,timeZone:s}=t,c=Y(r,n),d=$(u,n);if(c&&!a(n)){const t=d?.type,r=c.format?.dateFormat;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t||r)return f(e,{format:r,fieldType:t,timeZoneOptions:{layerTimeZone:u&&"preferredTimeZone"in u?u.preferredTimeZone:null,viewTimeZone:s,datesInUnknownTimezone:!(!u||!("datesInUnknownTimezone"in u))&&!!u.datesInUnknownTimezone}})}const p=c?.format;return"string"==typeof e&&a(n)&&p?W(e,p):"string"==typeof(e=_(e,p))||null==e||null==p?ae(e):i(e,l?{...o(p),minimumFractionDigits:0,maximumFractionDigits:20}:o(p))}function W(e,t){return e=e.trim(),/\d{2}-\d{2}/.test(e)?e:e.includes(",")?X(e,",",", ",t):e.includes(";")?X(e,";","; ",t):e.includes(" ")?X(e," "," ",t):i(Number(e),o(t))}function X(e,t,r,n){return e.trim().split(t).map((e=>i(Number(e),o(n)))).join(r)}function Y(e,t){if(e?.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function ee({fieldName:e,graphic:t,layer:r}){if(de(e))return null;if(!r||"function"!=typeof r.getFeatureType)return null;const{typeIdField:n}=r;if(!n||e!==n)return null;const i=r.getFeatureType(t);return i?i.name:null}function te({fieldName:e,value:t,graphic:r,layer:n}){if(de(e))return null;if(!n||"function"!=typeof n.getFieldDomain)return null;const i=r&&n.getFieldDomain(e,{feature:r});return i&&"coded-value"===i.type?i.getName(t):null}function re(e,t,r,i){const{creatorField:o,creationDateField:a,editorField:l,editDateField:u}=e;if(!t)return;const s=p(i&&"preferredTimeZone"in i?i.preferredTimeZone:null,!(!i||!("datesInUnknownTimezone"in i))&&!!i.datesInUnknownTimezone,r,Z,"date"),f={...Z,...s},c=t[u];if("number"==typeof c){const e=t[l];return{type:"edit",date:n(c,f),user:e}}const d=t[a];if("number"==typeof d){const e=t[o];return{type:"create",date:n(d,f),user:e}}return null}function ne(e,t){const r=new Map;if(!e)return r;for(const n of e){if(!n.fieldName)continue;const e=q(n.fieldName,t);n.fieldName=e,r.set(e.toLowerCase(),n)}return r}function ie(e){const t=[];if(!e)return t;const{fieldInfos:r,content:n}=e;return r&&t.push(...r),n&&Array.isArray(n)?(n.forEach((e=>{if("fields"===e.type){const r=e?.fieldInfos;r&&t.push(...r)}})),t):t}function oe(e){return e.replaceAll(w,(e=>`&#${e.charCodeAt(0)};`))}function ae(e){return"string"==typeof e?e.replaceAll(T,'<br class="esri-text-new-line" />'):e}function le(e){const{value:t,fieldName:r,fieldInfos:n,fieldInfoMap:i,layer:o,graphic:a,timeZone:l}=e;if(null==t)return"";const s=te({fieldName:r,value:t,graphic:a,layer:o});if(s)return s;const d=ee({fieldName:r,graphic:a,layer:o});if(d)return d;if(i.get(r.toLowerCase()))return V(t,{fieldInfos:n||Array.from(i.values()),fieldName:r,layer:o,timeZone:l});const p=o?.fieldsIndex?.get(r);return p&&(c(p)||u(p))?f(t,{fieldType:p.type,timeZoneOptions:{layerTimeZone:o&&"preferredTimeZone"in o?o.preferredTimeZone:null,viewTimeZone:l,datesInUnknownTimezone:!(!o||!("datesInUnknownTimezone"in o))&&!!o.datesInUnknownTimezone}}):ae(t)}function ue({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o,timeZone:a}){const l={};return o?.forEach((t=>me({attributes:l,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:r,timeZone:a}))),t&&Object.keys(t).forEach((o=>{const u=t[o];l[o]=le({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:u,graphic:n,timeZone:a})})),l}async function se(e,t){const{layer:r,graphic:n,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:r,graphic:n,objectId:u,requiredFields:i};return m().warn(e,t),null}if(!s(r)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:r,graphic:n,requiredFields:i,returnGeometry:a};return m().warn(e,t),null}const f=r.createQuery();f.objectIds=o,f.outFields=i?.length?i:[r.objectIdField],f.returnGeometry=!!a,f.returnZ=!!a,f.returnM=!!a,f.outSpatialReference=l;return(await r.queryFeatures(f,t)).features[0]}async function fe(e){if(!e.expressionInfos?.length)return!1;const t=await d(),{arcadeUtils:{hasGeometryFunctions:r}}=t;return r(e)}async function ce({graphic:e,popupTemplate:t,layer:r,spatialReference:n},i){if(!r||!t)return;if("function"==typeof r.load&&await r.load(i),!e.attributes)return;const o=r.objectIdField,a=e.attributes[o];if(null==a)return;const u=[a],s=await t.getRequiredFields(r.fieldsIndex),f=l(s,e),c=f?[]:s.includes(o)?s:[...s,o],d=t.returnGeometry||await fe(t);if(f&&!d)return;const p=await se({layer:r,graphic:e,outFields:c,objectIds:u,returnGeometry:d,spatialReference:n},i);p&&(p.geometry&&(e.geometry=p.geometry),p.attributes&&(e.attributes={...e.attributes,...p.attributes}))}function de(e=""){return!!e&&e.includes(j)}function pe(e){return e?`${j}${e.layerId}/${e.fieldName}`:""}function ye({attributes:e,graphic:t,relatedInfo:r,fieldInfos:n,fieldInfoMap:i,layer:o,timeZone:a}){e&&t&&r&&Object.keys(t.attributes).forEach((l=>{const u=pe({layerId:r.relation.id.toString(),fieldName:l}),s=t.attributes[l];e[u]=le({fieldName:u,fieldInfos:n,fieldInfoMap:i,layer:o,value:s,graphic:t,timeZone:a})}))}function me({attributes:e,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i,timeZone:o}){e&&t&&(t.relatedFeatures?.forEach((a=>ye({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i,timeZone:o}))),t.relatedStatsFeatures?.forEach((a=>ye({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i,timeZone:o}))))}const ge=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},he=({layer:e,method:t,query:r,definitionExpression:n})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=r.where?r.where:null,o=null!=r.geometry?r.geometry:null;ge(n)||ge(i)||"extent"===o?.type||"tile"===r.resultType||(r.cacheHint=!0)},be=({query:e,layer:t,method:r})=>{he({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})},Ie=({queryPayload:e,layer:t,method:r})=>{he({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})};function Te(e,t,r){return e&&t&&r?"sublayer"===t.type?we({layers:t.layer?.sublayers,map:e,relatedLayer:t,relationship:r})||we({layers:t.layer?.subtables,map:e,relatedLayer:t,relationship:r}):we({layers:e.allLayers,map:e,relatedLayer:t,relationship:r})||we({layers:e.allTables,map:e,relatedLayer:t,relationship:r}):null}function we({map:e,relationship:t,relationship:{relatedTableId:r},relatedLayer:n,layers:i}){if(!i)return null;for(const o of i){if("map-image"===o.type){const r=we({layers:o.sublayers,map:e,relatedLayer:n,relationship:t})||we({layers:o.subtables,map:e,relatedLayer:n,relationship:t});if(r)return r;continue}if(!B(o))continue;if("sublayer"===n.type){if(o!==n&&o.id===r)return"Table"===o?.sourceJSON?.type?e?.allTables.find((e=>"feature"===e.type&&e.layerId===o.id&&e.url===o.layer?.url))??o:o;continue}const i="scene"===n.type&&n.associatedLayer?n.associatedLayer.url:n.url;if(!i)return null;if("sublayer"!==o.type){if(o!==n&&o.url===i&&o.layerId===r)return o}else if(o!==n&&o.layer?.url===i&&o.id===r)return o}return null}function Fe(e){const t=e.getObjectId();return null!=t?`oid:${t}`:`uid:${e.uid}`}export{ae as applyTextFormattingHTML,ne as createFieldInfoMap,Te as findRelatedLayer,P as fixTokens,ue as formatAttributes,re as formatEditInfo,V as formatValueToFieldInfo,ie as getAllFieldInfos,Y as getFieldInfo,C as getFieldInfoLabel,q as getFixedFieldName,R as getFixedFieldNames,Fe as getHighlightKeyForFeature,L as getSourceLayer,E as graphicCallback,oe as htmlEntities,x as isExpressionField,H as isFeatureSupportedLayer,K as isGraphicForRelatableFeatureSupportedLayer,B as isRelatableFeatureSupportedLayer,J as isRelatableLayer,de as isRelatedField,be as preLayerQueryCallback,Ie as preRequestCallback,se as querySourceLayer,ce as queryUpdatedFeature,v as shouldOpenInNewTab,O as substituteAttributes,D as substituteFieldsInLinksAndAttributes};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Collection.js";import{referenceSetter as i}from"../../core/collectionUtils.js";import{deprecatedFunction as s}from"../../core/deprecate.js";import o from"../../core/Handles.js";import r from"../../core/Logger.js";import{debounce as n,ignoreAbortErrors as l}from"../../core/promiseUtils.js";import{watch as a,initial as h,on as d}from"../../core/reactiveUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as g}from"../../layers/support/fieldUtils.js";import{getTimeZoneFormattingOptions as p,system as u}from"../../time/timeZoneUtils.js";import{highlightsSupported as f}from"../../views/support/layerViewUtils.js";import{isSelectableLayer as y}from"../../views/support/selectionUtils.js";import b from"./ActionColumn.js";import _ from"./AttachmentsColumn.js";import C from"./FieldColumn.js";import v from"./RelationshipColumn.js";import I from"./Grid/Column.js";import w from"./Grid/Grid.js";import E from"./Grid/GridViewModel.js";import T from"./Grid/GroupColumn.js";import j from"./support/FeatureStore.js";import S from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithRelationships as R,findRelatedLayer as F,uniqueColumnNames as U}from"./support/tableUtils.js";import"../support/widgetUtils.js";import{messageBundle as O}from"../support/decorators/messageBundle.js";import{onLocaleChange as L}from"../../intl/locale.js";import{convertDateFormatToIntlOptions as x}from"../../intl/date.js";import{fetchMessageBundle as A}from"../../intl/messages.js";let z=class extends E{constructor(e){super(e),this._debounceRefresh=n((()=>this._refresh())),this._highlights=new o,this.actionColumnConfig=null,this.attachmentsEnabled=!1,this.autoRefreshEnabled=!0,this.columns=new t,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const o=this._sortOrdersToLayerOrderByFields(i,e.sortOrders);s.set({orderByFields:o});const{objectIds:r}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===r.length&&-1===r.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const n=await s.fetchItems(e);t&&t(n)},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.layer=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.relationshipColumnConfigs=null,this.returnGeometryEnabled=!1,this.selectionSource="table",this.showRelatedTableCallback=null,this.store=null,this.tableTemplate=null,this.tableTemplateOverride=null,this.timeZone=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new j),this._set("grid",new w({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await A("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await A("esri/t9n/common"),this.messagesURIUtils=await A("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([L((()=>{e(),this._generateColumns()})),a((()=>[this.messages,this.messagesCommon,this.messagesURIUtils]),(()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.columns.forEach((t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils})),this._requestContentUpdate()}),h),d((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this._highlights.removeAll()}),a((()=>this.attachmentsEnabled),(e=>{const{attachmentsColumn:t,columns:i}=this;this.store.attachmentsEnabled=e,t&&i.remove(t),e&&i.length&&i.add(this._generateAttachmentsColumn(),this._getIndexOfFirstFrozenToEndColumn())})),a((()=>this._viewSelection),(()=>{this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)})),a((()=>[this._tableHighlightsReady,this._viewSelectionReady]),(()=>this._syncSelection())),a((()=>this.returnGeometryEnabled),(e=>this.store.returnGeometry=e)),a((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),a((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),a((()=>this.store.state),(e=>{"loaded"===e&&(this.grid?.scrollToTop(),this.refreshCellContent())})),a((()=>this._effectiveTableTemplate),(()=>this.layer?.loaded&&this._generateColumns())),a((()=>[this.timeZone,this.view?.timeZone]),(()=>{this.columns.forEach((e=>{if("field"in e&&e.field){const{timeZone:t,timeZoneName:i}=this._getTimeZoneInfoForFieldColumn(e.field);e.set({timeZone:t,timeZoneName:i})}})),this._requestContentUpdate()})),a((()=>this.editingEnabled),(e=>{this.editorColumns.forEach((t=>t.tableEditingEnabled=e)),this._requestContentUpdate()})),a((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),a((()=>this.layer?.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),d((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e))),d((()=>this.grid),["cell-click","cell-pointerover","cell-pointerout","cell-keydown"],(({index:e,item:t,native:i,path:s,type:o})=>{const r=t?.feature;this.emit(o,{feature:r,index:e,native:i,type:o,fieldName:s??void 0,objectId:r?.getObjectId()})})),a((()=>this.actionColumnConfig),(e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())})),a((()=>[this.relationshipColumnConfigs?.length,this.relatedRecordsEnabled]),(([e,t])=>{const{columns:i,relationshipColumns:s}=this;s.length&&i.removeMany(s),i.length&&t&&i.addMany(this._generateRelationshipColumns(),this._getIndexOfFirstFrozenToEndColumn())})),d((()=>this.objectIds),"change",(()=>this._onObjectIdsChange()),{onListenerAdd:()=>this._onObjectIdsChange()})])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return g(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _highlightableLayerView(){const e=this.layerView;return f(e)?e:null}get _layerWithRelationships(){const e=this.layer;if(!R(e))return null;const t=e.effectiveCapabilities??e.capabilities;return t?.queryRelated?.supportsCount&&t.queryRelated.supportsPagination?e:null}get _relationshipInfos(){const{_layerWithRelationships:e,relatedRecordsEnabled:t,relationships:i,view:s}=this,o=[];return t&&e?.loaded&&s?.map&&i?.length?(i.forEach((t=>{const i=F(e,s,t);i&&(i.load(),o.push({layer:e,relatedLayer:i,relationshipId:t.id}))})),o):o}get _selectionManager(){const{view:e}=this;return!e||e.destroyed?null:e.selectionManager?.sources?.length?e.selectionManager:null}get _selectableLayer(){const{layer:e}=this;return y(e)&&this._selectionManager?.sources.includes(e)?e:null}get _tableHighlightsReady(){return!("table"!==this.selectionSource||!this.highlightEnabled||!this._highlightableLayerView)}get _viewSelection(){const{_selectableLayer:e}=this;return e?this._selectionManager?.getSelection(e)??[]:[]}get _viewSelectionReady(){return!(!this.layer||"view"!==this.selectionSource||!this._selectionManager)}get activeFilters(){const{filterGeometry:e,objectIds:i,filterBySelectionEnabled:s,highlightIds:o}=this,r=new t;return e&&r.push({type:"geometry",geometry:e}),s?r.push({type:"selection",objectIds:o.toArray()}):i.length&&r.push({type:"objectId",objectIds:i.toArray()}),r}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}get filterGeometry(){return this._get("filterGeometry")}set filterGeometry(e){this.store.filterGeometry=e,this._set("filterGeometry",e)}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get hiddenFields(){return this._get("hiddenFields")??new t}set hiddenFields(e){this._set("hiddenFields",i(e,this._get("hiddenFields"),t))}get isQueryingOrSyncing(){const{store:e}=this;return e?.syncing||e?.querying}get layerView(){return this.view?.allLayerViews.find((e=>e.layer===this.layer))||null}get objectIds(){return this._get("objectIds")??new t}set objectIds(e){this._set("objectIds",i(e,this._get("objectIds"),t))}get relatedRecordsEnabled(){return!!this._get("relatedRecordsEnabled")}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e,this._set("relatedRecordsEnabled",e)}get relationship(){const e=this.relationshipConfig?.relationshipId;return null==e?null:this.relationships?.find((({id:t})=>t===e))}get relationshipConfig(){return this._get("relationshipConfig")}set relationshipConfig(e){this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e,this._set("relationshipConfig",e)}get relationships(){const{layer:e}=this;return R(e)?e.relationships:null}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.highlightIds.removeMany(i),await this.refresh())}filterBySelection(){this.filterBySelectionEnabled?this._logWarning("Property 'filterBySelectionEnabled' is already 'true'. This method has no effect."):(s(r.getLogger(this),"`FeatureTable.filterBySelection` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.addMany(this.highlightIds.toArray()))}getObjectIdIndex(e){return this.store?.getItemIndexByObjectId(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}async refresh(){return l(this._debounceRefresh())}refreshCellContent(){this._requestContentUpdate()}async reset(){await(this.grid?.reset())}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){s(r.getLogger(this),"`FeatureTable.clearSelectionFilter` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.removeAll()}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const o=await e.queryFeatures(s);try{await t.goTo(o.features)}catch(r){"AbortError"!==r.name&&console.error(r)}}_requestContentUpdate(){this.grid?.requestContentUpdate()}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.highlightIds.remove(e[i])}))}this.grid?.refreshPageCache()}_onLayerLoad(){const{layer:e}=this;if(!e)return;const t=e.capabilities.query?.maxRecordCount;t&&t<this.pageSize&&this.grid&&(this.grid.pageSize=t),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const e=this._effectiveTableTemplate?.columnTemplates,t=[],i=e?this._generateColumnsFromTemplates(e):this._generateDefaultFieldColumns();t.push(...i),t.length&&this.attachmentsEnabled&&t.push(this._generateAttachmentsColumn()),t.length&&this.relatedRecordsEnabled&&this._relationshipInfos.length&&t.push(...this._generateRelationshipColumns()),this.actionColumnConfig&&t.push(this._generateActionColumn()),t.sort(((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0)),this.columns.addMany([...t])}_generateColumnsFromTemplates(e){const{editingEnabled:t,_effectiveTableTemplate:i,grid:s,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,store:a,timeZone:h}=this,d=o?.fields??[],m=[],c=e=>d.find((t=>e.fieldName.toLowerCase()===t.name?.toLowerCase()));return e.forEach((e=>{const{autoWidth:d,direction:g,flexGrow:p,fieldName:u,formatFunction:f,frozen:y,frozenToEnd:b,icon:_,initialSortPriority:v,invalid:w,label:E,menuConfig:j,resizable:S,sortable:R,textAlign:F,textWrap:U,type:O,width:L}=e;if(!O)return void this._logWarning("Property 'type' is missing from the provided template. Skipped generating a column for this template.");if(y&&b)return void this._logWarning("Both 'frozen' and 'frozenToEnd' cannot be true for a single template. Skipped generating a column for this template.");const x=!1===e.visible;if("group"===O){if(!e.columnTemplates?.length)return void this._logWarning("Group columns must contain column templates. Skipped generating a column for this template.");if(!e.label)return void this._logWarning("Group columns require a label. Skipped generating a column for this template.");const t=this._generateColumnsFromTemplates(e.columnTemplates),i=x||this._isFieldHidden(e.label);m.push(new T({autoWidth:d,columns:t,flexGrow:p,frozen:y,frozenToEnd:b,grid:s,hidden:i,icon:_,invalid:w,label:E,menuConfig:j,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,textAlign:F,textWrap:U,width:L}))}if(!u)return void this._logWarning("'fieldName' was missing from the provided template. Skipped generating a column for this template.");const A=x||this._isFieldHidden(u);if("column"===O&&m.push(new I({autoWidth:d,direction:g,fieldName:u,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:v,invalid:w,label:E,menuConfig:j,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,sortable:R,textAlign:F,textWrap:U,timeZone:h,width:L})),"field"===O){const h=c(e);if(!h)return void this._logWarning("A valid 'field' could not be found for the provided template. Skipped generating a column for this template.");const{editable:u,required:I}=e,T=i?.expressionInfos||null,{timeZone:O,timeZoneName:x}=this._getTimeZoneInfoForFieldColumn(h);m.push(new C({autoWidth:d,direction:g,editable:u,expressionInfos:T,field:h,fieldName:h.name,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:v,invalid:w,label:E,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,menuConfig:j,sortable:R,store:a,required:I,resizable:S,tableEditingEnabled:t,template:e,textAlign:F,textWrap:U,timeZone:O,timeZoneName:x,width:L}))}})),m}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n}=this;return(i?.fields??[]).map((l=>{const{timeZone:a,timeZoneName:h}=this._getTimeZoneInfoForFieldColumn(l),d=l.name;return new C({field:l,fieldName:d,grid:t,hidden:this._isFieldHidden(d),layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n,tableEditingEnabled:e,timeZone:a,timeZoneName:h})}))}_getTimeZoneInfoForFieldColumn(e){const{layer:t,timeZone:i,view:s}=this;return!t||"date"!==e?.type&&"timestamp-offset"!==e?.type?{timeZone:void 0,timeZoneName:void 0}:p(t.preferredTimeZone||null,!!t.datesInUnknownTimezone,i??s?.timeZone??u,x("short-time"),e.type)}_generateAttachmentsColumn(){return new _({hidden:this._isFieldHidden(U.attachments),messages:this.messages})}_generateRelationshipColumns(){const{_layerWithRelationships:e,_relationshipInfos:t,grid:i,messages:s,messagesCommon:o,messagesURIUtils:r,relationshipColumnConfigs:n}=this,l=[];if(!e)return l;const a={grid:i,messages:s,messagesCommon:o,messagesURIUtils:r};return n?n.forEach((e=>{const{relationshipId:i}=e,s=t.find((e=>e.relationshipId===i));s&&l.push(new v({...e,...a,fieldName:`${U.relationship}-${i}`,layer:s.relatedLayer,relatedLayer:s.layer,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})):t.forEach((({layer:e,relatedLayer:t,relationshipId:i})=>{l.push(new v({...a,fieldName:`${U.relationship}-${i}`,layer:t,relatedLayer:e,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})),l}_generateActionColumn(){return new b({hidden:this._isFieldHidden(U.action),...this.actionColumnConfig})}_sortOrdersToLayerOrderByFields(e,t=[]){const i=t.map((e=>e.path)),s=t.filter(((e,t)=>{const s=i.indexOf(e.path)===t,o=null!=e.direction;return s&&o})).map((({path:e,direction:t})=>`${e} ${t?.toUpperCase()}`));return!s.length&&!e.objectIdField&&e.fields?.length&&e.fields[0]?.name&&s.push(`${e.fields[0].name} ASC`),s}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_addTableHighlight(e){this._highlightableLayerView&&this._highlights.add(this._highlightableLayerView.highlight(e),e)}_removeTableHighlight(e){this._highlights.remove(e)}_syncSelection(){this._highlights.removeAll(),this._tableHighlightsReady?this.highlightIds.forEach((e=>this._addTableHighlight(e))):this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}_appendToViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.appendToSelection(t,e)}_removeFromViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.removeFromSelection(t,e)}_onHighlightIdsChange(e){const{added:t,removed:i}=e;this._tableHighlightsReady?(i.forEach((e=>this._removeTableHighlight(e))),t.forEach((e=>this._addTableHighlight(e)))):this._viewSelectionReady&&(this._removeFromViewSelection(i),this._appendToViewSelection(t)),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray())}_onShowRelatedTable(e){const{highlightIds:t}=this,{feature:i,layer:s,relatedLayer:o,relationshipId:r}=e,n=i.getObjectId()??i.attributes[o.objectIdField];if(null!=n){if(t.removeAll(),t.add(n),this.showRelatedTableCallback)return void this.showRelatedTableCallback(e);this.emit("show-related-table",{layer:s,relatedLayer:o,relationshipId:r,feature:i})}}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.grid?.refreshPageCache()}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex((e=>e.frozenToEnd));return e>-1?e:void 0}_logWarning(e){r.getLogger(this).warn(e)}};e([m()],z.prototype,"_defaultHiddenFields",null),e([m()],z.prototype,"_effectiveTableTemplate",null),e([m()],z.prototype,"_highlights",void 0),e([m()],z.prototype,"_highlightableLayerView",null),e([m({readOnly:!0})],z.prototype,"_layerWithRelationships",null),e([m()],z.prototype,"_relationshipInfos",null),e([m()],z.prototype,"_selectionManager",null),e([m()],z.prototype,"_selectableLayer",null),e([m()],z.prototype,"_tableHighlightsReady",null),e([m()],z.prototype,"_viewSelection",null),e([m()],z.prototype,"_viewSelectionReady",null),e([m()],z.prototype,"actionColumnConfig",void 0),e([m()],z.prototype,"activeFilters",null),e([m({readOnly:!0})],z.prototype,"activeSortOrders",null),e([m()],z.prototype,"attachmentsEnabled",void 0),e([m()],z.prototype,"autoRefreshEnabled",void 0),e([m({readOnly:!0})],z.prototype,"columns",void 0),e([m()],z.prototype,"dataProvider",void 0),e([m()],z.prototype,"editingEnabled",void 0),e([m()],z.prototype,"filterGeometry",null),e([m()],z.prototype,"filterBySelectionEnabled",null),e([m({readOnly:!0})],z.prototype,"grid",void 0),e([m()],z.prototype,"hiddenFields",null),e([m()],z.prototype,"highlightEnabled",void 0),e([m()],z.prototype,"isQueryingOrSyncing",null),e([m({readOnly:!0})],z.prototype,"itemIdPath",void 0),e([m()],z.prototype,"layer",void 0),e([m()],z.prototype,"layerView",null),e([m()],z.prototype,"messages",void 0),e([m(),O("esri/t9n/common")],z.prototype,"messagesCommon",void 0),e([m(),O("esri/widgets/support/t9n/uriUtils")],z.prototype,"messagesURIUtils",void 0),e([m()],z.prototype,"objectIds",null),e([m()],z.prototype,"relatedRecordsEnabled",null),e([m()],z.prototype,"relationship",null),e([m()],z.prototype,"relationshipColumnConfigs",void 0),e([m()],z.prototype,"relationshipConfig",null),e([m()],z.prototype,"relationships",null),e([m()],z.prototype,"returnGeometryEnabled",void 0),e([m()],z.prototype,"selectionSource",void 0),e([m()],z.prototype,"showRelatedTableCallback",void 0),e([m({readOnly:!0,type:j})],z.prototype,"store",void 0),e([m({type:S})],z.prototype,"tableTemplate",void 0),e([m()],z.prototype,"tableTemplateOverride",void 0),e([m()],z.prototype,"timeExtent",null),e([m()],z.prototype,"timeZone",void 0),e([m()],z.prototype,"view",void 0),z=e([c("esri.widgets.FeatureTable.FeatureTableViewModel")],z);const B=z;export{B as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Collection.js";import{referenceSetter as i}from"../../core/collectionUtils.js";import{deprecatedFunction as s}from"../../core/deprecate.js";import o from"../../core/Handles.js";import r from"../../core/Logger.js";import{debounce as n,ignoreAbortErrors as l}from"../../core/promiseUtils.js";import{watch as a,initial as h,on as d}from"../../core/reactiveUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as g}from"../../layers/support/fieldUtils.js";import{getTimeZoneFormattingOptions as p,system as u}from"../../time/timeZoneUtils.js";import{highlightsSupported as f}from"../../views/support/layerViewUtils.js";import{isSelectableLayer as y}from"../../views/support/selectionUtils.js";import b from"./ActionColumn.js";import _ from"./AttachmentsColumn.js";import v from"./FieldColumn.js";import C from"./RelationshipColumn.js";import I from"./Grid/Column.js";import w from"./Grid/Grid.js";import E from"./Grid/GridViewModel.js";import j from"./Grid/GroupColumn.js";import T from"./support/FeatureStore.js";import S from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithRelationships as R,findRelatedLayer as F,uniqueColumnNames as U}from"./support/tableUtils.js";import"../support/widgetUtils.js";import{messageBundle as O}from"../support/decorators/messageBundle.js";import{onLocaleChange as L}from"../../intl/locale.js";import{convertDateFormatToIntlOptions as x}from"../../intl/date.js";import{fetchMessageBundle as A}from"../../intl/messages.js";let Z=class extends E{constructor(e){super(e),this._debounceRefresh=n((()=>this._refresh())),this._highlights=new o,this.actionColumnConfig=null,this.attachmentsEnabled=!1,this.autoRefreshEnabled=!0,this.columns=new t,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const o=this._sortOrdersToLayerOrderByFields(i,e.sortOrders);s.set({orderByFields:o});const{objectIds:r}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===r.length&&-1===r.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const n=await s.fetchItems(e);t&&t(n)},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.layer=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.relationshipColumnConfigs=null,this.returnGeometryEnabled=!1,this.returnMEnabled=!1,this.returnZEnabled=!1,this.selectionSource="table",this.showRelatedTableCallback=null,this.store=null,this.tableTemplate=null,this.tableTemplateOverride=null,this.timeZone=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new T),this._set("grid",new w({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await A("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await A("esri/t9n/common"),this.messagesURIUtils=await A("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([L((()=>{e(),this._generateColumns()})),a((()=>[this.messages,this.messagesCommon,this.messagesURIUtils]),(()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.columns.forEach((t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils})),this._requestContentUpdate()}),h),d((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this._highlights.removeAll()}),a((()=>this.attachmentsEnabled),(e=>{const{attachmentsColumn:t,columns:i}=this;this.store.attachmentsEnabled=e,t&&i.remove(t),e&&i.length&&i.add(this._generateAttachmentsColumn(),this._getIndexOfFirstFrozenToEndColumn())})),a((()=>this._viewSelection),(()=>{this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)})),a((()=>[this._tableHighlightsReady,this._viewSelectionReady]),(()=>this._syncSelection())),a((()=>[this.returnGeometryEnabled,this.returnMEnabled,this.returnZEnabled]),(()=>{const{store:e}=this;e.set({returnGeometry:this.returnGeometryEnabled,returnM:this.returnMEnabled,returnZ:this.returnZEnabled})})),a((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),a((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),a((()=>this.store.state),(e=>{"loaded"===e&&(this.grid?.scrollToTop(),this.refreshCellContent())})),a((()=>this._effectiveTableTemplate),(()=>this.layer?.loaded&&this._generateColumns())),a((()=>[this.timeZone,this.view?.timeZone]),(()=>{this.columns.forEach((e=>{if("field"in e&&e.field){const{timeZone:t,timeZoneName:i}=this._getTimeZoneInfoForFieldColumn(e.field);e.set({timeZone:t,timeZoneName:i})}})),this._requestContentUpdate()})),a((()=>this.editingEnabled),(e=>{this.editorColumns.forEach((t=>t.tableEditingEnabled=e)),this._requestContentUpdate()})),a((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),a((()=>this.layer?.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),d((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e))),d((()=>this.grid),["cell-click","cell-pointerover","cell-pointerout","cell-keydown"],(({index:e,item:t,native:i,path:s,type:o})=>{const r=t?.feature;this.emit(o,{feature:r,index:e,native:i,type:o,fieldName:s??void 0,objectId:r?.getObjectId()})})),a((()=>this.actionColumnConfig),(e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())})),a((()=>[this.relationshipColumnConfigs?.length,this.relatedRecordsEnabled]),(([e,t])=>{const{columns:i,relationshipColumns:s}=this;s.length&&i.removeMany(s),i.length&&t&&i.addMany(this._generateRelationshipColumns(),this._getIndexOfFirstFrozenToEndColumn())})),d((()=>this.objectIds),"change",(()=>this._onObjectIdsChange()),{onListenerAdd:()=>this._onObjectIdsChange()})])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return g(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _highlightableLayerView(){const e=this.layerView;return f(e)?e:null}get _layerWithRelationships(){const e=this.layer;if(!R(e))return null;const t=e.effectiveCapabilities??e.capabilities;return t?.queryRelated?.supportsCount&&t.queryRelated.supportsPagination?e:null}get _relationshipInfos(){const{_layerWithRelationships:e,relatedRecordsEnabled:t,relationships:i,view:s}=this,o=[];return t&&e?.loaded&&s?.map&&i?.length?(i.forEach((t=>{const i=F(e,s,t);i&&(i.load(),o.push({layer:e,relatedLayer:i,relationshipId:t.id}))})),o):o}get _selectionManager(){const{view:e}=this;return!e||e.destroyed?null:e.selectionManager?.sources?.length?e.selectionManager:null}get _selectableLayer(){const{layer:e}=this;return y(e)&&this._selectionManager?.sources.includes(e)?e:null}get _tableHighlightsReady(){return!("table"!==this.selectionSource||!this.highlightEnabled||!this._highlightableLayerView)}get _viewSelection(){const{_selectableLayer:e}=this;return e?this._selectionManager?.getSelection(e)??[]:[]}get _viewSelectionReady(){return!(!this.layer||"view"!==this.selectionSource||!this._selectionManager)}get activeFilters(){const{filterGeometry:e,objectIds:i,filterBySelectionEnabled:s,highlightIds:o}=this,r=new t;return e&&r.push({type:"geometry",geometry:e}),s?r.push({type:"selection",objectIds:o.toArray()}):i.length&&r.push({type:"objectId",objectIds:i.toArray()}),r}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}get filterGeometry(){return this._get("filterGeometry")}set filterGeometry(e){this.store.filterGeometry=e,this._set("filterGeometry",e)}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get hiddenFields(){return this._get("hiddenFields")??new t}set hiddenFields(e){this._set("hiddenFields",i(e,this._get("hiddenFields"),t))}get isQueryingOrSyncing(){const{store:e}=this;return e?.syncing||e?.querying}get layerView(){const{layer:e,view:t}=this;if(!e||!t)return null;const i="sublayer"===e.type?e.parent:e;return t.allLayerViews.find((e=>e.layer===i))}get objectIds(){return this._get("objectIds")??new t}set objectIds(e){this._set("objectIds",i(e,this._get("objectIds"),t))}get relatedRecordsEnabled(){return!!this._get("relatedRecordsEnabled")}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e,this._set("relatedRecordsEnabled",e)}get relationship(){const e=this.relationshipConfig?.relationshipId;return null==e?null:this.relationships?.find((({id:t})=>t===e))}get relationshipConfig(){return this._get("relationshipConfig")}set relationshipConfig(e){this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e,this._set("relationshipConfig",e)}get relationships(){const{layer:e}=this;return R(e)?e.relationships:null}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.highlightIds.removeMany(i),await this.refresh())}filterBySelection(){this.filterBySelectionEnabled?this._logWarning("Property 'filterBySelectionEnabled' is already 'true'. This method has no effect."):(s(r.getLogger(this),"`FeatureTable.filterBySelection` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.addMany(this.highlightIds.toArray()))}getObjectIdIndex(e){return this.store?.getItemIndexByObjectId(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}async refresh(){return l(this._debounceRefresh())}refreshCellContent(){this._requestContentUpdate()}async reset(){await(this.grid?.reset())}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){s(r.getLogger(this),"`FeatureTable.clearSelectionFilter` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.removeAll()}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const o=await e.queryFeatures(s);try{await t.goTo(o.features)}catch(r){"AbortError"!==r.name&&console.error(r)}}_requestContentUpdate(){this.grid?.requestContentUpdate()}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.highlightIds.remove(e[i])}))}this.grid?.refreshPageCache()}_onLayerLoad(){const{layer:e}=this;if(!e)return;const t=e.capabilities.query?.maxRecordCount;t&&t<this.pageSize&&this.grid&&(this.grid.pageSize=t),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const e=this._effectiveTableTemplate?.columnTemplates,t=e?this._generateColumnsFromTemplates(e):this._generateDefaultFieldColumns();t.length&&this.attachmentsEnabled&&t.push(this._generateAttachmentsColumn()),t.length&&this.relatedRecordsEnabled&&this._relationshipInfos.length&&t.push(...this._generateRelationshipColumns()),this.actionColumnConfig&&t.push(this._generateActionColumn()),t.sort(((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0)),this.columns.addMany(t)}_generateColumnsFromTemplates(e){const{editingEnabled:t,_effectiveTableTemplate:i,grid:s,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,store:a,timeZone:h}=this,d=o?.fields??[],m=[],c=e=>d.find((t=>e.fieldName.toLowerCase()===t.name?.toLowerCase()));return e.forEach((e=>{const{autoWidth:d,direction:g,flexGrow:p,fieldName:u,formatFunction:f,frozen:y,frozenToEnd:b,icon:_,initialSortPriority:C,invalid:w,label:E,menuConfig:T,resizable:S,sortable:R,textAlign:F,textWrap:U,type:O,width:L}=e;if(!O)return void this._logWarning("Property 'type' is missing from the provided template. Skipped generating a column for this template.");if(y&&b)return void this._logWarning("Both 'frozen' and 'frozenToEnd' cannot be true for a single template. Skipped generating a column for this template.");const x=!1===e.visible;if("group"===O){if(!e.columnTemplates?.length)return void this._logWarning("Group columns must contain column templates. Skipped generating a column for this template.");if(!e.label)return void this._logWarning("Group columns require a label. Skipped generating a column for this template.");const t=this._generateColumnsFromTemplates(e.columnTemplates),i=x||this._isFieldHidden(e.label);m.push(new j({autoWidth:d,columns:t,flexGrow:p,frozen:y,frozenToEnd:b,grid:s,hidden:i,icon:_,invalid:w,label:E,menuConfig:T,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,textAlign:F,textWrap:U,width:L}))}if(!u)return void this._logWarning("'fieldName' was missing from the provided template. Skipped generating a column for this template.");const A=x||this._isFieldHidden(u);if("column"===O&&m.push(new I({autoWidth:d,direction:g,fieldName:u,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:C,invalid:w,label:E,menuConfig:T,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,sortable:R,textAlign:F,textWrap:U,timeZone:h,width:L})),"field"===O){const h=c(e);if(!h)return void this._logWarning("A valid 'field' could not be found for the provided template. Skipped generating a column for this template.");const{editable:u,required:I}=e,j=i?.expressionInfos||null,{timeZone:O,timeZoneName:x}=this._getTimeZoneInfoForFieldColumn(h);m.push(new v({autoWidth:d,direction:g,editable:u,expressionInfos:j,field:h,fieldName:h.name,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:C,invalid:w,label:E,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,menuConfig:T,sortable:R,store:a,required:I,resizable:S,tableEditingEnabled:t,template:e,textAlign:F,textWrap:U,timeZone:O,timeZoneName:x,width:L}))}})),m}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n}=this,l=[];return i?.fields.length?(i.fields.forEach((a=>{if("geometry"===a.type)return;const{timeZone:h,timeZoneName:d}=this._getTimeZoneInfoForFieldColumn(a),m=a.name;l.push(new v({field:a,fieldName:m,grid:t,hidden:this._isFieldHidden(m),layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n,tableEditingEnabled:e,timeZone:h,timeZoneName:d}))})),l):l}_getTimeZoneInfoForFieldColumn(e){const{layer:t,timeZone:i,view:s}=this;return!t||"date"!==e?.type&&"timestamp-offset"!==e?.type?{timeZone:void 0,timeZoneName:void 0}:p(t.preferredTimeZone||null,!!t.datesInUnknownTimezone,i??s?.timeZone??u,x("short-time"),e.type)}_generateAttachmentsColumn(){return new _({hidden:this._isFieldHidden(U.attachments),messages:this.messages})}_generateRelationshipColumns(){const{_layerWithRelationships:e,_relationshipInfos:t,grid:i,messages:s,messagesCommon:o,messagesURIUtils:r,relationshipColumnConfigs:n}=this,l=[];if(!e)return l;const a={grid:i,messages:s,messagesCommon:o,messagesURIUtils:r};return n?n.forEach((e=>{const{relationshipId:i}=e,s=t.find((e=>e.relationshipId===i));s&&l.push(new C({...e,...a,fieldName:`${U.relationship}-${i}`,layer:s.relatedLayer,relatedLayer:s.layer,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})):t.forEach((({layer:e,relatedLayer:t,relationshipId:i})=>{l.push(new C({...a,fieldName:`${U.relationship}-${i}`,layer:t,relatedLayer:e,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})),l}_generateActionColumn(){return new b({hidden:this._isFieldHidden(U.action),...this.actionColumnConfig})}_sortOrdersToLayerOrderByFields(e,t=[]){const i=t.map((e=>e.path)),s=t.filter(((e,t)=>{const s=i.indexOf(e.path)===t,o=null!=e.direction;return s&&o})).map((({path:e,direction:t})=>`${e} ${t?.toUpperCase()}`));return!s.length&&!e.objectIdField&&e.fields?.length&&e.fields[0]?.name&&s.push(`${e.fields[0].name} ASC`),s}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_addTableHighlight(e){const{_highlightableLayerView:t,layer:i}=this;if(t&&i){const s=this.store.getItemByObjectId(e),o="sublayer"===i.type&&s?.feature?s.feature:e;this._highlights.add(t.highlight(o),`${i.id}-${e}`)}}_removeTableHighlight(e){const{layer:t}=this;t&&this._highlights.remove(`${t.id}-${e}`)}_syncSelection(){this._highlights.removeAll(),this._tableHighlightsReady?this.highlightIds.forEach((e=>this._addTableHighlight(e))):this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}_appendToViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.appendToSelection(t,e)}_removeFromViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.removeFromSelection(t,e)}_onHighlightIdsChange(e){const{added:t,removed:i}=e;this._tableHighlightsReady?(i.forEach((e=>this._removeTableHighlight(e))),t.forEach((e=>this._addTableHighlight(e)))):this._viewSelectionReady&&(this._removeFromViewSelection(i),this._appendToViewSelection(t)),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray())}_onShowRelatedTable(e){const{highlightIds:t}=this,{feature:i,layer:s,relatedLayer:o,relationshipId:r}=e,n=i.getObjectId()??i.attributes[o.objectIdField];if(null!=n){if(t.removeAll(),t.add(n),this.showRelatedTableCallback)return void this.showRelatedTableCallback(e);this.emit("show-related-table",{layer:s,relatedLayer:o,relationshipId:r,feature:i})}}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.grid?.refreshPageCache()}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex((e=>e.frozenToEnd));return e>-1?e:void 0}_logWarning(e){r.getLogger(this).warn(e)}};e([m()],Z.prototype,"_defaultHiddenFields",null),e([m()],Z.prototype,"_effectiveTableTemplate",null),e([m()],Z.prototype,"_highlights",void 0),e([m()],Z.prototype,"_highlightableLayerView",null),e([m({readOnly:!0})],Z.prototype,"_layerWithRelationships",null),e([m()],Z.prototype,"_relationshipInfos",null),e([m()],Z.prototype,"_selectionManager",null),e([m()],Z.prototype,"_selectableLayer",null),e([m()],Z.prototype,"_tableHighlightsReady",null),e([m()],Z.prototype,"_viewSelection",null),e([m()],Z.prototype,"_viewSelectionReady",null),e([m()],Z.prototype,"actionColumnConfig",void 0),e([m()],Z.prototype,"activeFilters",null),e([m({readOnly:!0})],Z.prototype,"activeSortOrders",null),e([m()],Z.prototype,"attachmentsEnabled",void 0),e([m()],Z.prototype,"autoRefreshEnabled",void 0),e([m({readOnly:!0})],Z.prototype,"columns",void 0),e([m()],Z.prototype,"dataProvider",void 0),e([m()],Z.prototype,"editingEnabled",void 0),e([m()],Z.prototype,"filterGeometry",null),e([m()],Z.prototype,"filterBySelectionEnabled",null),e([m({readOnly:!0})],Z.prototype,"grid",void 0),e([m()],Z.prototype,"hiddenFields",null),e([m()],Z.prototype,"highlightEnabled",void 0),e([m()],Z.prototype,"isQueryingOrSyncing",null),e([m({readOnly:!0})],Z.prototype,"itemIdPath",void 0),e([m()],Z.prototype,"layer",void 0),e([m()],Z.prototype,"layerView",null),e([m()],Z.prototype,"messages",void 0),e([m(),O("esri/t9n/common")],Z.prototype,"messagesCommon",void 0),e([m(),O("esri/widgets/support/t9n/uriUtils")],Z.prototype,"messagesURIUtils",void 0),e([m()],Z.prototype,"objectIds",null),e([m()],Z.prototype,"relatedRecordsEnabled",null),e([m()],Z.prototype,"relationship",null),e([m()],Z.prototype,"relationshipColumnConfigs",void 0),e([m()],Z.prototype,"relationshipConfig",null),e([m()],Z.prototype,"relationships",null),e([m()],Z.prototype,"returnGeometryEnabled",void 0),e([m()],Z.prototype,"returnMEnabled",void 0),e([m()],Z.prototype,"returnZEnabled",void 0),e([m()],Z.prototype,"selectionSource",void 0),e([m()],Z.prototype,"showRelatedTableCallback",void 0),e([m({readOnly:!0,type:T})],Z.prototype,"store",void 0),e([m({type:S})],Z.prototype,"tableTemplate",void 0),e([m()],Z.prototype,"tableTemplateOverride",void 0),e([m()],Z.prototype,"timeExtent",null),e([m()],Z.prototype,"timeZone",void 0),e([m()],Z.prototype,"view",void 0),Z=e([c("esri.widgets.FeatureTable.FeatureTableViewModel")],Z);const z=Z;export{z as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{equals as s,isSome as i}from"../../../core/arrayUtils.js";import o from"../../../core/Collection.js";import a from"../../../core/Error.js";import{clone as n}from"../../../core/lang.js";import u from"../../../core/Logger.js";import{watch as l,when as p}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/AttachmentQuery.js";import y from"../../../rest/support/RelationshipQuery.js";import{isIFeatureTableSupportedLayerWithAttachments as _,isIFeatureTableSupportedLayerWithEditing as m,isIFeatureTableSupportedLayerWithRelationships as f}from"./tableUtils.js";let g=class extends r{constructor(e){super(e),this._editOperationQueue=new o,this._hasStaleCache=!1,this._loaded=!1,this._loadError=!1,this._loading=!1,this._objectIdCache=new o,this._queryOperationQueue=new o,this.attachmentsEnabled=!1,this.count=0,this.failures=new o,this.filterGeometry=null,this.itemCache=new o,this.layer=null,this.objectIds=null,this.relationshipConfig=null,this.relatedRecordsEnabled=!1,this.returnGeometry=!1,this.timeExtent=null,this.where=null}initialize(){this.addHandles([l((()=>[this.filterGeometry,this.layer,this.objectIds,this.relationshipConfig,this.returnGeometry,this.timeExtent,this.where]),(()=>this._reset())),p((()=>this.attachmentsEnabled),(()=>this._reset())),p((()=>this.relatedRecordsEnabled),(()=>this._reset()))])}destroy(){this.layer=null,this.itemCache?.destroy(),this.failures?.destroy()}get _capabilities(){const{layer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _layerWithAttachments(){const{_capabilities:e,attachmentsEnabled:t,layer:r,supportsAttachments:s}=this;if(e&&r&&t&&s)return _(r)?r:null}get _layerWithEditing(){const e=this.layer;return m(e)&&this.supportsEditing?e:null}get _layerWithRelationships(){const e=this.layer;return f(e)&&this.supportsQueryRelated?e:null}get _relatedLayer(){return this.relationshipConfig?.relatedLayer}get _relatedLayerCapabilities(){const{_relatedLayer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _relatedLayerSupportsCacheHint(){return!!this._relatedLayerCapabilities?.queryRelated?.supportsCacheHint}get _relatedLayerSupportsQuery(){return!!this._relatedLayerCapabilities?.operations.supportsQuery}get _relatedLayerSupportsQueryRelated(){const{_relatedLayerCapabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get _canUseRelatedLayer(){return!(!this._relatedLayerSupportsQuery||!this._relatedLayerSupportsQueryRelated)}get canAddRelatedFeature(){const{state:e,relationship:t,supportsAdd:r,supportsEditing:s}=this;if("loaded"!==e||!t||!r||!s)return!1;const{count:i}=this,{cardinality:o,role:a}=t,n=i>0;return("one-to-one"!==o||!n)&&("one-to-many"!==o||"origin"!==a||!n)}get effectiveTimeExtent(){const{layer:e,timeExtent:t}=this;return t||e&&"timeExtent"in e&&e.timeExtent||null}get effectiveWhere(){return this.where||this.layer?.definitionExpression||"1=1"}get orderByFields(){return this._get("orderByFields")||[]}set orderByFields(e){const t=this.orderByFields;s(e,t)||(this.itemCache.removeAll(),this._hasStaleCache=!0,this._set("orderByFields",e))}get querying(){return this._queryOperationQueue.length>0}get relationship(){const{relationshipConfig:e}=this;return null==e?.relationshipId?null:this.relationships?.find((t=>t.id===e.relationshipId))}get relationshipIds(){return this.relationships?.map((e=>e.id))??[]}get relationships(){return this._layerWithRelationships?.relationships}get state(){const{layer:e,_loaded:t,_loadError:r,_loading:s}=this;return!e||e.destroyed?"disabled":r||e.loadError?"error":"loaded"===e.loadStatus&&t?"loaded":s?"loading":"ready"}get supportsAdd(){return!!this._capabilities?.operations.supportsAdd}get supportsAttachments(){const{_capabilities:e}=this;return!(!e?.data?.supportsAttachment||!e?.operations.supportsQueryAttachments)}get supportsCacheHint(){return!!this._capabilities?.query?.supportsCacheHint}get supportsCacheHintQueryRelated(){return!!this._capabilities?.queryRelated?.supportsCacheHint}get supportsDelete(){return!!this._capabilities?.operations.supportsDelete}get supportsEditing(){return!!this._capabilities?.operations.supportsEditing}get supportsOrderBy(){return!!this._capabilities?.query?.supportsOrderBy}get supportsPagination(){return!!this._capabilities?.query?.supportsPagination}get supportsQuery(){return!!this._capabilities?.operations.supportsQuery}get supportsQueryRelated(){const{_capabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get supportsUpdate(){return!!this._capabilities?.operations.supportsUpdate}get syncing(){return this._editOperationQueue.length>0}async load(){const{layer:e}=this;if(!this._loading&&!this._loaded&&e){this._reset(),this._loading=!0;try{await e.when(),await this._syncLayerInfo(),this._loaded=!0,this._loading=!1}catch(t){throw this._reset(),this._loadError=!0,this._logError("store:load-error","An error occurred."),t}}}async refreshLayerInfo(){return this._syncLayerInfo()}async addItems(e){}async fetchItems(e){const{page:t,pageSize:r}=e,s=t*r,i=s+r,{layer:o,state:a}=this;return o&&"loaded"===a?this._query({layer:o,start:s,num:i,page:t,pageSize:r}):[]}async verifyFeaturesByObjectId(e){const{layer:t,state:r}=this;if(!t||"loaded"!==r)return[];const{objectIdField:s}=t,{features:i}=await this._verifyFeaturesByObjectId(e);return e.map((e=>i.some((t=>{const r=t.getObjectId()??t.attributes[s];return e===r}))))}async query(e){const{state:t}=this;return this.supportsQuery&&"loaded"===t?this._query(e):[]}async removeItemAt(e){}async reset(){this._reset()}async updateItem(e){await this._update(e)}async deleteRowsByObjectId(e){const{_layerWithEditing:t}=this;if(!this.supportsDelete||!t)throw new a("store:delete-error","Delete is not supported.");const r=e.map((e=>this.getItemByObjectId(e)?.feature)).filter(i);return this._queueEditOperation((()=>t.applyEdits({deleteFeatures:r})))}getItemByObjectId(e){const{itemCache:t,layer:r}=this;if(!r)return;const s=r.objectIdField;return t.find((({feature:t})=>!!t&&(t.getObjectId()??t.attributes[s])===e))}getItemIndexByObjectId(e){const{itemCache:t,layer:r}=this;if(!r)return-1;const s=r.objectIdField;return t.findIndex((({feature:t})=>!!t&&(t.getObjectId()??t.attributes[s])===e))}getLocalItemAt(e){return this.itemCache.at(e)}at(e){return Promise.resolve(this.itemCache.at(e))}_reset(){this.itemCache.removeAll(),this.failures.removeAll(),this._editOperationQueue.removeAll(),this._queryOperationQueue.removeAll(),this._hasStaleCache=!1,this._loading=!1,this._loaded=!1,this._loadError=!1,this._set("count",0),this._objectIdCache.removeAll()}_getIdsFromFeatures(e,t){return e.map((e=>e.getObjectId()??e.attributes[t]))}_resultsToFeatureData(e){const{attachments:t,features:r,layer:s,relatedRecords:i}=e,o=s.objectIdField;return r.map((e=>{const{attributes:r}=e,a=e.getObjectId()??r[o],n=[];return e.layer||e.sourceLayer||(e.layer=s,e.sourceLayer=s),i.forEach(((e,t)=>{n.push({relationshipId:t,count:e[a]??0})})),{objectId:a,feature:e,attachments:t[a]??null,relatedRecords:n}}))}async _update(e){const{_layerWithEditing:r}=this;if(!this.supportsUpdate||!r)throw new a("store:update-error","Update is not supported.");const{index:s,name:i,value:o}=e,u=await this.at(s);if(!u?.feature)throw new a("store:update-error","Feature with provided 'objectId' not found.");const{feature:l}=u,p=n(l.attributes);p[i]=o;const d=new t({attributes:p}),h=r.applyEdits({updateFeatures:[d]}).then((e=>{const{updateFeatureResults:t}=e,r=t.find((e=>!!e.error));if(r)throw r.error;return t.length&&(l.attributes=p),e}));return this._queueEditOperation((()=>h))}async _query(e){const{refresh:t}=e;return!0===t?(this.itemCache.removeAll(),this._syncLayerInfo().then((()=>this._queryFeatureData(e)))):(this._hasStaleCache&&(await this._syncObjectIdCache(),this._hasStaleCache=!1),this._queryFeatureData(e))}async _queryFeatureData(e){const{layer:t}=e;return this._queueQueryOperation((async()=>{const r=await this._queryFeatures(e),s=this._getIdsFromFeatures(r,t.objectIdField),i=await this._queryAttachments(s),o=await this._queryRelatedCounts(s);return this._resultsToFeatureData({layer:t,features:r,attachments:i,relatedRecords:o})||[]}))}async _syncLayerInfo(){await this._syncCount(),await this._syncObjectIdCache()}async _syncCount(){await this._queryCount().then((e=>this._set("count",e)))}async _syncObjectIdCache(){if(this.supportsPagination)return;const e=await this._queryForObjectIds();this._objectIdCache.removeAll(),this._objectIdCache.addMany(e)}async _queryCount(){const{_relatedLayerSupportsCacheHint:e,layer:t,relationshipConfig:r,supportsCacheHint:s}=this;if(!t)return 0;if(r&&this._canUseRelatedLayer){const{objectId:t,relatedLayer:s,relationshipId:i}=r;return(await s.queryRelatedFeaturesCount(new y({cacheHint:e,relationshipId:i,objectIds:[t]})))[t]??0}const{effectiveTimeExtent:i,effectiveWhere:o,filterGeometry:a,objectIds:n}=this,u=t.createQuery();return u.geometry=a,u.returnGeometry=!1,u.where=o,u.timeExtent=i,u.objectIds=n?.length?n:void 0,s&&(u.cacheHint=!0),t.queryFeatureCount(u)}async _queryRelatedCounts(e){const{_layerWithRelationships:t,relationshipIds:r,supportsCacheHintQueryRelated:s}=this,i=new Map;return t&&e?.length&&r.length?(await Promise.allSettled(r.map((async r=>{const o=await t.queryRelatedFeaturesCount(new y({cacheHint:s,relationshipId:r,objectIds:e}));i.set(r,o)}))),i):i}_queryForObjectIds(){const{effectiveTimeExtent:e,effectiveWhere:t,filterGeometry:r,layer:s,objectIds:i,orderByFields:o,supportsCacheHint:a,supportsOrderBy:n}=this;if(!s)return Promise.resolve([]);const u=s.createQuery();return u.geometry=r,u.outFields=[s.objectIdField],u.returnGeometry=!1,u.where=t,u.timeExtent=e,u.objectIds=i?.length?i:void 0,n&&(u.orderByFields=o),a&&(u.cacheHint=!0),s.queryObjectIds(u)}async _queryFeatures(e){const{relationshipConfig:t}=this;if(t&&this._canUseRelatedLayer)return this._queryRelatedFeatures(e,t);const{effectiveTimeExtent:r,effectiveWhere:s,filterGeometry:i,objectIds:o,orderByFields:a,returnGeometry:n,supportsCacheHint:u,supportsOrderBy:l,supportsPagination:p}=this,{layer:d,start:h,pageSize:c}=e,y=o?.length,_=d.createQuery();_.returnGeometry=n,p?(_.start=h,_.num=c,_.where=s,_.timeExtent=r,_.objectIds=y?o:void 0):_.objectIds=y?o:this._getObjectIdsForPage(h,c??0),l&&(_.orderByFields=a),i&&(_.geometry=i),u&&(_.cacheHint=!0);return(await d.queryFeatures(_)).features}async _queryRelatedFeatures(e,t){const{orderByFields:r,returnGeometry:s,supportsCacheHint:i}=this,{layer:o,start:a,pageSize:n}=e,{objectId:u,relatedLayer:l,relationshipId:p}=t,d=o.createQuery(),h=new y({cacheHint:i,num:n??0,objectIds:[u],orderByFields:r,outFields:["*"],relationshipId:p,returnGeometry:s,start:a,where:d.where??void 0}),c=await l.queryRelatedFeatures(h);return c[u]?.features||[]}async _verifyFeaturesByObjectId(e){const{layer:t}=this;if(!t||!this.supportsQuery)throw new a("store:query-error","Layer does not support query operation.");const{effectiveTimeExtent:r,effectiveWhere:s,orderByFields:i,supportsCacheHint:o,supportsOrderBy:n}=this,u=t.createQuery();return u.where=s,u.timeExtent=r,u.returnGeometry=!1,u.objectIds=e.length?e:void 0,u.outFields=[t.objectIdField],n&&(u.orderByFields=i),o&&(u.cacheHint=!0),t.queryFeatures(u)}_getObjectIdsForPage(e,t){const r=this._objectIdCache.toArray();return r.length>=e+t?r.slice(e,e+t):r.slice(e)}_queryAttachments(e){const{_layerWithAttachments:t,effectiveWhere:r}=this;return t?t.queryAttachments(new c({objectIds:e,where:r})):Promise.resolve({})}_syncLocalCache(e){const{layer:t}=this;if(!t)return;const{objectIdField:r}=t,{itemCache:s}=this;e.forEach((e=>{if(e?.feature){const{feature:t}=e,i=t.getObjectId()??t.attributes[r];if(null!=i){const t=this.getItemIndexByObjectId(i);-1===t?s.add(e):s.splice(t,1,e)}}}))}_queueQueryOperation(e){return this._queryOperationQueue.push(e),e().then((t=>this._queryOperationQueue.includes(e)?(this._syncLocalCache(t),t):[])).catch((t=>{this._logError("store:query-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueQueryOperation(e)},cancel:()=>this.failures.remove(r)};return this.failures.add(r),[]})).then((t=>(this._queryOperationQueue.remove(e),t)))}_queueEditOperation(e){return this._editOperationQueue.push(e),e().then((t=>(this._editOperationQueue.remove(e),t))).catch((t=>{this._logError("store:edit-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueEditOperation(e)},cancel:()=>this.failures.remove(r)};throw this.failures.add(r),this._editOperationQueue.remove(e),t}))}_logError(e,t){u.getLogger(this).error(e,t)}};e([d({readOnly:!0})],g.prototype,"_capabilities",null),e([d()],g.prototype,"_editOperationQueue",void 0),e([d()],g.prototype,"_hasStaleCache",void 0),e([d({readOnly:!0})],g.prototype,"_layerWithAttachments",null),e([d({readOnly:!0})],g.prototype,"_layerWithEditing",null),e([d({readOnly:!0})],g.prototype,"_layerWithRelationships",null),e([d()],g.prototype,"_loaded",void 0),e([d()],g.prototype,"_loadError",void 0),e([d()],g.prototype,"_loading",void 0),e([d()],g.prototype,"_objectIdCache",void 0),e([d()],g.prototype,"_queryOperationQueue",void 0),e([d({readOnly:!0})],g.prototype,"_relatedLayer",null),e([d({readOnly:!0})],g.prototype,"_relatedLayerCapabilities",null),e([d({readOnly:!0})],g.prototype,"_relatedLayerSupportsCacheHint",null),e([d()],g.prototype,"_relatedLayerSupportsQuery",null),e([d()],g.prototype,"_relatedLayerSupportsQueryRelated",null),e([d()],g.prototype,"_canUseRelatedLayer",null),e([d()],g.prototype,"attachmentsEnabled",void 0),e([d()],g.prototype,"canAddRelatedFeature",null),e([d({readOnly:!0})],g.prototype,"count",void 0),e([d()],g.prototype,"effectiveTimeExtent",null),e([d()],g.prototype,"effectiveWhere",null),e([d({readOnly:!0})],g.prototype,"failures",void 0),e([d()],g.prototype,"filterGeometry",void 0),e([d({readOnly:!0})],g.prototype,"itemCache",void 0),e([d()],g.prototype,"layer",void 0),e([d()],g.prototype,"objectIds",void 0),e([d()],g.prototype,"orderByFields",null),e([d({readOnly:!0})],g.prototype,"querying",null),e([d()],g.prototype,"relationship",null),e([d()],g.prototype,"relationshipConfig",void 0),e([d()],g.prototype,"relationshipIds",null),e([d()],g.prototype,"relationships",null),e([d()],g.prototype,"relatedRecordsEnabled",void 0),e([d()],g.prototype,"returnGeometry",void 0),e([d({readOnly:!0})],g.prototype,"state",null),e([d()],g.prototype,"supportsAdd",null),e([d()],g.prototype,"supportsAttachments",null),e([d()],g.prototype,"supportsCacheHint",null),e([d()],g.prototype,"supportsCacheHintQueryRelated",null),e([d()],g.prototype,"supportsDelete",null),e([d()],g.prototype,"supportsEditing",null),e([d()],g.prototype,"supportsOrderBy",null),e([d()],g.prototype,"supportsPagination",null),e([d()],g.prototype,"supportsQuery",null),e([d()],g.prototype,"supportsQueryRelated",null),e([d()],g.prototype,"supportsUpdate",null),e([d({readOnly:!0})],g.prototype,"syncing",null),e([d()],g.prototype,"timeExtent",void 0),e([d()],g.prototype,"where",void 0),g=e([h("esri.widgets.FeatureTable.support.FeatureStore")],g);const b=g;export{b as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{equals as s,isSome as i}from"../../../core/arrayUtils.js";import o from"../../../core/Collection.js";import a from"../../../core/Error.js";import{clone as n}from"../../../core/lang.js";import u from"../../../core/Logger.js";import{watch as l,when as p}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/AttachmentQuery.js";import y from"../../../rest/support/RelationshipQuery.js";import{isIFeatureTableSupportedLayerWithAttachments as _,isIFeatureTableSupportedLayerWithEditing as f,isIFeatureTableSupportedLayerWithRelationships as m}from"./tableUtils.js";let g=class extends r{constructor(e){super(e),this._defaultOutFields=["*"],this._editOperationQueue=new o,this._hasStaleCache=!1,this._loaded=!1,this._loadError=!1,this._loading=!1,this._objectIdCache=new o,this._queryOperationQueue=new o,this.attachmentsEnabled=!1,this.count=0,this.failures=new o,this.filterGeometry=null,this.itemCache=new o,this.layer=null,this.objectIds=null,this.outFields=null,this.relationshipConfig=null,this.relatedRecordsEnabled=!1,this.returnGeometry=!1,this.returnZ=!1,this.returnM=!1,this.timeExtent=null,this.where=null}initialize(){this.addHandles([l((()=>[this.filterGeometry,this.layer,this.objectIds,this.relationshipConfig,this.returnGeometry,this.returnM,this.returnZ,this.timeExtent,this.where]),(()=>this._reset())),p((()=>this.attachmentsEnabled),(()=>this._reset())),p((()=>this.relatedRecordsEnabled),(()=>this._reset()))])}destroy(){this.layer=null,this.itemCache?.destroy(),this.failures?.destroy()}get _capabilities(){const{layer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _effectiveReturnZ(){return this.returnZ&&this.supportsZ}get _effectiveReturnM(){return this.returnM&&this.supportsM}get _layerWithAttachments(){const{_capabilities:e,attachmentsEnabled:t,layer:r,supportsAttachments:s}=this;if(e&&r&&t&&s)return _(r)?r:null}get _layerWithEditing(){const e=this.layer;return f(e)&&this.supportsEditing?e:null}get _layerWithRelationships(){const e=this.layer;return m(e)&&this.supportsQueryRelated?e:null}get _relatedLayer(){return this.relationshipConfig?.relatedLayer}get _relatedLayerCapabilities(){const{_relatedLayer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _relatedLayerSupportsCacheHint(){return!!this._relatedLayerCapabilities?.queryRelated?.supportsCacheHint}get _relatedLayerSupportsQuery(){return!!this._relatedLayerCapabilities?.operations.supportsQuery}get _relatedLayerSupportsQueryRelated(){const{_relatedLayerCapabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get _canUseRelatedLayer(){return!(!this._relatedLayerSupportsQuery||!this._relatedLayerSupportsQueryRelated)}get canAddRelatedFeature(){const{state:e,relationship:t,supportsAdd:r,supportsEditing:s}=this;if("loaded"!==e||!t||!r||!s)return!1;const{count:i}=this,{cardinality:o,role:a}=t,n=i>0;return("one-to-one"!==o||!n)&&("one-to-many"!==o||"origin"!==a||!n)}get effectiveOutFields(){return this.outFields||this._defaultOutFields}get effectiveTimeExtent(){const{layer:e,timeExtent:t}=this;return t||e&&"timeExtent"in e&&e.timeExtent||null}get effectiveWhere(){return this.where||this.layer?.definitionExpression||"1=1"}get orderByFields(){return this._get("orderByFields")||[]}set orderByFields(e){const t=this.orderByFields;s(e,t)||(this.itemCache.removeAll(),this._hasStaleCache=!0,this._set("orderByFields",e))}get querying(){return this._queryOperationQueue.length>0}get relationship(){const{relationshipConfig:e}=this;return null==e?.relationshipId?null:this.relationships?.find((t=>t.id===e.relationshipId))}get relationshipIds(){return this.relationships?.map((e=>e.id))??[]}get relationships(){return this._layerWithRelationships?.relationships}get state(){const{layer:e,_loaded:t,_loadError:r,_loading:s}=this;return!e||e.destroyed?"disabled":r||e.loadError?"error":"loaded"===e.loadStatus&&t?"loaded":s?"loading":"ready"}get supportsAdd(){return!!this._capabilities?.operations.supportsAdd}get supportsAttachments(){const{_capabilities:e}=this;return!(!e?.data?.supportsAttachment||!e?.operations.supportsQueryAttachments)}get supportsCacheHint(){return!!this._capabilities?.query?.supportsCacheHint}get supportsCacheHintQueryRelated(){return!!this._capabilities?.queryRelated?.supportsCacheHint}get supportsDelete(){return!!this._capabilities?.operations.supportsDelete}get supportsEditing(){return!!this._capabilities?.operations.supportsEditing}get supportsM(){return!!this.layer?.hasM&&!!this._capabilities?.data?.supportsM}get supportsOrderBy(){return!!this._capabilities?.query?.supportsOrderBy}get supportsPagination(){return!!this._capabilities?.query?.supportsPagination}get supportsQuery(){return!!this._capabilities?.operations.supportsQuery}get supportsQueryRelated(){const{_capabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get supportsUpdate(){return!!this._capabilities?.operations.supportsUpdate}get supportsZ(){return!!this.layer?.hasZ&&!!this._capabilities?.data?.supportsZ}get syncing(){return this._editOperationQueue.length>0}async load(){const{layer:e}=this;if(!this._loading&&!this._loaded&&e){this._reset(),this._loading=!0;try{await e.when(),await this._syncLayerInfo(),this._loaded=!0,this._loading=!1}catch(t){throw this._reset(),this._loadError=!0,this._logError("store:load-error","An error occurred."),t}}}async refreshLayerInfo(){return this._syncLayerInfo()}async addItems(e){}async fetchItems(e){const{page:t,pageSize:r}=e,s=t*r,i=s+r,{layer:o,state:a}=this;return o&&"loaded"===a?this._query({layer:o,start:s,num:i,page:t,pageSize:r}):[]}async verifyFeaturesByObjectId(e){const{layer:t,state:r}=this;if(!t||"loaded"!==r)return[];const{objectIdField:s}=t,{features:i}=await this._verifyFeaturesByObjectId(e);return e.map((e=>i.some((t=>{const r=t.getObjectId()??t.attributes[s];return e===r}))))}async query(e){const{state:t}=this;return this.supportsQuery&&"loaded"===t?this._query(e):[]}async removeItemAt(e){}async reset(){this._reset()}async updateItem(e){await this._update(e)}async deleteRowsByObjectId(e){const{_layerWithEditing:t}=this;if(!this.supportsDelete||!t)throw new a("store:delete-error","Delete is not supported.");const r=e.map((e=>this.getItemByObjectId(e)?.feature)).filter(i);return this._queueEditOperation((()=>t.applyEdits({deleteFeatures:r})))}getItemByObjectId(e){const{itemCache:t,layer:r}=this;if(!r)return;const s=r.objectIdField;return t.find((({feature:t})=>!!t&&(t.getObjectId()??t.attributes[s])===e))}getItemIndexByObjectId(e){const{itemCache:t,layer:r}=this;if(!r)return-1;const s=r.objectIdField;return t.findIndex((({feature:t})=>!!t&&(t.getObjectId()??t.attributes[s])===e))}getLocalItemAt(e){return this.itemCache.at(e)}at(e){return Promise.resolve(this.itemCache.at(e))}_reset(){this.itemCache.removeAll(),this.failures.removeAll(),this._editOperationQueue.removeAll(),this._queryOperationQueue.removeAll(),this._hasStaleCache=!1,this._loading=!1,this._loaded=!1,this._loadError=!1,this._set("count",0),this._objectIdCache.removeAll()}_getIdsFromFeatures(e,t){return e.map((e=>e.getObjectId()??e.attributes[t]))}_resultsToFeatureData(e){const{attachments:t,features:r,layer:s,relatedRecords:i}=e,o=s.objectIdField;return r.map((e=>{const{attributes:r}=e,a=e.getObjectId()??r[o],n=[];return e.layer||e.sourceLayer||(e.layer=s,e.sourceLayer=s),i.forEach(((e,t)=>{n.push({relationshipId:t,count:e[a]??0})})),{objectId:a,feature:e,attachments:t[a]??null,relatedRecords:n}}))}async _update(e){const{_layerWithEditing:r}=this;if(!this.supportsUpdate||!r)throw new a("store:update-error","Update is not supported.");const{index:s,name:i,value:o}=e,u=await this.at(s);if(!u?.feature)throw new a("store:update-error","Feature with provided 'objectId' not found.");const{feature:l}=u,p=n(l.attributes);p[i]=o;const d=new t({attributes:p}),h=r.applyEdits({updateFeatures:[d]}).then((e=>{const{updateFeatureResults:t}=e,r=t.find((e=>!!e.error));if(r)throw r.error;return t.length&&(l.attributes=p),e}));return this._queueEditOperation((()=>h))}async _query(e){const{refresh:t}=e;return!0===t?(this.itemCache.removeAll(),this._syncLayerInfo().then((()=>this._queryFeatureData(e)))):(this._hasStaleCache&&(await this._syncObjectIdCache(),this._hasStaleCache=!1),this._queryFeatureData(e))}async _queryFeatureData(e){const{layer:t}=e;return this._queueQueryOperation((async()=>{const r=await this._queryFeatures(e),s=this._getIdsFromFeatures(r,t.objectIdField),i=await this._queryAttachments(s),o=await this._queryRelatedCounts(s);return this._resultsToFeatureData({layer:t,features:r,attachments:i,relatedRecords:o})||[]}))}async _syncLayerInfo(){await this._syncCount(),await this._syncObjectIdCache()}async _syncCount(){await this._queryCount().then((e=>this._set("count",e)))}async _syncObjectIdCache(){if(this.supportsPagination)return;const e=await this._queryForObjectIds();this._objectIdCache.removeAll(),this._objectIdCache.addMany(e)}async _queryCount(){const{_relatedLayerSupportsCacheHint:e,layer:t,relationshipConfig:r,supportsCacheHint:s}=this;if(!t)return 0;if(r&&this._canUseRelatedLayer){const{objectId:t,relatedLayer:s,relationshipId:i}=r;return(await s.queryRelatedFeaturesCount(new y({cacheHint:e,relationshipId:i,objectIds:[t]})))[t]??0}const{effectiveTimeExtent:i,effectiveWhere:o,filterGeometry:a,objectIds:n}=this,u=t.createQuery();return u.geometry=a,u.returnGeometry=!1,u.where=o,u.timeExtent=i,u.objectIds=n?.length?n:void 0,s&&(u.cacheHint=!0),t.queryFeatureCount(u)}async _queryRelatedCounts(e){const{_layerWithRelationships:t,relationshipIds:r,supportsCacheHintQueryRelated:s}=this,i=new Map;return t&&e?.length&&r.length?(await Promise.allSettled(r.map((async r=>{const o=await t.queryRelatedFeaturesCount(new y({cacheHint:s,relationshipId:r,objectIds:e}));i.set(r,o)}))),i):i}_queryForObjectIds(){const{effectiveTimeExtent:e,effectiveWhere:t,filterGeometry:r,layer:s,objectIds:i,orderByFields:o,supportsCacheHint:a,supportsOrderBy:n}=this;if(!s)return Promise.resolve([]);const u=s.createQuery();return u.geometry=r,u.outFields=[s.objectIdField],u.returnGeometry=!1,u.where=t,u.timeExtent=e,u.objectIds=i?.length?i:void 0,n&&(u.orderByFields=o),a&&(u.cacheHint=!0),s.queryObjectIds(u)}async _queryFeatures(e){const{relationshipConfig:t}=this;if(t&&this._canUseRelatedLayer)return this._queryRelatedFeatures(e,t);const{_effectiveReturnM:r,_effectiveReturnZ:s,effectiveOutFields:i,effectiveTimeExtent:o,effectiveWhere:a,filterGeometry:n,objectIds:u,orderByFields:l,returnGeometry:p,supportsCacheHint:d,supportsOrderBy:h,supportsPagination:c}=this,{layer:y,start:_,pageSize:f}=e,m=u?.length,g=y.createQuery();g.returnGeometry=p,g.outFields=i,g.returnM=r,g.returnZ=s,c?(g.start=_,g.num=f,g.where=a,g.timeExtent=o,g.objectIds=m?u:void 0):g.objectIds=m?u:this._getObjectIdsForPage(_,f??0),h&&(g.orderByFields=l),n&&(g.geometry=n),d&&(g.cacheHint=!0);return(await y.queryFeatures(g)).features}async _queryRelatedFeatures(e,t){const{_defaultOutFields:r,_effectiveReturnM:s,_effectiveReturnZ:i,orderByFields:o,returnGeometry:a,supportsCacheHint:n}=this,{layer:u,start:l,pageSize:p}=e,{objectId:d,relatedLayer:h,relationshipId:c}=t,_=u.createQuery(),f=new y({cacheHint:n,num:p??0,objectIds:[d],orderByFields:o,outFields:r,relationshipId:c,returnGeometry:a,returnM:s,returnZ:i,start:l,where:_.where??void 0}),m=await h.queryRelatedFeatures(f);return m[d]?.features||[]}async _verifyFeaturesByObjectId(e){const{layer:t}=this;if(!t||!this.supportsQuery)throw new a("store:query-error","Layer does not support query operation.");const{effectiveTimeExtent:r,effectiveWhere:s,orderByFields:i,supportsCacheHint:o,supportsOrderBy:n}=this,u=t.createQuery();return u.where=s,u.timeExtent=r,u.returnGeometry=!1,u.objectIds=e.length?e:void 0,u.outFields=[t.objectIdField],n&&(u.orderByFields=i),o&&(u.cacheHint=!0),t.queryFeatures(u)}_getObjectIdsForPage(e,t){const r=this._objectIdCache.toArray();return r.length>=e+t?r.slice(e,e+t):r.slice(e)}_queryAttachments(e){const{_layerWithAttachments:t,effectiveWhere:r}=this;return t?t.queryAttachments(new c({objectIds:e,where:r})):Promise.resolve({})}_syncLocalCache(e){const{layer:t}=this;if(!t)return;const{objectIdField:r}=t,{itemCache:s}=this;e.forEach((e=>{if(e?.feature){const{feature:t}=e,i=t.getObjectId()??t.attributes[r];if(null!=i){const t=this.getItemIndexByObjectId(i);-1===t?s.add(e):s.splice(t,1,e)}}}))}_queueQueryOperation(e){return this._queryOperationQueue.push(e),e().then((t=>this._queryOperationQueue.includes(e)?(this._syncLocalCache(t),t):[])).catch((t=>{this._logError("store:query-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueQueryOperation(e)},cancel:()=>this.failures.remove(r)};return this.failures.add(r),[]})).then((t=>(this._queryOperationQueue.remove(e),t)))}_queueEditOperation(e){return this._editOperationQueue.push(e),e().then((t=>(this._editOperationQueue.remove(e),t))).catch((t=>{this._logError("store:edit-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueEditOperation(e)},cancel:()=>this.failures.remove(r)};throw this.failures.add(r),this._editOperationQueue.remove(e),t}))}_logError(e,t){u.getLogger(this).error(e,t)}};e([d({readOnly:!0})],g.prototype,"_capabilities",null),e([d()],g.prototype,"_defaultOutFields",void 0),e([d()],g.prototype,"_editOperationQueue",void 0),e([d()],g.prototype,"_effectiveReturnZ",null),e([d()],g.prototype,"_effectiveReturnM",null),e([d()],g.prototype,"_hasStaleCache",void 0),e([d({readOnly:!0})],g.prototype,"_layerWithAttachments",null),e([d({readOnly:!0})],g.prototype,"_layerWithEditing",null),e([d({readOnly:!0})],g.prototype,"_layerWithRelationships",null),e([d()],g.prototype,"_loaded",void 0),e([d()],g.prototype,"_loadError",void 0),e([d()],g.prototype,"_loading",void 0),e([d()],g.prototype,"_objectIdCache",void 0),e([d()],g.prototype,"_queryOperationQueue",void 0),e([d({readOnly:!0})],g.prototype,"_relatedLayer",null),e([d({readOnly:!0})],g.prototype,"_relatedLayerCapabilities",null),e([d({readOnly:!0})],g.prototype,"_relatedLayerSupportsCacheHint",null),e([d()],g.prototype,"_relatedLayerSupportsQuery",null),e([d()],g.prototype,"_relatedLayerSupportsQueryRelated",null),e([d()],g.prototype,"_canUseRelatedLayer",null),e([d()],g.prototype,"attachmentsEnabled",void 0),e([d()],g.prototype,"canAddRelatedFeature",null),e([d({readOnly:!0})],g.prototype,"count",void 0),e([d()],g.prototype,"effectiveOutFields",null),e([d()],g.prototype,"effectiveTimeExtent",null),e([d()],g.prototype,"effectiveWhere",null),e([d({readOnly:!0})],g.prototype,"failures",void 0),e([d()],g.prototype,"filterGeometry",void 0),e([d({readOnly:!0})],g.prototype,"itemCache",void 0),e([d()],g.prototype,"layer",void 0),e([d()],g.prototype,"objectIds",void 0),e([d()],g.prototype,"orderByFields",null),e([d()],g.prototype,"outFields",void 0),e([d({readOnly:!0})],g.prototype,"querying",null),e([d()],g.prototype,"relationship",null),e([d()],g.prototype,"relationshipConfig",void 0),e([d()],g.prototype,"relationshipIds",null),e([d()],g.prototype,"relationships",null),e([d()],g.prototype,"relatedRecordsEnabled",void 0),e([d()],g.prototype,"returnGeometry",void 0),e([d()],g.prototype,"returnZ",void 0),e([d()],g.prototype,"returnM",void 0),e([d({readOnly:!0})],g.prototype,"state",null),e([d()],g.prototype,"supportsAdd",null),e([d()],g.prototype,"supportsAttachments",null),e([d()],g.prototype,"supportsCacheHint",null),e([d()],g.prototype,"supportsCacheHintQueryRelated",null),e([d()],g.prototype,"supportsDelete",null),e([d()],g.prototype,"supportsEditing",null),e([d()],g.prototype,"supportsM",null),e([d()],g.prototype,"supportsOrderBy",null),e([d()],g.prototype,"supportsPagination",null),e([d()],g.prototype,"supportsQuery",null),e([d()],g.prototype,"supportsQueryRelated",null),e([d()],g.prototype,"supportsUpdate",null),e([d()],g.prototype,"supportsZ",null),e([d({readOnly:!0})],g.prototype,"syncing",null),e([d()],g.prototype,"timeExtent",void 0),e([d()],g.prototype,"where",void 0),g=e([h("esri.widgets.FeatureTable.support.FeatureStore")],g);const b=g;export{b as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const e={action:"EsriFeatureTableActionColumn",attachments:"EsriFeatureTableAttachmentsColumn",relationship:"EsriFeatureTableRelationshipColumn"};function n(e){return e&&"selection"===e.type}function t(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"getField"in e&&"queryFeatureCount"in e&&"queryFeatures"in e&&"queryObjectIds"in e&&"capabilities"in e&&"fields"in e&&"fieldsIndex"in e&&"id"in e&&"load"in e&&"objectIdField"in e&&"
|
|
5
|
+
const e={action:"EsriFeatureTableActionColumn",attachments:"EsriFeatureTableAttachmentsColumn",relationship:"EsriFeatureTableRelationshipColumn"};function n(e){return e&&"selection"===e.type}function t(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"getField"in e&&"queryFeatureCount"in e&&"queryFeatures"in e&&"queryObjectIds"in e&&"capabilities"in e&&"fields"in e&&"fieldsIndex"in e&&"id"in e&&"load"in e&&"objectIdField"in e&&"type"in e&&"when"in e}function i(e){return t(e)&&"queryAttachments"in e}function r(e){return t(e)&&"editingEnabled"in e&&"applyEdits"in e}function a(e){return t(e)&&"relationships"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e}function u(e){return null!=e&&"object"==typeof e&&"type"in e&&null!==e.type&&("column"===e.type||"field"===e.type||"group"===e.type)}function l(e){return null!=e&&"object"==typeof e&&"type"in e&&"map-image"===e.type}function o(e,n,{relatedTableId:t}){if(!n?.map)return;const i="scene"===e.type&&e.associatedLayer?e.associatedLayer.url:e.url;if("sublayer"===e.type&&l(e.parent)){const n=e.parent,i=n=>a(n)&&n!==e&&n.id===t,r=n.sublayers?.find(i)||n.subtables?.find(i);if(a(r))return r}const r=n=>a(n)&&n!==e&&n.url===i&&n.layerId===t,u=[...n.map.allLayers,...n.map.allTables].find(r);return a(u)?u:void 0}export{o as findRelatedLayer,t as isIFeatureTableSupportedLayer,i as isIFeatureTableSupportedLayerWithAttachments,r as isIFeatureTableSupportedLayerWithEditing,a as isIFeatureTableSupportedLayerWithRelationships,l as isMapImageLayer,n as isSelectionFilter,u as isTemplateObjectWithType,e as uniqueColumnNames};
|
package/widgets/FeatureTable.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{watch as i,sync as l,initial as o,on as s}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isLayerFromCatalog as a}from"../layers/catalog/catalogUtils.js";import{isKnowledgeGraphLayer as d}from"../layers/support/layerUtils.js";import c from"./Widget.js";import h from"./FeatureTable/ColumnMenuVisibleElements.js";import p from"./FeatureTable/FeatureTableViewModel.js";import m from"./FeatureTable/VisibleElements.js";import u from"./FeatureTable/support/FieldColumnTemplate.js";import g from"./FeatureTable/support/TableTemplate.js";import{isIFeatureTableSupportedLayer as b,uniqueColumnNames as w,isIFeatureTableSupportedLayerWithAttachments as v}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as y}from"./support/componentsUtils.js";import{globalCss as f}from"./support/globalCss.js";import{Heading as _}from"./support/Heading.js";import{renderingSanitizer as M}from"./support/widgetUtils.js";import{messageBundle as C}from"./support/decorators/messageBundle.js";import{vmEvent as E}from"./support/decorators/vmEvent.js";import{tsx as S}from"./support/jsxFactory.js";import{substitute as T}from"../intl/substitute.js";var I;const A="esri-feature-table",R=`${A}__prompt`,j={base:A,content:`${A}__content`,menuPopover:`${A}__menu-popover`,layerDropdownMenu:`${A}__layer-switcher-menu`,tableContainer:`${A}__table-container`,tableNavigation:`${A}__table-navigation`,expanded:`${A}__expanded`,collapsed:`${A}__collapsed`,promptContainer:R,promptHeader:`${R}__header`,promptHeading:`${R}__header__heading`,promptMessage:`${R}__message`,promptDivider:`${R}__divider`,promptActions:`${R}__actions`},k={clearSelection:"clear-selection",delete:"trash",refresh:"refresh",showAll:"selection-x",showSelected:"selection-filter",zoomToSelection:"zoom-to-object"};let F=I=class extends c{constructor(e,i){super(e,i),this._columnVisibilityActions=new Map,this._prompt=null,this._showAllTablesEnabled=!1,this.description=null,this.disabled=!1,this.layers=null,this.menuConfig=null,this.relatedTables=new t,this.tableParent=null,this.title=null,this.viewModel=new p,this.visibleElements=new m,this.visibleElementsOverride=null,this._showDeletePrompt=this._showDeletePrompt.bind(this),this._onDeleteSelectionClick=this._onDeleteSelectionClick.bind(this)}initialize(){this.addHandles([i((()=>[this.viewModel.store.querying,this.viewModel.store.syncing,this.editingEnabled]),(()=>this.scheduleRender())),i((()=>({visibleElements:this._effectiveVisibleElements,items:this.columns.length})),(({visibleElements:e})=>{this.columns.forEach((t=>t.visibleElements=e)),this.refreshCellContent()}),l),i((()=>this._effectiveVisibleElements.selectionColumn),(e=>{this.grid&&(this.grid.selectionColumnEnabled=e)}),o),s((()=>this.viewModel),"show-related-table",(e=>this._onShowRelatedTable(e))),i((()=>this.viewModel.state),(e=>{"disabled"===e&&this.relatedTables.length&&this._drainRelatedTables()}))])}loadDependencies(){return y({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown.js"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group.js"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js")})}destroy(){this._clearPrompt()}get _effectiveDescription(){const{description:e}=this;return null!=e?M.sanitize("function"==typeof e?e():e):void 0}get _effectiveLayers(){const{layer:e,layers:t}=this,i=t?.length?t.filter(b):[],l=i.length?i:[...this._viewLayers];return e&&!l.includes(e)&&l.push(e),l}get _effectiveTitle(){const{layer:e,messages:t,state:i,highlightIds:l,title:o,viewModel:s}=this;if(o)return M.sanitize("function"==typeof o?o():o);if(!e)return t.noLayer;switch(i){case"disabled":return t.errorLayer;case"ready":case"loading":return t.loading;case"error":return t.errorData}return T(t.header,{title:M.sanitize(e.title),count:s.size,selected:l.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnsVisibilityAction)}get _shouldShowMenu(){const{header:e,menu:t}=this._effectiveVisibleElements;return!(!e||!t||!this._hasDefaultMenuItems&&!this._hasCustomMenuItems)}get _showClearSelectionAction(){return!(!this.highlightIds.length||!this._effectiveVisibleElements.menuItems?.clearSelection||this.relatedTables.length)}get _showColumnsVisibilityAction(){const{header:e,menu:t,menuItems:i}=this._effectiveVisibleElements;return!(!(e&&t&&i?.toggleColumns)||this.showRelatedTableCallback||this._showAllTablesEnabled)}get _showDeleteSelectionAction(){return!(!(this.editingEnabled&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.layer?.capabilities?.operations?.supportsDelete)||this.relatedTables.length)}get _showLayerDropdown(){return!(!this._effectiveLayers.length||!this._effectiveVisibleElements.layerDropdown)}get _showRefreshDataAction(){return!!this._effectiveVisibleElements.menuItems?.refreshData}get _showSelectedRecordsShowSelectedAction(){const e=this.objectIds.length,t=this.highlightIds.length;return!(!t||!this._effectiveVisibleElements.menuItems?.selectedRecordsShowSelectedToggle||e&&t===e||this.relatedTables.length)}get _showSelectedRecordsShowAllAction(){return!(!this._effectiveVisibleElements.menuItems?.selectedRecordsShowAllToggle||!this.objectIds.length||this.relatedTables.length)}get _showZoomToSelectionAction(){return!!(this.view&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.zoomToSelection)}get _viewLayers(){const e=this.view?.map;if(!e)return[];const t=[...e.allLayers,...e.allTables];if(!t.length)return[];const i=new Set,l=e=>{b(e)&&!i.has(e)&&i.add(e)};return t.forEach((e=>{a(e)||(d(e)?[...e.layers,...e.tables].forEach(l):l(e))})),[...i.values()]}get actionColumnConfig(){return this.viewModel.actionColumnConfig}set actionColumnConfig(e){this.viewModel.actionColumnConfig=e}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get filterBySelectionEnabled(){return this.viewModel.filterBySelectionEnabled}set filterBySelectionEnabled(e){this.viewModel.filterBySelectionEnabled=e}get grid(){return this.viewModel.grid}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get icon(){return"table"}set icon(e){this._overrideIfSome("icon",e)}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing||this.relatedTables.some((e=>!!e.isQueryingOrSyncing))}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this._drainRelatedTables(),this.viewModel.layer=e}get layerView(){return this.viewModel.layerView}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=e}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get objectIds(){return this.viewModel.objectIds}set objectIds(e){this.viewModel.objectIds=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relationship(){return this.viewModel.relationship}get relationshipColumnConfigs(){return this.viewModel.relationshipColumnConfigs}set relationshipColumnConfigs(e){this.viewModel.relationshipColumnConfigs=e}get relationshipConfig(){return this.viewModel.relationshipConfig}set relationshipConfig(e){this.viewModel.relationshipConfig=e}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get selectionSource(){return this.viewModel.selectionSource}set selectionSource(e){this.viewModel.selectionSource=e}get showRelatedTableCallback(){return this.viewModel.showRelatedTableCallback}set showRelatedTableCallback(e){this.viewModel.showRelatedTableCallback=e}get size(){return this.viewModel.size}get state(){return this.viewModel.state}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get tableTemplateOverride(){return this.viewModel.tableTemplateOverride}set tableTemplateOverride(e){this.viewModel.tableTemplateOverride=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}clearSelectionFilter(){this.viewModel.clearSelectionFilter()}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}filterBySelection(){this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}hideColumn(e){this.grid?.hideColumn(e)}async refresh(){this.relatedTables.forEach((async e=>await e.refresh())),await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollToIndex(e){this.viewModel.scrollToIndex(e)}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}zoomToSelection(){this.viewModel.zoomToSelection()}render(){const{_prompt:e,_effectiveVisibleElements:t,isQueryingOrSyncing:i,menuConfig:l,state:o}=this;return S("div",{bind:this,class:this.classes(j.base,f.widget)},S("calcite-panel",{bind:this,class:j.content,closable:t.close,description:this._effectiveDescription,disabled:this.disabled||"disabled"===o,heading:t.header?this._effectiveTitle:void 0,loading:"loading"===o,menuOpen:!!l?.open,overlayPositioning:"fixed",onCalcitePanelClose:e=>{e.target.closed=!1,this.emit("close")}},t.progress?S("calcite-progress",{type:i?"indeterminate":"determinate"}):null,this._showLayerDropdown?this._renderLayerDropdown():null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderRelatedTableNavigationBar(),S("div",{class:j.tableContainer},this._renderTables())),e?S("calcite-scrim",null,this._renderPrompt(e)):null)}_renderTables(){const{_showAllTablesEnabled:e,grid:t,relatedTables:i}=this;if(i.length){const l=i.toArray(),o=1===l.length,s=this.classes(j.base,e?j.expanded:j.collapsed),n=e||o,r=e?l:o?[l[0]]:l.slice(-2);return S("calcite-panel",{overlayPositioning:"fixed"},S("div",null,[n?S("div",{class:s},t?.render()):void 0,...r.map((e=>{const t=i.indexOf(e);return S("div",{class:s,key:`related-${t}`},e.render())})),,]))}return t?.render()}_clearPrompt(){this._prompt=null}_renderPrompt({title:e,message:t,context:i,actions:l}){const o=S("calcite-button",{appearance:"solid",key:"prompt-primary-button",kind:"danger"===i?"danger":"brand",onclick:l.primary.action,width:l.secondary?"half":"full"},l.primary.label),s=l.secondary?S("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:"danger"===i?"danger":"brand",onclick:l.secondary.action,width:"half"},l.secondary.label):null;return S("div",{class:`${j.promptContainer}--${i}`},S("div",{class:j.promptHeader},S("calcite-icon",{icon:"exclamation-mark-triangle"}),S(_,{class:j.promptHeading,level:2},e)),S("div",{class:j.promptMessage},t),S("div",{class:j.promptDivider}),S("div",{class:j.promptActions},s,o))}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=T(e.deleteSelectionCount,{count:this.highlightIds.length});this._prompt={title:i,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this._clearPrompt()}}}}async _onDeleteSelectionClick(){try{await this.viewModel.deleteSelection()}finally{this._clearPrompt()}}_renderHeaderMenuAction(e){const{disabled:t,hidden:i,icon:l,text:o,clickFunction:s}=e;if(!i)return S("calcite-action",{disabled:t??this.menuConfig?.disabled,icon:l??void 0,key:o,onclick:()=>s(),slot:"header-menu-actions",text:o,textEnabled:!0,title:o})}_renderHeaderMenuActions(){return this._shouldShowMenu?[this._renderDefaultHeaderMenuActions(),this._renderCustomHeaderMenuActions()]:[]}_renderDefaultHeaderMenuActions(){if(!this._hasDefaultMenuItems)return[];const{messages:e}=this,t=[];return this._showRefreshDataAction&&t.push(this._renderHeaderMenuAction({icon:k.refresh,text:e.refreshData,clickFunction:()=>this.refresh()})),this._showDeleteSelectionAction&&t.push(this._renderHeaderMenuAction({icon:k.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)})),this._showClearSelectionAction&&t.push(this._renderHeaderMenuAction({icon:k.clearSelection,text:e.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()})),this._showZoomToSelectionAction&&t.push(this._renderHeaderMenuAction({icon:k.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()})),this._showSelectedRecordsShowSelectedAction&&t.push(this._renderHeaderMenuAction({icon:k.showSelected,text:e.showSelected,clickFunction:()=>{const{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}})),this._showSelectedRecordsShowAllAction&&t.push(this._renderHeaderMenuAction({icon:k.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()})),t}_renderCustomHeaderMenuActions(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:i,label:l,clickFunction:o})=>this._renderHeaderMenuAction({hidden:"function"==typeof t?t():t,icon:i,text:l,disabled:e,clickFunction:e=>o(e)})))??[]}_renderColumnVisibilityAction(){if(!this._showColumnsVisibilityAction)return[];const{_columnVisibilityActions:e,_effectiveVisibleElements:t,id:i,messages:l}=this,o=this.relatedTables.at(-1)||this,s=o.columns.toArray(),n=l?.toggleColumns,r=`${i}__toggle-columns-action`,a=[S("calcite-action",{afterCreate:t=>e.set(i,t),afterRemoved:()=>e.delete(i),appearance:"transparent",bind:this,disabled:o.menuConfig?.disabled,icon:"show-column",id:r,slot:"header-actions-end",text:n},t.tooltips?S("calcite-tooltip",{closeOnClick:!0,overlayPositioning:"fixed",placement:"bottom-end",slot:"tooltip"},n):null)];return o.menuConfig?.disabled||a.push(S("calcite-popover",{autoClose:!0,class:j.menuPopover,label:n,overlayPositioning:"fixed",placement:"top-end",pointerDisabled:!0,referenceElement:e.get(i)},S("calcite-list",{filterEnabled:!0,filterPlaceholder:l.toggleColumns,selectionMode:"multiple"},...s.map((e=>{const t="columns"in e&&e.columns?.length?e.columns.map((e=>this._renderColumnListItem({column:e,table:o,ignoreSelect:!0}))):void 0;return this._renderColumnListItem({column:e,table:o,items:t})}))))),a}_renderColumnListItem(e){const{column:t,table:i,items:l,ignoreSelect:o}=e,{effectiveLabel:s,fieldName:n,hidden:r}=t;return S("calcite-list-item",{key:`toggle-columns__item-${n}`,label:s,open:!(!l?.length||r)||void 0,selected:!r,value:n,onCalciteListItemSelect:e=>{o||i.toggleColumnVisibility(e.target.value)}},l)}_renderLayerDropdown(){const e=this.messages.selectALayer;return S("div",{class:j.layerDropdownMenu,key:`${this.id}-layerDropdown`,slot:"header-actions-start"},S("calcite-dropdown",{bind:this,maxItems:5,overlayPositioning:"fixed",placement:"bottom-start"},S("calcite-action",{icon:"layers",slot:"trigger",text:e,title:e}),S("calcite-dropdown-group",{selectionMode:"single"},this._effectiveLayers.map(((e,t)=>this._renderLayerDropdownItem(e,t)))??null)))}_renderLayerDropdownItem(e,t){return S("calcite-dropdown-item",{key:`dropdown-item-${t}`,label:e.title??"",onclick:()=>{this.layer=e},selected:e===this.layer,value:e.id},e.title)}_onShowRelatedTable(e){if(this.showRelatedTableCallback)return;const{relatedTables:t}=this,{length:i}=t,l=i?t.getItemAt(i-1):this;this._collapseRelatedTable(l,e),this._createRelatedTable(e)}_renderRelatedTableNavigationBar(){const{messages:e}=this,t=e.exitRelatedRecords;if(this.relatedTables.length&&!this.showRelatedTableCallback)return S("div",{class:j.tableNavigation,key:"table-nav"},S("calcite-action",{icon:"move-up",iconFlipRtl:!0,key:t,onclick:()=>this._drainRelatedTables(),text:t,title:t}),this.relatedTables.toArray().map(((e,t)=>this._renderRelatedTableNavigationAction(e,t))),S("div",null,S("calcite-label",{layout:"inline"},e.showAllTables,S("calcite-switch",{checked:this._showAllTablesEnabled,onCalciteSwitchChange:e=>{const{relatedTables:t}=this,i=!!e.target.checked,l=t.at(-1);this._showAllTablesEnabled=i,l&&(i?this._enterShowAllView(l):this._exitShowAllView(l))}}))))}_renderRelatedTableNavigationAction(e,t){const i=this._getLabelForRelatedTableNavigationAction(e);return S("calcite-action",{icon:"chevron-right",iconFlipRtl:!0,key:t,onclick:()=>this._drainRelatedTablesAboveIndex(t),text:i,textEnabled:!0,title:e.layer?.title||""})}_getLabelForRelatedTableNavigationAction(e){const t=e.layer?.title;if(!t)return"";const{relatedTables:i}=this;if(i.length<=1)return t;return i.indexOf(e)!==i.length-1&&t.length>20?`${t.slice(0,20)}...`:t}_drainRelatedTables(){this.relatedTables.drain((e=>!e.destroyed&&e.destroy())),this.set({_showAllTablesEnabled:!1,multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:null,visibleElementsOverride:null}),this.hiddenFields.removeMany([w.action,w.attachments])}_drainRelatedTablesAboveIndex(e){const t=this.relatedTables,i=t.filter(((t,i)=>i>e));i.forEach((e=>!e.destroyed&&e.destroy())),t.removeMany(i);const l=t.at(-1);if(!l?.layer||!l?.relationship)return;const{layer:o,relationship:s}=l;this._showAllTablesEnabled?this._enterShowAllView(l):l.set({multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:this._getRelationshipIdsToShow(o,s.id),visibleElementsOverride:null}),l.hiddenFields.removeMany([w.action,w.attachments])}_getRelatedTableMenuItemConfig(e,t,i){return t.fields.map((({alias:l,name:o})=>({selected:o===i,label:l||o,clickFunction:i=>{i.stopPropagation(),e.tableTemplateOverride=new g({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]})}})))}_createRelatedFieldColumnTemplate(e,t,i){return new u({fieldName:i,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._getRelatedTableMenuItemConfig(e,t,i)},resizable:!1})}_enterShowAllView(e){const t=e.layer;if(!t)return;const i=e===this,{visibleElements:l}=e,o=t.displayField||t.objectIdField;e.set({relationshipColumnConfigs:[],tableTemplateOverride:new g({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]}),visibleElementsOverride:new m({header:i&&l.header,progress:i&&l.progress,columnMenus:l.columnMenus,close:l.close,tooltips:l.tooltips,selectionColumn:!1,columnMenuItems:new h({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([w.action,w.attachments])}_exitShowAllView(e){const{layer:t,relationship:i}=e;t&&null!=i?.id&&(e.set({relationshipColumnConfigs:this._getRelationshipIdsToShow(t,i.id),tableTemplateOverride:null,visibleElementsOverride:null}),e.hiddenFields.removeMany([w.action,w.attachments]))}_collapseRelatedTable(e,i){const{relatedLayer:l,feature:o,relationshipId:s}=i,n=l.relationships?.find((({id:e})=>e===s)),{objectIdField:r}=l,a=l.displayField||n?.keyField||r,d=o.getObjectId()??o.attributes[r],c=e===this,{close:p,columnMenus:u,header:b,layerDropdown:v,menu:y,menuItems:f,progress:_,tooltips:M}=e.visibleElements;e.set({highlightIds:new t([d]),multipleSelectionEnabled:!1,relationshipColumnConfigs:[{relationshipId:s,collapsed:!0}],tableTemplateOverride:new g({columnTemplates:[this._createRelatedFieldColumnTemplate(e,l,a)]}),visibleElementsOverride:new m({header:c&&b,progress:c&&_,columnMenus:u,close:p,layerDropdown:v,menu:y,menuItems:f,tooltips:M,selectionColumn:!1,columnMenuItems:new h({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([w.action,w.attachments]),e.grid?.scrollLeft(0)}_getRelationshipIdsToShow(e,t){return(e.relationships??[]).filter((e=>!(e.id===t&&"one-to-one"===e.cardinality))).map((({id:e})=>({relationshipId:e})))}async _createRelatedTable(e){const{editingEnabled:t,relatedTables:i,view:l,viewModel:o}=this,{layer:n,feature:r,relatedLayer:a,relationshipId:d}=e,c=r.getObjectId()??r.attributes[a.objectIdField],h=i.length,p=h?i.getItemAt(h-1):this;await n.load();const u=this.attachmentsEnabled&&v(n),g=new I({layer:n,attachmentsEnabled:u,editingEnabled:t,relatedRecordsEnabled:!0,relationshipConfig:{objectId:c,relatedLayer:a,relationshipId:d},relationshipColumnConfigs:this._getRelationshipIdsToShow(n,d),tableParent:p,view:l,visibleElements:new m({header:!1,progress:!1}),showRelatedTableCallback:({feature:e,layer:t,relatedLayer:i,relationshipId:l})=>{null!=(e.getObjectId()??e.attributes[i.objectIdField])&&o.emit("show-related-table",{feature:e,layer:t,relatedLayer:i,relationshipId:l})}});g.addHandles([s((()=>p.highlightIds),"change",(({added:e})=>{const t=e[0];null!=t&&(g.highlightIds.removeAll(),g.relationshipConfig={objectId:t,relatedLayer:a,relationshipId:d})})),s((()=>p),"cell-click",(e=>{const{feature:t}=e;if(t){const e=t.getObjectId()??t.attributes[a.objectIdField];null!=e&&p.highlightIds.add(e)}}))]),this.relatedTables.add(g),this.scheduleRender()}};e([n()],F.prototype,"_columnVisibilityActions",void 0),e([n()],F.prototype,"_effectiveDescription",null),e([n()],F.prototype,"_effectiveLayers",null),e([n()],F.prototype,"_effectiveTitle",null),e([n()],F.prototype,"_effectiveVisibleElements",null),e([n()],F.prototype,"_hasCustomMenuItems",null),e([n()],F.prototype,"_hasDefaultMenuItems",null),e([n()],F.prototype,"_prompt",void 0),e([n()],F.prototype,"_shouldShowMenu",null),e([n()],F.prototype,"_showAllTablesEnabled",void 0),e([n()],F.prototype,"_showClearSelectionAction",null),e([n()],F.prototype,"_showColumnsVisibilityAction",null),e([n()],F.prototype,"_showDeleteSelectionAction",null),e([n()],F.prototype,"_showLayerDropdown",null),e([n()],F.prototype,"_showRefreshDataAction",null),e([n()],F.prototype,"_showSelectedRecordsShowSelectedAction",null),e([n()],F.prototype,"_showSelectedRecordsShowAllAction",null),e([n()],F.prototype,"_showZoomToSelectionAction",null),e([n()],F.prototype,"_viewLayers",null),e([n()],F.prototype,"actionColumnConfig",null),e([n({readOnly:!0})],F.prototype,"activeFilters",null),e([n({readOnly:!0})],F.prototype,"activeSortOrders",null),e([n()],F.prototype,"attachmentsEnabled",null),e([n()],F.prototype,"autoRefreshEnabled",null),e([n()],F.prototype,"columnPerformanceModeEnabled",null),e([n()],F.prototype,"columnReorderingEnabled",null),e([n({readOnly:!0})],F.prototype,"columns",null),e([n()],F.prototype,"description",void 0),e([n()],F.prototype,"disabled",void 0),e([n()],F.prototype,"editingEnabled",null),e([n()],F.prototype,"filterGeometry",null),e([n()],F.prototype,"filterBySelectionEnabled",null),e([n({readOnly:!0})],F.prototype,"grid",null),e([n()],F.prototype,"hiddenFields",null),e([n()],F.prototype,"highlightEnabled",null),e([n()],F.prototype,"highlightIds",null),e([n()],F.prototype,"icon",null),e([n()],F.prototype,"isQueryingOrSyncing",null),e([n()],F.prototype,"label",null),e([n()],F.prototype,"layer",null),e([n()],F.prototype,"layers",void 0),e([n()],F.prototype,"layerView",null),e([n(),C("esri/widgets/FeatureTable/t9n/FeatureTable")],F.prototype,"messages",null),e([n(),C("esri/t9n/common")],F.prototype,"messagesCommon",null),e([n(),C("esri/widgets/support/t9n/uriUtils")],F.prototype,"messagesURIUtils",null),e([n()],F.prototype,"menuConfig",void 0),e([n()],F.prototype,"multipleSelectionEnabled",null),e([n()],F.prototype,"multiSortEnabled",null),e([n()],F.prototype,"objectIds",null),e([n()],F.prototype,"pageSize",null),e([n()],F.prototype,"relatedRecordsEnabled",null),e([n()],F.prototype,"relatedTable",null),e([n()],F.prototype,"relatedTables",void 0),e([n()],F.prototype,"relationship",null),e([n()],F.prototype,"relationshipColumnConfigs",null),e([n()],F.prototype,"relationshipConfig",null),e([n()],F.prototype,"returnGeometryEnabled",null),e([n()],F.prototype,"rowHighlightIds",null),e([n()],F.prototype,"selectionSource",null),e([n()],F.prototype,"showRelatedTableCallback",null),e([n()],F.prototype,"size",null),e([n({readOnly:!0})],F.prototype,"state",null),e([n({constructOnly:!0})],F.prototype,"tableParent",void 0),e([n()],F.prototype,"tableTemplate",null),e([n()],F.prototype,"tableTemplateOverride",null),e([n()],F.prototype,"title",void 0),e([n()],F.prototype,"timeExtent",null),e([n()],F.prototype,"timeZone",null),e([n()],F.prototype,"view",null),e([n({type:p}),E(["cell-click","cell-pointerover","cell-pointerout","cell-keydown","show-related-table"])],F.prototype,"viewModel",void 0),e([n({type:m,nonNullable:!0})],F.prototype,"visibleElements",void 0),e([n({type:m})],F.prototype,"visibleElementsOverride",void 0),F=I=e([r("esri.widgets.FeatureTable")],F);const D=F;export{D as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{watch as i,sync as l,initial as o,on as s}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isLayerFromCatalog as a}from"../layers/catalog/catalogUtils.js";import{isKnowledgeGraphLayer as d}from"../layers/support/layerUtils.js";import c from"./Widget.js";import h from"./FeatureTable/ColumnMenuVisibleElements.js";import p from"./FeatureTable/FeatureTableViewModel.js";import m from"./FeatureTable/VisibleElements.js";import u from"./FeatureTable/support/FieldColumnTemplate.js";import g from"./FeatureTable/support/TableTemplate.js";import{isIFeatureTableSupportedLayer as b,uniqueColumnNames as w,isIFeatureTableSupportedLayerWithAttachments as v,isMapImageLayer as y}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as f}from"./support/componentsUtils.js";import{globalCss as _}from"./support/globalCss.js";import{Heading as M}from"./support/Heading.js";import{renderingSanitizer as E}from"./support/widgetUtils.js";import{messageBundle as C}from"./support/decorators/messageBundle.js";import{vmEvent as S}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";import{substitute as I}from"../intl/substitute.js";var A;const R="esri-feature-table",j=`${R}__prompt`,k={base:R,content:`${R}__content`,menuPopover:`${R}__menu-popover`,layerDropdownMenu:`${R}__layer-switcher-menu`,tableContainer:`${R}__table-container`,tableNavigation:`${R}__table-navigation`,expanded:`${R}__expanded`,collapsed:`${R}__collapsed`,promptContainer:j,promptHeader:`${j}__header`,promptHeading:`${j}__header__heading`,promptMessage:`${j}__message`,promptDivider:`${j}__divider`,promptActions:`${j}__actions`},F={clearSelection:"clear-selection",delete:"trash",refresh:"refresh",showAll:"selection-x",showSelected:"selection-filter",zoomToSelection:"zoom-to-object"};let D=A=class extends c{constructor(e,i){super(e,i),this._columnVisibilityActions=new Map,this._prompt=null,this._showAllTablesEnabled=!1,this.description=null,this.disabled=!1,this.layers=null,this.menuConfig=null,this.relatedTables=new t,this.tableParent=null,this.title=null,this.viewModel=new p,this.visibleElements=new m,this.visibleElementsOverride=null,this._showDeletePrompt=this._showDeletePrompt.bind(this),this._onDeleteSelectionClick=this._onDeleteSelectionClick.bind(this)}initialize(){this.addHandles([i((()=>[this.viewModel.store.querying,this.viewModel.store.syncing,this.editingEnabled]),(()=>this.scheduleRender())),i((()=>({visibleElements:this._effectiveVisibleElements,items:this.columns.length})),(({visibleElements:e})=>{this.columns.forEach((t=>t.visibleElements=e)),this.refreshCellContent()}),l),i((()=>this._effectiveVisibleElements.selectionColumn),(e=>{this.grid&&(this.grid.selectionColumnEnabled=e)}),o),s((()=>this.viewModel),"show-related-table",(e=>this._onShowRelatedTable(e))),i((()=>this.viewModel.state),(e=>{"disabled"===e&&this.relatedTables.length&&this._drainRelatedTables()}))])}loadDependencies(){return f({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown.js"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group.js"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js")})}destroy(){this._clearPrompt()}get _effectiveDescription(){const{description:e}=this;return null!=e?E.sanitize("function"==typeof e?e():e):void 0}get _effectiveLayers(){const{layer:e,layers:t}=this,i=t?.length?t.filter(b):[],l=i.length?i:[...this._viewLayers];return e&&!l.includes(e)&&l.push(e),l}get _effectiveTitle(){const{layer:e,messages:t,state:i,highlightIds:l,title:o,viewModel:s}=this;if(o)return E.sanitize("function"==typeof o?o():o);if(!e)return t.noLayer;switch(i){case"disabled":return t.errorLayer;case"ready":case"loading":return t.loading;case"error":return t.errorData}return I(t.header,{title:E.sanitize(e.title),count:s.size,selected:l.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnsVisibilityAction)}get _shouldShowMenu(){const{header:e,menu:t}=this._effectiveVisibleElements;return!(!e||!t||!this._hasDefaultMenuItems&&!this._hasCustomMenuItems)}get _showClearSelectionAction(){return!(!this.highlightIds.length||!this._effectiveVisibleElements.menuItems?.clearSelection||this.relatedTables.length)}get _showColumnsVisibilityAction(){const{header:e,menu:t,menuItems:i}=this._effectiveVisibleElements;return!(!(e&&t&&i?.toggleColumns)||this.showRelatedTableCallback||this._showAllTablesEnabled)}get _showDeleteSelectionAction(){return!(!(this.editingEnabled&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.layer?.capabilities?.operations?.supportsDelete)||this.relatedTables.length)}get _showLayerDropdown(){return!(!this._effectiveLayers.length||!this._effectiveVisibleElements.layerDropdown)}get _showRefreshDataAction(){return!!this._effectiveVisibleElements.menuItems?.refreshData}get _showSelectedRecordsShowSelectedAction(){const e=this.objectIds.length,t=this.highlightIds.length;return!(!t||!this._effectiveVisibleElements.menuItems?.selectedRecordsShowSelectedToggle||e&&t===e||this.relatedTables.length)}get _showSelectedRecordsShowAllAction(){return!(!this._effectiveVisibleElements.menuItems?.selectedRecordsShowAllToggle||!this.objectIds.length||this.relatedTables.length)}get _showZoomToSelectionAction(){return!!(this.view&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.zoomToSelection)}get _viewLayers(){const e=this.view?.map;if(!e)return[];const t=new Set,i=e=>{b(e)&&!t.has(e)&&t.add(e)},l=e=>{a(e)||"catalog-footprint"===e.type||(d(e)?(e.layers?.forEach(i),e.tables?.forEach(i)):y(e)?(e.sublayers?.forEach(i),e.subtables?.forEach(i)):i(e))};return e.allLayers.forEach(l),e.allTables.forEach(l),[...t.values()]}get actionColumnConfig(){return this.viewModel.actionColumnConfig}set actionColumnConfig(e){this.viewModel.actionColumnConfig=e}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get filterBySelectionEnabled(){return this.viewModel.filterBySelectionEnabled}set filterBySelectionEnabled(e){this.viewModel.filterBySelectionEnabled=e}get grid(){return this.viewModel.grid}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get icon(){return"table"}set icon(e){this._overrideIfSome("icon",e)}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing||this.relatedTables.some((e=>!!e.isQueryingOrSyncing))}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this._drainRelatedTables(),this.viewModel.layer=e}get layerView(){return this.viewModel.layerView}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=e}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get objectIds(){return this.viewModel.objectIds}set objectIds(e){this.viewModel.objectIds=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relationship(){return this.viewModel.relationship}get relationshipColumnConfigs(){return this.viewModel.relationshipColumnConfigs}set relationshipColumnConfigs(e){this.viewModel.relationshipColumnConfigs=e}get relationshipConfig(){return this.viewModel.relationshipConfig}set relationshipConfig(e){this.viewModel.relationshipConfig=e}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}get returnMEnabled(){return this.viewModel.returnMEnabled}set returnMEnabled(e){this.viewModel.returnMEnabled=e}get returnZEnabled(){return this.viewModel.returnZEnabled}set returnZEnabled(e){this.viewModel.returnZEnabled=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get selectionSource(){return this.viewModel.selectionSource}set selectionSource(e){this.viewModel.selectionSource=e}get showRelatedTableCallback(){return this.viewModel.showRelatedTableCallback}set showRelatedTableCallback(e){this.viewModel.showRelatedTableCallback=e}get size(){return this.viewModel.size}get state(){return this.viewModel.state}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get tableTemplateOverride(){return this.viewModel.tableTemplateOverride}set tableTemplateOverride(e){this.viewModel.tableTemplateOverride=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}clearSelectionFilter(){this.viewModel.clearSelectionFilter()}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}filterBySelection(){this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}hideColumn(e){this.grid?.hideColumn(e)}async refresh(){this.relatedTables.forEach((async e=>await e.refresh())),await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollToIndex(e){this.viewModel.scrollToIndex(e)}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}zoomToSelection(){this.viewModel.zoomToSelection()}render(){const{_prompt:e,_effectiveVisibleElements:t,isQueryingOrSyncing:i,menuConfig:l,state:o}=this;return T("div",{bind:this,class:this.classes(k.base,_.widget)},T("calcite-panel",{bind:this,class:k.content,closable:t.close,description:this._effectiveDescription,disabled:this.disabled||"disabled"===o,heading:t.header?this._effectiveTitle:void 0,loading:"loading"===o,menuOpen:!!l?.open,overlayPositioning:"fixed",onCalcitePanelClose:e=>{e.target.closed=!1,this.emit("close")}},t.progress?T("calcite-progress",{type:i?"indeterminate":"determinate"}):null,this._showLayerDropdown?this._renderLayerDropdown():null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderRelatedTableNavigationBar(),T("div",{class:k.tableContainer},this._renderTables())),e?T("calcite-scrim",null,this._renderPrompt(e)):null)}_renderTables(){const{_showAllTablesEnabled:e,grid:t,relatedTables:i}=this;if(i.length){const l=i.toArray(),o=1===l.length,s=this.classes(k.base,e?k.expanded:k.collapsed),n=e||o,r=e?l:o?[l[0]]:l.slice(-2);return T("calcite-panel",{overlayPositioning:"fixed"},T("div",null,[n?T("div",{class:s},t?.render()):void 0,...r.map((e=>{const t=i.indexOf(e);return T("div",{class:s,key:`related-${t}`},e.render())})),,]))}return t?.render()}_clearPrompt(){this._prompt=null}_renderPrompt({title:e,message:t,context:i,actions:l}){const o=T("calcite-button",{appearance:"solid",key:"prompt-primary-button",kind:"danger"===i?"danger":"brand",onclick:l.primary.action,width:l.secondary?"half":"full"},l.primary.label),s=l.secondary?T("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:"danger"===i?"danger":"brand",onclick:l.secondary.action,width:"half"},l.secondary.label):null;return T("div",{class:`${k.promptContainer}--${i}`},T("div",{class:k.promptHeader},T("calcite-icon",{icon:"exclamation-mark-triangle"}),T(M,{class:k.promptHeading,level:2},e)),T("div",{class:k.promptMessage},t),T("div",{class:k.promptDivider}),T("div",{class:k.promptActions},s,o))}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=I(e.deleteSelectionCount,{count:this.highlightIds.length});this._prompt={title:i,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this._clearPrompt()}}}}async _onDeleteSelectionClick(){try{await this.viewModel.deleteSelection()}finally{this._clearPrompt()}}_renderHeaderMenuAction(e){const{disabled:t,hidden:i,icon:l,text:o,clickFunction:s}=e;if(!i)return T("calcite-action",{disabled:t??this.menuConfig?.disabled,icon:l??void 0,key:o,onclick:()=>s(),slot:"header-menu-actions",text:o,textEnabled:!0,title:o})}_renderHeaderMenuActions(){return this._shouldShowMenu?[this._renderDefaultHeaderMenuActions(),this._renderCustomHeaderMenuActions()]:[]}_renderDefaultHeaderMenuActions(){if(!this._hasDefaultMenuItems)return[];const{messages:e}=this,t=[];return this._showRefreshDataAction&&t.push(this._renderHeaderMenuAction({icon:F.refresh,text:e.refreshData,clickFunction:()=>this.refresh()})),this._showDeleteSelectionAction&&t.push(this._renderHeaderMenuAction({icon:F.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)})),this._showClearSelectionAction&&t.push(this._renderHeaderMenuAction({icon:F.clearSelection,text:e.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()})),this._showZoomToSelectionAction&&t.push(this._renderHeaderMenuAction({icon:F.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()})),this._showSelectedRecordsShowSelectedAction&&t.push(this._renderHeaderMenuAction({icon:F.showSelected,text:e.showSelected,clickFunction:()=>{const{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}})),this._showSelectedRecordsShowAllAction&&t.push(this._renderHeaderMenuAction({icon:F.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()})),t}_renderCustomHeaderMenuActions(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:i,label:l,clickFunction:o})=>this._renderHeaderMenuAction({hidden:"function"==typeof t?t():t,icon:i,text:l,disabled:e,clickFunction:e=>o(e)})))??[]}_renderColumnVisibilityAction(){if(!this._showColumnsVisibilityAction)return[];const{_columnVisibilityActions:e,_effectiveVisibleElements:t,id:i,messages:l}=this,o=this.relatedTables.at(-1)||this,s=o.columns.toArray(),n=l?.toggleColumns,r=`${i}__toggle-columns-action`,a=[T("calcite-action",{afterCreate:t=>e.set(i,t),afterRemoved:()=>e.delete(i),appearance:"transparent",bind:this,disabled:o.menuConfig?.disabled,icon:"show-column",id:r,slot:"header-actions-end",text:n},t.tooltips?T("calcite-tooltip",{closeOnClick:!0,overlayPositioning:"fixed",placement:"bottom-end",slot:"tooltip"},n):null)];return o.menuConfig?.disabled||a.push(T("calcite-popover",{autoClose:!0,class:k.menuPopover,label:n,overlayPositioning:"fixed",placement:"top-end",pointerDisabled:!0,referenceElement:e.get(i)},T("calcite-list",{filterEnabled:!0,filterPlaceholder:l.toggleColumns,selectionMode:"multiple"},...s.map((e=>{const t="columns"in e&&e.columns?.length?e.columns.map((e=>this._renderColumnListItem({column:e,table:o,ignoreSelect:!0}))):void 0;return this._renderColumnListItem({column:e,table:o,items:t})}))))),a}_renderColumnListItem(e){const{column:t,table:i,items:l,ignoreSelect:o}=e,{effectiveLabel:s,fieldName:n,hidden:r}=t;return T("calcite-list-item",{key:`toggle-columns__item-${n}`,label:s,open:!(!l?.length||r)||void 0,selected:!r,value:n,onCalciteListItemSelect:e=>{o||i.toggleColumnVisibility(e.target.value)}},l)}_renderLayerDropdown(){const e=this.messages.selectALayer;return T("div",{class:k.layerDropdownMenu,key:`${this.id}-layerDropdown`,slot:"header-actions-start"},T("calcite-dropdown",{bind:this,maxItems:5,overlayPositioning:"fixed",placement:"bottom-start"},T("calcite-action",{icon:"layers",slot:"trigger",text:e,title:e}),T("calcite-dropdown-group",{selectionMode:"single"},this._effectiveLayers.map(((e,t)=>this._renderLayerDropdownItem(e,t)))??null)))}_renderLayerDropdownItem(e,t){return T("calcite-dropdown-item",{key:`dropdown-item-${t}`,label:e.title??"",selected:e===this.layer,value:e.id,onCalciteDropdownItemSelect:()=>{this.layer=e}},e.title)}_onShowRelatedTable(e){if(this.showRelatedTableCallback)return;const{relatedTables:t}=this,{length:i}=t,l=i?t.getItemAt(i-1):this;this._collapseRelatedTable(l,e),this._createRelatedTable(e)}_renderRelatedTableNavigationBar(){const{messages:e}=this,t=e.exitRelatedRecords;if(this.relatedTables.length&&!this.showRelatedTableCallback)return T("div",{class:k.tableNavigation,key:"table-nav"},T("calcite-action",{icon:"move-up",iconFlipRtl:!0,key:t,onclick:()=>this._drainRelatedTables(),text:t,title:t}),this.relatedTables.toArray().map(((e,t)=>this._renderRelatedTableNavigationAction(e,t))),T("div",null,T("calcite-label",{layout:"inline"},e.showAllTables,T("calcite-switch",{checked:this._showAllTablesEnabled,onCalciteSwitchChange:e=>{const{relatedTables:t}=this,i=!!e.target.checked,l=t.at(-1);this._showAllTablesEnabled=i,l&&(i?this._enterShowAllView(l):this._exitShowAllView(l))}}))))}_renderRelatedTableNavigationAction(e,t){const i=this._getLabelForRelatedTableNavigationAction(e);return T("calcite-action",{icon:"chevron-right",iconFlipRtl:!0,key:t,onclick:()=>this._drainRelatedTablesAboveIndex(t),text:i,textEnabled:!0,title:e.layer?.title||""})}_getLabelForRelatedTableNavigationAction(e){const t=e.layer?.title;if(!t)return"";const{relatedTables:i}=this;if(i.length<=1)return t;return i.indexOf(e)!==i.length-1&&t.length>20?`${t.slice(0,20)}...`:t}_drainRelatedTables(){this.relatedTables.drain((e=>!e.destroyed&&e.destroy())),this.set({_showAllTablesEnabled:!1,multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:null,visibleElementsOverride:null}),this.hiddenFields.removeMany([w.action,w.attachments])}_drainRelatedTablesAboveIndex(e){const t=this.relatedTables,i=t.filter(((t,i)=>i>e));i.forEach((e=>!e.destroyed&&e.destroy())),t.removeMany(i);const l=t.at(-1);if(!l?.layer||!l?.relationship)return;const{layer:o,relationship:s}=l;this._showAllTablesEnabled?this._enterShowAllView(l):l.set({multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:this._getRelationshipIdsToShow(o,s.id),visibleElementsOverride:null}),l.hiddenFields.removeMany([w.action,w.attachments])}_getRelatedTableMenuItemConfig(e,t,i){return t.fields.map((({alias:l,name:o})=>({selected:o===i,label:l||o,clickFunction:i=>{i.stopPropagation(),e.tableTemplateOverride=new g({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]})}})))}_createRelatedFieldColumnTemplate(e,t,i){return new u({fieldName:i,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._getRelatedTableMenuItemConfig(e,t,i)},resizable:!1})}_enterShowAllView(e){const t=e.layer;if(!t)return;const i=e===this,{visibleElements:l}=e,o=t.displayField||t.objectIdField;e.set({relationshipColumnConfigs:[],tableTemplateOverride:new g({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]}),visibleElementsOverride:new m({header:i&&l.header,progress:i&&l.progress,columnMenus:l.columnMenus,close:l.close,tooltips:l.tooltips,selectionColumn:!1,columnMenuItems:new h({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([w.action,w.attachments])}_exitShowAllView(e){const{layer:t,relationship:i}=e;t&&null!=i?.id&&(e.set({relationshipColumnConfigs:this._getRelationshipIdsToShow(t,i.id),tableTemplateOverride:null,visibleElementsOverride:null}),e.hiddenFields.removeMany([w.action,w.attachments]))}_collapseRelatedTable(e,i){const{relatedLayer:l,feature:o,relationshipId:s}=i,n=l.relationships?.find((({id:e})=>e===s)),{objectIdField:r}=l,a=l.displayField||n?.keyField||r,d=o.getObjectId()??o.attributes[r],c=e===this,{close:p,columnMenus:u,header:b,layerDropdown:v,menu:y,menuItems:f,progress:_,tooltips:M}=e.visibleElements;e.set({highlightIds:new t([d]),multipleSelectionEnabled:!1,relationshipColumnConfigs:[{relationshipId:s,collapsed:!0}],tableTemplateOverride:new g({columnTemplates:[this._createRelatedFieldColumnTemplate(e,l,a)]}),visibleElementsOverride:new m({header:c&&b,progress:c&&_,columnMenus:u,close:p,layerDropdown:v,menu:y,menuItems:f,tooltips:M,selectionColumn:!1,columnMenuItems:new h({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([w.action,w.attachments]),e.grid?.scrollLeft(0)}_getRelationshipIdsToShow(e,t){return(e.relationships??[]).filter((e=>!(e.id===t&&"one-to-one"===e.cardinality))).map((({id:e})=>({relationshipId:e})))}async _createRelatedTable(e){const{editingEnabled:t,relatedTables:i,view:l,viewModel:o}=this,{layer:n,feature:r,relatedLayer:a,relationshipId:d}=e,c=r.getObjectId()??r.attributes[a.objectIdField],h=i.length,p=h?i.getItemAt(h-1):this;await n.load();const u=this.attachmentsEnabled&&v(n),g=new A({layer:n,attachmentsEnabled:u,editingEnabled:t,relatedRecordsEnabled:!0,relationshipConfig:{objectId:c,relatedLayer:a,relationshipId:d},relationshipColumnConfigs:this._getRelationshipIdsToShow(n,d),tableParent:p,view:l,visibleElements:new m({header:!1,progress:!1}),showRelatedTableCallback:({feature:e,layer:t,relatedLayer:i,relationshipId:l})=>{null!=(e.getObjectId()??e.attributes[i.objectIdField])&&o.emit("show-related-table",{feature:e,layer:t,relatedLayer:i,relationshipId:l})}});g.addHandles([s((()=>p.highlightIds),"change",(({added:e})=>{const t=e[0];null!=t&&(g.highlightIds.removeAll(),g.relationshipConfig={objectId:t,relatedLayer:a,relationshipId:d})})),s((()=>p),"cell-click",(e=>{const{feature:t}=e;if(t){const e=t.getObjectId()??t.attributes[a.objectIdField];null!=e&&p.highlightIds.add(e)}}))]),this.relatedTables.add(g),this.scheduleRender()}};e([n()],D.prototype,"_columnVisibilityActions",void 0),e([n()],D.prototype,"_effectiveDescription",null),e([n()],D.prototype,"_effectiveLayers",null),e([n()],D.prototype,"_effectiveTitle",null),e([n()],D.prototype,"_effectiveVisibleElements",null),e([n()],D.prototype,"_hasCustomMenuItems",null),e([n()],D.prototype,"_hasDefaultMenuItems",null),e([n()],D.prototype,"_prompt",void 0),e([n()],D.prototype,"_shouldShowMenu",null),e([n()],D.prototype,"_showAllTablesEnabled",void 0),e([n()],D.prototype,"_showClearSelectionAction",null),e([n()],D.prototype,"_showColumnsVisibilityAction",null),e([n()],D.prototype,"_showDeleteSelectionAction",null),e([n()],D.prototype,"_showLayerDropdown",null),e([n()],D.prototype,"_showRefreshDataAction",null),e([n()],D.prototype,"_showSelectedRecordsShowSelectedAction",null),e([n()],D.prototype,"_showSelectedRecordsShowAllAction",null),e([n()],D.prototype,"_showZoomToSelectionAction",null),e([n()],D.prototype,"_viewLayers",null),e([n()],D.prototype,"actionColumnConfig",null),e([n({readOnly:!0})],D.prototype,"activeFilters",null),e([n({readOnly:!0})],D.prototype,"activeSortOrders",null),e([n()],D.prototype,"attachmentsEnabled",null),e([n()],D.prototype,"autoRefreshEnabled",null),e([n()],D.prototype,"columnPerformanceModeEnabled",null),e([n()],D.prototype,"columnReorderingEnabled",null),e([n({readOnly:!0})],D.prototype,"columns",null),e([n()],D.prototype,"description",void 0),e([n()],D.prototype,"disabled",void 0),e([n()],D.prototype,"editingEnabled",null),e([n()],D.prototype,"filterGeometry",null),e([n()],D.prototype,"filterBySelectionEnabled",null),e([n({readOnly:!0})],D.prototype,"grid",null),e([n()],D.prototype,"hiddenFields",null),e([n()],D.prototype,"highlightEnabled",null),e([n()],D.prototype,"highlightIds",null),e([n()],D.prototype,"icon",null),e([n()],D.prototype,"isQueryingOrSyncing",null),e([n()],D.prototype,"label",null),e([n()],D.prototype,"layer",null),e([n()],D.prototype,"layers",void 0),e([n()],D.prototype,"layerView",null),e([n(),C("esri/widgets/FeatureTable/t9n/FeatureTable")],D.prototype,"messages",null),e([n(),C("esri/t9n/common")],D.prototype,"messagesCommon",null),e([n(),C("esri/widgets/support/t9n/uriUtils")],D.prototype,"messagesURIUtils",null),e([n()],D.prototype,"menuConfig",void 0),e([n()],D.prototype,"multipleSelectionEnabled",null),e([n()],D.prototype,"multiSortEnabled",null),e([n()],D.prototype,"objectIds",null),e([n()],D.prototype,"pageSize",null),e([n()],D.prototype,"relatedRecordsEnabled",null),e([n()],D.prototype,"relatedTable",null),e([n()],D.prototype,"relatedTables",void 0),e([n()],D.prototype,"relationship",null),e([n()],D.prototype,"relationshipColumnConfigs",null),e([n()],D.prototype,"relationshipConfig",null),e([n()],D.prototype,"returnGeometryEnabled",null),e([n()],D.prototype,"returnMEnabled",null),e([n()],D.prototype,"returnZEnabled",null),e([n()],D.prototype,"rowHighlightIds",null),e([n()],D.prototype,"selectionSource",null),e([n()],D.prototype,"showRelatedTableCallback",null),e([n()],D.prototype,"size",null),e([n({readOnly:!0})],D.prototype,"state",null),e([n({constructOnly:!0})],D.prototype,"tableParent",void 0),e([n()],D.prototype,"tableTemplate",null),e([n()],D.prototype,"tableTemplateOverride",null),e([n()],D.prototype,"title",void 0),e([n()],D.prototype,"timeExtent",null),e([n()],D.prototype,"timeZone",null),e([n()],D.prototype,"view",null),e([n({type:p}),S(["cell-click","cell-pointerover","cell-pointerout","cell-keydown","show-related-table"])],D.prototype,"viewModel",void 0),e([n({type:m,nonNullable:!0})],D.prototype,"visibleElements",void 0),e([n({type:m})],D.prototype,"visibleElementsOverride",void 0),D=A=e([r("esri.widgets.FeatureTable")],D);const x=D;export{x as default};
|