You've already forked AstralRinth
forked from didirus/AstralRinth
Attempt to fix displayName undefined error (#3424)
This commit is contained in:
@@ -58,7 +58,7 @@
|
|||||||
:value="option"
|
:value="option"
|
||||||
:name="name"
|
:name="name"
|
||||||
/>
|
/>
|
||||||
<label :for="`${name}-${index}`">{{ displayName(option) }}</label>
|
<label :for="`${name}-${index}`">{{ getOptionLabel(option) }}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
@@ -101,10 +101,14 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
displayName: {
|
displayName: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: (option) => option,
|
default: undefined,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function getOptionLabel(option) {
|
||||||
|
return props.displayName?.(option) ?? option
|
||||||
|
}
|
||||||
|
|
||||||
const emit = defineEmits(['input', 'change', 'update:modelValue'])
|
const emit = defineEmits(['input', 'change', 'update:modelValue'])
|
||||||
|
|
||||||
const dropdownVisible = ref(false)
|
const dropdownVisible = ref(false)
|
||||||
@@ -114,7 +118,7 @@ const dropdown = ref(null)
|
|||||||
const optionElements = ref(null)
|
const optionElements = ref(null)
|
||||||
|
|
||||||
const selectedOption = computed(() => {
|
const selectedOption = computed(() => {
|
||||||
return props.displayName(selectedValue.value) || props.placeholder || 'Select an option'
|
return getOptionLabel(selectedValue.value) ?? props.placeholder ?? 'Select an option'
|
||||||
})
|
})
|
||||||
|
|
||||||
const radioValue = computed({
|
const radioValue = computed({
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
class="!w-full"
|
class="!w-full"
|
||||||
:color="manyValues.includes(option) ? 'secondary' : 'default'"
|
:color="manyValues.includes(option) ? 'secondary' : 'default'"
|
||||||
>
|
>
|
||||||
<slot name="option" :option="option">{{ displayName?.(option) }}</slot>
|
<slot name="option" :option="option">{{ getOptionLabel(option) }}</slot>
|
||||||
<CheckIcon
|
<CheckIcon
|
||||||
class="h-5 w-5 text-contrast ml-auto transition-opacity"
|
class="h-5 w-5 text-contrast ml-auto transition-opacity"
|
||||||
:class="{ 'opacity-0': !manyValues.includes(option) }"
|
:class="{ 'opacity-0': !manyValues.includes(option) }"
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
class="!w-full"
|
class="!w-full"
|
||||||
:color="manyValues.includes(option) ? 'secondary' : 'default'"
|
:color="manyValues.includes(option) ? 'secondary' : 'default'"
|
||||||
>
|
>
|
||||||
<slot name="option" :option="option">{{ displayName?.(option) }}</slot>
|
<slot name="option" :option="option">{{ getOptionLabel(option) }}</slot>
|
||||||
<CheckIcon
|
<CheckIcon
|
||||||
class="h-5 w-5 text-contrast ml-auto transition-opacity"
|
class="h-5 w-5 text-contrast ml-auto transition-opacity"
|
||||||
:class="{ 'opacity-0': !manyValues.includes(option) }"
|
:class="{ 'opacity-0': !manyValues.includes(option) }"
|
||||||
@@ -97,7 +97,7 @@ const props = withDefaults(
|
|||||||
disabled: false,
|
disabled: false,
|
||||||
position: 'auto',
|
position: 'auto',
|
||||||
direction: 'auto',
|
direction: 'auto',
|
||||||
displayName: (option: Option) => option as string,
|
displayName: undefined,
|
||||||
search: false,
|
search: false,
|
||||||
dropdownId: '',
|
dropdownId: '',
|
||||||
dropdownClass: '',
|
dropdownClass: '',
|
||||||
@@ -106,6 +106,10 @@ const props = withDefaults(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
function getOptionLabel(option: Option): string {
|
||||||
|
return props.displayName?.(option) ?? (option as string)
|
||||||
|
}
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'change'])
|
const emit = defineEmits(['update:modelValue', 'change'])
|
||||||
const selectedValues = ref(props.modelValue || [])
|
const selectedValues = ref(props.modelValue || [])
|
||||||
const searchInput = ref()
|
const searchInput = ref()
|
||||||
@@ -127,7 +131,7 @@ const filteredOptions = computed(() => {
|
|||||||
return props.options.filter(
|
return props.options.filter(
|
||||||
(x) =>
|
(x) =>
|
||||||
!searchQuery.value ||
|
!searchQuery.value ||
|
||||||
props.displayName(x).toLowerCase().includes(searchQuery.value.toLowerCase()),
|
getOptionLabel(x).toLowerCase().includes(searchQuery.value.toLowerCase()),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -51,10 +51,10 @@
|
|||||||
<Avatar :src="option.icon" :circle="circledIcons" />
|
<Avatar :src="option.icon" :circle="circledIcons" />
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
{{ displayName(option.title) }}
|
{{ getOptionLabel(option.title) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="author">
|
<div class="author">
|
||||||
{{ displayName(option.subtitle) }}
|
{{ getOptionLabel(option.subtitle) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -98,7 +98,7 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
displayName: {
|
displayName: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: (option) => option,
|
default: undefined,
|
||||||
},
|
},
|
||||||
circledIcons: {
|
circledIcons: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -106,6 +106,10 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function getOptionLabel(option) {
|
||||||
|
return props.displayName?.(option) ?? option
|
||||||
|
}
|
||||||
|
|
||||||
const emit = defineEmits(['input', 'onSelected', 'update:modelValue', 'enter'])
|
const emit = defineEmits(['input', 'onSelected', 'update:modelValue', 'enter'])
|
||||||
|
|
||||||
const dropdownVisible = ref(false)
|
const dropdownVisible = ref(false)
|
||||||
|
|||||||
Reference in New Issue
Block a user