UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 3.99 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 e}from"../chunks/tslib.es6.js";import{deprecateWidget as t}from"../core/deprecate.js";import i from"../core/Logger.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";import{systemTimeZone as r,system as n,unknown as a}from"../time/constants.js";import c from"./Widget.js";import{loadCalciteComponents as l}from"./support/componentsUtils.js";import{globalCss as d}from"./support/globalCss.js";import{isRTL as p}from"./support/widgetUtils.js";import{messageBundle as m}from"./support/decorators/messageBundle.js";import{tsx as h}from"./support/jsxFactory.js";import{css as b}from"./TimeZoneLabel/css.js";import g from"./TimeZoneLabel/TimeZoneLabelViewModel.js";let u=class extends c{constructor(e,s){super(e,s),this.disabled=!1,this.expanded=!1,this.messages=null,this.viewModel=new g,this._onExpanderClick=()=>{this.expanded=!this.expanded},t(i.getLogger(this),"Time Zone Label","arcgis-time-zone-label",{version:"4.33"})}loadDependencies(){return l({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label")})}get expandDirection(){if(!this.view||!this.container)return"end";const e=p();switch(this.view.ui.getPosition(this.container)){case"top-right":case"bottom-right":case"top-trailing":case"bottom-trailing":return e?"end":"start";case"top-left":case"bottom-left":case"top-leading":case"bottom-leading":return e?"start":"end";default:return"end"}}set expandDirection(e){this._overrideIfSome("expandDirection",e)}get icon(){return"time-zone"}set icon(e){this._overrideIfSome("icon",e)}get interactive(){return!(this.disabled||"disabled"===this.viewModel.state)}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}render(){const{expandDirection:e,interactive:t,label:i}=this,s=this.classes(b.base,d.widget,!t&&d.disabled),o=[this._renderExpander(),this._renderName(),this._renderBadge()];return"start"===e&&o.reverse(),h("div",{"aria-label":i,class:s},o)}_getIcon(){const{expanded:e,expandDirection:t}=this;return e?p()?"start"===t?"chevrons-left":"chevrons-right":"start"===t?"chevrons-right":"chevrons-left":"time-zone"}_renderExpander(){const{interactive:e,label:t}=this,i=this._getIcon();return h("calcite-action",{active:!1,class:b.expander,disabled:!e,icon:i,key:b.expander,onclick:this._onExpanderClick,scale:"s",text:t,title:t})}_renderBadge(){const{expanded:e,interactive:t}=this;return h("div",{class:this.classes(b.badge,!e&&b.badgeHidden,!t&&b.badgeDisabled)},h("calcite-icon",{class:b.badgeIcon,icon:"time-zone",scale:"s"}))}_renderName(){const e=this.viewModel.view?.timeZone,t=e===n?r:e,i=e===a;return[h("calcite-label",{class:this.classes(b.label,(!this.expanded||!i)&&b.labelHidden,!this.interactive&&b.labelDisabled)},this.messages.noAdjustment),h("calcite-input-time-zone",{class:this.classes(b.name,(!this.expanded||!t||i)&&b.nameHidden),disabled:!this.interactive,mode:"region",readOnly:!0,value:t})]}};e([s()],u.prototype,"disabled",void 0),e([s()],u.prototype,"expandDirection",null),e([s()],u.prototype,"expanded",void 0),e([s()],u.prototype,"icon",null),e([s({readOnly:!0})],u.prototype,"interactive",null),e([s()],u.prototype,"label",null),e([s(),m("esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel")],u.prototype,"messages",void 0),e([s()],u.prototype,"view",null),e([s()],u.prototype,"viewModel",void 0),u=e([o("esri.widgets.TimeZoneLabel")],u);const v=u;export{v as default};