11import { LitElement , html , nothing , css } from 'lit' ;
2- import { Event } from '../core/Event' ;
32
43/**
54 * @class FormControlElement
@@ -10,6 +9,7 @@ import { Event } from '../core/Event';
109 * @property {String } value - The value of the control
1110 * @property {Boolean } disabled - Whether the form control is disabled
1211 * @property {Boolean } required - Whether the form control is required before submitting
12+ * @property {Boolean } autocomplete - Whether the form control allows autocomplete
1313 *
1414 * @example
1515 * <wc-form-control>Power</wc-form-switch>
@@ -27,7 +27,10 @@ export class FormControlElement extends LitElement {
2727
2828 // Default properties
2929 this . name = '' ;
30+ this . value = '' ;
3031 this . disabled = false ;
32+ this . required = false ;
33+ this . autocomplete = false ;
3134 }
3235
3336 static get formAssociated ( ) {
@@ -40,6 +43,7 @@ export class FormControlElement extends LitElement {
4043 value : { type : String } ,
4144 disabled : { type : Boolean } ,
4245 required : { type : Boolean } ,
46+ autocomplete : { type : Boolean } ,
4347 } ;
4448 }
4549
@@ -72,6 +76,25 @@ export class FormControlElement extends LitElement {
7276 background-position: right center;
7377 }
7478 }
79+
80+ label.select {
81+ cursor: inherit;
82+
83+ & select {
84+ width: 100%;
85+ cursor: pointer;
86+ font-family: inherit;
87+ appearance: none;
88+ padding: var(--form-select-padding-y) var(--form-select-padding-x);
89+ background-color: var(--form-select-background-color);
90+ border: 1px solid var(--form-select-border-color);
91+ border-radius: var(--form-select-border-radius);
92+
93+ &:focus {
94+ outline: 0;
95+ }
96+ }
97+ }
7598 ` ;
7699 }
77100
@@ -83,6 +106,7 @@ export class FormControlElement extends LitElement {
83106 value =${ this . value || nothing }
84107 ?disabled=${ this . disabled }
85108 ?required=${ this . required }
109+ ?autocomplete=${ this . autocomplete }
86110 @input=${ this . onInput } >
87111 < slot > </ slot >
88112 </ label >
@@ -121,14 +145,8 @@ export class FormControlElement extends LitElement {
121145 if ( ! this . disabled ) {
122146 this . value = event . target . value ;
123147 this . internals . setFormValue ( this . value ) ;
124-
125- // Dispatch a click event
126- this . dispatchEvent ( new CustomEvent (
127- Event . CHANGE , {
128- bubbles : true ,
129- composed : true ,
130- detail : this . name || this . textContent ,
131- } ) ) ;
148+ return true ;
132149 }
150+ return false ;
133151 }
134152}
0 commit comments