@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.18 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as t}from"tslib";import{property as e,subclass as o}from"../../core/accessorSupport/decorators.js";import s from"../Widget.js";import{loadCalciteComponents as i}from"./componentsUtils.js";import{getTimezoneInfos as n}from"./timeWidgetUtils.js";import{messageBundle as r,tsx as d}from"./widget.js";const p="esri-timezone-picker",l={base:p,trigger:`${p}__trigger`,itemTitle:`${p}__item-title`,itemDescription:`${p}__item_description`};let c=class extends s{constructor(t,e){super(t,e),this.disabled=!1,this.value=null,this.onChange=null,this.open=!1,this.onOpen=null,this.onClose=null,this._selectedId=null,this._onOpen=()=>{this.open=!0,this.onOpen?.()},this._onClose=()=>{this.open=!1,this.onClose?.()},this._killEvent=t=>(t.stopPropagation(),!0),this._onChange=t=>{const e=t.target.selectedItems?.[0].getAttribute("data-id"),o=a(this._gmtOffsets,e)?.utcOffset;null!=o&&(this._selectedId=e,this.onChange?.(o))}}loadDependencies(){return i({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item")})}render(){const t=this._messages;if(!t)return d("div",{class:l.base,key:"empty"});const e=this._selectedItem,o=h(e);return d("div",{class:l.base,key:"container",onpointerdown:this._killEvent},d("calcite-dropdown",{disabled:this.disabled,open:this.open,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",topLayerDisabled:this.topLayerDisabled,onCalciteDropdownClose:this._onClose,onCalciteDropdownOpen:this._onOpen,onCalciteDropdownSelect:this._onChange},d("calcite-button",{appearance:"transparent",class:l.trigger,"data-testid":"timezone-picker-button",disabled:this.disabled,key:"trigger",kind:"neutral",scale:"s",slot:"trigger",title:t.chooseTimezone},e?.short??""),d("calcite-dropdown-group",{selectionMode:"single"},this._gmtOffsets.map(t=>{const e=h(t);return d("calcite-dropdown-item",{"data-id":e,"data-testid":e,key:e,selected:o===e},d("div",{class:l.itemTitle,key:"title"},t.shortWithUTC),d("div",{class:l.itemDescription,key:"description"},t.long))}))))}get _gmtOffsets(){const t=this._messages;return t?n(t):[]}get _selectedItem(){const t=this._gmtOffsets,e=this.value,o=a(t,this._selectedId);return o?.utcOffset===e?o:m(t,e)}};function a(t,e){return t.find(t=>h(t)===e)}function m(t,e){return t.find(t=>t.utcOffset===e)}function h(t){return t?`${t.utcOffset}-${t.long}`:void 0}t([e()],c.prototype,"disabled",void 0),t([e()],c.prototype,"value",void 0),t([e()],c.prototype,"onChange",void 0),t([e()],c.prototype,"open",void 0),t([e()],c.prototype,"onOpen",void 0),t([e()],c.prototype,"onClose",void 0),t([e(),r("esri/widgets/support/t9n/timezone")],c.prototype,"_messages",void 0),t([e()],c.prototype,"_gmtOffsets",null),t([e()],c.prototype,"_selectedItem",null),t([e()],c.prototype,"_selectedId",void 0),c=t([o("esri.widgets.support.TimezonePicker")],c);export{c as TimezonePicker,l as css};