iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
10 lines • 15.7 kB
JavaScript
export const __rspack_esm_id=16508;export const __rspack_esm_ids=[16508];export const __webpack_modules__={32656(e,t,a){a.a(e,async function(e,t){try{a(74423);var i=a(62826),s=a(5124),o=a(22441),l=a(63672),r=a(1087),n=a(57237),d=a(26300),h=(a(3449),a(606)),u=a(91485),p=e([d,h,u]);[d,h,u]=p.then?(await p)():p;const c="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z";class b extends s.WF{reportValidity(){const e=this._inputs;return!e||[...e].every(e=>e.reportValidity())}render(){return s.qy` ${this.label?s.qy`<label>${this.label}${this.required?" *":""}</label>`:s.s6} <div class="time-input-wrap-wrap"> <div class="time-input-wrap"> ${this.enableDay?s.qy` <ha-input id="day" type="number" inputmode="numeric" .value="${this.days.toFixed()}" .label="${this.placeholderLabels?"":this.dayLabel}" .placeholder="${this.placeholderLabels?this.dayLabel:""}" name="days" ="${this._valueChanged}" ="${this._onFocus}" without-spin-buttons .required="${this.required}" .autoValidate="${this.autoValidate}" min="0" .disabled="${this.disabled}"> </ha-input> <div class="time-separator">:</div> `:s.s6} <ha-input id="hour" type="number" inputmode="numeric" .value="${this.hours.toFixed()}" .label="${this.placeholderLabels?"":this.hourLabel}" .placeholder="${this.placeholderLabels?this.hourLabel:""}" name="hours" ="${this._valueChanged}" ="${this._onFocus}" without-spin-buttons .required="${this.required}" .autoValidate="${this.autoValidate}" maxlength="2" max="${(0,l.J)(this._hourMax)}" min="0" .disabled="${this.disabled}"> </ha-input> <div class="time-separator">:</div> <ha-input id="min" type="number" inputmode="numeric" .value="${this._formatValue(this.minutes)}" .label="${this.placeholderLabels?"":this.minLabel}" .placeholder="${this.placeholderLabels?this.minLabel:""}" ="${this._valueChanged}" ="${this._onFocus}" name="minutes" without-spin-buttons .required="${this.required}" .autoValidate="${this.autoValidate}" maxlength="2" max="59" min="0" .disabled="${this.disabled}"> </ha-input> ${this.enableSecond?s.qy`<div class="time-separator">:</div>`:s.s6} ${this.enableSecond?s.qy`<ha-input id="sec" type="number" inputmode="decimal" step="any" .value="${this._formatValue(this.seconds)}" .label="${this.placeholderLabels?"":this.secLabel}" .placeholder="${this.placeholderLabels?this.secLabel:""}" ="${this._valueChanged}" ="${this._onFocus}" name="seconds" without-spin-buttons .required="${this.required}" .autoValidate="${this.autoValidate}" max="59" min="0" .disabled="${this.disabled}"> </ha-input> ${this.enableMillisecond?s.qy`<div class="time-separator">:</div>`:s.s6}`:s.s6} ${this.enableMillisecond?s.qy`<ha-input id="millisec" type="number" .value="${this._formatValue(this.milliseconds,3)}" .label="${this.placeholderLabels?"":this.millisecLabel}" .placeholder="${this.placeholderLabels?this.millisecLabel:""}" ="${this._valueChanged}" ="${this._onFocus}" name="milliseconds" without-spin-buttons .required="${this.required}" .autoValidate="${this.autoValidate}" maxlength="3" max="999" min="0" .disabled="${this.disabled}"> </ha-input>`:s.s6} ${24===this.format?s.s6:s.qy`<ha-select .required="${this.required}" .value="${this.amPm}" .disabled="${this.disabled}" .name="${"amPm"}" ="${this._valueChanged}" -after-hide="${n.d}" -hide="${n.d}" .options="${["AM","PM"]}"> </ha-select>`} ${!this.clearable||this.required||this.disabled?s.s6:s.qy`<ha-icon-button label="clear" ="${this._clearValue}" .path="${c}"></ha-icon-button>`} </div> </div> ${this.helper?s.qy`<ha-input-helper-text .disabled="${this.disabled}">${this.helper}</ha-input-helper-text>`:s.s6} `}_clearValue(){(0,r.r)(this,"value-changed")}_valueChanged(e){const t=e.currentTarget;this[t.name||""]="amPm"===t.name?e.detail.value:Number(t.value);const a={hours:this.hours,minutes:this.minutes,seconds:this.seconds,milliseconds:this.milliseconds};this.enableDay&&(a.days=this.days),12===this.format&&(a.amPm=this.amPm),(0,r.r)(this,"value-changed",{value:a})}_onFocus(e){e.currentTarget.select()}_formatValue(e,t=2){const a=e.toString();return a.includes(".")?a:a.padStart(t,"0")}get _hourMax(){if(!this.noHoursLimit)return 12===this.format?12:23}constructor(...e){super(...e),this.autoValidate=!1,this.required=!1,this.format=12,this.disabled=!1,this.days=0,this.hours=0,this.minutes=0,this.seconds=0,this.milliseconds=0,this.dayLabel="",this.hourLabel="",this.minLabel="",this.secLabel="",this.millisecLabel="",this.enableSecond=!1,this.enableMillisecond=!1,this.enableDay=!1,this.noHoursLimit=!1,this.amPm="AM",this.placeholderLabels=!1}}b.shadowRootOptions={...s.WF.shadowRootOptions,delegatesFocus:!0},b.styles=s.AH`:host([clearable]){position:relative}.time-input-wrap-wrap{display:flex}.time-input-wrap{display:flex;flex:var(--time-input-flex,unset);border-radius:var(--mdc-shape-small,var(--ha-border-radius-sm)) var(--mdc-shape-small,var(--ha-border-radius-sm)) var(--ha-border-radius-square) var(--ha-border-radius-square);overflow:hidden;position:relative;direction:ltr;padding-right:3px}ha-input{height:56px;padding:0;width:60px;flex-grow:1}ha-input:first-child{--text-field-border-top-left-radius:var(--mdc-shape-medium)}ha-input:last-child{--text-field-border-top-right-radius:var(--mdc-shape-medium)}ha-input::part(wa-base){padding:var(--ha-space-1)}ha-input:first-child::part(wa-base){padding-inline-start:var(--ha-space-4)}ha-input:last-child::part(wa-base){padding-inline-end:var(--ha-space-4)}ha-input::part(wa-hint){height:0}ha-input::part(wa-input){text-align:center}.time-separator,ha-icon-button{background-color:var(--ha-color-form-background);color:var(--ha-color-text-secondary);border-bottom:1px solid var(--ha-color-border-neutral-loud);box-sizing:border-box;height:56px;margin-inline-start:calc(var(--ha-space-1) * -1)}.time-separator{width:12px;margin-inline-end:calc(var(--ha-space-1) * -1);display:flex;align-items:center;justify-content:center}:host([clearable]) .mdc-select__anchor{padding-inline-end:var(--select-selected-text-padding-end,12px)}ha-icon-button{position:relative;--ha-icon-button-size:36px;border-start-end-radius:var(--ha-border-radius-sm);--mdc-icon-size:20px;direction:var(--direction);display:flex;align-items:center}ha-select{margin-inline:calc(var(--ha-space-1) * -1)}label{-moz-osx-font-smoothing:var(--ha-moz-osx-font-smoothing);-webkit-font-smoothing:var(--ha-font-smoothing);font-family:var(
--mdc-typography-body2-font-family,
var(--mdc-typography-font-family, var(--ha-font-family-body))
);font-size:var(--mdc-typography-body2-font-size, var(--ha-font-size-s));line-height:var(
--mdc-typography-body2-line-height,
var(--ha-line-height-condensed)
);font-weight:var(--mdc-typography-body2-font-weight,var(--ha-font-weight-normal));letter-spacing:var(
--mdc-typography-body2-letter-spacing,
.0178571429em
);text-decoration:var(--mdc-typography-body2-text-decoration,inherit);text-transform:var(--mdc-typography-body2-text-transform,inherit);color:var(--mdc-theme-text-primary-on-background,rgba(0,0,0,.87));padding-left:4px;padding-inline-start:4px;padding-inline-end:initial}ha-input-helper-text{padding-top:8px;line-height:var(--ha-line-height-condensed)}`,(0,i.Cg)([(0,o.MZ)()],b.prototype,"label",void 0),(0,i.Cg)([(0,o.MZ)()],b.prototype,"helper",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"auto-validate",type:Boolean})],b.prototype,"autoValidate",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean})],b.prototype,"required",void 0),(0,i.Cg)([(0,o.MZ)({type:Number})],b.prototype,"format",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean})],b.prototype,"disabled",void 0),(0,i.Cg)([(0,o.MZ)({type:Number})],b.prototype,"days",void 0),(0,i.Cg)([(0,o.MZ)({type:Number})],b.prototype,"hours",void 0),(0,i.Cg)([(0,o.MZ)({type:Number})],b.prototype,"minutes",void 0),(0,i.Cg)([(0,o.MZ)({type:Number})],b.prototype,"seconds",void 0),(0,i.Cg)([(0,o.MZ)({type:Number})],b.prototype,"milliseconds",void 0),(0,i.Cg)([(0,o.MZ)({type:String,attribute:"day-label"})],b.prototype,"dayLabel",void 0),(0,i.Cg)([(0,o.MZ)({type:String,attribute:"hour-label"})],b.prototype,"hourLabel",void 0),(0,i.Cg)([(0,o.MZ)({type:String,attribute:"min-label"})],b.prototype,"minLabel",void 0),(0,i.Cg)([(0,o.MZ)({type:String,attribute:"sec-label"})],b.prototype,"secLabel",void 0),(0,i.Cg)([(0,o.MZ)({type:String,attribute:"ms-label"})],b.prototype,"millisecLabel",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"enable-second",type:Boolean})],b.prototype,"enableSecond",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"enable-millisecond",type:Boolean})],b.prototype,"enableMillisecond",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"enable-day",type:Boolean})],b.prototype,"enableDay",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"no-hours-limit",type:Boolean})],b.prototype,"noHoursLimit",void 0),(0,i.Cg)([(0,o.MZ)({attribute:!1})],b.prototype,"amPm",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean,reflect:!0})],b.prototype,"clearable",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"placeholder-labels",type:Boolean})],b.prototype,"placeholderLabels",void 0),(0,i.Cg)([(0,o.YG)("ha-input")],b.prototype,"_inputs",void 0),b=(0,i.Cg)([(0,o.EM)("ha-base-time-input")],b),t()}catch(e){t(e)}})},89865(e,t,a){a.a(e,async function(e,t){try{a(18111),a(61701);var i=a(62826),s=(a(22395),a(5124)),o=a(22441),l=a(1087),r=a(18350),n=(a(67094),e([r]));r=(n.then?(await n)():n)[0];class d extends s.WF{render(){return s.qy` <wa-button-group childSelector="ha-button"> ${this.buttons.map(e=>s.qy`<ha-button iconTag="ha-svg-icon" class="icon" .variant="${this.active===e.value&&this.activeVariant?this.activeVariant:this.variant}" .size="${this.size}" .value="${e.value}" ="${this._handleClick}" .title="${e.label}" .appearance="${this.active===e.value?"accent":"filled"}"> ${e.iconPath?s.qy`<ha-svg-icon aria-label="${e.label}" .path="${e.iconPath}"></ha-svg-icon>`:e.label} </ha-button>`)} </wa-button-group> `}_handleClick(e){this.active=e.currentTarget.value,(0,l.r)(this,"value-changed",{value:this.active})}constructor(...e){super(...e),this.size="medium",this.nowrap=!1,this.fullWidth=!1,this.variant="brand"}}d.styles=s.AH`:host{--mdc-icon-size:var(--button-toggle-icon-size, 20px)}:host([no-wrap]) wa-button-group::part(base){flex-wrap:nowrap}wa-button-group{padding:var(--ha-button-toggle-group-padding)}:host([full-width]) wa-button-group,:host([full-width]) wa-button-group::part(base){width:100%}:host([full-width]) ha-button{flex:1}`,(0,i.Cg)([(0,o.MZ)({attribute:!1})],d.prototype,"buttons",void 0),(0,i.Cg)([(0,o.MZ)()],d.prototype,"active",void 0),(0,i.Cg)([(0,o.MZ)({reflect:!0})],d.prototype,"size",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean,reflect:!0,attribute:"no-wrap"})],d.prototype,"nowrap",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean,reflect:!0,attribute:"full-width"})],d.prototype,"fullWidth",void 0),(0,i.Cg)([(0,o.MZ)()],d.prototype,"variant",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"active-variant"})],d.prototype,"activeVariant",void 0),d=(0,i.Cg)([(0,o.EM)("ha-button-toggle-group")],d),t()}catch(e){t(e)}})},39927(e,t,a){a.a(e,async function(e,t){try{var i=a(62826),s=a(5124),o=a(22441),l=a(1087),r=a(32656),n=a(89865),d=e([r,n]);[r,n]=d.then?(await d)():d;const h="M20 14H4V10H20",u="M20 14H14V20H10V14H4V10H10V4H14V10H20V14Z",p=["milliseconds","seconds","minutes","hours","days"];class c extends s.WF{reportValidity(){return this._input?.reportValidity()??!0}render(){return s.qy` <div class="row"> ${this.allowNegative?s.qy` <ha-button-toggle-group size="small" .buttons="${[{label:"+",iconPath:u,value:"+"},{label:"-",iconPath:h,value:"-"}]}" .active="${this._negative?"-":"+"}" -changed="${this._negativeChanged}"></ha-button-toggle-group> `:s.s6} <ha-base-time-input .label="${this.label}" .helper="${this.helper}" .required="${this.required}" .clearable="${!this.required&&void 0!==this.data}" .autoValidate="${this.required}" .disabled="${this.disabled}" errorMessage="Required" .enableSecond="${this.enableSecond}" .enableMillisecond="${this.enableMillisecond}" .enableDay="${this.enableDay}" format="24" .days="${this._days}" .hours="${this._hours}" .minutes="${this._minutes}" .seconds="${this._seconds}" .milliseconds="${this._milliseconds}" -changed="${this._durationChanged}" no-hours-limit day-label="dd" hour-label="hh" min-label="mm" sec-label="ss" ms-label="ms"></ha-base-time-input> </div> `}get _negative(){return this._toggleNegative||(this.data?.days?this.data.days<0:this.data?.hours?this.data.hours<0:this.data?.minutes?this.data.minutes<0:this.data?.seconds?this.data.seconds<0:!!this.data?.milliseconds&&this.data.milliseconds<0)}get _days(){return this.data?.days?this.allowNegative?Math.abs(Number(this.data.days)):Number(this.data.days):this.required||this.data?0:NaN}get _hours(){return this.data?.hours?this.allowNegative?Math.abs(Number(this.data.hours)):Number(this.data.hours):this.required||this.data?0:NaN}get _minutes(){return this.data?.minutes?this.allowNegative?Math.abs(Number(this.data.minutes)):Number(this.data.minutes):this.required||this.data?0:NaN}get _seconds(){return this.data?.seconds?this.allowNegative?Math.abs(Number(this.data.seconds)):Number(this.data.seconds):this.required||this.data?0:NaN}get _milliseconds(){return this.data?.milliseconds?this.allowNegative?Math.abs(Number(this.data.milliseconds)):Number(this.data.milliseconds):this.required||this.data?0:NaN}_durationChanged(e){e.stopPropagation();const t=e.detail.value?{...e.detail.value}:void 0;t&&(t.hours||=0,t.minutes||=0,"days"in t&&(t.days||=0),"seconds"in t&&(t.seconds||=0),"milliseconds"in t&&(t.milliseconds||=0),this.allowNegative&&p.forEach(e=>{t[e]&&(t[e]=Math.abs(t[e]))}),this.enableMillisecond||t.milliseconds?t.milliseconds>999&&(t.seconds+=Math.floor(t.milliseconds/1e3),t.milliseconds%=1e3):delete t.milliseconds,this.enableSecond||t.seconds?this.enableSecond&&t.seconds>59&&(t.minutes=(t.minutes??0)+Math.floor(t.seconds/60),t.seconds%=60):delete t.seconds,t.minutes>59&&(t.hours+=Math.floor(t.minutes/60),t.minutes%=60),this.enableDay&&t.hours>24&&(t.days=(t.days??0)+Math.floor(t.hours/24),t.hours%=24),this._negative&&p.forEach(e=>{t[e]&&(t[e]=-Math.abs(t[e]))})),(0,l.r)(this,"value-changed",{value:t})}_negativeChanged(e){e.stopPropagation();const t="-"===(e.detail?.value||e.target.value);this._toggleNegative=t;const a=this.data;a&&(p.forEach(e=>{a[e]&&(a[e]=t?-Math.abs(a[e]):Math.abs(a[e]))}),(0,l.r)(this,"value-changed",{value:a}))}constructor(...e){super(...e),this.required=!1,this.enableMillisecond=!1,this.enableDay=!1,this.allowNegative=!1,this.enableSecond=!0,this.disabled=!1,this._toggleNegative=!1}}c.shadowRootOptions={...s.WF.shadowRootOptions,delegatesFocus:!0},c.styles=s.AH`.row{display:flex;align-items:center}ha-button-toggle-group{margin:var(--ha-space-2)}`,(0,i.Cg)([(0,o.MZ)({attribute:!1})],c.prototype,"data",void 0),(0,i.Cg)([(0,o.MZ)()],c.prototype,"label",void 0),(0,i.Cg)([(0,o.MZ)()],c.prototype,"helper",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean})],c.prototype,"required",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"enable-millisecond",type:Boolean})],c.prototype,"enableMillisecond",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"enable-day",type:Boolean})],c.prototype,"enableDay",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"allow-negative",type:Boolean})],c.prototype,"allowNegative",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"enable-second",type:Boolean})],c.prototype,"enableSecond",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean})],c.prototype,"disabled",void 0),(0,i.Cg)([(0,o.P)("ha-base-time-input",!0)],c.prototype,"_input",void 0),c=(0,i.Cg)([(0,o.EM)("ha-duration-input")],c),t()}catch(e){t(e)}})}};