Refactor #3922 - For SelectButton

This commit is contained in:
Tuğçe Küçükoğlu 2023-05-09 11:43:08 +03:00
parent cae74f5c97
commit 515ae35fc5
2 changed files with 27 additions and 2 deletions

View file

@ -14,10 +14,10 @@
@keydown="onKeydown($event, option, i)"
@focus="onFocus($event)"
@blur="onBlur($event, option)"
v-bind="ptm('button')"
v-bind="getPTOptions(option, 'button')"
>
<slot name="option" :option="option" :index="i">
<span class="p-button-label" v-bind="ptm('label')">{{ getOptionLabel(option) }}</span>
<span class="p-button-label" v-bind="getPTOptions(option, 'label')">{{ getOptionLabel(option) }}</span>
</slot>
</div>
</div>
@ -78,6 +78,14 @@ export default {
getOptionRenderKey(option) {
return this.dataKey ? ObjectUtils.resolveFieldData(option, this.dataKey) : this.getOptionLabel(option);
},
getPTOptions(option, key) {
return this.ptm(key, {
context: {
active: this.isSelected(option),
disabled: this.isOptionDisabled(option)
}
});
},
isOptionDisabled(option) {
return this.optionDisabled ? ObjectUtils.resolveFieldData(option, this.optionDisabled) : false;
},