@@ -11,7 +11,7 @@ import { property, state } from 'lit/decorators.js';
1111@defineElement ( 'uui-input-color' )
1212export class UUIInputColorElement extends UUIInputElement {
1313 @state ( )
14- private inputType : InputType = 'color ' ;
14+ private inputType : InputType = 'text ' ;
1515
1616 // this overrides the inherited type property, and moves the input's type handling to the passwordType state.
1717 @property ( )
@@ -22,31 +22,58 @@ export class UUIInputColorElement extends UUIInputElement {
2222 this . inputType = newValue ;
2323 }
2424
25+ onChange ( e : Event ) : void {
26+ const target = e . target as HTMLInputElement ;
27+ this . value = target . value ;
28+ }
29+
2530 connectedCallback ( ) : void {
2631 super . connectedCallback ( ) ;
2732
2833 demandCustomElement ( this , 'uui-color-swatch' ) ;
2934 }
3035
3136 renderPrepend ( ) {
32- return html `< uui-color-swatch
33- .disabled =${ this . disabled }
34- .readonly =${ this . readonly }
35- .value=${ this . value } >
36- </ uui-color-swatch > ` ;
37+ return html `<label id= "color-picker" >
38+ <uui- color - swatch
39+ ?dis abled= ${ this . disabled }
40+ ?readonly = ${ this . readonly }
41+ .value = ${ this . value } >
42+ </ uui- color - swatch>
43+ <input
44+ type= "color"
45+ id = "color-input"
46+ .value = "${ this . value } "
47+ ?dis abled= ${ this . disabled }
48+ ?readonly = ${ this . readonly }
49+ aria- hidden= "true" / >
50+ </ label> ` ;
3751 }
3852
39- static styles = [ ...UUIInputElement . styles , css `` ] ;
40-
41- /*render(){
42- return html`
43- <div class="color-wrapper">
44- <uui-input id="input" label="Value" placeholder="Value" required style="--uui-show-focus-outline: 0;">
45- <uui-color-swatch slot="prepend" label="" value="#"></uui-color-swatch>
46- </uui-input>
47- <input type="color" id="color" aria-hidden="true" value="">
48- </div>`;
49- }*/
53+ static styles = [
54+ ...UUIInputElement . styles ,
55+ css `
56+ : host {
57+ }
58+
59+ # color-picker {
60+ cursor : pointer;
61+ position : relative;
62+ border-right : var (--uui-input-border-width , 1px ) solid
63+ var (--uui-input-border-color , var (--uui-color-border ));
64+ }
65+
66+ # color-input {
67+ visibility : hidden;
68+ appearance : none;
69+ }
70+
71+ uui-color-swatch {
72+ margin-left : 0.25rem ;
73+ margin-right : 0.25rem ;
74+ }
75+ ` ,
76+ ] ;
5077}
5178
5279declare global {
0 commit comments