@@ -84,9 +84,65 @@ export class InternalSelectControl extends InternalEditableControl {
84
84
const selection = this . options . find ( v => v . value === this . _value ) ;
85
85
86
86
return html `
87
- < div class ="flex items-start leading-xs ">
88
- < div class ="flex-1 ">
89
- < label class ="text-m text-body " for ="select "> ${ this . label } </ label >
87
+ < div class ="leading-xs ">
88
+ < div class ="flex items-center gap-s ">
89
+ < label class ="text-m text-body flex-1 whitespace-nowrap " for ="select ">
90
+ ${ this . label }
91
+ </ label >
92
+ < div
93
+ class =${ classMap ( {
94
+ 'relative rounded-s transition-colors transition-opacity min-w-0' : true ,
95
+ 'focus-within-ring-2 focus-within-ring-primary-50' : ! this . disabled && ! this . readonly ,
96
+ 'text-body hover-opacity-80 cursor-pointer' : ! this . disabled && ! this . readonly ,
97
+ 'text-secondary' : this . readonly ,
98
+ 'text-disabled' : this . disabled ,
99
+ 'font-medium' : ! this . readonly ,
100
+ } ) }
101
+ >
102
+ < div class ="flex items-center gap-xs min-w-0 ">
103
+ < div class ="truncate min-w-0 ">
104
+ ${ selection
105
+ ? 'label' in selection
106
+ ? this . t ( selection . label )
107
+ : selection . rawLabel
108
+ : this . placeholder }
109
+ </ div >
110
+ ${ this . readonly
111
+ ? ''
112
+ : svg `< svg xmlns ="http://www.w3.org/2000/svg " viewBox ="0 0 20 20 " fill ="currentColor " class ="flex-shrink-0 " style ="width: 1em; height: 1em; transform: scale(1.25) "> < path fill-rule ="evenodd " d ="M10.53 3.47a.75.75 0 0 0-1.06 0L6.22 6.72a.75.75 0 0 0 1.06 1.06L10 5.06l2.72 2.72a.75.75 0 1 0 1.06-1.06l-3.25-3.25Zm-4.31 9.81 3.25 3.25a.75.75 0 0 0 1.06 0l3.25-3.25a.75.75 0 1 0-1.06-1.06L10 14.94l-2.72-2.72a.75.75 0 0 0-1.06 1.06Z " clip-rule ="evenodd " /> </ svg > ` }
113
+ </ div >
114
+
115
+ < select
116
+ class =${ classMap ( {
117
+ 'absolute inset-0 opacity-0' : true ,
118
+ 'cursor-pointer' : ! this . disabled && ! this . readonly ,
119
+ } ) }
120
+ id ="select"
121
+ ?disabled=${ this . disabled }
122
+ ?hidden=${ this . readonly }
123
+ @blur=${ ( ) => ( this . __isErrorVisible = true ) }
124
+ @change=${ ( evt : Event ) => {
125
+ evt . stopPropagation ( ) ;
126
+ this . _value = ( evt . target as HTMLSelectElement ) . value ;
127
+ } }
128
+ >
129
+ < option value ="" ?selected =${ ! selection } disabled hidden > ${ this . placeholder } </ option >
130
+ ${ this . options . map (
131
+ option =>
132
+ html `
133
+ < option
134
+ value =${ option . value }
135
+ ?selected =${ selection && option . value === this . _value }
136
+ >
137
+ ${ 'label' in option ? this . t ( option . label ) : option . rawLabel }
138
+ </ option >
139
+ `
140
+ ) }
141
+ </ select >
142
+ </ div >
143
+ </ div >
144
+
145
+ < div style ="max-width: 32rem ">
90
146
< p class ="text-xs text-secondary "> ${ this . helperText } </ p >
91
147
< p
92
148
class ="text-xs text-error "
@@ -95,58 +151,6 @@ export class InternalSelectControl extends InternalEditableControl {
95
151
${ this . _errorMessage }
96
152
</ p >
97
153
</ div >
98
-
99
- < div
100
- class =${ classMap ( {
101
- 'relative rounded-s transition-colors transition-opacity' : true ,
102
- 'focus-within-ring-2 focus-within-ring-primary-50' : ! this . disabled && ! this . readonly ,
103
- 'text-body hover-opacity-80 cursor-pointer' : ! this . disabled && ! this . readonly ,
104
- 'text-secondary' : this . readonly ,
105
- 'text-disabled' : this . disabled ,
106
- 'font-medium' : ! this . readonly ,
107
- } ) }
108
- >
109
- < div class ="flex items-center gap-xs ">
110
- < div >
111
- ${ selection
112
- ? 'label' in selection
113
- ? this . t ( selection . label )
114
- : selection . rawLabel
115
- : this . placeholder }
116
- </ div >
117
- ${ this . readonly
118
- ? ''
119
- : svg `< svg xmlns ="http://www.w3.org/2000/svg " viewBox ="0 0 20 20 " fill ="currentColor " style ="width: 1em; height: 1em; transform: scale(1.25) "> < path fill-rule ="evenodd " d ="M10.53 3.47a.75.75 0 0 0-1.06 0L6.22 6.72a.75.75 0 0 0 1.06 1.06L10 5.06l2.72 2.72a.75.75 0 1 0 1.06-1.06l-3.25-3.25Zm-4.31 9.81 3.25 3.25a.75.75 0 0 0 1.06 0l3.25-3.25a.75.75 0 1 0-1.06-1.06L10 14.94l-2.72-2.72a.75.75 0 0 0-1.06 1.06Z " clip-rule ="evenodd " /> </ svg > ` }
120
- </ div >
121
-
122
- < select
123
- class =${ classMap ( {
124
- 'absolute inset-0 opacity-0' : true ,
125
- 'cursor-pointer' : ! this . disabled && ! this . readonly ,
126
- } ) }
127
- id ="select"
128
- ?disabled=${ this . disabled }
129
- ?hidden=${ this . readonly }
130
- @blur=${ ( ) => ( this . __isErrorVisible = true ) }
131
- @change=${ ( evt : Event ) => {
132
- evt . stopPropagation ( ) ;
133
- this . _value = ( evt . target as HTMLSelectElement ) . value ;
134
- } }
135
- >
136
- < option value ="" ?selected =${ ! selection } disabled hidden > ${ this . placeholder } </ option >
137
- ${ this . options . map (
138
- option =>
139
- html `
140
- < option
141
- value =${ option . value }
142
- ?selected =${ selection && option . value === this . _value }
143
- >
144
- ${ 'label' in option ? this . t ( option . label ) : option . rawLabel }
145
- </ option >
146
- `
147
- ) }
148
- </ select >
149
- </ div >
150
154
</ div >
151
155
` ;
152
156
}
0 commit comments