Refactor #3965 - For OrderList

pull/4034/head
Tuğçe Küçükoğlu 2023-06-06 16:20:55 +03:00
parent b37904f0d9
commit c98ab6e3fc
2 changed files with 8 additions and 14 deletions

View File

@ -53,11 +53,11 @@ const classes = {
header: 'p-orderlist-header', header: 'p-orderlist-header',
container: 'p-orderlist-list-container', container: 'p-orderlist-list-container',
list: 'p-orderlist-list', list: 'p-orderlist-list',
item: ({ context }) => [ item: ({ instance, item, id }) => [
'p-orderlist-item', 'p-orderlist-item',
{ {
'p-highlight': context.active, 'p-highlight': instance.isSelected(item),
'p-focus': context.focused 'p-focus': id === instance.focusedOptionId
} }
] ]
}; };

View File

@ -59,20 +59,14 @@
:id="id + '_' + i" :id="id + '_' + i"
v-ripple v-ripple
role="option" role="option"
:class=" :class="cx('item', { item, id: `${id}_${i}` })"
cx('item', {
context: {
active: isSelected(item),
focused: `${id}_${i}` === focusedOptionId
}
})
"
:data-p-highlight="isSelected(item)"
@click="onItemClick($event, item, i)" @click="onItemClick($event, item, i)"
@touchend="onItemTouchEnd" @touchend="onItemTouchEnd"
:aria-selected="isSelected(item)" :aria-selected="isSelected(item)"
@mousedown="onOptionMouseDown(i)" @mousedown="onOptionMouseDown(i)"
v-bind="getPTOptions(item, 'item')" v-bind="getPTOptions(item, 'item')"
:data-p-highlight="isSelected(item)"
:data-p-focused="`${id}_${i}` === focusedOptionId"
> >
<slot name="item" :item="item" :index="i"> </slot> <slot name="item" :item="item" :index="i"> </slot>
</li> </li>
@ -448,13 +442,13 @@ export default {
findNextItem(item) { findNextItem(item) {
let nextItem = item.nextElementSibling; let nextItem = item.nextElementSibling;
if (nextItem) return !(DomHandler.getAttribute(nextItem, 'data-p-section') === 'item') ? this.findNextItem(nextItem) : nextItem; if (nextItem) return !(DomHandler.getAttribute(nextItem, 'data-pc-section') === 'item') ? this.findNextItem(nextItem) : nextItem;
else return null; else return null;
}, },
findPrevItem(item) { findPrevItem(item) {
let prevItem = item.previousElementSibling; let prevItem = item.previousElementSibling;
if (prevItem) return !(DomHandler.getAttribute(nextItem, 'data-p-section') === 'item') ? this.findPrevItem(prevItem) : prevItem; if (prevItem) return !(DomHandler.getAttribute(nextItem, 'data-pc-section') === 'item') ? this.findPrevItem(prevItem) : prevItem;
else return null; else return null;
}, },
updateListScroll() { updateListScroll() {