-
Notifications
You must be signed in to change notification settings - Fork 0
/
p-369db64b.entry.js
5 lines (5 loc) · 3.3 KB
/
p-369db64b.entry.js
1
2
3
4
5
/*!
* Built by BASIS
* Copyright BASIS International Ltd.
*/
import{r as t,c as i,h as s,H as e,g as n}from"./p-00e3df8e.js";import{D as o}from"./p-6c02d679.js";import{h}from"./p-3e9fe89f.js";import"./p-2b4379f2.js";const a=class{constructor(s){t(this,s),this.modifiedEvent=i(this,"dwc-modified",7),this.spinedEvent=i(this,"dwc-spun",7),this.disabled=!1,this.readonly=!1,this.min=-1,this.max=-1,this.field="MINUTE",this.amount=1}connectedCallback(){this.handleSlotChange=this.handleSlotChange.bind(this)}componentDidLoad(){this.handleSlotChange()}handleSpinedUp(){this.doSpin("up")}handleSpinedDown(){this.doSpin("down")}handleRequiredPropsChanged(t){t.stopPropagation();const{disabled:i,readonly:s,min:e,max:n}=t.detail;this.disabled=i,this.readonly=s,this.min=e,this.max=n}async setFocus(){await this.$inputt.setFocus()}async removeFocus(){await this.$inputt.removeFocus()}async spin(t){this.doSpin(t?"up":"down",!1)}async getNextTime(){return this.modifyTime("up")}async getPreviousTime(){return this.modifyTime("down")}doSpin(t,i=!0){if(!this.$inputt)return;if((this.readonly||this.disabled)&&1==i)return;const s=this.$inputt,e=s.mask,n=s.locale,h=this.modifyTime(t);-1!==h&&(s.value=o.format(h,e,n)),i&&this.fireModifiedEvent(),this.fireSpinedEvent()}modifyTime(t){const i=this.$inputt.rawValue;if(null==i)return-1;const s=o.fromNumber(i),e=this.field.toUpperCase(),n="up"===t?this.amount||1:-(this.amount||1);switch(e){case"HOUR":s.setTime(s.getTime()+60*n*60*1e3);break;case"MINUTE":s.setTime(s.getTime()+60*n*1e3);break;case"SECOND":s.setTime(s.getTime()+1e3*n);break;case"MILLISECOND":s.setTime(s.getTime()+n)}if("up"===t){if(this.max>-1){const t=o.fromNumber(this.max);if(s.getTime()>=t.getTime())return this.max}}else if(this.min>-1){const t=o.fromNumber(this.min);if(s.getTime()<=t.getTime())return this.min}return o.fromDate(s)}fireSpinedEvent(){if(this.readonly||this.disabled)return;let t=-1;const i=this.$inputt;null!=i.rawValue&&(t=i.rawValue),this.spinedEvent.emit(t)}fireModifiedEvent(){this.readonly||this.disabled||this.modifiedEvent.emit(this.$inputt.value)}handleSlotChange(){this.$inputt=this.el.querySelector("dwc-timefield"),this.$inputt&&(this.$inputt.showSpinners=!0,this.$inputt.spinnable=!0,this.disabled=this.$inputt.disabled,this.readonly=this.$inputt.readonly,this.min=this.$inputt.min,this.max=this.$inputt.max)}render(){return s(e,{key:"a4cdd3ab8163c70174772e997a2a43042b480b03",class:h({BBjControl:!0,BBjSpinner:!0,BBjInputTSpinner:!0,"bbj-disabled":this.disabled,"bbj-readonly":this.readonly})},s("slot",{key:"0157ab24e12755dc9be71da5b337f9cb4e018a22",onSlotchange:this.handleSlotChange}))}get el(){return n(this)}};a.style="@media (prefers-reduced-motion: reduce){*,::before,::after{animation-delay:-1ms !important;animation-duration:1ms !important;animation-iteration-count:1 !important;background-attachment:initial !important;scroll-behavior:auto !important;transition-delay:0s !important;transition-duration:0s !important}}:host{box-sizing:border-box;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;position:relative;-webkit-tap-highlight-color:transparent;text-size-adjust:100%}:host *,:host *::before,:host *::after{box-sizing:inherit}:host{cursor:pointer;display:inline-block}:host(:focus),:host(:active){outline:none}:host ::slotted(dwc-timefield){height:100%;width:100%}";export{a as dwc_timefield_spinner}