12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import i from"../core/Handles.js";import{destroyMaybe as t,isNone as s,applySome as o,isSome as a}from"../core/maybe.js";import{watch as r,syncAndInitial as l}from"../core/reactiveUtils.js";import{convertTime as n}from"../core/timeUtils.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/accessorSupport/ensureType.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{substitute as c}from"../intl/substitute.js";import p from"./Slider.js";import h from"./Widget.js";import{CSS as u}from"./ShadowCast/css.js";import{ShadowCastState as v}from"./ShadowCast/ShadowCastState.js";import w from"./ShadowCast/ShadowCastViewModel.js";import g from"./ShadowCast/ShadowCastVisibleElements.js";import{ShadowVisualizationType as f}from"./ShadowCast/ShadowVisualizationType.js";import{DiscreteConfigurator as b}from"./ShadowCast/components/DiscreteConfigurator.js";import{DurationConfigurator as S}from"./ShadowCast/components/DurationConfigurator.js";import{ShadowTooltip as _}from"./ShadowCast/components/ShadowTooltip.js";import{ThresholdConfigurator as y}from"./ShadowCast/components/ThresholdConfigurator.js";import{TimezonePicker as C}from"./ShadowCast/components/TimezonePicker.js";import M from"./support/DatePicker.js";import{Heading as T}from"./support/Heading.js";import{formatSliderLabel as j}from"./support/timeWidgetUtils.js";import"./support/widgetUtils.js";import{messageBundle as k}from"./support/decorators/messageBundle.js";import{tsx as D}from"./support/jsxFactory.js";import{formatDate as z}from"../intl/date.js";var V;!function(e){e.Slider="slider"}(V||(V={}));const O={hour:"2-digit",minute:"2-digit",timeZone:"UTC"},R=/(.*)\s(.*)/,L={labelFormatFunction:j,min:0,max:1439,steps:15,rangeLabelInputsEnabled:!1,visibleElements:{labels:!1,rangeLabels:!1},tickConfigs:[{mode:"position",values:[0,360,720,1080,1439],labelsVisible:!0,tickCreatedFunction:(e,i,t)=>{i.classList.add(u.timeRangePrimaryTick),t.classList.add(u.timeRangePrimaryTickLabel);const s=t.innerText.match(R);s&&(t.innerHTML=`${s[1]}<br><div class="${u.timeRangeAMPMLabel}">${s[2]}</div>`)}},{mode:"position",values:[120,240,480,600,840,960,1200,1320],tickCreatedFunction:(e,i)=>{i.classList.add(u.timeRangeSecondaryTick)}}]};let P=class extends h{constructor(e,t){super(e,t),this.viewModel=null,this.headingLevel=4,this.iconClass=u.widgetIcon,this.visibleElements=new g,this._handles=new i,this._defaultViewModel=null,this._timeSlider=new p({...L,container:document.createElement("div")}),this._tooltip=null,this._onTimezoneChange=e=>{this.viewModel.utcOffset=e},this._onDateChange=e=>{this.viewModel.date=e},e?.viewModel||(this._defaultViewModel=new w({view:e?.view}),this.viewModel=this._defaultViewModel)}initialize(){this._handles.add([r((()=>({viewModel:this.viewModel,slider:this._timeSlider})),(e=>this._connectTimeSlider(e)),l),r((()=>({container:o(this.view,(e=>e.surface)),viewModel:this.viewModel,tooltipVisible:this.visibleElements.tooltip})),(({container:e,viewModel:i,tooltipVisible:o})=>{this._tooltip=t(this._tooltip),!s(e)&&o&&(this._tooltip=new _({viewModel:i,container:e}))}),l),r((()=>({viewModel:this.viewModel,visible:this.visible})),(({viewModel:e,visible:i})=>e.setRunning(i)),l)])}destroy(){this._handles=t(this._handles),this._timeSlider=t(this._timeSlider),a(this._defaultViewModel)&&this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-select.js"),import("@esri/calcite-components/dist/components/calcite-option.js")])}render(){const{visibleElements:e,viewModel:i}=this,t=i.state===v.Disabled;return D("div",{key:this,class:this.classes(u.base,u.esriWidget,{[u.esriWidgetDisabled]:t})},this._renderTimeRangeSection(),e.visualizationOptions&&this._renderVisualizationOptionsSection())}get view(){return this.viewModel?.view}set view(e){this.viewModel&&(this.viewModel.view=e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get testData(){return{tooltip:this._tooltip}}_connectTimeSlider({viewModel:e,slider:i}){if(this._handles.remove(V.Slider),s(i))return;const t=e=>n(e,"milliseconds","minutes"),o=e=>n(e,"minutes","milliseconds"),a=({index:i,value:t})=>{0===i?e.startTimeOfDay=o(t):e.endTimeOfDay=o(t)};this._handles.add([r((()=>[e.startTimeOfDay,e.endTimeOfDay]),(e=>{i.values=e.map(t)}),l),i.on("thumb-change",a),i.on("thumb-drag",a),i.on("segment-drag",(()=>{[e.startTimeOfDay,e.endTimeOfDay]=i.values.map(o)}))],V.Slider)}_renderTimeRangeSection(){const{visibleElements:e}=this;return e.timeRangeSlider||e.datePicker?D("section",{key:"time-range",class:u.timeRange},D(T,{level:this.headingLevel},this.messages.timeLabel),e.timeRangeSlider&&this._renderTimeRange(),e.datePicker&&this._renderDatePicker()):null}_renderTimeRange(){const{messages:e,viewModel:i,visibleElements:t}=this,{startTimeOfDay:s,endTimeOfDay:o}=i,[a,r]=[s,o].map((e=>z(new Date(e),O)));return[D("div",{key:"time-range-indicator",class:u.timeRangeIndicator},c(e.timeRange,{start:a,end:r}),t.timezone&&D(C,{value:i.utcOffset,onChange:this._onTimezoneChange})),D("div",{key:"time-slider-container",bind:this,afterCreate:this._timeSliderContainerAfterCreate,afterRemoved:this._timeSliderContainerAfterRemoved})]}_timeSliderContainerAfterCreate(e){o(this._timeSlider,(i=>{e.appendChild(i.container)}))}_timeSliderContainerAfterRemoved(e){o(this._timeSlider,(i=>{e.removeChild(i.container)}))}_renderDatePicker(){return D("div",{key:"date-picker",class:u.datePickerContainer},D(M,{value:this.viewModel.date,onChange:this._onDateChange}))}_renderVisualizationOptionsSection(){const{headingLevel:e,messages:i,viewModel:t,visibleElements:s}=this,o=s.colorPicker,a=e=>this.classes(t.visualizationType===e?null:u.visualizationConfigHidden);return D("section",{key:"visualization",class:u.visualization},D(T,{level:e},i.visualizationLabel),this._renderVisualizationSelect(),D("div",{key:"threshold-configurator",class:a(f.Threshold)},D(y,{options:t.thresholdOptions,colorPickerVisible:o})),D("div",{key:"duration-configurator",class:a(f.Duration)},D(S,{options:t.durationOptions,colorPickerVisible:o})),D("div",{key:"discrete-configurator",class:a(f.Discrete)},D(b,{options:t.discreteOptions,colorPickerVisible:o})))}_renderVisualizationSelect(){const e=this.messages,i=this.viewModel.visualizationType;return D("calcite-select",{class:u.visualizationSelect,key:"visualization-select",label:e.visualizationLabel,bind:this,onCalciteSelectChange:this._onVisualizationTypeChange},[{type:f.Threshold,label:e.threshold.label},{type:f.Duration,label:e.duration.label},{type:f.Discrete,label:e.discrete.label}].map((({type:e,label:t})=>D("calcite-option",{value:e,selected:e===i},t))))}_onVisualizationTypeChange(e){const i=e.target.selectedOption?.value;this.viewModel.visualizationType=i??f.Threshold}};e([d()],P.prototype,"viewModel",void 0),e([d()],P.prototype,"view",null),e([d()],P.prototype,"headingLevel",void 0),e([d()],P.prototype,"iconClass",void 0),e([d()],P.prototype,"label",null),e([d({type:g,nonNullable:!0})],P.prototype,"visibleElements",void 0),e([d(),k("esri/widgets/ShadowCast/t9n/ShadowCast")],P.prototype,"messages",void 0),e([d()],P.prototype,"_defaultViewModel",void 0),e([d()],P.prototype,"_timeSlider",void 0),e([d()],P.prototype,"_tooltip",void 0),P=e([m("esri.widgets.ShadowCast")],P);const E=P;export{E as default};
|