OrderList はコレクションをソートするために使用されます。
import OrderList from 'primevue/orderlist';
OrderList は、v-model ディレクティブとコンテンツのためのoption テンプレートでバインドされた配列を値として必要とします。
<OrderList v-model="products" dataKey="id" breakpoint="575px" pt:pcList:root="w-full sm:w-56">
<template #option="{ option }">
{{ option.name }}
</template>
</OrderList>
カスタムコンテンツのサポートのために、アイテムインスタンスをパラメータとして取得するoptionテンプレートを定義します。さらに、header スロットはさらなるカスタマイズのために提供されています。
<OrderList v-model="products" dataKey="id" breakpoint="575px" scrollHeight="20rem">
<template #option="{ option , selected }">
<div class="flex flex-wrap p-1 items-center gap-4 w-full">
<img class="w-12 shrink-0 rounded" :src="'https://primefaces.org/cdn/primevue/images/product/' + option.image" :alt="option.name" />
<div class="flex-1 flex flex-col">
<span class="font-medium text-sm">{{ option.name }}</span>
<span :class="['text-sm', { 'text-surface-500 dark:text-surface-400': !selected, 'text-inherit': selected }]">{{ option.category }}</span>
</div>
<span class="font-bold sm:ml-8">${{ option.price }}</span>
</div>
</template>
</OrderList>
リストボックスを記述する値は、aria-labelledbyまたはaria-labelプロパティを渡すことによってlistPropsで提供できます。リスト要素は、aria-multiselectable属性を持つlistboxロールを持ちます。各リストアイテムは、aria-selectedとaria-disabledを属性として持つoptionロールを持ちます。
コントロールボタンは、デフォルトでロケールAPIのaria.moveTop、aria.moveUp、aria.moveDown、aria.moveBottomプロパティを参照するaria-labelを持つbutton要素です。または、moveTopButtonProps、moveUpButtonProps、moveDownButtonProps、moveBottomButtonPropsを使用して、デフォルトのaria-label属性を上書きするなど、ボタンをカスタマイズできます。
<span id="lb">Options</span>
<OrderList aria-labelledby="lb" />
<OrderList aria-label="City" />
キー | 機能 |
---|---|
tab | フォーカスを最初の選択されたオプションに移動します。選択されていない場合は、最初のオプションにフォーカスが移動します。 |
上矢印 | フォーカスを前のオプションに移動します。 |
下矢印 | フォーカスを次のオプションに移動します。 |
Enter | フォーカスされたオプションの選択状態を切り替えます。 |
スペース | フォーカスされたオプションの選択状態を切り替えます。 |
Home | フォーカスを最初のオプションに移動します。 |
End | フォーカスを最後のオプションに移動します。 |
Shift + 下矢印 | フォーカスを次のオプションに移動し、選択状態を切り替えます。 |
Shift + 上矢印 | フォーカスを前のオプションに移動し、選択状態を切り替えます。 |
Shift + スペース | 最後に選択されたオプションとフォーカスされたオプションの間のアイテムを選択します。 |
Ctrl + Shift + Home | フォーカスされたオプションと最初のオプションまでのすべてのオプションを選択します。 |
Ctrl + Shift + End | フォーカスされたオプションと最初のオプション以降のすべてのオプションを選択します。 |
Ctrl + A | すべてのオプションを選択します。 |
キー | 機能 |
---|---|
Enter | ボタンのアクションを実行します。 |
スペース | ボタンのアクションを実行します。 |