11import { localized , msg } from "@lit/localize" ;
22import type { SlSelect } from "@shoelace-style/shoelace" ;
3- import { html } from "lit" ;
3+ import { html , type PropertyValues } from "lit" ;
44import { customElement , property , state } from "lit/decorators.js" ;
55import { ifDefined } from "lit/directives/if-defined.js" ;
66
@@ -40,15 +40,30 @@ export class SelectCrawlerProxy extends BtrixElement {
4040 @property ( { type : String } )
4141 defaultProxyId : string | null = null ;
4242
43+ @property ( { type : String } )
44+ profileProxyId ?: string | null = null ;
45+
4346 @property ( { type : Array } )
4447 proxyServers : Proxy [ ] = [ ] ;
4548
4649 @property ( { type : String } )
4750 proxyId : string | null = null ;
4851
52+ @property ( { type : String } )
53+ label ?: string ;
54+
4955 @property ( { type : String } )
5056 size ?: SlSelect [ "size" ] ;
5157
58+ @property ( { type : String } )
59+ placeholder ?: string ;
60+
61+ @property ( { type : String } )
62+ helpText ?: string ;
63+
64+ @property ( { type : Boolean } )
65+ disabled ?: boolean ;
66+
5267 @state ( )
5368 private selectedProxy ?: Proxy ;
5469
@@ -59,6 +74,18 @@ export class SelectCrawlerProxy extends BtrixElement {
5974 return this . selectedProxy ?. id || "" ;
6075 }
6176
77+ protected willUpdate ( changedProperties : PropertyValues ) : void {
78+ if ( changedProperties . has ( "proxyId" ) ) {
79+ if ( this . proxyId ) {
80+ this . selectedProxy = this . proxyServers . find (
81+ ( { id } ) => id === this . proxyId ,
82+ ) ;
83+ } else if ( changedProperties . get ( "proxyId" ) ) {
84+ this . selectedProxy = undefined ;
85+ }
86+ }
87+ }
88+
6289 protected firstUpdated ( ) {
6390 void this . initProxies ( ) ;
6491 }
@@ -75,18 +102,21 @@ export class SelectCrawlerProxy extends BtrixElement {
75102 return html `
76103 < sl-select
77104 name ="proxyId "
78- label =${ msg ( "Crawler Proxy Server" ) }
105+ label =${ this . label || msg ( "Crawler Proxy Server" ) }
79106 value =${ this . selectedProxy ?. id || "" }
80107 placeholder=${ this . defaultProxy
81108 ? `${ msg ( `Default Proxy:` ) } ${ this . defaultProxy . label } `
82109 : msg ( "No Proxy" ) }
83110 hoist
84111 clearable
112+ ?disabled=${ this . disabled ?? Boolean ( this . profileProxyId ) }
85113 size=${ ifDefined ( this . size ) }
86114 @sl-change=${ this . onChange }
87115 @sl-hide=${ this . stopProp }
88116 @sl-after-hide=${ this . stopProp }
89117 >
118+ < slot name ="prefix " slot ="prefix "> </ slot >
119+ < slot name ="suffix " slot ="suffix "> </ slot >
90120 ${ this . proxyServers . map (
91121 ( server ) =>
92122 html ` < sl-option value =${ server . id } >
@@ -102,7 +132,7 @@ export class SelectCrawlerProxy extends BtrixElement {
102132 ? html `
103133 < div slot ="help-text ">
104134 ${ msg ( "Description:" ) }
105- < span class ="font-monospace "
135+ < span class ="font-monospace leading-tight "
106136 > ${ this . selectedProxy . description || "" } </ span
107137 >
108138 </ div >
@@ -112,12 +142,13 @@ export class SelectCrawlerProxy extends BtrixElement {
112142 ? html `
113143 < div slot ="help-text ">
114144 ${ msg ( "Description:" ) }
115- < span class ="font-monospace "
145+ < span class ="font-monospace leading-tight "
116146 > ${ this . defaultProxy . description || "" } </ span
117147 >
118148 </ div >
119149 `
120150 : `` }
151+ < slot name ="help-text " slot ="help-text "> </ slot >
121152 </ sl-select >
122153 ` ;
123154 }
0 commit comments