@@ -36,6 +36,14 @@ interface PlayerSelectInputProps extends WegasComponentProps {
36
36
* choices - the allowed choices
37
37
*/
38
38
choices ?: Choice [ ] | IScript ;
39
+ /**
40
+ * placeholder - the grey text inside the box when nothing is selected
41
+ */
42
+ placeholder ?: IScript ;
43
+ /**
44
+ * noOptionsMessage - the text to inform that there is no available choice
45
+ */
46
+ noOptionsMessage ?: IScript ;
39
47
onVariableChange ?: OnVariableChange ;
40
48
}
41
49
@@ -50,6 +58,8 @@ function PlayerSelectInput({
50
58
onVariableChange,
51
59
pageId,
52
60
path,
61
+ placeholder,
62
+ noOptionsMessage,
53
63
} : PlayerSelectInputProps ) {
54
64
const { somethingIsUndefined } = useInternalTranslate ( commonTranslations ) ;
55
65
const descriptor = useScript < SStringDescriptor | SNumberDescriptor | string > (
@@ -62,15 +72,19 @@ function PlayerSelectInput({
62
72
context ,
63
73
) ;
64
74
65
- const value = useStore (
66
- ( ) =>
67
- ( descriptor != null && typeof descriptor === 'object'
75
+ const value = useStore ( ( ) => {
76
+ const v =
77
+ descriptor != null && typeof descriptor === 'object'
68
78
? descriptor . getValue ( Player . self ( ) )
69
- : descriptor ) || '' ,
70
- ) ;
79
+ : descriptor ;
80
+ return v == undefined ? '' : v ;
81
+ } ) ;
71
82
72
83
const { lang } = React . useContext ( languagesCTX ) ;
73
84
const { handleOnChange } = useOnVariableChange ( onVariableChange , context ) ;
85
+ const placeholderText = useScript < string > ( placeholder , context ) || undefined ;
86
+ const noOptionsMessageText =
87
+ useScript < string > ( noOptionsMessage , context ) || undefined ;
74
88
75
89
if ( descriptor == null ) {
76
90
return (
@@ -106,6 +120,8 @@ function PlayerSelectInput({
106
120
id = { id }
107
121
value = { String ( value ) }
108
122
choices = { computedChoices }
123
+ placeholder = { placeholderText }
124
+ noOptionsMessage = { noOptionsMessageText }
109
125
onChange = { v => {
110
126
const newValue = v ;
111
127
if ( handleOnChange ) {
@@ -154,16 +170,27 @@ registerComponent(
154
170
label : 'Choices' ,
155
171
scriptProps : {
156
172
language : 'TypeScript' ,
157
- returnType : [ '{label:string, value: string}[]' ] ,
173
+ returnType : [
174
+ '{label:string, value: string, disabled?: boolean}[] | undefined' ,
175
+ ] ,
158
176
} ,
159
177
literalSchema : schemaProps . array ( {
160
178
itemSchema : {
161
179
label : schemaProps . string ( { label : 'Label' } ) ,
162
180
value : schemaProps . string ( { label : 'Value' } ) ,
181
+ disabled : schemaProps . boolean ( { label : 'Disabled' } ) ,
163
182
} ,
164
183
} ) ,
165
184
} ,
166
185
} ,
186
+ placeholder : schemaProps . scriptString ( {
187
+ label : 'Placeholder' ,
188
+ richText : false ,
189
+ } ) ,
190
+ noOptionsMessage : schemaProps . scriptString ( {
191
+ label : 'No options message' ,
192
+ richText : false ,
193
+ } ) ,
167
194
onVariableChange : onVariableChangeSchema ( 'On text change action' ) ,
168
195
...classStyleIdSchema ,
169
196
} ,
0 commit comments