@@ -183,6 +183,31 @@ function getKey(obj, key, default_value) {
183183 let val = obj [ key ] ;
184184 return typeof val !== 'undefined' ? val : default_value ;
185185}
186+ function choicesValueTitleMap ( choices ) {
187+ /* Returns a mapping of {value: title} for the given choices.
188+ * E.g.:
189+ * Input: [{'title': 'One', 'value': 1}, 2]
190+ * Output: {1: 'One', 2: 2}
191+ */
192+ let map = { } ;
193+
194+ for ( let i = 0 ; i < choices . length ; i ++ ) {
195+ let choice = choices [ i ] ;
196+ let value , title ;
197+
198+ if ( actualType ( choice ) === 'object' ) {
199+ value = choice . value ;
200+ title = choice . title ;
201+ } else {
202+ value = choice ;
203+ title = choice ;
204+ }
205+
206+ map [ value ] = title ;
207+ }
208+
209+ return map ;
210+ }
186211function valueInChoices ( schema , value ) {
187212 /* Checks whether the given value is in schema choices or not.
188213 If schema doesn't have choices, returns true.
@@ -1170,6 +1195,7 @@ class FormMultiSelectInput extends React__default["default"].Component {
11701195 inputRef : this . input ,
11711196 onClick : this . toggleOptions ,
11721197 value : this . props . value ,
1198+ options : this . props . options ,
11731199 onChange : this . handleChange ,
11741200 disabled : this . props . readOnly ,
11751201 placeholder : this . props . placeholder
@@ -1204,6 +1230,7 @@ class FormMultiSelectInputField extends React__default["default"].Component {
12041230 }
12051231
12061232 render ( ) {
1233+ let valueTitleMap = choicesValueTitleMap ( this . props . options ) ;
12071234 return /*#__PURE__*/ React__default [ "default" ] . createElement ( "div" , {
12081235 className : "rjf-multiselect-field-input" ,
12091236 onClick : this . props . onClick ,
@@ -1212,7 +1239,7 @@ class FormMultiSelectInputField extends React__default["default"].Component {
12121239 } , this . props . value . length ? this . props . value . map ( ( item , index ) => /*#__PURE__*/ React__default [ "default" ] . createElement ( "span" , {
12131240 className : "rjf-multiselect-field-input-item" ,
12141241 key : item + '_' + index
1215- } , /*#__PURE__*/ React__default [ "default" ] . createElement ( "span" , null , item ) , this . props . disabled || /*#__PURE__*/ React__default [ "default" ] . createElement ( "button" , {
1242+ } , /*#__PURE__*/ React__default [ "default" ] . createElement ( "span" , null , valueTitleMap [ item ] ) , this . props . disabled || /*#__PURE__*/ React__default [ "default" ] . createElement ( "button" , {
12161243 title : "Remove" ,
12171244 type : "button" ,
12181245 onClick : e => this . handleRemove ( e , index )
0 commit comments