|
101 | 101 | </template>
|
102 | 102 |
|
103 | 103 | <script>
|
104 |
| -import {inputProps, useFormInput} from './useFormInput.js' |
| 104 | +import { inputProps, useFormInput } from './useFormInput.js' |
105 | 105 | import InputWrapper from './components/InputWrapper.vue'
|
106 | 106 |
|
107 | 107 | /**
|
108 | 108 | * Options: {name,value} objects
|
109 | 109 | */
|
110 | 110 | export default {
|
111 | 111 | name: 'SelectInput',
|
112 |
| - components: {InputWrapper}, |
| 112 | + components: { InputWrapper }, |
113 | 113 |
|
114 | 114 | props: {
|
115 | 115 | ...inputProps,
|
116 |
| - options: {type: Array, required: true}, |
117 |
| - optionKey: {type: String, default: 'value'}, |
118 |
| - emitKey: {type: String, default: 'value'}, |
119 |
| - displayKey: {type: String, default: 'name'}, |
120 |
| - loading: {type: Boolean, default: false}, |
121 |
| - multiple: {type: Boolean, default: false}, |
122 |
| - searchable: {type: Boolean, default: false}, |
123 |
| - clearable: {type: Boolean, default: false}, |
124 |
| - allowCreation: {type: Boolean, default: false}, |
125 |
| - dropdownClass: {type: String, default: 'w-full'}, |
126 |
| - remote: {type: Function, default: null} |
| 116 | + options: { type: Array, required: true }, |
| 117 | + optionKey: { type: String, default: 'value' }, |
| 118 | + emitKey: { type: String, default: 'value' }, |
| 119 | + displayKey: { type: String, default: 'name' }, |
| 120 | + loading: { type: Boolean, default: false }, |
| 121 | + multiple: { type: Boolean, default: false }, |
| 122 | + searchable: { type: Boolean, default: false }, |
| 123 | + clearable: { type: Boolean, default: false }, |
| 124 | + allowCreation: { type: Boolean, default: false }, |
| 125 | + dropdownClass: { type: String, default: 'w-full' }, |
| 126 | + remote: { type: Function, default: null } |
127 | 127 | },
|
128 | 128 | setup(props, context) {
|
129 | 129 | return {
|
@@ -160,8 +160,10 @@ export default {
|
160 | 160 | return optionCandidate[this.optionKey] === val ||
|
161 | 161 | (typeof val === 'object' && optionCandidate[this.optionKey] === val[this.optionKey])
|
162 | 162 | })
|
163 |
| - if (option) return option[this.displayKey] |
164 |
| - return null |
| 163 | + if (option && option[this.displayKey] !== undefined) { |
| 164 | + return option[this.displayKey] |
| 165 | + } |
| 166 | + return val // Return the original value if no matching option is found |
165 | 167 | },
|
166 | 168 | getOptionNames(values) {
|
167 | 169 | return values.map(val => {
|
|
0 commit comments