@@ -208,24 +208,24 @@ export class AppPackageFormBase extends LitElement {
208208 return html `
209209 < div class ="colorPickerAndValue ">
210210 < sl-color-picker
211- id ="${ formInput . inputId } "
212- class ="form-control "
211+ id ="${ formInput . inputId } "
212+ class ="form-control "
213213 placeholder ="${ formInput . placeholder || '' } "
214- value ="${ ( ifDefined ( formInput . value ) as string ) } "
215- type ="color "
214+ value ="${ ( ifDefined ( formInput . value ) as string ) } "
215+ type ="color "
216216 ?required ="${ formInput . required } "
217- name ="${ ifDefined ( formInput . name ) } "
217+ name ="${ ifDefined ( formInput . name ) } "
218218 minlength ="${ ifDefined ( formInput . minLength ) } "
219219 maxlength ="${ ifDefined ( formInput . maxLength ) } "
220220 min =${ ifDefined ( formInput . minValue ) }
221- max ="${ ifDefined ( formInput . maxValue ) } "
221+ max ="${ ifDefined ( formInput . maxValue ) } "
222222 pattern="${ ifDefined ( formInput . pattern ) } "
223- spellcheck="${ ifDefined ( formInput . spellcheck ) } "
224- ?checked="${ formInput . checked } "
223+ spellcheck="${ ifDefined ( formInput . spellcheck ) } "
224+ ?checked="${ formInput . checked } "
225225 ?readonly="${ formInput . readonly } "
226226 custom-validation-error-message="${ ifDefined ( formInput . validationErrorMessage ) } "
227227 ?disabled=${ formInput . disabled }
228- @sl-change="${ ( e : UIEvent ) => this . colorChanged ( e , formInput ) } "
228+ @sl-change="${ ( e : UIEvent ) => this . colorChanged ( e , formInput ) } "
229229 @sl-invalid=${ this . inputInvalid }
230230 > </ sl-color-picker >
231231 < p > ${ formInput . value } </ p >
@@ -235,19 +235,35 @@ export class AppPackageFormBase extends LitElement {
235235 private renderFormInputTextbox ( formInput : FormInput ) : TemplateResult {
236236 const inputType = formInput . type || 'text' ;
237237 const inputClass = formInput . type === 'radio' ? 'form-check-input' : 'form-control' ;
238- return html `
239- < input id ="${ formInput . inputId } " class ="${ inputClass } " placeholder ="${ formInput . placeholder || '' } "
240- value ="${ ifDefined ( formInput . value ) } " type ="${ inputType } " ?required ="${ formInput . required } "
241- name ="${ ifDefined ( formInput . name ) } " minlength ="${ ifDefined ( formInput . minLength ) } "
242- maxlength ="${ ifDefined ( formInput . maxLength ) } " min =${ ifDefined ( formInput . minValue ) }
243- max ="${ ifDefined ( formInput . maxValue ) } " pattern="${ ifDefined ( formInput . pattern ) } "
244- spellcheck="${ ifDefined ( formInput . spellcheck ) } " ?checked="${ formInput . checked } " ?readonly="${ formInput . readonly } "
238+
239+ const input = html `
240+ < input id ="${ formInput . inputId } "
241+ class ="${ inputClass } "
242+ placeholder ="${ formInput . placeholder || '' } "
243+ value ="${ ifDefined ( formInput . value ) } "
244+ type ="${ inputType } "
245+ ?required ="${ formInput . required } "
246+ name ="${ ifDefined ( formInput . name ) } "
247+ minlength ="${ ifDefined ( formInput . minLength ) } "
248+ maxlength ="${ ifDefined ( formInput . maxLength ) } "
249+ min =${ ifDefined ( formInput . minValue ) }
250+ max ="${ ifDefined ( formInput . maxValue ) } "
251+ pattern="${ ifDefined ( formInput . pattern ) } "
252+ spellcheck="${ ifDefined ( formInput . spellcheck ) } "
253+ ?checked="${ formInput . checked } "
254+ ?readonly="${ formInput . readonly } "
245255 custom-validation-error-message="${ ifDefined ( formInput . validationErrorMessage ) } "
246256 ?disabled=${ formInput . disabled }
247- @input="${ ( e : UIEvent ) => this . inputChanged ( e , formInput ) } " @invalid=${ this . inputInvalid } />
257+ @input="${ ( e : UIEvent ) => this . inputChanged ( e , formInput ) } "
258+ @invalid=${ this . inputInvalid } />
248259 ` ;
260+
261+ return formInput . disabled
262+ ? html `< sl-tooltip content ="${ formInput . disabledTooltipText } "> ${ input } </ sl-tooltip > `
263+ : input ;
249264 }
250265
266+
251267 private renderFormInputLabel ( formInput : FormInput ) : TemplateResult {
252268 return html `
253269 < label for ="${ formInput . inputId } ">
@@ -284,12 +300,12 @@ export class AppPackageFormBase extends LitElement {
284300 const inputElement = e . target as HTMLSlColorPicker ;
285301
286302 if ( ! inputElement || ! inputElement . nextElementSibling ) return ;
287-
303+
288304 const formattedValue = inputElement . getFormattedValue ( 'hex' ) . toLocaleUpperCase ( ) ;
289305 const colorValue = inputElement . nextElementSibling ;
290306 const newValue = document . createElement ( 'p' ) ;
291307 newValue . textContent = formattedValue ;
292-
308+
293309 colorValue . replaceWith ( newValue ) ;
294310
295311 // Fire the input handler
@@ -303,7 +319,7 @@ export class AppPackageFormBase extends LitElement {
303319 inputElement . setCustomValidity ( errorMessage ) ;
304320 inputElement . title = errorMessage ;
305321 }
306-
322+
307323 }
308324
309325 private inputChanged ( e : UIEvent , formInput : FormInput ) {
@@ -381,5 +397,6 @@ export interface FormInput {
381397 validationErrorMessage ?: string ;
382398 checked ?: boolean ;
383399 disabled ?: boolean ;
400+ disabledTooltipText ?: string ;
384401 inputHandler ?: ( val : string , checked : boolean , input : HTMLInputElement ) => void ;
385402}
0 commit comments