UNPKG

iobroker.javascript

Version:
2 lines 2.19 kB
import{$t as e,Hn as t,Lt as n,Un as r,Xn as i,Xt as a,Yt as o,Zt as s,f as c,lt as l,xt as u,yr as d,zt as f}from"./_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-CxICLr5Z.js";import{t as p}from"./ScriptEditorVanillaMonaco-DyMQtoTQ.js";d();var m={textArea:{width:`calc(100% - 10px)`,resize:`none`},dialog:{height:`95%`},fullHeight:{height:`100%`,overflow:`hidden`},args:e=>({color:e.palette.mode===`dark`?`white`:`black`,height:30,width:`100%`,fontSize:16}),argsTitle:e=>({color:e.palette.mode===`dark`?`white`:`black`,fontWeight:`bold`})},h=class extends i.Component{constructor(e){super(e),this.state={changed:!1,source:!e.source&&e.isReturn?` return false`:e.source}}componentDidMount(){setTimeout(()=>{try{var e;(e=window.document.getElementById(`source-text-area`))==null||e.focus()}catch{}},100)}handleCancel(){this.props.onClose(!1)}handleOk(){(!this.props.isReturn||this.state.source.includes(`return `))&&this.props.onClose(this.state.source)}onChange(e){this.setState({changed:!0,source:e})}render(){return r(o,{onClose:()=>!1,maxWidth:`lg`,sx:{"& .MuiDialog-paper":m.dialog},fullWidth:!0,open:!0,"aria-labelledby":`source-dialog-title`,children:[t(e,{id:`source-dialog-title`,children:c.t(`Function editor`)}),r(s,{style:m.fullHeight,children:[this.props.args&&r(n,{sx:m.args,children:[t(n,{component:`span`,sx:m.argsTitle,children:c.t(`function (`)}),this.props.args,t(n,{component:`span`,sx:m.argsTitle,children:`)`})]},`arguments`),t(p,{triggerPrettier:1,adapterName:this.props.adapterName,runningInstances:this.props.runningInstances,style:{...m.textArea,height:this.props.args?`calc(100% - 30px)`:`100%`},name:`blockly`,socket:this.props.socket,readOnly:!1,checkJs:!1,changed:this.state.changed,code:this.state.source,isDark:this.props.themeType===`dark`,onChange:e=>this.onChange(e),language:`javascript`},`scriptEditor`)]}),r(a,{children:[t(f,{variant:`contained`,onClick:()=>this.handleOk(),color:`primary`,startIcon:t(l,{}),children:c.t(`Save`)}),t(f,{color:`grey`,variant:`contained`,onClick:()=>this.handleCancel(),startIcon:t(u,{}),children:c.t(`Cancel`)})]})]})}};export{h as default};