zigbee2mqtt-windfront
Version:
[](https://npmjs.org/package/zigbee2mqtt-windfront) [](https://github.com/Nerivec/zigbee2mqtt-windf
2 lines (1 loc) • 3.29 kB
JavaScript
import{E as j,P as h,b as p,r as b,j as e,Q as y,C as f,F as u,R as w,aD as x,T as _,aH as g,m as k,G as C,aI as E}from"./index-C9teBVht.js";import{R as D}from"./RemoveDeviceModal-BwBAE1DK.js";import{C as N}from"./CheckboxField-ZdCJFDzF.js";import{I}from"./InputField-CoouO8KX.js";const R=j.create(({sourceIdx:l,homeassistantEnabled:t,name:i,renameDevice:m})=>{const o=h(),{t:r}=p(["zigbee","common"]),[s,v]=b.useState(!1),[d,c]=b.useState(i);return b.useEffect(()=>{c(i)},[i]),b.useEffect(()=>{const n=a=>{a.key==="Escape"&&(a.preventDefault(),o.remove())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[o]),e.jsx(y,{isOpen:o.visible,title:`${r(n=>n.rename_device)} ${i}`,footer:e.jsxs(e.Fragment,{children:[e.jsx(f,{className:"btn btn-neutral",onClick:o.remove,children:r(n=>n.cancel,{ns:"common"})}),e.jsx(f,{className:"btn btn-primary ms-1",onClick:async()=>{o.remove(),await m(l,i,d,s)},children:r(n=>n.rename_device)})]}),children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(I,{name:"friendly_name",label:r(n=>n.friendly_name,{ns:"common"}),onChange:n=>c(n.target.value),value:d,type:"text"}),t&&e.jsx(N,{label:r(n=>n.update_Home_assistant_entity_id),name:"update_Home_assistant_entity_id",onChange:n=>v(n.target.checked),checked:s})]})})}),A=b.memo(({sourceIdx:l,name:t,homeassistantEnabled:i,style:m,renameDevice:o})=>{const{t:r}=p("zigbee");return e.jsx(f,{className:`btn ${m} tooltip`,onClick:async()=>await j.show(R,{sourceIdx:l,name:t,renameDevice:o,homeassistantEnabled:i}),"data-tip":r(s=>s.rename_device),children:e.jsx(u,{icon:w})})});function H({sourceIdx:l,device:t,otaState:i,homeassistantEnabled:m,renameDevice:o,configureDevice:r,interviewDevice:s,removeDevice:v,btnClassName:d=""}){const{t:c}=p(["zigbee","common"]),n=t.interview_state===x.InProgress||t.interview_state===x.Pending||i==="updating";return e.jsxs("div",{className:"join join-horizontal",children:[e.jsx(A,{sourceIdx:l,name:t.friendly_name,renameDevice:o,homeassistantEnabled:m,style:`btn-outline btn-primary join-item btn-square ${d}`}),e.jsx(_,{className:`btn btn-outline btn-warning join-item btn-square ${d}`,onClick:r,item:[l,t.ieee_address],title:c(a=>a.reconfigure),modalDescription:c(a=>a.dialog_confirmation_prompt,{ns:"common"}),modalCancelLabel:c(a=>a.cancel,{ns:"common"}),disabled:n,children:e.jsx(u,{icon:g})}),e.jsx(_,{className:`btn btn-outline btn-info join-item btn-square ${d}`,onClick:s,item:[l,t.ieee_address],title:c(a=>a.interview),modalDescription:c(a=>a.dialog_confirmation_prompt,{ns:"common"}),modalCancelLabel:c(a=>a.cancel,{ns:"common"}),disabled:n,children:e.jsx(u,{icon:k})}),e.jsx(f,{onClick:async()=>await j.show(D,{sourceIdx:l,device:t,removeDevice:v}),className:`btn btn-outline btn-error join-item btn-square ${d}`,title:c(a=>a.remove_device),children:e.jsx(u,{icon:C})})]})}const M=b.memo(l=>{const{t}=p("availability"),{availability:i,availabilityFeatureEnabled:m,availabilityEnabledForDevice:o,disabled:r}=l;return r?e.jsx("span",{children:t(s=>s.disabled)}):o??m?e.jsx("span",{className:i==="online"?"text-success":"text-error",children:t(s=>s[i])}):e.jsx("a",{className:"link link-hover",target:"_blank",rel:"noopener noreferrer",href:E,children:t(s=>s.disabled)})});export{M as A,H as D,A as a};