@arcgis/core 4.30.0-next.20240316 → 4.30.0-next.20240318
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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/interactive/tooltip/components/DrawHeaderActions.js +1 -1
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/Bookmarks.js +1 -1
- package/widgets/DirectionalPad.js +1 -1
- package/widgets/ElevationProfile/components/LegendItem.js +1 -1
- package/widgets/ElevationProfile/components/SettingsButton.js +1 -1
- package/widgets/ElevationProfile.js +1 -1
- package/widgets/Features/FeaturesRelatedRecords.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/Slice.js +1 -1
- package/widgets/TableList.js +1 -1
- package/widgets/TimeSlider.js +1 -1
- package/widgets/TimeZoneLabel.js +1 -1
- package/widgets/UtilityNetworkValidateTopology.js +1 -1
- package/widgets/ValuePicker.js +1 -1
- package/widgets/VideoPlayer/components/PlayerActionsGroup.js +1 -1
- package/widgets/support/SelectionToolbar.js +1 -1
- package/widgets/support/SnappingControls.js +1 -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 n from"../core/Logger.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as r,getActionStyles as a}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 b,getStatusIcon as f,sortLayersToIds as v,sortChildLayersToIds as _,listItemHasChildren as y,areChildrenHidden as I,canSortSublayers as E,getVisibilityIcon as L}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as w}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="basemap",j=".*\\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._lastDragDetail=null,this._selectedDragItemLayerUid=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 n="pull"===s?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,o=g(e);if(!o?.sortable)return!1;const l=g(t),r=b(t),a=g(i),c=b(i),d=!!r&&!!c&&r===c,m={selected:o,from:l,to:a};return t.group&&i.group&&"function"==typeof n?n.call(null,m):d&&"sublayer"!==o?.layer?.type&&"map-image"!==l?.layer?.type&&"map-image"!==a?.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:n,newIndex:o}=e;if(!s||!i||t?.newIndex===o&&t?.dragEl===n&&t?.toEl===i&&t?.fromEl===s)return;this._lastDragDetail=e;const l=s,r=i;if(l!==r)this._moveLayerFromChildList({toEl:r,fromEl:l,dragEl:n,newIndex:o});else{const e=Array.from(s.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(l,e)}}}normalizeCtorArgs(e){return null!=e?.editingEnabled&&null!=e.visibleElements?{...e,visibleElements:new m({...e.visibleElements,editTitleButton:e.editingEnabled})}:e}loadDependencies(){return w({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 _baseFilterEnabled(){return this.viewModel.totalBaseItems>=this.minFilterItems&&this.visibleElements.filter}get _referenceFilterEnabled(){return this.viewModel.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(n.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(n.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(n.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(n.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)))}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((e=>!e.hidden)).toArray().filter((({panel:e})=>e?.open&&!e.disabled&&e.flowEnabled)).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}_renderItem(e,t,i,s,n){const{_activeItem:o,_selectedDragItemLayerUid:l,selectionMode:r,selectedItems:a,messages:c}=this,d=e.title||c.untitledLayer,m=e.visibleAtCurrentScale?d:`${d} (${c.layerInvisibleAtScale})`,u=this._filterActions(e.actionsSections),h=this._countActions(u);return A("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes(p.item,{[p.itemActive]:o===e}),"data-item":e,dragDisabled:!e.sortable||i,dragSelected:e.layer.uid===l,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:d,metadata:{parentTitles:n,title:d},open:e.open,selected:"none"!==r&&a.includes(e),title:m,value:e.layer.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:t=>this._handleCalciteListItemSelect(t,e,s),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},A("div",{class:this.classes({[p.itemContent]:!0,[p.itemInvisibleAtScale]:!e.visibleAtCurrentScale}),slot:"content"},d),this._renderItemStatus(e,s),this._renderItemToggle(e,s),this._renderItemTemporaryIcon(e),this._renderChildList(e,t,n),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),h>1?this._renderActionsSections(e,u):1===h?this._renderAction({item:e,action:this._getSingleActionButton(u),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:s,publishing:n,updating:o}=e,l=o&&!t,r=!!s;return A("calcite-icon",{class:this.classes({[p.statusIndicator]:!0,[p.publishing]:n,[p.updating]:l,[p.connectionStatus]:r,[p.connectionStatusConnected]:r&&"connected"===s}),icon:f({connectionStatus:s,publishing:n}),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:n}=e,o=t?.visibilityMode;if("inherited"===o)return null;const l=L({visible:n,exclusive:"exclusive"===o,visibilityAppearance:s}),r="checkbox"===s;return A("calcite-action",{appearance:"transparent",class:p.visibleToggle,icon:r?l:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:r?"actions-start":"actions-end",text:i.layerVisibility,title:i.layerVisibility},r?null:A("calcite-icon",{class:this.classes({[p.visibleIcon]:"exclusive"!==o&&n}),icon:l,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: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){return A("calcite-action-menu",{appearance:"transparent",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:this.messagesCommon.options,title:this.messagesCommon.options}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return A("calcite-action-group",{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,n={[p.itemActionIcon]:!!t,[p.itemActionImage]:!!s};return t&&(n[t]=!0),s||t?A("span",{"aria-hidden":"true",class:this.classes(p.itemActionIcon,n),key:"icon",styles:a(s)}):null}_renderAction(e){const{item:t,action:i,textEnabled:s}=e,{active:n,disabled:o,title:l,type:a,indicator:c}=i;return A("calcite-action",{active:"toggle"===a&&i.value,appearance:"transparent",disabled:o,icon:r(i),indicator:c,key:`action-${i.uid}`,loading:n,onclick:()=>this._triggerAction(t,i),scale:"s",slot:s?void 0:"actions-end",text:l??"",textEnabled:s,title:l??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 n=g(i),o=g(e),l=g(t),r=B(t),a=B(e);r&&a&&this.viewModel.moveListItem({targetItem:n,fromParentItem:l,toParentItem:o,newIndex:s,from:r,to:a})}_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.uid){const i=B(e),s="base"===i?this.view?.map?.basemap?.baseLayers:"reference"===i?this.view?.map?.basemap?.referenceLayers:null;v(s,t)}else{const i=g(e);if(!i)return;_(i,t)}}_getSingleActionButton(e){return e.reduce((e=>e)).filter((e=>e&&"button"===e.type)).at(0)}_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:j,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:{editTitleButton:t},messagesCommon:{edit:i}}=this;return t&&!e?A("calcite-action",{bind:this,icon:"pencil",label:i,onclick:this._toggleEditingTitle,slot:"header-actions-end",text:i,title:i}):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:n,flow:o},messages:l,viewModel:r,referenceItems:a,baseItems:c}=this,d=this.visibleElements.referenceLayers?this._getFilteredItems(a):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:n?r.basemapTitle??l.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)];return t?[o?A("calcite-flow",{key:"root-flow"},p):p,this._renderItemTooltips(d),this._renderItemTooltips(m)]:null}_renderChildList(e,t,i=[]){const{dragEnabled:s,uid:n}=this,{children:o}=e,l=y(e),r=!I(e.layer)&&!l&&s&&"group"===e.layer?.type;return l||r?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:!!s&&(e.childrenSortable&&E(e)),group:`bmlayerlist-${n}-${e.layer.uid}`},o?.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:n,selectionMode:o,filterPlaceholder:l,baseFilterText:r,referenceFilterText:a,_baseFilterEnabled:c,_referenceFilterEnabled:d,uid: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":S,dragEnabled:n,filterEnabled:h,filterPlaceholder:l,filterText:h?"reference"===t?a:r:"",group:`bmlayerlist-${m}`,key:`list-${t}`,label:s.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:o,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 B(e){return e?.getAttribute("data-basemap-layer-type")}e([o()],x.prototype,"_activeItem",void 0),e([o()],x.prototype,"_tooltipReferenceMap",void 0),e([o()],x.prototype,"_focusRootFlowItem",void 0),e([o()],x.prototype,"_focusPanelFlowItem",void 0),e([o()],x.prototype,"_focusEditingFlowItem",void 0),e([o()],x.prototype,"_baseFilterEnabled",null),e([o()],x.prototype,"_referenceFilterEnabled",null),e([o()],x.prototype,"basemapTitle",null),e([o()],x.prototype,"collapsed",void 0),e([o()],x.prototype,"dragEnabled",void 0),e([o()],x.prototype,"editingTitle",void 0),e([o()],x.prototype,"filterPlaceholder",void 0),e([o()],x.prototype,"baseFilterText",void 0),e([o()],x.prototype,"referenceFilterText",void 0),e([o()],x.prototype,"listItemCanGiveFunction",void 0),e([o()],x.prototype,"listItemCanReceiveFunction",void 0),e([o()],x.prototype,"baseListItemCreatedFunction",null),e([o()],x.prototype,"editingEnabled",null),e([o()],x.prototype,"headingLevel",void 0),e([o()],x.prototype,"icon",null),e([o()],x.prototype,"label",null),e([o(),T("esri/widgets/BasemapLayerList/t9n/BasemapLayerList")],x.prototype,"messages",void 0),e([o(),T("esri/t9n/common")],x.prototype,"messagesCommon",void 0),e([o()],x.prototype,"minFilterItems",void 0),e([o()],x.prototype,"multipleSelectionEnabled",null),e([o()],x.prototype,"referenceListItemCreatedFunction",null),e([o({readOnly:!0})],x.prototype,"baseItems",null),e([o({readOnly:!0})],x.prototype,"referenceItems",null),e([o()],x.prototype,"selectedItems",void 0),e([o()],x.prototype,"selectionMode",void 0),e([o()],x.prototype,"view",null),e([M("trigger-action"),o({type:d})],x.prototype,"viewModel",void 0),e([o()],x.prototype,"visibilityAppearance",void 0),e([o({type:m,nonNullable:!0})],x.prototype,"visibleElements",void 0),x=e([l("esri.widgets.BasemapLayerList")],x);const P=x;export{P 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 n from"../core/Logger.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as r,getActionStyles as a}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 b,getStatusIcon as f,sortLayersToIds as v,sortChildLayersToIds as _,listItemHasChildren as y,areChildrenHidden as I,canSortSublayers as E,getVisibilityIcon as L}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as w}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="basemap",j=".*\\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._lastDragDetail=null,this._selectedDragItemLayerUid=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 n="pull"===s?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,o=g(e);if(!o?.sortable)return!1;const l=g(t),r=b(t),a=g(i),c=b(i),d=!!r&&!!c&&r===c,m={selected:o,from:l,to:a};return t.group&&i.group&&"function"==typeof n?n.call(null,m):d&&"sublayer"!==o?.layer?.type&&"map-image"!==l?.layer?.type&&"map-image"!==a?.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:n,newIndex:o}=e;if(!s||!i||t?.newIndex===o&&t?.dragEl===n&&t?.toEl===i&&t?.fromEl===s)return;this._lastDragDetail=e;const l=s,r=i;if(l!==r)this._moveLayerFromChildList({toEl:r,fromEl:l,dragEl:n,newIndex:o});else{const e=Array.from(s.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(l,e)}}}normalizeCtorArgs(e){return null!=e?.editingEnabled&&null!=e.visibleElements?{...e,visibleElements:new m({...e.visibleElements,editTitleButton:e.editingEnabled})}:e}loadDependencies(){return w({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 _baseFilterEnabled(){return this.viewModel.totalBaseItems>=this.minFilterItems&&this.visibleElements.filter}get _referenceFilterEnabled(){return this.viewModel.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(n.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(n.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(n.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(n.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)))}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((e=>!e.hidden)).toArray().filter((({panel:e})=>e?.open&&!e.disabled&&e.flowEnabled)).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}_renderItem(e,t,i,s,n){const{_activeItem:o,_selectedDragItemLayerUid:l,selectionMode:r,selectedItems:a,messages:c}=this,d=e.title||c.untitledLayer,m=e.visibleAtCurrentScale?d:`${d} (${c.layerInvisibleAtScale})`,u=this._filterActions(e.actionsSections),h=this._countActions(u);return A("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes(p.item,{[p.itemActive]:o===e}),"data-item":e,dragDisabled:!e.sortable||i,dragSelected:e.layer.uid===l,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:d,metadata:{parentTitles:n,title:d},open:e.open,selected:"none"!==r&&a.includes(e),title:m,value:e.layer.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:t=>this._handleCalciteListItemSelect(t,e,s),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},A("div",{class:this.classes({[p.itemContent]:!0,[p.itemInvisibleAtScale]:!e.visibleAtCurrentScale}),slot:"content"},d),this._renderItemStatus(e,s),this._renderItemToggle(e,s),this._renderItemTemporaryIcon(e),this._renderChildList(e,t,n),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),h>1?this._renderActionsSections(e,u):1===h?this._renderAction({item:e,action:this._getSingleActionButton(u),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:s,publishing:n,updating:o}=e,l=o&&!t,r=!!s;return A("calcite-icon",{class:this.classes({[p.statusIndicator]:!0,[p.publishing]:n,[p.updating]:l,[p.connectionStatus]:r,[p.connectionStatusConnected]:r&&"connected"===s}),icon:f({connectionStatus:s,publishing:n}),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:n}=e,o=t?.visibilityMode;if("inherited"===o)return null;const l=L({visible:n,exclusive:"exclusive"===o,visibilityAppearance:s}),r="checkbox"===s,a=i.layerVisibility;return A("calcite-action",{appearance:"transparent",class:p.visibleToggle,icon:r?l:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:r?"actions-start":"actions-end",text:a,title:a},r?null:A("calcite-icon",{class:this.classes({[p.visibleIcon]:"exclusive"!==o&&n}),icon:l,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: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 A("calcite-action-menu",{appearance:"transparent",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",{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,n={[p.itemActionIcon]:!!t,[p.itemActionImage]:!!s};return t&&(n[t]=!0),s||t?A("span",{"aria-hidden":"true",class:this.classes(p.itemActionIcon,n),key:"icon",styles:a(s)}):null}_renderAction(e){const{item:t,action:i,textEnabled:s}=e,{active:n,disabled:o,title:l,type:a,indicator:c}=i;return A("calcite-action",{active:"toggle"===a&&i.value,appearance:"transparent",disabled:o,icon:r(i),indicator:c,key:`action-${i.uid}`,loading:n,onclick:()=>this._triggerAction(t,i),scale:"s",slot:s?void 0:"actions-end",text:l??"",textEnabled:s,title:l??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 n=g(i),o=g(e),l=g(t),r=B(t),a=B(e);r&&a&&this.viewModel.moveListItem({targetItem:n,fromParentItem:l,toParentItem:o,newIndex:s,from:r,to:a})}_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.uid){const i=B(e),s="base"===i?this.view?.map?.basemap?.baseLayers:"reference"===i?this.view?.map?.basemap?.referenceLayers:null;v(s,t)}else{const i=g(e);if(!i)return;_(i,t)}}_getSingleActionButton(e){return e.reduce((e=>e)).filter((e=>e&&"button"===e.type)).at(0)}_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:j,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:n,flow:o},messages:l,viewModel:r,referenceItems:a,baseItems:c}=this,d=this.visibleElements.referenceLayers?this._getFilteredItems(a):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:n?r.basemapTitle??l.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)];return t?[o?A("calcite-flow",{key:"root-flow"},p):p,this._renderItemTooltips(d),this._renderItemTooltips(m)]:null}_renderChildList(e,t,i=[]){const{dragEnabled:s,uid:n}=this,{children:o}=e,l=y(e),r=!I(e.layer)&&!l&&s&&"group"===e.layer?.type;return l||r?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:!!s&&(e.childrenSortable&&E(e)),group:`bmlayerlist-${n}-${e.layer.uid}`},o?.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:n,selectionMode:o,filterPlaceholder:l,baseFilterText:r,referenceFilterText:a,_baseFilterEnabled:c,_referenceFilterEnabled:d,uid: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":S,dragEnabled:n,filterEnabled:h,filterPlaceholder:l,filterText:h?"reference"===t?a:r:"",group:`bmlayerlist-${m}`,key:`list-${t}`,label:s.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:o,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 B(e){return e?.getAttribute("data-basemap-layer-type")}e([o()],x.prototype,"_activeItem",void 0),e([o()],x.prototype,"_tooltipReferenceMap",void 0),e([o()],x.prototype,"_focusRootFlowItem",void 0),e([o()],x.prototype,"_focusPanelFlowItem",void 0),e([o()],x.prototype,"_focusEditingFlowItem",void 0),e([o()],x.prototype,"_baseFilterEnabled",null),e([o()],x.prototype,"_referenceFilterEnabled",null),e([o()],x.prototype,"basemapTitle",null),e([o()],x.prototype,"collapsed",void 0),e([o()],x.prototype,"dragEnabled",void 0),e([o()],x.prototype,"editingTitle",void 0),e([o()],x.prototype,"filterPlaceholder",void 0),e([o()],x.prototype,"baseFilterText",void 0),e([o()],x.prototype,"referenceFilterText",void 0),e([o()],x.prototype,"listItemCanGiveFunction",void 0),e([o()],x.prototype,"listItemCanReceiveFunction",void 0),e([o()],x.prototype,"baseListItemCreatedFunction",null),e([o()],x.prototype,"editingEnabled",null),e([o()],x.prototype,"headingLevel",void 0),e([o()],x.prototype,"icon",null),e([o()],x.prototype,"label",null),e([o(),T("esri/widgets/BasemapLayerList/t9n/BasemapLayerList")],x.prototype,"messages",void 0),e([o(),T("esri/t9n/common")],x.prototype,"messagesCommon",void 0),e([o()],x.prototype,"minFilterItems",void 0),e([o()],x.prototype,"multipleSelectionEnabled",null),e([o()],x.prototype,"referenceListItemCreatedFunction",null),e([o({readOnly:!0})],x.prototype,"baseItems",null),e([o({readOnly:!0})],x.prototype,"referenceItems",null),e([o()],x.prototype,"selectedItems",void 0),e([o()],x.prototype,"selectionMode",void 0),e([o()],x.prototype,"view",null),e([M("trigger-action"),o({type:d})],x.prototype,"viewModel",void 0),e([o()],x.prototype,"visibilityAppearance",void 0),e([o({type:m,nonNullable:!0})],x.prototype,"visibleElements",void 0),x=e([l("esri.widgets.BasemapLayerList")],x);const P=x;export{P as default};
|
package/widgets/Bookmarks.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{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as o}from"../core/deprecate.js";import{IdentifiableMixin as i}from"../core/Identifiable.js";import r from"../core/Logger.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import{formatDate as n,convertDateFormatToIntlOptions as l}from"../intl/date.js";import{system as d}from"../time/timeZoneUtils.js";import{SlideThumbnail as m}from"../webdoc/support/SlideThumbnail.js";import c from"./Widget.js";import u from"./Bookmarks/BookmarksUserState.js";import k from"./Bookmarks/BookmarksViewModel.js";import h from"./Bookmarks/BookmarksVisibleElements.js";import{ThumbnailInputPattern as p}from"./Bookmarks/bookmarkUtils.js";import{css as b}from"./Bookmarks/css.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{globalCss as _}from"./support/globalCss.js";import{Heading as v}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as B}from"./support/decorators/messageBundle.js";import{vmEvent as f}from"./support/decorators/vmEvent.js";import{tsx as E}from"./support/jsxFactory.js";let w=class extends(i(c)){constructor(e,t){super(e,t),this._addInputNode=null,this._editInputNode=null,this._urlEditInputNode=null,this._lastDragDetail=null,this._selectedDragBookmarkUid=null,this._editIncludeTimeExtent=void 0,this._userState=null,this._focusRootFlowItem=!1,this._focusAddFlowItem=!1,this._focusEditFlowItem=!1,this.disabled=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.viewModel=new k,this.visibleElements=new h,this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t,bookmarks:o}=this,{toEl:i,fromEl:r,dragEl:a,newIndex:s}=e;if(!o.length)return;if(!r||!i||t?.newIndex===s&&t?.dragEl===a&&t?.toEl===i&&t?.fromEl===r)return;this._lastDragDetail=e;const n=Array.from(r.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));o.sort(((e,t)=>{const o=n.indexOf(e.uid),i=n.indexOf(t.uid);return o>i?1:o<i?-1:0}))}}normalizeCtorArgs(e){return null!=e?.editingEnabled&&null!=e.visibleElements?{...e,visibleElements:new h({...e.visibleElements,addBookmarkButton:e.editingEnabled,editBookmarkButton:e.editingEnabled})}:e}loadDependencies(){return g({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),"chip-group":()=>import("@esri/calcite-components/dist/components/calcite-chip-group.js"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip.js"),fab:()=>import("@esri/calcite-components/dist/components/calcite-fab.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"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.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"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),table:()=>import("@esri/calcite-components/dist/components/calcite-table.js"),"table-cell":()=>import("@esri/calcite-components/dist/components/calcite-table-cell.js"),"table-header":()=>import("@esri/calcite-components/dist/components/calcite-table-header.js"),"table-row":()=>import("@esri/calcite-components/dist/components/calcite-table-row.js")})}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultEditOptions(){return this.viewModel.defaultEditOptions}set defaultEditOptions(e){this.viewModel.defaultEditOptions=e}get bookmarks(){return this.viewModel.bookmarks}set bookmarks(e){this.viewModel.bookmarks=e}get editingEnabled(){return o(r.getLogger(this),"editingEnabled",{replacement:"dragEnabled, visibleElements.editBookmarkButton, visibleElements.addBookmarkButton",version:"4.29",warnOnce:!0}),this.dragEnabled&&this.visibleElements.editBookmarkButton&&this.visibleElements.addBookmarkButton}set editingEnabled(e){o(r.getLogger(this),"editingEnabled",{replacement:"dragEnabled, visibleElements.editBookmarkButton, visibleElements.addBookmarkButton",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.visibleElements.editBookmarkButton=e,this.visibleElements.addBookmarkButton=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"bookmark"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}endAddBookmark(){this._userState=null}goTo(e){return this.viewModel.goTo(e)}render(){return E("div",{class:this.classes(b.base,_.widget,_.panel)},this._renderBookmarksContainer())}startAddBookmark(){this._userState=new u({state:"add"}),this._focusAddFlowItem=!0}_renderNoBookmarksContainer(e){const{messages:t,viewModel:{state:o}}=this;return e.length||"loading"===o?null:E("div",{class:_.empty,key:"no-bookmarks"},E("calcite-icon",{icon:"bookmark",scale:"l"}),E(v,{class:this.classes(_.heading,b.noBookmarksHeader),level:this.headingLevel},t?.noBookmarksHeading),E("p",{class:b.noBookmarksDescription},t.noBookmarksDescription))}_renderEditBookmarkFlowItems(){const{_userState:e}=this,t=e?.editedBookmark;return t&&"edit"===e?.state?this._renderEditingBookmark(t):[]}_renderBookmarkItems(e){return e?e.toArray().map((e=>this._renderBookmark(e))):[]}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:o,oldIndex:i}=e;t.insertBefore(o,t.children[i])}_renderBookmarksContainer(){const{viewModel:{state:e,bookmarks:o},dragEnabled:i,messages:r,disabled:a,filterPlaceholder:s,filterText:n,visible:l,headingLevel:d,visibleElements:{closeButton:m,collapseButton:c,filter:u,heading:k,flow:h},uid:p}=this,g=o.filter(t),_=g.length?E("calcite-list",{class:b.list,dragEnabled:i,filterEnabled:u,filterPlaceholder:s,filterText:n,group:`bookmarks-${p}`,key:"bookmark-list",label:r.widgetLabel,selectionAppearance:"border",selectionMode:"none",onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},this._renderBookmarkItems(g),u?E("div",{class:b.filterNoResults,slot:"filter-no-results"},E("calcite-notice",{kind:"info",open:!0,width:"full"},E("div",{slot:"message"},r.noBookmarksHeading),";")):null):null,v=[E("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:m,closed:!l,collapsible:c,disabled:a,heading:k?r.widgetLabel:void 0,headingLevel:d,loading:"loading"===e,onCalciteFlowItemClose:()=>this.visible=!1},this._renderNoBookmarksContainer(g),_,this._renderAddBookmarkButton()),this._renderAddingBookmark(),this._renderEditBookmarkFlowItems()];return l?h?E("calcite-flow",{key:"root-flow"},v):v:null}_renderAddBookmarkButton(){const{messages:e,_userState:t,disabled:o,viewModel:{view:i,state:r},visibleElements:{addBookmarkButton:a}}=this,s=t?.loading??!1;return i&&"loading"!==r&&a?E("calcite-fab",{appearance:"outline-fill",bind:this,class:b.addBookmarkButton,disabled:o||s,icon:"plus",key:"add-bookmark-item",kind:"neutral",loading:s,onclick:this.startAddBookmark,slot:"fab",text:e.addBookmark,textEnabled:!0,title:e.addBookmark,type:"button"}):null}_renderEditContainer(e){const{messagesCommon:t,visibleElements:{editBookmarkButton:o}}=this,i=this._getBookmarkTitle(e);return o?E("calcite-action",{appearance:"transparent",icon:"pencil",key:"edit-action",onclick:()=>this._showEditBookmarkForm(e),slot:"actions-end",text:`${t.edit} ${i}`,title:`${t.edit} ${i}`}):null}_renderBookmarkImage(e,t){return t?E("img",{alt:"",class:b.bookmarkImage,key:"bookmark-image",src:e.thumbnail?.url}):null}_renderBookmarkTimeSwitch(e){const{messages:t,viewModel:{view:o}}=this,{timeExtent:i}=e;return o?.timeExtent??i?E("calcite-label",{layout:"inline-space-between"},t.includeTimeExtent,E("calcite-switch",{checked:!!i,onCalciteSwitchChange:e=>{this._editIncludeTimeExtent=!!e.target.checked}})):null}_renderEditBookmarkTimeExtent(e){return this._editIncludeTimeExtent?this._renderBookmarkTimeExtent(e):null}_getTimeExtentStrings(e){const{visibleElements:t}=this,{timeExtent:o}=e;if(!o)return{};const{start:i,end:r}=o,a=null!=r&&(null==i||i.getTime()!==r.getTime()),s=i?this._formatDate(i):"",n=i&&t.time?this._formatTime(i):"";if(!a)return{startDate:s,startTime:n};return{startDate:s,startTime:n,endDate:this._formatDate(r),endTime:t.time?this._formatTime(r):""}}_renderTimeExtentDescription(e){const{startDate:t,startTime:o,endDate:i,endTime:r}=this._getTimeExtentStrings(e);if(!t)return"";const a=`${t} ${o}`;return i?`${a} - ${`${i} ${r}`}`:a}_renderBookmarkTimeExtent(e,t=!1){const{messages:o}=this,{startDate:i,startTime:r,endDate:a,endTime:s}=this._getTimeExtentStrings(e),n=t?null:E("calcite-table-row",{slot:"table-header"},E("calcite-table-header",{heading:o.startDate}),a?E("calcite-table-header",{heading:o.endDate}):null);return i?E("calcite-table",{caption:o.timeExtent,scale:"s"},n,E("calcite-table-row",null,E("calcite-table-cell",null,i," ",r?[E("br",null),r]:null),a?E("calcite-table-cell",null,a,s?[E("br",null),s]:null):null)):null}_renderBookmarkActiveScrim(e,t){return this.viewModel.activeBookmark===e&&t?E("calcite-scrim",{key:"bookmark-active-scrim",loading:!0}):null}_renderBookmarkActiveLoader(e,t){return this.viewModel.activeBookmark!==e||t?null:E("calcite-loader",{class:b.loader,inline:!0,key:"bookmark-active-loader",label:this.messagesCommon.loading})}_renderBookmarkImageIcon(e,t){return this.viewModel.activeBookmark===e||t?null:E("calcite-icon",{icon:"bookmark",key:"bookmark-icon",scale:"s"})}_renderBookmarkThumbnail(e){const t=this.visibleElements.thumbnail&&!!e.thumbnail?.url;return E("div",{class:b.bookmarkImageContainer,slot:"content-start"},this._renderBookmarkActiveScrim(e,t),this._renderBookmarkImage(e,t),this._renderBookmarkActiveLoader(e,t),this._renderBookmarkImageIcon(e,t))}_focusSelectedDragEl(e,t){this._selectedDragBookmarkUid===t.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const o=e.target.dragSelected;this._selectedDragBookmarkUid=o?t.uid:null}_renderBookmark(e){return E("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes({[b.dragEnabled]:this.dragEnabled}),description:this._renderTimeExtentDescription(e),dragSelected:e.uid===this._selectedDragBookmarkUid,key:e.uid,label:this._getBookmarkTitle(e),value:e.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:()=>this._goToBookmark(e)},this._renderBookmarkThumbnail(e),this._renderBookmarkContent(e),this._renderEditContainer(e))}_renderBookmarkContent(e){return E("div",{class:b.bookmarkContent,slot:"content"},E("span",{class:b.bookmarkContentLabel},this._getBookmarkTitle(e)),this._renderBookmarkTimeExtent(e,!0))}_renderEditingBookmarkName(e){const{messages:t,_userState:o}=this,i="name-required"===o?.validationState;return E("calcite-label",null,t.title,E("calcite-input",{afterCreate:this._storeEditInput,bind:this,class:b.editBookmarkInput,name:"bookmark-name",placeholder:t.titlePlaceholder,required:!0,type:"text",value:e.name}),i?E("calcite-input-message",{icon:"exclamation-mark-triangle",status:"invalid"},t.invalidTitle):null)}_renderEditingBookmarkActions(){const{messagesCommon:e,_userState:t}=this,o=t?.bookmark;return[E("calcite-button",{appearance:"transparent",kind:"danger",onclick:()=>this._deleteBookmark(o),slot:"footer",type:"button",width:"full"},e.delete),E("calcite-button",{appearance:"outline",bind:this,onclick:this._closeEditBookmarkForm,slot:"footer",type:"button",width:"full"},e.cancel),E("calcite-button",{slot:"footer",type:"submit",width:"full"},e.save)]}_handleUrlEditInputChange(){const{_userState:e,_urlEditInputNode:t}=this,o=t?.value;if(!e?.editedBookmark||!o)return;e.validationState=void 0,e.editedBookmark.thumbnail?.isDataURI&&(e.screenshotUrl=e.editedBookmark.thumbnail?.url);const i=new m({url:o});i.isSecureUrl&&(e.customUrl=o,e.editedBookmark.thumbnail=i)}_renderEditingTimeExtent(e){const{capabilities:t,view:o}=this.viewModel,{timeExtent:i}=e;return t.time&&(o?.timeExtent??i)?E("div",{key:"edit-bookmark-time-container"},this._renderBookmarkTimeSwitch(e),this._renderEditBookmarkTimeExtent(e)):null}_renderEditingBookmarkImage(e){const{_userState:t}=this,o=t?.thumbnailState,i=e.thumbnail?.isSecureUrl?"url"===o:e.thumbnail?.isDataURI?"screenshot"===o:null;if(i)return this._renderBookmarkImage(e,i)}_renderEditingThumbnail(e){const{_userState:t,visibleElements:o}=this,i=t?.thumbnailState;return o.thumbnail&&"none"!==i?E("div",{class:b.authoringImageContainer},this._renderEditingBookmarkImage(e)):null}_renderUpdateThumbnailButton(){const{visibleElements:e,messages:t,_userState:o}=this,i=o?.thumbnailState;return e.thumbnail&&"screenshot"===i?E("calcite-button",{appearance:"outline",class:b.authoringRefreshThumbnailButton,iconStart:"refresh",key:"update-thumbnail",kind:"neutral",onclick:()=>{this._updateThumbnail()},width:"half"},t.updateThumbnail):null}_renderEditingBookmarkUrlInput(e){const{messages:t,_userState:o}=this,i=e.thumbnail?.url,r=e.thumbnail?.isSecureUrl?i:void 0,a=i&&"absolute-url-required"===o?.validationState,s=o?.thumbnailState;return"url"===s?E("calcite-label",{key:"thumbnail-url-input"},E("calcite-input",{afterCreate:this._storeUrlEditInput,bind:this,name:"bookmark-thumbnail-url",pattern:p,placeholder:t?`https://<${t.imageUrlPlaceholder}>`:void 0,required:!0,title:t.imageUrlTooltip,type:"text",value:r,onCalciteInputChange:this._handleUrlEditInputChange,onCalciteInputInput:this._handleUrlEditInputChange}),a?E("calcite-input-message",{icon:"exclamation-mark-triangle",status:"invalid"},t.invalidImageUrl):null):null}_renderThumbnailSelector(){const{visibleElements:e,messages:t,_userState:o}=this,i=o?.thumbnailState;return e.thumbnail?E("calcite-label",{key:"thumbnail-chip-group"},t.thumbnail,E("calcite-chip-group",{label:t.thumbnail,selectionMode:"single-persist",onCalciteChipGroupSelect:e=>this._handleThumbnailTypeSelect(e.target.selectedItems[0].value)},E("calcite-chip",{selected:"screenshot"===i,value:"screenshot"},t.screenshot),E("calcite-chip",{selected:"url"===i,value:"url"},t.url),E("calcite-chip",{selected:"none"===i,value:"none"},t.none))):null}_renderEditingBookmark(e){const{disabled:t,messagesCommon:o,headingLevel:i}=this;return e?E("form",{bind:this,class:b.form,disabled:this.disabled,onsubmit:this._editBookmarkSubmit},E("calcite-flow-item",{afterCreate:this._focusEditFlowItemNode,afterUpdate:this._focusEditFlowItemNode,bind:this,disabled:t,heading:o.edit,headingLevel:i,key:"edit-bookmark-form",onCalciteFlowItemBack:e=>{e.preventDefault(),this._closeEditBookmarkForm()}},E("div",{class:b.formContent},E("div",{class:b.authoring},this._renderEditingBookmarkName(e),this._renderThumbnailSelector(),this._renderEditingThumbnail(e),this._renderEditingBookmarkUrlInput(e),this._renderUpdateThumbnailButton(),this._renderEditingTimeExtent(e))),this._renderEditingBookmarkActions())):null}_renderAddingBookmarkName(){const{_userState:e,messages:t}=this,o="name-required"===e?.validationState;return E("calcite-label",null,t.title,E("calcite-input",{afterCreate:this._storeAddInput,bind:this,class:b.addBookmarkInput,name:"bookmark-name",placeholder:t.titlePlaceholder,required:!0,type:"text",value:""}),o?E("calcite-input-message",{icon:"exclamation-mark-triangle",status:"invalid"},t.invalidTitle):null)}_renderAddingBookmarkActions(){const{messagesCommon:e}=this;return[E("calcite-button",{appearance:"outline",bind:this,onclick:this._endAddBookmark,slot:"footer",type:"button",width:"half"},e.cancel),E("calcite-button",{slot:"footer",type:"submit",width:"half"},e.add)]}_renderAddingBookmark(){const{disabled:e,messages:t,headingLevel:o,_userState:i}=this;return"add"===i?.state?E("form",{bind:this,class:b.form,disabled:e,onsubmit:this._addBookmarkSubmitClick},E("calcite-flow-item",{afterCreate:this._focusAddFlowItemNode,afterUpdate:this._focusAddFlowItemNode,bind:this,disabled:e,heading:t.addBookmark,headingLevel:o,key:"add-bookmark-form",onCalciteFlowItemBack:e=>{e.preventDefault(),this._endAddBookmark()}},E("div",{class:b.formContent},this._renderAddingBookmarkName()),this._renderAddingBookmarkActions())):null}_getBookmarkTitle(e){return e?.name||this.messagesCommon.untitled}_formatDate(e){return e?n(e,{...l("short-date"),timeZone:this.viewModel.view?.timeZone??d}):""}_formatTime(e){return e?n(e,{...l("long-time"),timeZone:this.viewModel.view?.timeZone??d}):""}_endAddBookmark(){this.endAddBookmark(),this._focusRootFlowItem=!0}_showEditBookmarkForm(e){e&&(this._editIncludeTimeExtent=!!e.timeExtent,this._userState=new u({bookmark:e,state:"edit"}),this._focusEditFlowItem=!0,this.viewModel.goTo(e))}async _createNewScreenshotUrl(){const e=await this.viewModel.createBookmark();return e.thumbnail?.url??null}_storeCurrentUrl(){const{_userState:e}=this,t=e?.editedBookmark?.thumbnail?.url;t&&(e?.editedBookmark?.thumbnail?.isSecureUrl?e.customUrl=t:e?.editedBookmark?.thumbnail?.isDataURI&&(e.screenshotUrl=t))}async _handleThumbnailTypeSelect(e){const{_userState:t}=this;if(!t)return;const{screenshotUrl:o,customUrl:i,editedBookmark:r}=t,a="screenshot"===e?o??await this._createNewScreenshotUrl():"url"===e&&i?i:null;this._storeCurrentUrl(),r&&a&&(r.thumbnail=new m({url:a})),t.validationState=void 0,t.thumbnailState=e}_closeEditBookmarkForm(){this._userState=null,this._focusRootFlowItem=!0}_addBookmarkSubmitClick(e){e.preventDefault(),this._addBookmarkSubmit()}async _addBookmarkSubmit(){const{_addInputNode:e,_userState:t,viewModel:o,viewModel:{bookmarks:i}}=this;if(!t)return;const r=e?e.value.trim():null;if(!r)return void(t.validationState="name-required");t.loading=!0;const a=await o.createBookmark();a.name=r,i.add(a),this._endAddBookmark()}async _editBookmarkAndClose(e,t){const{viewModel:o,viewModel:{defaultEditOptions:i}}=this;await o.editBookmark(e,{...i,...t}),this._closeEditBookmarkForm()}_editBookmarkSubmit(e){e.preventDefault();const{_editInputNode:t,_userState:o,_editIncludeTimeExtent:i,_urlEditInputNode:r}=this;if(!o?.bookmark||!o.editedBookmark)return;o.validationState=void 0,o.customUrl=void 0,o.screenshotUrl=void 0;const a=t&&t.value.trim();if(!a)return void(o.validationState="name-required");o.bookmark.name=a,o.bookmark.thumbnail=o.editedBookmark.thumbnail,i||(o.bookmark.timeExtent=null);const s=o.thumbnailState;if("url"===s&&r){const e=r.value,t=new m({url:e});if(!t.isSecureUrl)return void(o.validationState="absolute-url-required");o.bookmark.thumbnail=t}else"none"===s&&(o.bookmark.thumbnail=null);this._editBookmarkAndClose(o.bookmark,{takeScreenshot:!1,captureTimeExtent:i})}_storeEditInput(e){this._editInputNode=e}_storeAddInput(e){this._addInputNode=e}_storeUrlEditInput(e){this._urlEditInputNode=e}_deleteBookmark(e){this._closeEditBookmarkForm(),e&&this.viewModel.bookmarks.remove(e)}_goToBookmark(e){e&&(this.endAddBookmark(),this.viewModel.goTo(e))}async _updateThumbnail(){const{_userState:e,viewModel:t}=this;e&&(e.validationState=void 0,await t.editBookmark(e.editedBookmark,{takeScreenshot:!0,captureViewpoint:!1,captureRotation:!1,captureScale:!1,captureTimeExtent:!1}))}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusEditFlowItemNode(e){this._focusEditFlowItem&&(this._focusEditFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusAddFlowItemNode(e){this._focusAddFlowItem&&(this._focusAddFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}};e([a()],w.prototype,"_editIncludeTimeExtent",void 0),e([a({type:u})],w.prototype,"_userState",void 0),e([a()],w.prototype,"_focusRootFlowItem",void 0),e([a()],w.prototype,"_focusAddFlowItem",void 0),e([a()],w.prototype,"_focusEditFlowItem",void 0),e([a()],w.prototype,"defaultCreateOptions",null),e([a()],w.prototype,"defaultEditOptions",null),e([a()],w.prototype,"bookmarks",null),e([a()],w.prototype,"disabled",void 0),e([a()],w.prototype,"dragEnabled",void 0),e([a()],w.prototype,"editingEnabled",null),e([a()],w.prototype,"filterPlaceholder",void 0),e([a()],w.prototype,"filterText",void 0),e([a()],w.prototype,"headingLevel",void 0),e([a()],w.prototype,"goToOverride",null),e([a()],w.prototype,"icon",null),e([a()],w.prototype,"label",null),e([a(),B("esri/widgets/Bookmarks/t9n/Bookmarks")],w.prototype,"messages",void 0),e([a(),B("esri/t9n/common")],w.prototype,"messagesCommon",void 0),e([a()],w.prototype,"uiStrings",void 0),e([a()],w.prototype,"view",null),e([a({type:k}),f(["select-bookmark","bookmark-edit","bookmark-select"])],w.prototype,"viewModel",void 0),e([a({type:h,nonNullable:!0})],w.prototype,"visibleElements",void 0),e([a()],w.prototype,"endAddBookmark",null),e([a()],w.prototype,"startAddBookmark",null),w=e([s("esri.widgets.Bookmarks")],w);const I=w;export{I as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as o}from"../core/deprecate.js";import{IdentifiableMixin as i}from"../core/Identifiable.js";import r from"../core/Logger.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import{formatDate as n,convertDateFormatToIntlOptions as l}from"../intl/date.js";import{system as d}from"../time/timeZoneUtils.js";import{SlideThumbnail as m}from"../webdoc/support/SlideThumbnail.js";import c from"./Widget.js";import u from"./Bookmarks/BookmarksUserState.js";import k from"./Bookmarks/BookmarksViewModel.js";import h from"./Bookmarks/BookmarksVisibleElements.js";import{ThumbnailInputPattern as p}from"./Bookmarks/bookmarkUtils.js";import{css as b}from"./Bookmarks/css.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{globalCss as _}from"./support/globalCss.js";import{Heading as v}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as B}from"./support/decorators/messageBundle.js";import{vmEvent as f}from"./support/decorators/vmEvent.js";import{tsx as E}from"./support/jsxFactory.js";let w=class extends(i(c)){constructor(e,t){super(e,t),this._addInputNode=null,this._editInputNode=null,this._urlEditInputNode=null,this._lastDragDetail=null,this._selectedDragBookmarkUid=null,this._editIncludeTimeExtent=void 0,this._userState=null,this._focusRootFlowItem=!1,this._focusAddFlowItem=!1,this._focusEditFlowItem=!1,this.disabled=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.viewModel=new k,this.visibleElements=new h,this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t,bookmarks:o}=this,{toEl:i,fromEl:r,dragEl:a,newIndex:s}=e;if(!o.length)return;if(!r||!i||t?.newIndex===s&&t?.dragEl===a&&t?.toEl===i&&t?.fromEl===r)return;this._lastDragDetail=e;const n=Array.from(r.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));o.sort(((e,t)=>{const o=n.indexOf(e.uid),i=n.indexOf(t.uid);return o>i?1:o<i?-1:0}))}}normalizeCtorArgs(e){return null!=e?.editingEnabled&&null!=e.visibleElements?{...e,visibleElements:new h({...e.visibleElements,addBookmarkButton:e.editingEnabled,editBookmarkButton:e.editingEnabled})}:e}loadDependencies(){return g({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),"chip-group":()=>import("@esri/calcite-components/dist/components/calcite-chip-group.js"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip.js"),fab:()=>import("@esri/calcite-components/dist/components/calcite-fab.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"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.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"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),table:()=>import("@esri/calcite-components/dist/components/calcite-table.js"),"table-cell":()=>import("@esri/calcite-components/dist/components/calcite-table-cell.js"),"table-header":()=>import("@esri/calcite-components/dist/components/calcite-table-header.js"),"table-row":()=>import("@esri/calcite-components/dist/components/calcite-table-row.js")})}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultEditOptions(){return this.viewModel.defaultEditOptions}set defaultEditOptions(e){this.viewModel.defaultEditOptions=e}get bookmarks(){return this.viewModel.bookmarks}set bookmarks(e){this.viewModel.bookmarks=e}get editingEnabled(){return o(r.getLogger(this),"editingEnabled",{replacement:"dragEnabled, visibleElements.editBookmarkButton, visibleElements.addBookmarkButton",version:"4.29",warnOnce:!0}),this.dragEnabled&&this.visibleElements.editBookmarkButton&&this.visibleElements.addBookmarkButton}set editingEnabled(e){o(r.getLogger(this),"editingEnabled",{replacement:"dragEnabled, visibleElements.editBookmarkButton, visibleElements.addBookmarkButton",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.visibleElements.editBookmarkButton=e,this.visibleElements.addBookmarkButton=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"bookmark"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}endAddBookmark(){this._userState=null}goTo(e){return this.viewModel.goTo(e)}render(){return E("div",{class:this.classes(b.base,_.widget,_.panel)},this._renderBookmarksContainer())}startAddBookmark(){this._userState=new u({state:"add"}),this._focusAddFlowItem=!0}_renderNoBookmarksContainer(e){const{messages:t,viewModel:{state:o}}=this;return e.length||"loading"===o?null:E("div",{class:_.empty,key:"no-bookmarks"},E("calcite-icon",{icon:"bookmark",scale:"l"}),E(v,{class:this.classes(_.heading,b.noBookmarksHeader),level:this.headingLevel},t?.noBookmarksHeading),E("p",{class:b.noBookmarksDescription},t.noBookmarksDescription))}_renderEditBookmarkFlowItems(){const{_userState:e}=this,t=e?.editedBookmark;return t&&"edit"===e?.state?this._renderEditingBookmark(t):[]}_renderBookmarkItems(e){return e?e.toArray().map((e=>this._renderBookmark(e))):[]}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:o,oldIndex:i}=e;t.insertBefore(o,t.children[i])}_renderBookmarksContainer(){const{viewModel:{state:e,bookmarks:o},dragEnabled:i,messages:r,disabled:a,filterPlaceholder:s,filterText:n,visible:l,headingLevel:d,visibleElements:{closeButton:m,collapseButton:c,filter:u,heading:k,flow:h},uid:p}=this,g=o.filter(t),_=g.length?E("calcite-list",{class:b.list,dragEnabled:i,filterEnabled:u,filterPlaceholder:s,filterText:n,group:`bookmarks-${p}`,key:"bookmark-list",label:r.widgetLabel,selectionAppearance:"border",selectionMode:"none",onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},this._renderBookmarkItems(g),u?E("div",{class:b.filterNoResults,slot:"filter-no-results"},E("calcite-notice",{kind:"info",open:!0,width:"full"},E("div",{slot:"message"},r.noBookmarksHeading),";")):null):null,v=[E("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:m,closed:!l,collapsible:c,disabled:a,heading:k?r.widgetLabel:void 0,headingLevel:d,loading:"loading"===e,onCalciteFlowItemClose:()=>this.visible=!1},this._renderNoBookmarksContainer(g),_,this._renderAddBookmarkButton()),this._renderAddingBookmark(),this._renderEditBookmarkFlowItems()];return l?h?E("calcite-flow",{key:"root-flow"},v):v:null}_renderAddBookmarkButton(){const{messages:e,_userState:t,disabled:o,viewModel:{view:i,state:r},visibleElements:{addBookmarkButton:a}}=this,s=t?.loading??!1;return i&&"loading"!==r&&a?E("calcite-fab",{appearance:"outline-fill",bind:this,class:b.addBookmarkButton,disabled:o||s,icon:"plus",key:"add-bookmark-item",kind:"neutral",loading:s,onclick:this.startAddBookmark,slot:"fab",text:e.addBookmark,textEnabled:!0,title:e.addBookmark,type:"button"}):null}_renderEditContainer(e){const{messagesCommon:t,visibleElements:{editBookmarkButton:o}}=this,i=`${t.edit} ${this._getBookmarkTitle(e)}`;return o?E("calcite-action",{appearance:"transparent",icon:"pencil",key:"edit-action",onclick:()=>this._showEditBookmarkForm(e),slot:"actions-end",text:i,title:i}):null}_renderBookmarkImage(e,t){return t?E("img",{alt:"",class:b.bookmarkImage,key:"bookmark-image",src:e.thumbnail?.url}):null}_renderBookmarkTimeSwitch(e){const{messages:t,viewModel:{view:o}}=this,{timeExtent:i}=e;return o?.timeExtent??i?E("calcite-label",{layout:"inline-space-between"},t.includeTimeExtent,E("calcite-switch",{checked:!!i,onCalciteSwitchChange:e=>{this._editIncludeTimeExtent=!!e.target.checked}})):null}_renderEditBookmarkTimeExtent(e){return this._editIncludeTimeExtent?this._renderBookmarkTimeExtent(e):null}_getTimeExtentStrings(e){const{visibleElements:t}=this,{timeExtent:o}=e;if(!o)return{};const{start:i,end:r}=o,a=null!=r&&(null==i||i.getTime()!==r.getTime()),s=i?this._formatDate(i):"",n=i&&t.time?this._formatTime(i):"";if(!a)return{startDate:s,startTime:n};return{startDate:s,startTime:n,endDate:this._formatDate(r),endTime:t.time?this._formatTime(r):""}}_renderTimeExtentDescription(e){const{startDate:t,startTime:o,endDate:i,endTime:r}=this._getTimeExtentStrings(e);if(!t)return"";const a=`${t} ${o}`;return i?`${a} - ${`${i} ${r}`}`:a}_renderBookmarkTimeExtent(e,t=!1){const{messages:o}=this,{startDate:i,startTime:r,endDate:a,endTime:s}=this._getTimeExtentStrings(e),n=t?null:E("calcite-table-row",{slot:"table-header"},E("calcite-table-header",{heading:o.startDate}),a?E("calcite-table-header",{heading:o.endDate}):null);return i?E("calcite-table",{caption:o.timeExtent,scale:"s"},n,E("calcite-table-row",null,E("calcite-table-cell",null,i," ",r?[E("br",null),r]:null),a?E("calcite-table-cell",null,a,s?[E("br",null),s]:null):null)):null}_renderBookmarkActiveScrim(e,t){return this.viewModel.activeBookmark===e&&t?E("calcite-scrim",{key:"bookmark-active-scrim",loading:!0}):null}_renderBookmarkActiveLoader(e,t){return this.viewModel.activeBookmark!==e||t?null:E("calcite-loader",{class:b.loader,inline:!0,key:"bookmark-active-loader",label:this.messagesCommon.loading})}_renderBookmarkImageIcon(e,t){return this.viewModel.activeBookmark===e||t?null:E("calcite-icon",{icon:"bookmark",key:"bookmark-icon",scale:"s"})}_renderBookmarkThumbnail(e){const t=this.visibleElements.thumbnail&&!!e.thumbnail?.url;return E("div",{class:b.bookmarkImageContainer,slot:"content-start"},this._renderBookmarkActiveScrim(e,t),this._renderBookmarkImage(e,t),this._renderBookmarkActiveLoader(e,t),this._renderBookmarkImageIcon(e,t))}_focusSelectedDragEl(e,t){this._selectedDragBookmarkUid===t.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const o=e.target.dragSelected;this._selectedDragBookmarkUid=o?t.uid:null}_renderBookmark(e){return E("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes({[b.dragEnabled]:this.dragEnabled}),description:this._renderTimeExtentDescription(e),dragSelected:e.uid===this._selectedDragBookmarkUid,key:e.uid,label:this._getBookmarkTitle(e),value:e.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:()=>this._goToBookmark(e)},this._renderBookmarkThumbnail(e),this._renderBookmarkContent(e),this._renderEditContainer(e))}_renderBookmarkContent(e){return E("div",{class:b.bookmarkContent,slot:"content"},E("span",{class:b.bookmarkContentLabel},this._getBookmarkTitle(e)),this._renderBookmarkTimeExtent(e,!0))}_renderEditingBookmarkName(e){const{messages:t,_userState:o}=this,i="name-required"===o?.validationState;return E("calcite-label",null,t.title,E("calcite-input",{afterCreate:this._storeEditInput,bind:this,class:b.editBookmarkInput,name:"bookmark-name",placeholder:t.titlePlaceholder,required:!0,type:"text",value:e.name}),i?E("calcite-input-message",{icon:"exclamation-mark-triangle",status:"invalid"},t.invalidTitle):null)}_renderEditingBookmarkActions(){const{messagesCommon:e,_userState:t}=this,o=t?.bookmark;return[E("calcite-button",{appearance:"transparent",kind:"danger",onclick:()=>this._deleteBookmark(o),slot:"footer",type:"button",width:"full"},e.delete),E("calcite-button",{appearance:"outline",bind:this,onclick:this._closeEditBookmarkForm,slot:"footer",type:"button",width:"full"},e.cancel),E("calcite-button",{slot:"footer",type:"submit",width:"full"},e.save)]}_handleUrlEditInputChange(){const{_userState:e,_urlEditInputNode:t}=this,o=t?.value;if(!e?.editedBookmark||!o)return;e.validationState=void 0,e.editedBookmark.thumbnail?.isDataURI&&(e.screenshotUrl=e.editedBookmark.thumbnail?.url);const i=new m({url:o});i.isSecureUrl&&(e.customUrl=o,e.editedBookmark.thumbnail=i)}_renderEditingTimeExtent(e){const{capabilities:t,view:o}=this.viewModel,{timeExtent:i}=e;return t.time&&(o?.timeExtent??i)?E("div",{key:"edit-bookmark-time-container"},this._renderBookmarkTimeSwitch(e),this._renderEditBookmarkTimeExtent(e)):null}_renderEditingBookmarkImage(e){const{_userState:t}=this,o=t?.thumbnailState,i=e.thumbnail?.isSecureUrl?"url"===o:e.thumbnail?.isDataURI?"screenshot"===o:null;if(i)return this._renderBookmarkImage(e,i)}_renderEditingThumbnail(e){const{_userState:t,visibleElements:o}=this,i=t?.thumbnailState;return o.thumbnail&&"none"!==i?E("div",{class:b.authoringImageContainer},this._renderEditingBookmarkImage(e)):null}_renderUpdateThumbnailButton(){const{visibleElements:e,messages:t,_userState:o}=this,i=o?.thumbnailState;return e.thumbnail&&"screenshot"===i?E("calcite-button",{appearance:"outline",class:b.authoringRefreshThumbnailButton,iconStart:"refresh",key:"update-thumbnail",kind:"neutral",onclick:()=>{this._updateThumbnail()},width:"half"},t.updateThumbnail):null}_renderEditingBookmarkUrlInput(e){const{messages:t,_userState:o}=this,i=e.thumbnail?.url,r=e.thumbnail?.isSecureUrl?i:void 0,a=i&&"absolute-url-required"===o?.validationState,s=o?.thumbnailState;return"url"===s?E("calcite-label",{key:"thumbnail-url-input"},E("calcite-input",{afterCreate:this._storeUrlEditInput,bind:this,name:"bookmark-thumbnail-url",pattern:p,placeholder:t?`https://<${t.imageUrlPlaceholder}>`:void 0,required:!0,title:t.imageUrlTooltip,type:"text",value:r,onCalciteInputChange:this._handleUrlEditInputChange,onCalciteInputInput:this._handleUrlEditInputChange}),a?E("calcite-input-message",{icon:"exclamation-mark-triangle",status:"invalid"},t.invalidImageUrl):null):null}_renderThumbnailSelector(){const{visibleElements:e,messages:t,_userState:o}=this,i=o?.thumbnailState;return e.thumbnail?E("calcite-label",{key:"thumbnail-chip-group"},t.thumbnail,E("calcite-chip-group",{label:t.thumbnail,selectionMode:"single-persist",onCalciteChipGroupSelect:e=>this._handleThumbnailTypeSelect(e.target.selectedItems[0].value)},E("calcite-chip",{selected:"screenshot"===i,value:"screenshot"},t.screenshot),E("calcite-chip",{selected:"url"===i,value:"url"},t.url),E("calcite-chip",{selected:"none"===i,value:"none"},t.none))):null}_renderEditingBookmark(e){const{disabled:t,messagesCommon:o,headingLevel:i}=this;return e?E("form",{bind:this,class:b.form,disabled:this.disabled,onsubmit:this._editBookmarkSubmit},E("calcite-flow-item",{afterCreate:this._focusEditFlowItemNode,afterUpdate:this._focusEditFlowItemNode,bind:this,disabled:t,heading:o.edit,headingLevel:i,key:"edit-bookmark-form",onCalciteFlowItemBack:e=>{e.preventDefault(),this._closeEditBookmarkForm()}},E("div",{class:b.formContent},E("div",{class:b.authoring},this._renderEditingBookmarkName(e),this._renderThumbnailSelector(),this._renderEditingThumbnail(e),this._renderEditingBookmarkUrlInput(e),this._renderUpdateThumbnailButton(),this._renderEditingTimeExtent(e))),this._renderEditingBookmarkActions())):null}_renderAddingBookmarkName(){const{_userState:e,messages:t}=this,o="name-required"===e?.validationState;return E("calcite-label",null,t.title,E("calcite-input",{afterCreate:this._storeAddInput,bind:this,class:b.addBookmarkInput,name:"bookmark-name",placeholder:t.titlePlaceholder,required:!0,type:"text",value:""}),o?E("calcite-input-message",{icon:"exclamation-mark-triangle",status:"invalid"},t.invalidTitle):null)}_renderAddingBookmarkActions(){const{messagesCommon:e}=this;return[E("calcite-button",{appearance:"outline",bind:this,onclick:this._endAddBookmark,slot:"footer",type:"button",width:"half"},e.cancel),E("calcite-button",{slot:"footer",type:"submit",width:"half"},e.add)]}_renderAddingBookmark(){const{disabled:e,messages:t,headingLevel:o,_userState:i}=this;return"add"===i?.state?E("form",{bind:this,class:b.form,disabled:e,onsubmit:this._addBookmarkSubmitClick},E("calcite-flow-item",{afterCreate:this._focusAddFlowItemNode,afterUpdate:this._focusAddFlowItemNode,bind:this,disabled:e,heading:t.addBookmark,headingLevel:o,key:"add-bookmark-form",onCalciteFlowItemBack:e=>{e.preventDefault(),this._endAddBookmark()}},E("div",{class:b.formContent},this._renderAddingBookmarkName()),this._renderAddingBookmarkActions())):null}_getBookmarkTitle(e){return e?.name||this.messagesCommon.untitled}_formatDate(e){return e?n(e,{...l("short-date"),timeZone:this.viewModel.view?.timeZone??d}):""}_formatTime(e){return e?n(e,{...l("long-time"),timeZone:this.viewModel.view?.timeZone??d}):""}_endAddBookmark(){this.endAddBookmark(),this._focusRootFlowItem=!0}_showEditBookmarkForm(e){e&&(this._editIncludeTimeExtent=!!e.timeExtent,this._userState=new u({bookmark:e,state:"edit"}),this._focusEditFlowItem=!0,this.viewModel.goTo(e))}async _createNewScreenshotUrl(){const e=await this.viewModel.createBookmark();return e.thumbnail?.url??null}_storeCurrentUrl(){const{_userState:e}=this,t=e?.editedBookmark?.thumbnail?.url;t&&(e?.editedBookmark?.thumbnail?.isSecureUrl?e.customUrl=t:e?.editedBookmark?.thumbnail?.isDataURI&&(e.screenshotUrl=t))}async _handleThumbnailTypeSelect(e){const{_userState:t}=this;if(!t)return;const{screenshotUrl:o,customUrl:i,editedBookmark:r}=t,a="screenshot"===e?o??await this._createNewScreenshotUrl():"url"===e&&i?i:null;this._storeCurrentUrl(),r&&a&&(r.thumbnail=new m({url:a})),t.validationState=void 0,t.thumbnailState=e}_closeEditBookmarkForm(){this._userState=null,this._focusRootFlowItem=!0}_addBookmarkSubmitClick(e){e.preventDefault(),this._addBookmarkSubmit()}async _addBookmarkSubmit(){const{_addInputNode:e,_userState:t,viewModel:o,viewModel:{bookmarks:i}}=this;if(!t)return;const r=e?e.value.trim():null;if(!r)return void(t.validationState="name-required");t.loading=!0;const a=await o.createBookmark();a.name=r,i.add(a),this._endAddBookmark()}async _editBookmarkAndClose(e,t){const{viewModel:o,viewModel:{defaultEditOptions:i}}=this;await o.editBookmark(e,{...i,...t}),this._closeEditBookmarkForm()}_editBookmarkSubmit(e){e.preventDefault();const{_editInputNode:t,_userState:o,_editIncludeTimeExtent:i,_urlEditInputNode:r}=this;if(!o?.bookmark||!o.editedBookmark)return;o.validationState=void 0,o.customUrl=void 0,o.screenshotUrl=void 0;const a=t&&t.value.trim();if(!a)return void(o.validationState="name-required");o.bookmark.name=a,o.bookmark.thumbnail=o.editedBookmark.thumbnail,i||(o.bookmark.timeExtent=null);const s=o.thumbnailState;if("url"===s&&r){const e=r.value,t=new m({url:e});if(!t.isSecureUrl)return void(o.validationState="absolute-url-required");o.bookmark.thumbnail=t}else"none"===s&&(o.bookmark.thumbnail=null);this._editBookmarkAndClose(o.bookmark,{takeScreenshot:!1,captureTimeExtent:i})}_storeEditInput(e){this._editInputNode=e}_storeAddInput(e){this._addInputNode=e}_storeUrlEditInput(e){this._urlEditInputNode=e}_deleteBookmark(e){this._closeEditBookmarkForm(),e&&this.viewModel.bookmarks.remove(e)}_goToBookmark(e){e&&(this.endAddBookmark(),this.viewModel.goTo(e))}async _updateThumbnail(){const{_userState:e,viewModel:t}=this;e&&(e.validationState=void 0,await t.editBookmark(e.editedBookmark,{takeScreenshot:!0,captureViewpoint:!1,captureRotation:!1,captureScale:!1,captureTimeExtent:!1}))}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusEditFlowItemNode(e){this._focusEditFlowItem&&(this._focusEditFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusAddFlowItemNode(e){this._focusAddFlowItem&&(this._focusAddFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}};e([a()],w.prototype,"_editIncludeTimeExtent",void 0),e([a({type:u})],w.prototype,"_userState",void 0),e([a()],w.prototype,"_focusRootFlowItem",void 0),e([a()],w.prototype,"_focusAddFlowItem",void 0),e([a()],w.prototype,"_focusEditFlowItem",void 0),e([a()],w.prototype,"defaultCreateOptions",null),e([a()],w.prototype,"defaultEditOptions",null),e([a()],w.prototype,"bookmarks",null),e([a()],w.prototype,"disabled",void 0),e([a()],w.prototype,"dragEnabled",void 0),e([a()],w.prototype,"editingEnabled",null),e([a()],w.prototype,"filterPlaceholder",void 0),e([a()],w.prototype,"filterText",void 0),e([a()],w.prototype,"headingLevel",void 0),e([a()],w.prototype,"goToOverride",null),e([a()],w.prototype,"icon",null),e([a()],w.prototype,"label",null),e([a(),B("esri/widgets/Bookmarks/t9n/Bookmarks")],w.prototype,"messages",void 0),e([a(),B("esri/t9n/common")],w.prototype,"messagesCommon",void 0),e([a()],w.prototype,"uiStrings",void 0),e([a()],w.prototype,"view",null),e([a({type:k}),f(["select-bookmark","bookmark-edit","bookmark-select"])],w.prototype,"viewModel",void 0),e([a({type:h,nonNullable:!0})],w.prototype,"visibleElements",void 0),e([a()],w.prototype,"endAddBookmark",null),e([a()],w.prototype,"startAddBookmark",null),w=e([s("esri.widgets.Bookmarks")],w);const I=w;export{I 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 t}from"../chunks/tslib.es6.js";import{watch as e}from"../core/reactiveUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";import s from"./Widget.js";import{canShowNorth as n}from"./Compass/utils.js";import{directionalPadAngles as r,directionalPadArrows as a}from"./DirectionalPad/constants.js";import{css as l}from"./DirectionalPad/css.js";import d from"./DirectionalPad/DirectionalPadViewModel.js";import{findElementCenter as c}from"./DirectionalPad/utils.js";import u from"./DirectionalPad/VisibleElements.js";import{loadCalciteComponents as p}from"./support/componentsUtils.js";import{globalCss as h}from"./support/globalCss.js";import{isActivationKey as m}from"./support/widgetUtils.js";import{messageBundle as v}from"./support/decorators/messageBundle.js";import{tsx as b}from"./support/jsxFactory.js";let _=class extends s{constructor(t,e){super(t,e),this._buttonsContainer=null,this._buttons={},this.messages=null,this.visibleElements=new u,this.viewModel=new d,this.visualScale="s",this._rotateIcon=t=>({"--rotation":`rotate(${t}deg)`}),this._afterButtonContainerCreate=t=>{this._buttonsContainer=t,this._buttonsContainer.addEventListener("contextmenu",this._onContextMenu,{capture:!0})},this._afterButtonContainerRemoved=()=>{this._buttonsContainer?.removeEventListener("contextmenu",this._onContextMenu,{capture:!0}),this._buttonsContainer=null},this._afterButtonCreate=(t,e)=>{this._buttons[t]=e},this._afterButtonRemoved=t=>{this._buttons[t]=void 0},this._onContextMenu=t=>t.preventDefault(),this._onButtonPointerDown=t=>{if(null===this._buttonsContainer)return;const e=t.target,i=e?.shadowRoot?.querySelector("button");i?.hasPointerCapture(t.pointerId)&&i.releasePointerCapture(t.pointerId);const o=c(this._buttonsContainer);this.viewModel.beginFollowingPointer(t,o)},this._onKeyDown=(t,{key:e})=>{m(e)&&this.viewModel.moveOnce(t)},this._onSliderInput=({target:t})=>{"number"==typeof t.value&&(this.viewModel.rotation=t.value)},this._onRotationReset=()=>{this.viewModel.rotation=0}}loadDependencies(){return p({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-pad":()=>import("@esri/calcite-components/dist/components/calcite-action-pad.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider.js")})}initialize(){this.addHandles(e((()=>this.viewModel.angle),(()=>{const t=this._buttonsContainer?.contains(document.activeElement);t&&(null==this.viewModel.angle?this.container?.focus():this._buttons[this.viewModel.angle]?.setFocus())})))}get disabled(){return this.viewModel.disabled}set disabled(t){this.viewModel.disabled=t}get icon(){return"move"}set icon(t){this._overrideIfSome("icon",t)}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}get speed(){return this.viewModel.speed}set speed(t){this.viewModel.speed=t}get _rotationEnabled(){return!this.view?.ready||this.view.constraints.rotationEnabled}render(){const{label:t,disabled:e,viewModel:i}=this,o=this.classes(l.base,h.widget,e?h.disabled:null);return b("div",{"aria-label":t,class:o,tabIndex:-1},i.supported?this._renderContent():this._renderUnsupportedMessage())}_renderUnsupportedMessage(){return b("section",{class:l.error,key:"unsupported"},b("p",null,this.messages.unsupported))}_renderContent(){return[this.visibleElements.directionalButtons?this._renderDirectionalButtons():void 0,this.visibleElements.rotationSlider?this._renderRotation():void 0]}_renderDirectionalButtons(){return b("calcite-action-pad",{expandDisabled:!0,key:"directional-buttons-container",layout:"grid"},b("calcite-action-group",{afterCreate:this._afterButtonContainerCreate,afterRemoved:this._afterButtonContainerRemoved,class:l.buttonsContainer,dir:"ltr"},r.slice(0,4).map((t=>this._renderButton(t))),this._renderCompass(),r.slice(4).map((t=>this._renderButton(t)))))}_renderButton(t){const{label:e,iconName:i}=a[t];return b("calcite-action",{active:this.viewModel.angle===t,afterCreate:e=>this._afterButtonCreate(t,e),afterRemoved:()=>this._afterButtonRemoved(t),alignment:"center",class:l.button,"data-angle":t.toString(),disabled:this.disabled,key:t,onkeydown:this._onKeyDown.bind(void 0,t),onpointerdown:this._onButtonPointerDown,scale:this.visualScale,text:
|
|
5
|
+
import{_ as t}from"../chunks/tslib.es6.js";import{watch as e}from"../core/reactiveUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";import s from"./Widget.js";import{canShowNorth as n}from"./Compass/utils.js";import{directionalPadAngles as r,directionalPadArrows as a}from"./DirectionalPad/constants.js";import{css as l}from"./DirectionalPad/css.js";import d from"./DirectionalPad/DirectionalPadViewModel.js";import{findElementCenter as c}from"./DirectionalPad/utils.js";import u from"./DirectionalPad/VisibleElements.js";import{loadCalciteComponents as p}from"./support/componentsUtils.js";import{globalCss as h}from"./support/globalCss.js";import{isActivationKey as m}from"./support/widgetUtils.js";import{messageBundle as v}from"./support/decorators/messageBundle.js";import{tsx as b}from"./support/jsxFactory.js";let _=class extends s{constructor(t,e){super(t,e),this._buttonsContainer=null,this._buttons={},this.messages=null,this.visibleElements=new u,this.viewModel=new d,this.visualScale="s",this._rotateIcon=t=>({"--rotation":`rotate(${t}deg)`}),this._afterButtonContainerCreate=t=>{this._buttonsContainer=t,this._buttonsContainer.addEventListener("contextmenu",this._onContextMenu,{capture:!0})},this._afterButtonContainerRemoved=()=>{this._buttonsContainer?.removeEventListener("contextmenu",this._onContextMenu,{capture:!0}),this._buttonsContainer=null},this._afterButtonCreate=(t,e)=>{this._buttons[t]=e},this._afterButtonRemoved=t=>{this._buttons[t]=void 0},this._onContextMenu=t=>t.preventDefault(),this._onButtonPointerDown=t=>{if(null===this._buttonsContainer)return;const e=t.target,i=e?.shadowRoot?.querySelector("button");i?.hasPointerCapture(t.pointerId)&&i.releasePointerCapture(t.pointerId);const o=c(this._buttonsContainer);this.viewModel.beginFollowingPointer(t,o)},this._onKeyDown=(t,{key:e})=>{m(e)&&this.viewModel.moveOnce(t)},this._onSliderInput=({target:t})=>{"number"==typeof t.value&&(this.viewModel.rotation=t.value)},this._onRotationReset=()=>{this.viewModel.rotation=0}}loadDependencies(){return p({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-pad":()=>import("@esri/calcite-components/dist/components/calcite-action-pad.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider.js")})}initialize(){this.addHandles(e((()=>this.viewModel.angle),(()=>{const t=this._buttonsContainer?.contains(document.activeElement);t&&(null==this.viewModel.angle?this.container?.focus():this._buttons[this.viewModel.angle]?.setFocus())})))}get disabled(){return this.viewModel.disabled}set disabled(t){this.viewModel.disabled=t}get icon(){return"move"}set icon(t){this._overrideIfSome("icon",t)}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}get speed(){return this.viewModel.speed}set speed(t){this.viewModel.speed=t}get _rotationEnabled(){return!this.view?.ready||this.view.constraints.rotationEnabled}render(){const{label:t,disabled:e,viewModel:i}=this,o=this.classes(l.base,h.widget,e?h.disabled:null);return b("div",{"aria-label":t,class:o,tabIndex:-1},i.supported?this._renderContent():this._renderUnsupportedMessage())}_renderUnsupportedMessage(){return b("section",{class:l.error,key:"unsupported"},b("p",null,this.messages.unsupported))}_renderContent(){return[this.visibleElements.directionalButtons?this._renderDirectionalButtons():void 0,this.visibleElements.rotationSlider?this._renderRotation():void 0]}_renderDirectionalButtons(){return b("calcite-action-pad",{expandDisabled:!0,key:"directional-buttons-container",layout:"grid"},b("calcite-action-group",{afterCreate:this._afterButtonContainerCreate,afterRemoved:this._afterButtonContainerRemoved,class:l.buttonsContainer,dir:"ltr"},r.slice(0,4).map((t=>this._renderButton(t))),this._renderCompass(),r.slice(4).map((t=>this._renderButton(t)))))}_renderButton(t){const{label:e,iconName:i}=a[t],o=this.messages[e];return b("calcite-action",{active:this.viewModel.angle===t,afterCreate:e=>this._afterButtonCreate(t,e),afterRemoved:()=>this._afterButtonRemoved(t),alignment:"center",class:l.button,"data-angle":t.toString(),disabled:this.disabled,key:t,onkeydown:this._onKeyDown.bind(void 0,t),onpointerdown:this._onButtonPointerDown,scale:this.visualScale,text:o,title:o},b("calcite-icon",{icon:i,scale:this.visualScale}))}_renderCompass(){const t=this.disabled||n(this.view)?"compass-needle":"arrow-up",e=0===this.viewModel.rotation,i=this.messages.resetHeading;return b("calcite-action",{alignment:"center",class:l.compassButton,disabled:this.disabled||!this._rotationEnabled||e,key:"compass",onclick:this._onRotationReset,scale:this.visualScale,styles:this._rotateIcon(this.viewModel.rotation),text:i,title:i},!e&&b("calcite-icon",{icon:t,scale:this.visualScale}))}_renderRotation(){return b("calcite-action-pad",{expandDisabled:!0,key:"slider-container",layout:"horizontal"},b("calcite-action-group",{class:l.rotationContainer},this.visibleElements.rotationResetButton?this._renderRotationResetButton():null,this._renderRotationSlider()))}_renderRotationResetButton(){const t=this.messages.resetHeading;return b("calcite-action",{alignment:"center",class:l.rotationReset,disabled:this.disabled||!this._rotationEnabled,onclick:this._onRotationReset,scale:this.visualScale,text:t,title:t},b("calcite-icon",{flipRtl:!0,icon:"rotate",scale:this.visualScale}))}_renderRotationSlider(){return b("div",{class:l.rotationSliderContainer},b("calcite-slider",{"aria-label":this.messages.heading,disabled:this.disabled||!this._rotationEnabled,labelHandles:!0,max:360,min:0,required:!0,scale:this.visualScale,value:Math.round(this.viewModel.rotation),onCalciteSliderInput:this._onSliderInput}))}};t([i()],_.prototype,"_buttonsContainer",void 0),t([i()],_.prototype,"_buttons",void 0),t([i()],_.prototype,"disabled",null),t([i()],_.prototype,"icon",null),t([i()],_.prototype,"label",null),t([i(),v("esri/widgets/DirectionalPad/t9n/DirectionalPad")],_.prototype,"messages",void 0),t([i({type:u,nonNullable:!0})],_.prototype,"visibleElements",void 0),t([i()],_.prototype,"view",null),t([i()],_.prototype,"viewModel",void 0),t([i()],_.prototype,"visualScale",void 0),t([i()],_.prototype,"speed",null),t([i({readOnly:!0})],_.prototype,"_rotationEnabled",null),_=t([o("esri.widgets.DirectionalPad")],_);const g=_;export{g 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"../../../intl.js";import{destroyMaybe as t}from"../../../core/maybe.js";import{watch as s}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import r from"../../Widget.js";import{legendItemCss as c}from"../css.js";import{Statistics as l}from"./Statistics.js";import{getTranslatedLineTitle as n}from"../support/intlUtils.js";import{loadCalciteComponents as a}from"../../support/componentsUtils.js";import"../../support/widgetUtils.js";import{tsx as p,tsxFragment as d}from"../../support/jsxFactory.js";import{substitute as h}from"../../../intl/substitute.js";let m=class extends r{constructor(e,t){super(e,t),this.checkboxVisible=!0,this.expanded=!1}loadDependencies(){return a({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}initialize(){this._statistics=new l(this._statisticsProps),this.addHandles(s((()=>this._statisticsProps),(e=>this._statistics.set(e))))}destroy(){this._statistics=t(this._statistics)}render(){const e=this.expanded;return p("div",{class:this.classes(c.base,{[c.disabled]:this.disabled,[c.expanded]:e}),key:this},this._renderColorIndicator(),p("div",{class:c.header,key:"header"},this._renderLabelWithCheckbox(),this._renderCollapseToggleButton()),e?p("div",{class:c.content,key:"content"},this._statistics.render()):null)}get disabled(){return!this.line.available}get _statisticsProps(){return{line:this.line,effectiveUnits:this.effectiveUnits}}_renderColorIndicator(){return p("div",{class:c.colorIndicator,key:"color-indicator",styles:{backgroundColor:this.line.color.toCss()}})}_renderCollapseToggleButton(){const{expanded:e,messages:t}=this,s=e?t.hideDetails:t.showDetails;return p("calcite-action",{appearance:"transparent",bind:this,class:c.collapseToggle,"data-testid":"legend-toggle",icon:e?"chevron-up":"chevron-down",key:"collapse-toggle",onclick:this._onCollapseToggleClick,scale:"s",text:s})}_onCollapseToggleClick(){this.onExpandedToggle()}_renderLabelWithCheckbox(){const{line:e,checkboxVisible:t,disabled:s,messages:o}=this,i=`label-${e.id}`;return p("calcite-label",{class:c.label,disabled:s,key:i,layout:"inline"},t?this._renderCheckbox(e.id):null,n(e,o))}_renderCheckbox(e){const{disabled:t,line:s,messages:o}=this,i=s.visible,r=`${e}-checkbox`,l=i?o.hideProfile:o.showProfile,a=h(l,{name:n(s,o)});return p(d,null,p("calcite-checkbox",{checked:i,class:c.checkbox,disabled:t,id:r,key:"checkbox",onCalciteCheckboxChange:()=>s.toggleVisibility()}),p("calcite-tooltip",{overlayPositioning:"fixed",placement:"top",referenceElement:r},a))}};e([o()],m.prototype,"checkboxVisible",void 0),e([o()],m.prototype,"disabled",null),e([o({nonNullable:!0})],m.prototype,"effectiveUnits",void 0),e([o()],m.prototype,"expanded",void 0),e([o({nonNullable:!0})],m.prototype,"line",void 0),e([o()],m.prototype,"messages",void 0),e([o()],m.prototype,"onExpandedToggle",void 0),e([o()],m.prototype,"_statistics",void 0),m=e([i("esri.widgets.ElevationProfile.components.LegendItem")],m);export{m as LegendItem};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{destroyMaybe as t}from"../../../core/maybe.js";import{watch as s}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import r from"../../Widget.js";import{legendItemCss as c}from"../css.js";import{Statistics as l}from"./Statistics.js";import{getTranslatedLineTitle as n}from"../support/intlUtils.js";import{loadCalciteComponents as a}from"../../support/componentsUtils.js";import"../../support/widgetUtils.js";import{tsx as p,tsxFragment as d}from"../../support/jsxFactory.js";import{substitute as h}from"../../../intl/substitute.js";let m=class extends r{constructor(e,t){super(e,t),this.checkboxVisible=!0,this.expanded=!1}loadDependencies(){return a({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}initialize(){this._statistics=new l(this._statisticsProps),this.addHandles(s((()=>this._statisticsProps),(e=>this._statistics.set(e))))}destroy(){this._statistics=t(this._statistics)}render(){const e=this.expanded;return p("div",{class:this.classes(c.base,{[c.disabled]:this.disabled,[c.expanded]:e}),key:this},this._renderColorIndicator(),p("div",{class:c.header,key:"header"},this._renderLabelWithCheckbox(),this._renderCollapseToggleButton()),e?p("div",{class:c.content,key:"content"},this._statistics.render()):null)}get disabled(){return!this.line.available}get _statisticsProps(){return{line:this.line,effectiveUnits:this.effectiveUnits}}_renderColorIndicator(){return p("div",{class:c.colorIndicator,key:"color-indicator",styles:{backgroundColor:this.line.color.toCss()}})}_renderCollapseToggleButton(){const{expanded:e,messages:t}=this,s=e?t.hideDetails:t.showDetails;return p("calcite-action",{appearance:"transparent",bind:this,class:c.collapseToggle,"data-testid":"legend-toggle",icon:e?"chevron-up":"chevron-down",key:"collapse-toggle",onclick:this._onCollapseToggleClick,scale:"s",text:s,title:s})}_onCollapseToggleClick(){this.onExpandedToggle()}_renderLabelWithCheckbox(){const{line:e,checkboxVisible:t,disabled:s,messages:o}=this,i=`label-${e.id}`;return p("calcite-label",{class:c.label,disabled:s,key:i,layout:"inline"},t?this._renderCheckbox(e.id):null,n(e,o))}_renderCheckbox(e){const{disabled:t,line:s,messages:o}=this,i=s.visible,r=`${e}-checkbox`,l=i?o.hideProfile:o.showProfile,a=h(l,{name:n(s,o)});return p(d,null,p("calcite-checkbox",{checked:i,class:c.checkbox,disabled:t,id:r,key:"checkbox",onCalciteCheckboxChange:()=>s.toggleVisibility()}),p("calcite-tooltip",{overlayPositioning:"fixed",placement:"top",referenceElement:r},a))}};e([o()],m.prototype,"checkboxVisible",void 0),e([o()],m.prototype,"disabled",null),e([o({nonNullable:!0})],m.prototype,"effectiveUnits",void 0),e([o()],m.prototype,"expanded",void 0),e([o({nonNullable:!0})],m.prototype,"line",void 0),e([o()],m.prototype,"messages",void 0),e([o()],m.prototype,"onExpandedToggle",void 0),e([o()],m.prototype,"_statistics",void 0),m=e([i("esri.widgets.ElevationProfile.components.LegendItem")],m);export{m as LegendItem};
|
|
@@ -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{on as t}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import r from"../../Widget.js";import{settingsCss as n}from"../css.js";import{loadCalciteComponents as s}from"../../support/componentsUtils.js";import{UnitSelect as c}from"../../support/UnitSelect.js";import"../../support/widgetUtils.js";import{tsx as a}from"../../support/jsxFactory.js";let p=class extends r{constructor(){super(...arguments),this.messages=null,this._popover=null,this._popoverIsOpen=!1,this._onPopoverAfterCreate=e=>{this._popover=e},this._onUniformChartScalingChange=e=>{this.onUniformChartScalingChange(e.target.checked)}}loadDependencies(){return s({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}initialize(){const e=()=>this._popover;this.addHandles([t(e,"calcitePopoverOpen",(()=>this._popoverIsOpen=!0)),t(e,"calcitePopoverClose",(()=>this._popoverIsOpen=!1))])}render(){const{id:e,messages:t,visibleElements:o}=this,{unitSelector:i,uniformChartScalingToggle:r}=o;if(!t||!i&&!r)return a("div",{key:`${e}-empty`});const s=`${e}__action`,c=this._popoverIsOpen?t.hideSettings:t.showSettings;return a("div",{class:n.base,key:this},a("calcite-popover",{afterCreate:this._onPopoverAfterCreate,autoClose:!0,label:c,overlayPositioning:"fixed",placement:"bottom-end",referenceElement:s},this._renderPopoverContent()),a("calcite-action",{appearance:"transparent","data-testid":"settings-button",icon:"gear",id:s,
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{on as t}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import r from"../../Widget.js";import{settingsCss as n}from"../css.js";import{loadCalciteComponents as s}from"../../support/componentsUtils.js";import{UnitSelect as c}from"../../support/UnitSelect.js";import"../../support/widgetUtils.js";import{tsx as a}from"../../support/jsxFactory.js";let p=class extends r{constructor(){super(...arguments),this.messages=null,this._popover=null,this._popoverIsOpen=!1,this._onPopoverAfterCreate=e=>{this._popover=e},this._onUniformChartScalingChange=e=>{this.onUniformChartScalingChange(e.target.checked)}}loadDependencies(){return s({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}initialize(){const e=()=>this._popover;this.addHandles([t(e,"calcitePopoverOpen",(()=>this._popoverIsOpen=!0)),t(e,"calcitePopoverClose",(()=>this._popoverIsOpen=!1))])}render(){const{id:e,messages:t,visibleElements:o}=this,{unitSelector:i,uniformChartScalingToggle:r}=o;if(!t||!i&&!r)return a("div",{key:`${e}-empty`});const s=`${e}__action`,c=this._popoverIsOpen?t.hideSettings:t.showSettings;return a("div",{class:n.base,key:this},a("calcite-popover",{afterCreate:this._onPopoverAfterCreate,autoClose:!0,label:c,overlayPositioning:"fixed",placement:"bottom-end",referenceElement:s},this._renderPopoverContent()),a("calcite-action",{appearance:"transparent","data-testid":"settings-button",icon:"gear",id:s,scale:"s",text:c,title:c}))}_renderPopoverContent(){const{unitSelector:e,uniformChartScalingToggle:t}=this.visibleElements;return a("div",{class:n.popoverContent},e?this._renderUnitSelector():null,t?this._renderUniformChartScalingToggle():null)}_renderUnitSelector(){const{messages:e}=this;return a(c,{key:"unit-selector-label",options:this.unitOptions,selectLabel:e?.unitSelectLabel??"",value:this.unit,onChange:this.onUnitChange})}_renderUniformChartScalingToggle(){const{messages:e}=this,t=this.uniformChartScaling,o=`${this.id}__uniform-chart-scaling-toggle`,i=e?.[t?"uniformChartScalingDisable":"uniformChartScalingEnable"]??"";return a("calcite-label",{class:n.uniformChartScalingLabel,key:"uniform-chart-scaling-label",layout:"inline"},a("calcite-checkbox",{checked:t,class:n.uniformChartScalingCheckbox,id:o,onCalciteCheckboxChange:this._onUniformChartScalingChange}),a("calcite-tooltip",{overlayPositioning:"fixed",referenceElement:o},i),e?.uniformChartScalingLabel)}};e([o()],p.prototype,"messages",void 0),e([o()],p.prototype,"onUniformChartScalingChange",void 0),e([o()],p.prototype,"onUnitChange",void 0),e([o()],p.prototype,"uniformChartScaling",void 0),e([o()],p.prototype,"unit",void 0),e([o()],p.prototype,"unitOptions",void 0),e([o()],p.prototype,"visibleElements",void 0),e([o()],p.prototype,"_popover",void 0),e([o()],p.prototype,"_popoverIsOpen",void 0),p=e([i("esri.widgets.ElevationProfile.components.SettingsButton")],p);export{p as SettingsButton};
|
|
@@ -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 t}from"../chunks/tslib.es6.js";import{createTask as e}from"../core/asyncUtils.js";import{abortMaybe as i,destroyMaybe as s}from"../core/maybe.js";import{memoize as r}from"../core/memoize.js";import{throwIfAborted as n,createAbortError as o}from"../core/promiseUtils.js";import{watch as a,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import{css as p}from"./ElevationProfile/css.js";import u from"./ElevationProfile/ElevationProfileViewModel.js";import m from"./ElevationProfile/ElevationProfileVisibleElements.js";import{Legend as _}from"./ElevationProfile/components/Legend.js";import{SettingsButton as C}from"./ElevationProfile/components/SettingsButton.js";import{ElevationProfileErrorState as v,getConfig as g,ElevationProfileState as f}from"./ElevationProfile/support/constants.js";import{loadCalciteComponents as y}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import{onResize as b}from"./support/widgetUtils.js";import{messageBundle as k}from"./support/decorators/messageBundle.js";import{tsx as S,tsxFragment as M}from"./support/jsxFactory.js";var B;!function(t){t.Sketch="sketch",t.SketchCancel="sketch-cancel",t.SketchDone="sketch-done",t.Select="select",t.SelectCancel="select-cancel"}(B||(B={}));const P=[{type:B.Select},{type:B.Sketch}],E={[v.None]:null,[v.NoValidInput]:"noProfile",[v.NoVisibleProfiles]:"noProfile",[v.RefinedButNoChartData]:"noProfile",[v.TooComplex]:"tooComplex",[v.UnknownError]:"unknown",[v.InvalidGeometry]:"invalidGeometry",[v.InvalidElevationInfo]:"invalidElevationInfo"},j=Symbol("resize-observer-handle");let R=class extends d{constructor(t,e){super(t,e),this.viewModel=null,this.visibleElements=new m,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this._chartContainer=null,this._chart=null,this._chartInitTask=null,this._chartIsRefined=!1,this._width=0,this._zoomOutButtonVisible=!1,this._getChartUpdateParamsMemoized=r(((t,e,i,s)=>({chart:t,data:e,stationary:i,messages:s}))),this._onZoomOutButtonClick=()=>{this._chart?.zoomOut()},this._onClearButtonClick=()=>{this.viewModel.clear()},t?.viewModel||(this._defaultViewModel=new u({view:t?.view}),this.viewModel=this._defaultViewModel)}loadDependencies(){return y({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")})}postInitialize(){this.addHandles([a((()=>({container:this._chartContainer,width:this._width})),(({container:t,width:e})=>{this._destroyChart(),null!=t&&e>0&&this._initializeChart(t)}),l),a((()=>this._chartUpdateParams),(()=>this._updateChart(this._chartUpdateParams)),l)])}destroy(){this._destroyChart(),null!=this._defaultViewModel&&this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}get input(){return this.viewModel.input}set input(t){this.viewModel.input=t}get profiles(){return this.viewModel.profiles}set profiles(t){this.viewModel.profiles=t}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(t){this.viewModel.unitOptions=t}get unit(){return this.viewModel.unit}set unit(t){this.viewModel.unit=t}get geodesicDistanceThreshold(){return this.viewModel.geodesicDistanceThreshold}set geodesicDistanceThreshold(t){this.viewModel.geodesicDistanceThreshold=t}get icon(){return"altitude"}set icon(t){this._overrideIfSome("icon",t)}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get visible(){return this.viewModel.visible}set visible(t){this.viewModel.visible=t}get _portrait(){return this._width<g().portraitModePixelBreakpoint}get _chartUpdateParams(){const t=this.view;return this._getChartUpdateParamsMemoized(this._chart,this.viewModel.chartData,null==t||t.stationary,this._chartMessages)}get _chartMessages(){return{...this.messagesUnits,...this.messages}}get _profilesArray(){return this.profiles.toArray()}render(){const{viewModel:t,visible:e}=this;return S("div",{"aria-label":this.messages.widgetLabel,class:this.classes({[p.base]:e,[w.widget]:e,[w.panel]:e,[w.widgetDisabled]:e&&"disabled"===t.state,[p.portrait]:this._portrait,[p.refined]:1===t.progress}),key:this},S("div",{afterCreate:this._onContentWrapperAfterCreate,afterRemoved:this._onContentWrapperRemoved,bind:this,key:"content-wrapper"},e?this._renderContentForState():null))}_renderContentForState(){switch(this.viewModel.state){case f.Ready:return this._renderContentForReadyState();case f.Selecting:return this._renderContentForSelectingState();case f.Creating:return this._renderContentForCreatingState();case f.Selected:return this._renderContentForSelectedState();case f.Created:return this._renderContentForCreatedState();case f.Disabled:return this._renderContentForReadyState()}}_renderContentForReadyState(){const{sketchButton:t,selectButton:e}=this.visibleElements,i=this.messages;let s;return s=t&&e?i.readyPrompt:t?i.readyPromptCreateOnly:e?i.readyPromptSelectOnly:i.errors?.noProfile,this._renderContent({prompt:s,chart:!1,actions:P})}_renderContentForSelectingState(){const t=this.view;if(null==t)return null;const e=this.messages[`selectingPrompt-${t.type}`];return this._renderContent({prompt:e,chart:!1,actions:[{type:B.SelectCancel}]})}_renderContentForCreatingState(){const{view:t,viewModel:e}=this;if(null==t)return null;const i=e.hasVertices?[{type:B.SketchCancel},{type:B.SketchDone,disabled:!e.tool.interaction.canStopCreating}]:[{type:B.Select},{type:B.Sketch,disabled:!0}];if(e.errorState===v.NoValidInput){const e=this.messages[`creatingPrompt-${t.type}`];return this._renderContent({chart:!1,actions:i,prompt:e})}const s=this._getErrorMessage();return s?this._renderContent({chart:!1,actions:i,prompt:s}):this._renderContent({chart:!0,actions:i})}_renderContentForSelectedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:P,prompt:t}):this._renderContent({chart:!0,actions:P})}_renderContentForCreatedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:P,prompt:t}):this._renderContent({chart:!0,actions:P})}_getErrorMessage(){const t=E[this.viewModel.errorState];return t?this.messages?.errors?.[t]:null}_renderContent(t){const e=null!=t.prompt?this._renderPrompt(t.prompt):t.chart&&this._renderChart(),{viewModel:i}=this,s=null!=i.input;return S(M,null,S("header",{class:p.header,key:"header"},this._zoomOutButtonVisible?this._renderZoomOutButton():null,this.visibleElements.clearButton&&s?this._renderClearButton():null,this.visibleElements.settingsButton?S(C,{messages:this.messages,uniformChartScaling:i.uniformChartScaling,unit:i.unit,unitOptions:i.unitOptions,visibleElements:this.visibleElements,onUniformChartScalingChange:t=>i.uniformChartScaling=t,onUnitChange:t=>i.unit=t}):null),S("div",{class:p.mainContainer,key:"main-container"},e),this.visibleElements.legend?S(_,{effectiveUnits:i.effectiveUnits,messages:this.messages,profiles:this._profilesArray}):null,this._renderActions(t))}_renderZoomOutButton(){return S("calcite-action",{appearance:"transparent",class:p.zoomOutButton,"data-testid":"zoom-out-button",icon:"magnifying-glass-minus",key:"zoom-out",onclick:this._onZoomOutButtonClick,scale:"s",text:this.messages.zoomOut})}_renderClearButton(){return S("calcite-action",{appearance:"transparent",class:p.clearButton,"data-testid":"clear-button",icon:"trash",key:"clear-profile",onclick:this._onClearButtonClick,scale:"s",text:this.messages.clearProfile})}_renderPrompt(t){return[S("div",{bind:this,class:p.promptContainer,key:"prompt-container"},S("p",null,t))]}_renderChart(){if(!this.visibleElements.chart)return S("div",{class:p.chartContainer,key:"empty-chart-container"});const{chartData:t,progress:e}=this.viewModel,i=this._chartIsRefined||this._canRenderChart(),s=null!=t&&e<1;return i?S(M,null,this._renderSpinner({size:i?"small":"large",visible:s}),S("div",{afterCreate:this._onChartContainerAfterCreate,afterRemoved:this._onChartContainerRemoved,bind:this,class:p.chartContainer,key:"chart-container"})):S(M,null,this._renderSpinner({size:"large",visible:s}),S("div",{class:p.chartContainer,key:"chart-container-empty"}))}_renderSpinner(t){const e="small"===t.size,i=t.visible??!0;return S("calcite-loader",{class:this.classes(p.chartSpinner,e&&p.chartSpinnerSmall,i&&p.chartSpinnerVisible),inline:e,key:"spinner",label:"",scale:"s"})}_canRenderChart(){const t=this.viewModel.chartData;if(null==t)return!1;if(!this.viewModel.inputIsSketched)return t.refined;let e=0;for(const{samples:i}of t.lines)e+=null!=i?i.length:0;return t.refined||e<=g().largeChartSamples}_renderActions({actions:t}){const e=t.map((t=>{switch(t.type){case B.Sketch:return this.visibleElements.sketchButton&&this._renderAction({action:t,className:p.sketchButton,label:this.messages.sketchButtonLabel,onClick:this._onSketchButtonClick,primary:!0});case B.SketchCancel:return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:p.sketchCancelButton,label:this.messagesCommon.cancel,primary:!1});case B.SketchDone:return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onDoneButtonClick,className:p.sketchDoneButton,label:this.messagesCommon.done,primary:!0});case B.Select:return this.visibleElements.selectButton&&this._renderAction({action:t,onClick:this._onSelectButtonClick,className:p.selectButton,label:this.messages.selectButtonLabel,primary:!1});case B.SelectCancel:return this.visibleElements.selectButton&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:p.selectCancelButton,label:this.messagesCommon.cancel,primary:!1})}})).filter(Boolean);return e.length?S("footer",{class:p.footer,key:"footer"},e):null}_renderAction({action:t,className:e,label:i,onClick:s,primary:r}){return S("calcite-button",{appearance:r?"solid":"outline-fill",bind:this,class:this.classes(p.actionButton,e),disabled:t.disabled,key:`action-${t.type}`,onclick:s},i)}_onSketchButtonClick(){this.viewModel.start({mode:"sketch"})}_onSelectButtonClick(){this.viewModel.start({mode:"select"})}_onCancelButtonClick(){this.viewModel.cancel()}_onDoneButtonClick(){this.viewModel.stop()}_onContentWrapperAfterCreate(t){const e=b(t,(t=>{this._width=t.contentRect.width}));this.addHandles(e,j)}_onContentWrapperRemoved(){this.removeHandles(j)}_updateChart(t){const{data:e,chart:i,messages:s,stationary:r}=t;null!=i&&null!=s&&r&&this._canRenderChart()&&(i.update(t),this._chartIsRefined=null!=e&&e.refined)}_onChartContainerAfterCreate(t){this._chartContainer=t}_onChartContainerRemoved(){this._chartContainer=null}_initializeChart(t){i(this._chartInitTask),this._chartInitTask=e((async e=>{const{createChart:i}=await import("./ElevationProfile/support/chartUtils.js");n(e);const r=await i({container:t,abortOptions:{signal:e},onRangeChange:(t,e)=>{this._zoomOutButtonVisible=1!==t||1!==e},onCursorPositionChange:t=>{this.viewModel.hoveredChartPosition=t}});if(e.aborted)throw s(r),o();this._chart=r,this._updateChart(this._chartUpdateParams)}))}_destroyChart(){this._chartInitTask=i(this._chartInitTask),this._chart=s(this._chart),this._chartIsRefined=!1}};t([c({type:u})],R.prototype,"viewModel",void 0),t([c()],R.prototype,"view",null),t([c()],R.prototype,"input",null),t([c()],R.prototype,"profiles",null),t([c()],R.prototype,"unitOptions",null),t([c()],R.prototype,"unit",null),t([c()],R.prototype,"geodesicDistanceThreshold",null),t([c({type:m,nonNullable:!0})],R.prototype,"visibleElements",void 0),t([c()],R.prototype,"icon",null),t([c()],R.prototype,"label",null),t([c()],R.prototype,"visible",null),t([c(),k("esri/widgets/ElevationProfile/t9n/ElevationProfile")],R.prototype,"messages",void 0),t([c(),k("esri/t9n/common")],R.prototype,"messagesCommon",void 0),t([c(),k("esri/core/t9n/Units")],R.prototype,"messagesUnits",void 0),t([c()],R.prototype,"_chartContainer",void 0),t([c()],R.prototype,"_chart",void 0),t([c()],R.prototype,"_chartInitTask",void 0),t([c()],R.prototype,"_chartIsRefined",void 0),t([c()],R.prototype,"_width",void 0),t([c()],R.prototype,"_portrait",null),t([c()],R.prototype,"_zoomOutButtonVisible",void 0),t([c()],R.prototype,"_chartUpdateParams",null),t([c()],R.prototype,"_chartMessages",null),t([c()],R.prototype,"_profilesArray",null),R=t([h("esri.widgets.ElevationProfile")],R);const U=R;export{U as default};
|
|
5
|
+
import{_ as t}from"../chunks/tslib.es6.js";import{createTask as e}from"../core/asyncUtils.js";import{abortMaybe as i,destroyMaybe as s}from"../core/maybe.js";import{memoize as r}from"../core/memoize.js";import{throwIfAborted as n,createAbortError as o}from"../core/promiseUtils.js";import{watch as a,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import{css as p}from"./ElevationProfile/css.js";import u from"./ElevationProfile/ElevationProfileViewModel.js";import m from"./ElevationProfile/ElevationProfileVisibleElements.js";import{Legend as _}from"./ElevationProfile/components/Legend.js";import{SettingsButton as C}from"./ElevationProfile/components/SettingsButton.js";import{ElevationProfileErrorState as v,getConfig as g,ElevationProfileState as f}from"./ElevationProfile/support/constants.js";import{loadCalciteComponents as y}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import{onResize as b}from"./support/widgetUtils.js";import{messageBundle as k}from"./support/decorators/messageBundle.js";import{tsx as S,tsxFragment as M}from"./support/jsxFactory.js";var B;!function(t){t.Sketch="sketch",t.SketchCancel="sketch-cancel",t.SketchDone="sketch-done",t.Select="select",t.SelectCancel="select-cancel"}(B||(B={}));const P=[{type:B.Select},{type:B.Sketch}],E={[v.None]:null,[v.NoValidInput]:"noProfile",[v.NoVisibleProfiles]:"noProfile",[v.RefinedButNoChartData]:"noProfile",[v.TooComplex]:"tooComplex",[v.UnknownError]:"unknown",[v.InvalidGeometry]:"invalidGeometry",[v.InvalidElevationInfo]:"invalidElevationInfo"},j=Symbol("resize-observer-handle");let R=class extends d{constructor(t,e){super(t,e),this.viewModel=null,this.visibleElements=new m,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this._chartContainer=null,this._chart=null,this._chartInitTask=null,this._chartIsRefined=!1,this._width=0,this._zoomOutButtonVisible=!1,this._getChartUpdateParamsMemoized=r(((t,e,i,s)=>({chart:t,data:e,stationary:i,messages:s}))),this._onZoomOutButtonClick=()=>{this._chart?.zoomOut()},this._onClearButtonClick=()=>{this.viewModel.clear()},t?.viewModel||(this._defaultViewModel=new u({view:t?.view}),this.viewModel=this._defaultViewModel)}loadDependencies(){return y({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")})}postInitialize(){this.addHandles([a((()=>({container:this._chartContainer,width:this._width})),(({container:t,width:e})=>{this._destroyChart(),null!=t&&e>0&&this._initializeChart(t)}),l),a((()=>this._chartUpdateParams),(()=>this._updateChart(this._chartUpdateParams)),l)])}destroy(){this._destroyChart(),null!=this._defaultViewModel&&this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}get input(){return this.viewModel.input}set input(t){this.viewModel.input=t}get profiles(){return this.viewModel.profiles}set profiles(t){this.viewModel.profiles=t}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(t){this.viewModel.unitOptions=t}get unit(){return this.viewModel.unit}set unit(t){this.viewModel.unit=t}get geodesicDistanceThreshold(){return this.viewModel.geodesicDistanceThreshold}set geodesicDistanceThreshold(t){this.viewModel.geodesicDistanceThreshold=t}get icon(){return"altitude"}set icon(t){this._overrideIfSome("icon",t)}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get visible(){return this.viewModel.visible}set visible(t){this.viewModel.visible=t}get _portrait(){return this._width<g().portraitModePixelBreakpoint}get _chartUpdateParams(){const t=this.view;return this._getChartUpdateParamsMemoized(this._chart,this.viewModel.chartData,null==t||t.stationary,this._chartMessages)}get _chartMessages(){return{...this.messagesUnits,...this.messages}}get _profilesArray(){return this.profiles.toArray()}render(){const{viewModel:t,visible:e}=this;return S("div",{"aria-label":this.messages.widgetLabel,class:this.classes({[p.base]:e,[w.widget]:e,[w.panel]:e,[w.widgetDisabled]:e&&"disabled"===t.state,[p.portrait]:this._portrait,[p.refined]:1===t.progress}),key:this},S("div",{afterCreate:this._onContentWrapperAfterCreate,afterRemoved:this._onContentWrapperRemoved,bind:this,key:"content-wrapper"},e?this._renderContentForState():null))}_renderContentForState(){switch(this.viewModel.state){case f.Ready:return this._renderContentForReadyState();case f.Selecting:return this._renderContentForSelectingState();case f.Creating:return this._renderContentForCreatingState();case f.Selected:return this._renderContentForSelectedState();case f.Created:return this._renderContentForCreatedState();case f.Disabled:return this._renderContentForReadyState()}}_renderContentForReadyState(){const{sketchButton:t,selectButton:e}=this.visibleElements,i=this.messages;let s;return s=t&&e?i.readyPrompt:t?i.readyPromptCreateOnly:e?i.readyPromptSelectOnly:i.errors?.noProfile,this._renderContent({prompt:s,chart:!1,actions:P})}_renderContentForSelectingState(){const t=this.view;if(null==t)return null;const e=this.messages[`selectingPrompt-${t.type}`];return this._renderContent({prompt:e,chart:!1,actions:[{type:B.SelectCancel}]})}_renderContentForCreatingState(){const{view:t,viewModel:e}=this;if(null==t)return null;const i=e.hasVertices?[{type:B.SketchCancel},{type:B.SketchDone,disabled:!e.tool.interaction.canStopCreating}]:[{type:B.Select},{type:B.Sketch,disabled:!0}];if(e.errorState===v.NoValidInput){const e=this.messages[`creatingPrompt-${t.type}`];return this._renderContent({chart:!1,actions:i,prompt:e})}const s=this._getErrorMessage();return s?this._renderContent({chart:!1,actions:i,prompt:s}):this._renderContent({chart:!0,actions:i})}_renderContentForSelectedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:P,prompt:t}):this._renderContent({chart:!0,actions:P})}_renderContentForCreatedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:P,prompt:t}):this._renderContent({chart:!0,actions:P})}_getErrorMessage(){const t=E[this.viewModel.errorState];return t?this.messages?.errors?.[t]:null}_renderContent(t){const e=null!=t.prompt?this._renderPrompt(t.prompt):t.chart&&this._renderChart(),{viewModel:i}=this,s=null!=i.input;return S(M,null,S("header",{class:p.header,key:"header"},this._zoomOutButtonVisible?this._renderZoomOutButton():null,this.visibleElements.clearButton&&s?this._renderClearButton():null,this.visibleElements.settingsButton?S(C,{messages:this.messages,uniformChartScaling:i.uniformChartScaling,unit:i.unit,unitOptions:i.unitOptions,visibleElements:this.visibleElements,onUniformChartScalingChange:t=>i.uniformChartScaling=t,onUnitChange:t=>i.unit=t}):null),S("div",{class:p.mainContainer,key:"main-container"},e),this.visibleElements.legend?S(_,{effectiveUnits:i.effectiveUnits,messages:this.messages,profiles:this._profilesArray}):null,this._renderActions(t))}_renderZoomOutButton(){const t=this.messages.zoomOut;return S("calcite-action",{appearance:"transparent",class:p.zoomOutButton,"data-testid":"zoom-out-button",icon:"magnifying-glass-minus",key:"zoom-out",onclick:this._onZoomOutButtonClick,scale:"s",text:t,title:t})}_renderClearButton(){const t=this.messages.clearProfile;return S("calcite-action",{appearance:"transparent",class:p.clearButton,"data-testid":"clear-button",icon:"trash",key:"clear-profile",onclick:this._onClearButtonClick,scale:"s",text:t,title:t})}_renderPrompt(t){return[S("div",{bind:this,class:p.promptContainer,key:"prompt-container"},S("p",null,t))]}_renderChart(){if(!this.visibleElements.chart)return S("div",{class:p.chartContainer,key:"empty-chart-container"});const{chartData:t,progress:e}=this.viewModel,i=this._chartIsRefined||this._canRenderChart(),s=null!=t&&e<1;return i?S(M,null,this._renderSpinner({size:i?"small":"large",visible:s}),S("div",{afterCreate:this._onChartContainerAfterCreate,afterRemoved:this._onChartContainerRemoved,bind:this,class:p.chartContainer,key:"chart-container"})):S(M,null,this._renderSpinner({size:"large",visible:s}),S("div",{class:p.chartContainer,key:"chart-container-empty"}))}_renderSpinner(t){const e="small"===t.size,i=t.visible??!0;return S("calcite-loader",{class:this.classes(p.chartSpinner,e&&p.chartSpinnerSmall,i&&p.chartSpinnerVisible),inline:e,key:"spinner",label:"",scale:"s"})}_canRenderChart(){const t=this.viewModel.chartData;if(null==t)return!1;if(!this.viewModel.inputIsSketched)return t.refined;let e=0;for(const{samples:i}of t.lines)e+=null!=i?i.length:0;return t.refined||e<=g().largeChartSamples}_renderActions({actions:t}){const e=t.map((t=>{switch(t.type){case B.Sketch:return this.visibleElements.sketchButton&&this._renderAction({action:t,className:p.sketchButton,label:this.messages.sketchButtonLabel,onClick:this._onSketchButtonClick,primary:!0});case B.SketchCancel:return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:p.sketchCancelButton,label:this.messagesCommon.cancel,primary:!1});case B.SketchDone:return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onDoneButtonClick,className:p.sketchDoneButton,label:this.messagesCommon.done,primary:!0});case B.Select:return this.visibleElements.selectButton&&this._renderAction({action:t,onClick:this._onSelectButtonClick,className:p.selectButton,label:this.messages.selectButtonLabel,primary:!1});case B.SelectCancel:return this.visibleElements.selectButton&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:p.selectCancelButton,label:this.messagesCommon.cancel,primary:!1})}})).filter(Boolean);return e.length?S("footer",{class:p.footer,key:"footer"},e):null}_renderAction({action:t,className:e,label:i,onClick:s,primary:r}){return S("calcite-button",{appearance:r?"solid":"outline-fill",bind:this,class:this.classes(p.actionButton,e),disabled:t.disabled,key:`action-${t.type}`,onclick:s},i)}_onSketchButtonClick(){this.viewModel.start({mode:"sketch"})}_onSelectButtonClick(){this.viewModel.start({mode:"select"})}_onCancelButtonClick(){this.viewModel.cancel()}_onDoneButtonClick(){this.viewModel.stop()}_onContentWrapperAfterCreate(t){const e=b(t,(t=>{this._width=t.contentRect.width}));this.addHandles(e,j)}_onContentWrapperRemoved(){this.removeHandles(j)}_updateChart(t){const{data:e,chart:i,messages:s,stationary:r}=t;null!=i&&null!=s&&r&&this._canRenderChart()&&(i.update(t),this._chartIsRefined=null!=e&&e.refined)}_onChartContainerAfterCreate(t){this._chartContainer=t}_onChartContainerRemoved(){this._chartContainer=null}_initializeChart(t){i(this._chartInitTask),this._chartInitTask=e((async e=>{const{createChart:i}=await import("./ElevationProfile/support/chartUtils.js");n(e);const r=await i({container:t,abortOptions:{signal:e},onRangeChange:(t,e)=>{this._zoomOutButtonVisible=1!==t||1!==e},onCursorPositionChange:t=>{this.viewModel.hoveredChartPosition=t}});if(e.aborted)throw s(r),o();this._chart=r,this._updateChart(this._chartUpdateParams)}))}_destroyChart(){this._chartInitTask=i(this._chartInitTask),this._chart=s(this._chart),this._chartIsRefined=!1}};t([c({type:u})],R.prototype,"viewModel",void 0),t([c()],R.prototype,"view",null),t([c()],R.prototype,"input",null),t([c()],R.prototype,"profiles",null),t([c()],R.prototype,"unitOptions",null),t([c()],R.prototype,"unit",null),t([c()],R.prototype,"geodesicDistanceThreshold",null),t([c({type:m,nonNullable:!0})],R.prototype,"visibleElements",void 0),t([c()],R.prototype,"icon",null),t([c()],R.prototype,"label",null),t([c()],R.prototype,"visible",null),t([c(),k("esri/widgets/ElevationProfile/t9n/ElevationProfile")],R.prototype,"messages",void 0),t([c(),k("esri/t9n/common")],R.prototype,"messagesCommon",void 0),t([c(),k("esri/core/t9n/Units")],R.prototype,"messagesUnits",void 0),t([c()],R.prototype,"_chartContainer",void 0),t([c()],R.prototype,"_chart",void 0),t([c()],R.prototype,"_chartInitTask",void 0),t([c()],R.prototype,"_chartIsRefined",void 0),t([c()],R.prototype,"_width",void 0),t([c()],R.prototype,"_portrait",null),t([c()],R.prototype,"_zoomOutButtonVisible",void 0),t([c()],R.prototype,"_chartUpdateParams",null),t([c()],R.prototype,"_chartMessages",null),t([c()],R.prototype,"_profilesArray",null),R=t([h("esri.widgets.ElevationProfile")],R);const U=R;export{U 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{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import s from"../Widget.js";import{css as i}from"./css.js";import{loadCalciteComponents as r}from"../support/componentsUtils.js";import"../support/widgetUtils.js";import{messageBundle as l}from"../support/decorators/messageBundle.js";import{tsx as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import s from"../Widget.js";import{css as i}from"./css.js";import{loadCalciteComponents as r}from"../support/componentsUtils.js";import"../support/widgetUtils.js";import{messageBundle as l}from"../support/decorators/messageBundle.js";import{tsx as c,tsxFragment as a}from"../support/jsxFactory.js";let n=class extends s{constructor(e,t){super(e,t),this.messages=null,this.closed=!1,this.closable=!0,this._handleOpenRelatedFeature=e=>{this.emit("open-related-feature",{feature:e})}}loadDependencies(){return r({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js")})}render(){const{flowItems:e}=this,t=e?.toArray();return c(a,null,t?.map((e=>this._renderRelatedRecordsFlowItem(e))))}_handleCloseClick(){this.emit("close")}_handleExitClick(){this.emit("exit")}_handleRelatedRecordsBackClick(){const e=this.flowItems?.pop();e&&("showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e&&(e.viewModel=null,e.destroy()))}_renderRelatedRecordsFlowItem(e){const{messages:t,closable:o,closed:s}=this,r="graphic"in e&&!e.isTable,l=t.exitRelatedRecords,a=t.selectFeature;return c("calcite-flow-item",{bind:this,closable:o,closed:s,description:this._getRelatedRecordsFlowItemDescription(e),heading:e.title??"",key:`flow-item-${e.viewModel.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleRelatedRecordsBackClick()},onCalciteFlowItemClose:this._handleCloseClick},c("calcite-action",{appearance:"transparent",bind:this,class:i.actionExit,icon:"move-up",key:"exit-related-records-action",onclick:this._handleExitClick,slot:"header-actions-start",text:l,title:l}),r?c("calcite-action",{appearance:"transparent",bind:this,icon:"zoom-to-object",key:"open-related-feature-action",onclick:()=>this._handleOpenRelatedFeature(e),slot:"header-actions-end",text:a,title:a}):null,c("div",{class:i.container},e.render()))}_getRelatedRecordsFlowItemDescription(e){return"featureCountDescription"in e?e.featureCountDescription:e.viewModel.description??""}};e([t()],n.prototype,"flowItems",void 0),e([t(),l("esri/widgets/Features/t9n/Features")],n.prototype,"messages",void 0),e([t()],n.prototype,"closed",void 0),e([t()],n.prototype,"closable",void 0),n=e([o("esri.widgets.Features.FeaturesRelatedRecords")],n);const d=n;export{d as default};
|
package/widgets/Features.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 i from"../core/Logger.js";import{watch as o,when as s}from"../core/reactiveUtils.js";import{throttle as r}from"../core/throttle.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{getPointFromGeometry as l}from"../geometry/support/geometryUtils.js";import{substituteActionImage as d,getActionStyles as c}from"../support/actions/actionUtils.js";import u from"./Feature.js";import h from"./Spinner.js";import p from"./Widget.js";import{css as m}from"./Feature/resources.js";import{FeatureContentMixin as v}from"./Feature/support/FeatureContentMixin.js";import{css as w}from"./Features/css.js";import _ from"./Features/FeaturesRelatedRecords.js";import g from"./Features/FeaturesViewModel.js";import f from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as M}from"./Popup/actions.js";import{loadCalciteComponents as F}from"./support/componentsUtils.js";import{globalCss as b}from"./support/globalCss.js";import{Heading as y}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as I}from"./support/decorators/messageBundle.js";import{vmEvent as C}from"./support/decorators/vmEvent.js";import{tsx as A}from"./support/jsxFactory.js";import{substitute as N}from"../intl/substitute.js";import{formatNumber as x}from"../intl/number.js";const O="selected-index",R=0,j="features-spinner",k=50;let T=class extends(v(p)){constructor(e,i){super(e,i),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._focusOn=null,this._spinner=null,this._feature=null,this._relatedRecordsFlowItems=new t,this._relatedRecordsWidget=new _({flowItems:this._relatedRecordsFlowItems}),this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this._actionBarMenuNode=null,this.collapsed=!1,this.featureNavigationTop=!1,this.headerActions=new M,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new g,this.visibleElements=new f,this._renderAction=(e,t)=>{const i=this._getActionTitle(e),{type:o,active:s,uid:r,disabled:n,indicator:a}=e;return e.visible?A("calcite-action",{active:"toggle"===o&&e.value,appearance:"solid",bind:this,"data-action-uid":r,disabled:n,icon:this._getActionIcon(e),indicator:a,key:`action-${t}`,loading:s,onclick:this._triggerAction,scale:"s",text:i,title:this._hideActionText?i:void 0},this._getFallbackIcon(e)):null},this._openFeatureMenu=()=>{this.featureMenuOpen=!0,this._focusOn="menu-flow-item"},this._previousFeature=()=>{this.viewModel.selectedFeatureIndex--},this._nextFeature=()=>{this.viewModel.selectedFeatureIndex++},this._handleFeatureMenuBack=()=>{this.featureMenuOpen&&(this._focusOn="root-flow-item",this.featureMenuOpen=!1)},this._focusFlowItemNode=e=>{this._focusOn===e&&requestAnimationFrame((async()=>{switch(e){case"menu-flow-item":await(this._featureMenuViewportNode?.setFocus());break;case"root-flow-item":await(this._rootFlowItemNode?.setFocus())}this._focusOn=null}))},this._focusFlowItemNodeThrottled=r(this._focusFlowItemNode,k),this._displaySpinnerThrottled=r((()=>this._displaySpinner()),R),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,this._focusFlowItemNodeThrottled,o((()=>this.viewModel?.active),(()=>this._toggleScreenLocationEnabled())),o((()=>this.viewModel?.active),(e=>this._relatedRecordsWidget.closed=!e)),o((()=>this.visibleElements?.closeButton),(e=>this._relatedRecordsWidget.closable=e)),o((()=>this.visibleElements?.spinner),(e=>this._spinnerEnabledChange(e))),o((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),o((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),o((()=>[this.viewModel?.waitingForResult,this.viewModel?.location]),(()=>{this._hideSpinner(),this._displaySpinnerThrottled()})),o((()=>this.viewModel?.screenLocation),(()=>this._closeOpenActionMenu())),o((()=>this.selectedFeatureWidget),(()=>this._destroyRelatedRecordsFlowItemWidgets())),o((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]}),(()=>this._setTitleFromFeatureWidget())),o((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]}),(()=>this._setContentFromFeatureWidget())),o((()=>this.viewModel?.featureViewModels),(()=>this._featureMenuViewportScrollTop())),this._relatedRecordsWidget.on("close",(()=>this.close())),this._relatedRecordsWidget.on("exit",(()=>this._destroyRelatedRecordsFlowItemWidgets())),this._relatedRecordsWidget.on("open-related-feature",(({feature:e})=>this._openRelatedFeature(e)))])}loadDependencies(){return F({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.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"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")})}destroy(){this._destroyRelatedRecordsFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._relatedRecordsWidget?.destroy()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&!!this.title&&!!this.content}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get icon(){return null}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_relatedRecordsFlowItems:i}=this,{selectedFeatureViewModel:o}=this.viewModel,s={title:!1};return o?(e?(e.viewModel=o,e.visibleElements=s):this._feature=new u({flowItems:i,headingLevel:t+1,viewModel:o,visibleElements:s}),this._feature):null}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e?this._rootFlowItemNode?.blur():i.getLogger(this).warn("Features can only be blurred when currently active.")}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e?this._setFocusOn():i.getLogger(this).warn("Features can only be focused when currently active.")}next(){return this.viewModel.next()}open(e){this.removeHandles(O);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(s((()=>!this.viewModel.waitingForResult),(()=>this._addSelectedFeatureIndexHandle()),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return A("div",{bind:this,class:this.classes(w.base,b.widget,b.panel),onkeydown:this._onMainKeydown},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),this._renderFeatureMenuButton()]}_renderHeader(){return!this.featureMenuOpen&&this.featureNavigationTop&&this._featureNavigationVisible?A("div",{class:w.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return this.featureMenuOpen||this.featureNavigationTop||!this._featureNavigationVisible?null:A("div",{class:w.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation())}_renderFeatureMenuButton(){const{messages:e,viewModel:t}=this,{featureCount:i,selectedFeatureIndex:o,pendingPromisesCount:s}=t;return A("calcite-action",{appearance:"solid",bind:this,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:s>0,onclick:this._openFeatureMenu,scale:"s",text:N(e.pageText,{index:x(o+1),total:x(i)}),textEnabled:!0,title:e.selectFeature})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return A("calcite-action-bar",{class:w.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},A("calcite-action-group",{scale:"s"},A("calcite-action",{appearance:"solid",class:w.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,onclick:this._previousFeature,scale:"s",text:e,title:e}),A("calcite-action",{appearance:"solid",icon:"chevron-right",iconFlipRtl:!0,label:t,onclick:this._nextFeature,scale:"s",text:t,title:t})))}_renderFeatureMenuItem(e){const{selectedFeatureViewModel:t,featureViewModels:i}=this.viewModel,o=e===t,s=i.indexOf(e);return A("calcite-list-item",{bind:this,"data-feature-index":s,key:`feature-menu-item-${e.uid}`,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature,selected:o,onCalciteListItemSelect:this._selectFeature},A("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}))}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach((e=>{const i=e?.graphic;if(!i)return;const o=i.sourceLayer??i.layer,s=t.get(o)??[];t.set(o,[...s,e])})),t}_renderFeatureMenu(){const{featureViewModels:e}=this.viewModel,t=this._groupResultsByLayer();return e.length?A("calcite-list",{selectionAppearance:"icon",selectionMode:"single"},Array.from(t.keys()).map((e=>A("calcite-list-item-group",{heading:e?.title??this.messagesCommon.untitled,key:e?.uid||"untitled"},t.get(e)?.map((e=>this._renderFeatureMenuItem(e))))))):null}_renderHeaderAction(e,t){return e.visible?A("calcite-action",{active:"toggle"===e.type&&e.value,appearance:"solid",bind:this,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon||"",indicator:e.indicator,key:`header-action-${t}`,loading:e.active,onclick:this._triggerHeaderAction,slot:"header-actions-end",text:e.title||"",title:e.title||""}):null}_renderHeaderActions(){return this.headerActions.map(((e,t)=>this._renderHeaderAction(e,t))).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:o,featureNavigationTop:s}=this,{title:r,active:n}=this.viewModel,a=t.heading&&r?r:"";return A("calcite-flow-item",{afterCreate:this._storeRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,class:this.classes({[w.contentFeature]:!0,[w.flowItemCollapsed]:i}),closable:t.closeButton,closed:!n,collapsed:i,collapseDirection:s?"down":"up",collapsible:o,headingLevel:e,key:"root-flow-item",onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},a?A(y,{class:this.classes(w.featuresHeading,b.heading),innerHTML:a,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),i?null:A("div",{class:this.classes(w.container,w.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,featureMenuOpen:t,messages:i,messagesCommon:o}=this,{active:s,featureViewModels:r,pendingPromisesCount:n}=e;return t?A("calcite-flow-item",{afterCreate:this._storeFeatureMenuFlowItemNode,afterUpdate:this._focusFeatureMenuFlowItemNode,bind:this,closable:!1,closed:!s,description:N(i.total,{total:r.length}),heading:i.selectFeature,key:"feature-menu",loading:e.waitingForContents,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleFeatureMenuBack()}},n>0?A("calcite-loader",{class:w.loader,inline:!0,key:"feature-menu-loader",label:o.loading,slot:"header-actions-end"}):null,A("div",{class:w.container},this._renderFeatureMenu()),A("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:w.featureMenuObserver}),A("calcite-button",{appearance:"transparent",onclick:this._handleFeatureMenuBack,slot:"footer-actions",width:"full"},o.back)):null}_renderContentContainer(){const e=[this._renderContentFeature(),this._renderFeatureMenuContainer(),this._relatedRecordsWidget.render()];return this.visibleElements.flow?A("calcite-flow",{key:"content-container"},e):e}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=d({action:e,feature:this.selectedFeature}),s={[w.icon]:!!t,[w.actionImage]:!!o};return t&&(s[t]=!0),o||t?A("span",{"aria-hidden":"true",class:this.classes(w.icon,s),key:"icon",styles:c(o)}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?A("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},A("calcite-action-group",{afterCreate:e=>this._actionBarMenuNode=e,overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?A("div",{class:m.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_setFocusOn(){this.renderNow(),requestAnimationFrame((()=>{this._focusOn=this.featureMenuOpen?"menu-flow-item":"root-flow-item"}))}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyRelatedRecordsFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=l(i);this.open({features:[t],location:null!=o?o:void 0})}_focusRootFlowItemNode(){this._focusFlowItemNodeThrottled("root-flow-item")}_focusFeatureMenuFlowItemNode(){this._focusFlowItemNodeThrottled("menu-flow-item")}_storeRootFlowItemNode(e){this._rootFlowItemNode=e,this._focusFlowItemNodeThrottled("root-flow-item")}_storeFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e,this._focusFlowItemNodeThrottled("menu-flow-item")}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),this._handleFeatureMenuBack()}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionIcon(e){return e.icon?e.icon:e.image||e.className?void 0:"question"}_getActionTitle(e){const{messages:t,selectedFeature:i,messagesCommon:o}=this,{id:s}=e,r=i?.attributes,n=e.title??"",a="zoom-to-feature"===s?N(n,{messages:t}):"remove-selected-feature"===s?N(n,{messages:o}):"zoom-to-clustered-features"===s||"browse-clustered-features"===s?N(n,{messages:t}):e.title;return a&&r?N(a,r):a??""}_onMainKeydown(e){const{key:t}=e;"ArrowLeft"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode&&this._featureMenuViewportNode.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=o((()=>this.viewModel?.selectedFeatureIndex),((e,t)=>this._selectedFeatureIndexUpdated(e,t)));this.addHandles(e,O)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyRelatedRecordsFlowItemWidgets(),this._rootFlowItemNode&&this._rootFlowItemNode.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find((({uid:e})=>e===i));o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex((e=>e.uid===i)),r=o.at(s);r&&"toggle"===r.type&&(r.value=!r.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new h({view:e}),e.ui.add(this._spinner,{key:j,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_closeOpenActionMenu(){const{_actionBarMenuNode:e}=this;e&&(e.menuOpen=!1)}_destroyRelatedRecordsFlowItemWidgets(){this._relatedRecordsFlowItems.removeAll().forEach((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}))}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t?.ui?.remove(e,j),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([n()],T.prototype,"_focusOn",void 0),e([n()],T.prototype,"_relatedRecordsFlowItems",void 0),e([n()],T.prototype,"_hideActionText",null),e([n()],T.prototype,"_featureNavigationVisible",null),e([n()],T.prototype,"_isCollapsed",null),e([n()],T.prototype,"_collapseEnabled",null),e([n()],T.prototype,"collapsed",void 0),e([n()],T.prototype,"content",null),e([n()],T.prototype,"icon",null),e([n()],T.prototype,"featureMenuOpen",null),e([n()],T.prototype,"featureNavigationTop",void 0),e([n()],T.prototype,"features",null),e([n({type:M})],T.prototype,"headerActions",void 0),e([n()],T.prototype,"headingLevel",void 0),e([n()],T.prototype,"location",null),e([n()],T.prototype,"label",null),e([n(),I("esri/widgets/Features/t9n/Features")],T.prototype,"messages",void 0),e([n(),I("esri/t9n/common")],T.prototype,"messagesCommon",void 0),e([n()],T.prototype,"promises",null),e([n()],T.prototype,"responsiveActionsEnabled",void 0),e([n({readOnly:!0})],T.prototype,"selectedFeature",null),e([n()],T.prototype,"selectedFeatureIndex",null),e([n({readOnly:!0})],T.prototype,"selectedFeatureWidget",null),e([n()],T.prototype,"title",null),e([n()],T.prototype,"updateLocationEnabled",null),e([n()],T.prototype,"view",null),e([n({type:g}),C(["triggerAction","trigger-action"])],T.prototype,"viewModel",void 0),e([n({type:f,nonNullable:!0})],T.prototype,"visibleElements",void 0),e([n()],T.prototype,"visible",null),T=e([a("esri.widgets.Features")],T);const E=T;export{E as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import i from"../core/Logger.js";import{watch as o,when as s}from"../core/reactiveUtils.js";import{throttle as r}from"../core/throttle.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{getPointFromGeometry as l}from"../geometry/support/geometryUtils.js";import{substituteActionImage as d,getActionStyles as c}from"../support/actions/actionUtils.js";import u from"./Feature.js";import h from"./Spinner.js";import p from"./Widget.js";import{css as m}from"./Feature/resources.js";import{FeatureContentMixin as v}from"./Feature/support/FeatureContentMixin.js";import{css as w}from"./Features/css.js";import _ from"./Features/FeaturesRelatedRecords.js";import g from"./Features/FeaturesViewModel.js";import f from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as M}from"./Popup/actions.js";import{loadCalciteComponents as F}from"./support/componentsUtils.js";import{globalCss as b}from"./support/globalCss.js";import{Heading as y}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as I}from"./support/decorators/messageBundle.js";import{vmEvent as C}from"./support/decorators/vmEvent.js";import{tsx as A}from"./support/jsxFactory.js";import{substitute as N}from"../intl/substitute.js";import{formatNumber as x}from"../intl/number.js";const O="selected-index",R=0,j="features-spinner",k=50;let T=class extends(v(p)){constructor(e,i){super(e,i),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._focusOn=null,this._spinner=null,this._feature=null,this._relatedRecordsFlowItems=new t,this._relatedRecordsWidget=new _({flowItems:this._relatedRecordsFlowItems}),this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this._actionBarMenuNode=null,this.collapsed=!1,this.featureNavigationTop=!1,this.headerActions=new M,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new g,this.visibleElements=new f,this._renderAction=(e,t)=>{const i=this._getActionTitle(e),{type:o,active:s,uid:r,disabled:n,indicator:a}=e;return e.visible?A("calcite-action",{active:"toggle"===o&&e.value,appearance:"solid",bind:this,"data-action-uid":r,disabled:n,icon:this._getActionIcon(e),indicator:a,key:`action-${t}`,loading:s,onclick:this._triggerAction,scale:"s",text:i,title:this._hideActionText?i:void 0},this._getFallbackIcon(e)):null},this._openFeatureMenu=()=>{this.featureMenuOpen=!0,this._focusOn="menu-flow-item"},this._previousFeature=()=>{this.viewModel.selectedFeatureIndex--},this._nextFeature=()=>{this.viewModel.selectedFeatureIndex++},this._handleFeatureMenuBack=()=>{this.featureMenuOpen&&(this._focusOn="root-flow-item",this.featureMenuOpen=!1)},this._focusFlowItemNode=e=>{this._focusOn===e&&requestAnimationFrame((async()=>{switch(e){case"menu-flow-item":await(this._featureMenuViewportNode?.setFocus());break;case"root-flow-item":await(this._rootFlowItemNode?.setFocus())}this._focusOn=null}))},this._focusFlowItemNodeThrottled=r(this._focusFlowItemNode,k),this._displaySpinnerThrottled=r((()=>this._displaySpinner()),R),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,this._focusFlowItemNodeThrottled,o((()=>this.viewModel?.active),(()=>this._toggleScreenLocationEnabled())),o((()=>this.viewModel?.active),(e=>this._relatedRecordsWidget.closed=!e)),o((()=>this.visibleElements?.closeButton),(e=>this._relatedRecordsWidget.closable=e)),o((()=>this.visibleElements?.spinner),(e=>this._spinnerEnabledChange(e))),o((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),o((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),o((()=>[this.viewModel?.waitingForResult,this.viewModel?.location]),(()=>{this._hideSpinner(),this._displaySpinnerThrottled()})),o((()=>this.viewModel?.screenLocation),(()=>this._closeOpenActionMenu())),o((()=>this.selectedFeatureWidget),(()=>this._destroyRelatedRecordsFlowItemWidgets())),o((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]}),(()=>this._setTitleFromFeatureWidget())),o((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]}),(()=>this._setContentFromFeatureWidget())),o((()=>this.viewModel?.featureViewModels),(()=>this._featureMenuViewportScrollTop())),this._relatedRecordsWidget.on("close",(()=>this.close())),this._relatedRecordsWidget.on("exit",(()=>this._destroyRelatedRecordsFlowItemWidgets())),this._relatedRecordsWidget.on("open-related-feature",(({feature:e})=>this._openRelatedFeature(e)))])}loadDependencies(){return F({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.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"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")})}destroy(){this._destroyRelatedRecordsFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._relatedRecordsWidget?.destroy()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&!!this.title&&!!this.content}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get icon(){return null}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_relatedRecordsFlowItems:i}=this,{selectedFeatureViewModel:o}=this.viewModel,s={title:!1};return o?(e?(e.viewModel=o,e.visibleElements=s):this._feature=new u({flowItems:i,headingLevel:t+1,viewModel:o,visibleElements:s}),this._feature):null}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e?this._rootFlowItemNode?.blur():i.getLogger(this).warn("Features can only be blurred when currently active.")}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e?this._setFocusOn():i.getLogger(this).warn("Features can only be focused when currently active.")}next(){return this.viewModel.next()}open(e){this.removeHandles(O);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(s((()=>!this.viewModel.waitingForResult),(()=>this._addSelectedFeatureIndexHandle()),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return A("div",{bind:this,class:this.classes(w.base,b.widget,b.panel),onkeydown:this._onMainKeydown},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),this._renderFeatureMenuButton()]}_renderHeader(){return!this.featureMenuOpen&&this.featureNavigationTop&&this._featureNavigationVisible?A("div",{class:w.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return this.featureMenuOpen||this.featureNavigationTop||!this._featureNavigationVisible?null:A("div",{class:w.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation())}_renderFeatureMenuButton(){const{messages:e,viewModel:t}=this,{featureCount:i,selectedFeatureIndex:o,pendingPromisesCount:s}=t;return A("calcite-action",{appearance:"solid",bind:this,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:s>0,onclick:this._openFeatureMenu,scale:"s",text:N(e.pageText,{index:x(o+1),total:x(i)}),textEnabled:!0,title:e.selectFeature})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return A("calcite-action-bar",{class:w.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},A("calcite-action-group",{scale:"s"},A("calcite-action",{appearance:"solid",class:w.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,onclick:this._previousFeature,scale:"s",text:e,title:e}),A("calcite-action",{appearance:"solid",icon:"chevron-right",iconFlipRtl:!0,label:t,onclick:this._nextFeature,scale:"s",text:t,title:t})))}_renderFeatureMenuItem(e){const{selectedFeatureViewModel:t,featureViewModels:i}=this.viewModel,o=e===t,s=i.indexOf(e);return A("calcite-list-item",{bind:this,"data-feature-index":s,key:`feature-menu-item-${e.uid}`,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature,selected:o,onCalciteListItemSelect:this._selectFeature},A("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}))}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach((e=>{const i=e?.graphic;if(!i)return;const o=i.sourceLayer??i.layer,s=t.get(o)??[];t.set(o,[...s,e])})),t}_renderFeatureMenu(){const{featureViewModels:e}=this.viewModel,t=this._groupResultsByLayer();return e.length?A("calcite-list",{selectionAppearance:"icon",selectionMode:"single"},Array.from(t.keys()).map((e=>A("calcite-list-item-group",{heading:e?.title??this.messagesCommon.untitled,key:e?.uid||"untitled"},t.get(e)?.map((e=>this._renderFeatureMenuItem(e))))))):null}_renderHeaderAction(e,t){const i=e.title||"";return e.visible?A("calcite-action",{active:"toggle"===e.type&&e.value,appearance:"solid",bind:this,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon||"",indicator:e.indicator,key:`header-action-${t}`,loading:e.active,onclick:this._triggerHeaderAction,slot:"header-actions-end",text:i,title:i}):null}_renderHeaderActions(){return this.headerActions.map(((e,t)=>this._renderHeaderAction(e,t))).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:o,featureNavigationTop:s}=this,{title:r,active:n}=this.viewModel,a=t.heading&&r?r:"";return A("calcite-flow-item",{afterCreate:this._storeRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,class:this.classes({[w.contentFeature]:!0,[w.flowItemCollapsed]:i}),closable:t.closeButton,closed:!n,collapsed:i,collapseDirection:s?"down":"up",collapsible:o,headingLevel:e,key:"root-flow-item",onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},a?A(y,{class:this.classes(w.featuresHeading,b.heading),innerHTML:a,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),i?null:A("div",{class:this.classes(w.container,w.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,featureMenuOpen:t,messages:i,messagesCommon:o}=this,{active:s,featureViewModels:r,pendingPromisesCount:n}=e;return t?A("calcite-flow-item",{afterCreate:this._storeFeatureMenuFlowItemNode,afterUpdate:this._focusFeatureMenuFlowItemNode,bind:this,closable:!1,closed:!s,description:N(i.total,{total:r.length}),heading:i.selectFeature,key:"feature-menu",loading:e.waitingForContents,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleFeatureMenuBack()}},n>0?A("calcite-loader",{class:w.loader,inline:!0,key:"feature-menu-loader",label:o.loading,slot:"header-actions-end"}):null,A("div",{class:w.container},this._renderFeatureMenu()),A("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:w.featureMenuObserver}),A("calcite-button",{appearance:"transparent",onclick:this._handleFeatureMenuBack,slot:"footer-actions",width:"full"},o.back)):null}_renderContentContainer(){const e=[this._renderContentFeature(),this._renderFeatureMenuContainer(),this._relatedRecordsWidget.render()];return this.visibleElements.flow?A("calcite-flow",{key:"content-container"},e):e}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=d({action:e,feature:this.selectedFeature}),s={[w.icon]:!!t,[w.actionImage]:!!o};return t&&(s[t]=!0),o||t?A("span",{"aria-hidden":"true",class:this.classes(w.icon,s),key:"icon",styles:c(o)}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?A("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},A("calcite-action-group",{afterCreate:e=>this._actionBarMenuNode=e,overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?A("div",{class:m.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_setFocusOn(){this.renderNow(),requestAnimationFrame((()=>{this._focusOn=this.featureMenuOpen?"menu-flow-item":"root-flow-item"}))}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyRelatedRecordsFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=l(i);this.open({features:[t],location:null!=o?o:void 0})}_focusRootFlowItemNode(){this._focusFlowItemNodeThrottled("root-flow-item")}_focusFeatureMenuFlowItemNode(){this._focusFlowItemNodeThrottled("menu-flow-item")}_storeRootFlowItemNode(e){this._rootFlowItemNode=e,this._focusFlowItemNodeThrottled("root-flow-item")}_storeFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e,this._focusFlowItemNodeThrottled("menu-flow-item")}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),this._handleFeatureMenuBack()}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionIcon(e){return e.icon?e.icon:e.image||e.className?void 0:"question"}_getActionTitle(e){const{messages:t,selectedFeature:i,messagesCommon:o}=this,{id:s}=e,r=i?.attributes,n=e.title??"",a="zoom-to-feature"===s?N(n,{messages:t}):"remove-selected-feature"===s?N(n,{messages:o}):"zoom-to-clustered-features"===s||"browse-clustered-features"===s?N(n,{messages:t}):e.title;return a&&r?N(a,r):a??""}_onMainKeydown(e){const{key:t}=e;"ArrowLeft"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode&&this._featureMenuViewportNode.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=o((()=>this.viewModel?.selectedFeatureIndex),((e,t)=>this._selectedFeatureIndexUpdated(e,t)));this.addHandles(e,O)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyRelatedRecordsFlowItemWidgets(),this._rootFlowItemNode&&this._rootFlowItemNode.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find((({uid:e})=>e===i));o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex((e=>e.uid===i)),r=o.at(s);r&&"toggle"===r.type&&(r.value=!r.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new h({view:e}),e.ui.add(this._spinner,{key:j,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_closeOpenActionMenu(){const{_actionBarMenuNode:e}=this;e&&(e.menuOpen=!1)}_destroyRelatedRecordsFlowItemWidgets(){this._relatedRecordsFlowItems.removeAll().forEach((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}))}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t?.ui?.remove(e,j),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([n()],T.prototype,"_focusOn",void 0),e([n()],T.prototype,"_relatedRecordsFlowItems",void 0),e([n()],T.prototype,"_hideActionText",null),e([n()],T.prototype,"_featureNavigationVisible",null),e([n()],T.prototype,"_isCollapsed",null),e([n()],T.prototype,"_collapseEnabled",null),e([n()],T.prototype,"collapsed",void 0),e([n()],T.prototype,"content",null),e([n()],T.prototype,"icon",null),e([n()],T.prototype,"featureMenuOpen",null),e([n()],T.prototype,"featureNavigationTop",void 0),e([n()],T.prototype,"features",null),e([n({type:M})],T.prototype,"headerActions",void 0),e([n()],T.prototype,"headingLevel",void 0),e([n()],T.prototype,"location",null),e([n()],T.prototype,"label",null),e([n(),I("esri/widgets/Features/t9n/Features")],T.prototype,"messages",void 0),e([n(),I("esri/t9n/common")],T.prototype,"messagesCommon",void 0),e([n()],T.prototype,"promises",null),e([n()],T.prototype,"responsiveActionsEnabled",void 0),e([n({readOnly:!0})],T.prototype,"selectedFeature",null),e([n()],T.prototype,"selectedFeatureIndex",null),e([n({readOnly:!0})],T.prototype,"selectedFeatureWidget",null),e([n()],T.prototype,"title",null),e([n()],T.prototype,"updateLocationEnabled",null),e([n()],T.prototype,"view",null),e([n({type:g}),C(["triggerAction","trigger-action"])],T.prototype,"viewModel",void 0),e([n({type:f,nonNullable:!0})],T.prototype,"visibleElements",void 0),e([n()],T.prototype,"visible",null),T=e([a("esri.widgets.Features")],T);const E=T;export{E as default};
|