UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.62 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ 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{loadCalciteComponents as s}from"../support/componentsUtils.js";import"../support/widgetUtils.js";import{tsx as i}from"../support/jsxFactory.js";import l from"./ValuePickerBaseComponent.js";const r="esri-value-picker__combobox";let a=class extends l{constructor(e,t){super(e,t),this.items=null,this.placeholder=null,this.type="combobox"}loadDependencies(){return s({combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item")})}get canNext(){return!(!this.items||!this.viewModel)&&this.items.findIndex((({value:e})=>e===this.viewModel.values?.[0]))!==this.items.length-1}get canPlay(){return null!=this.viewModel&&!!this.items?.length}get canPrevious(){const{items:e,viewModel:t}=this;return!(!e||!t)&&0!==e.findIndex((({value:e})=>e===t.values?.[0]))}render(){const{viewModel:e}=this;if(null==e)return i("div",null);const t=e.values?.[0];return i("div",{class:r},i("calcite-combobox",{disabled:e.disabled,label:this.label,maxItems:10,overlayPositioning:"fixed",placeholder:this.placeholder??void 0,selectionMode:"single",onCalciteComboboxChange:t=>{Array.isArray(t.currentTarget.value)||(null!=e.values?e.values[0]!==t.currentTarget.value&&(e.values=[t.currentTarget.value]):e.values=[t.currentTarget.value])}},this.items?.map((({value:e,label:o},s)=>i("calcite-combobox-item",{key:s,selected:e===t,textLabel:o,value:e})))))}animate(e){this._step(1,e)}next(){this._step(1)}previous(){this._step(-1)}_step(e,t=!1){const{viewModel:o,items:s}=this;if(!s?.length||!o)return;if(!o.values)return void(o.values=[s[0].value]);const i=s.findIndex((({value:e})=>e===o.values[0]));if(-1===i)return void(o.values=[s[0].value]);const l=i+e;l<0||l>=s.length?o.loop||t?o.values=[s[1===e?0:s.length-1].value]:"playing"===o.state&&o.pause():o.values=[s[l].value]}};e([t()],a.prototype,"canNext",null),e([t()],a.prototype,"canPlay",null),e([t()],a.prototype,"canPrevious",null),e([t()],a.prototype,"items",void 0),e([t()],a.prototype,"placeholder",void 0),e([t()],a.prototype,"type",void 0),a=e([o("esri.widgets.ValuePicker.ValuePickerCombobox")],a);const n=a;export{n as default};