UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 3.48 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as t}from"../../chunks/tslib.es6.js";import{property as e}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{loadCalciteComponents as i}from"./componentsUtils.js";import{getTimezoneInfos as n}from"./timeWidgetUtils.js";import"./widgetUtils.js";import{messageBundle as r}from"./decorators/messageBundle.js";import{tsx as p}from"./jsxFactory.js";const c="esri-timezone-picker",d={base:c,trigger:`${c}__trigger`,itemTitle:`${c}__item-title`,itemDescription:`${c}__item_description`};let l=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 p("div",{class:d.base,key:"empty"});const e=this._selectedItem,o=u(e);return p("div",{class:d.base,key:"container",onpointerdown:this._killEvent},p("calcite-dropdown",{disabled:this.disabled,open:this.open,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",onCalciteDropdownClose:this._onClose,onCalciteDropdownOpen:this._onOpen,onCalciteDropdownSelect:this._onChange},p("calcite-button",{appearance:"transparent",class:d.trigger,"data-testid":"timezone-picker-button",disabled:this.disabled,key:"trigger",kind:"neutral",scale:"s",slot:"trigger",title:t.chooseTimezone},e?.short??""),p("calcite-dropdown-group",{selectionMode:"single"},this._gmtOffsets.map((t=>{const e=u(t);return p("calcite-dropdown-item",{"data-id":e,"data-testid":e,key:e,selected:o===e},p("div",{class:d.itemTitle,key:"title"},t.shortWithUTC),p("div",{class:d.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=>u(t)===e))}function m(t,e){return t.find((t=>t.utcOffset===e))}function u(t){return t?`${t.utcOffset}-${t.long}`:void 0}t([e()],l.prototype,"disabled",void 0),t([e()],l.prototype,"value",void 0),t([e()],l.prototype,"onChange",void 0),t([e()],l.prototype,"open",void 0),t([e()],l.prototype,"onOpen",void 0),t([e()],l.prototype,"onClose",void 0),t([e(),r("esri/widgets/support/t9n/timezone")],l.prototype,"_messages",void 0),t([e()],l.prototype,"_gmtOffsets",null),t([e()],l.prototype,"_selectedItem",null),t([e()],l.prototype,"_selectedId",void 0),l=t([o("esri.widgets.support.TimezonePicker")],l);export{l as TimezonePicker,d as css};