오더리스트
오더리스트 (OrderList)
OrderList는 컬렉션을 정렬할 때 사용하는 컴포넌트예요. value 프로퍼티로 값을 제어하는 방식으로 동작하고, item 템플릿으로 각 항목의 내용을 직접 정의할 수 있어요. 드래그 앤 드롭으로 순서를 바꾸거나 필터 기능을 활용할 수 있고, 스크린 리더와 키보드 조작을 위한 접근성 지원도 갖춰져 있어요. Props, Emits, Templates 같은 API 구성과 테마 설정 방법까지 문서에서 자세히 다뤄요
출처: 문서
본문
접근성
스크린 리더 sourceListProps와 targetListProps에 aria-labelledby 또는 aria-label props를 전달하면 소스 리스트박스와 타깃 리스트박스를 설명하는 값을 제공할 수 있어요. 리스트 요소는 aria-multiselectable 속성과 함께 listbox 역할을 가져요. 각 리스트 항목은 option 역할을 가지며 aria-selected와 aria-disabled가 속성으로 붙어요. 컨트롤 버튼은 button 요소로서, 기본적으로 locale API의 aria.moveTop, aria.moveUp, aria.moveDown, aria.moveBottom, aria.moveTo, aria.moveAllTo, aria.moveFrom, aria.moveAllFrom 프로퍼티를 참조하는 aria-label을 가져요. 대신 moveTopButtonProps, moveUpButtonProps, moveDownButtonProps, moveToButtonProps, moveAllToButtonProps, moveFromButtonProps, moveFromButtonProps, moveAllFromButtonProps를 사용해서 기본 aria-label 속성을 재정의하는 등 버튼을 커스터마이즈할 수도 있어요. OrderList 키보드 지원 키 기능 tab 첫 번째로 선택된 옵션으로 포커스를 이동해요. 선택된 옵션이 없으면 첫 번째 옵션이 포커스를 받아요. 위쪽 화살표 이전 옵션으로 포커스를 이동해요. 아래쪽 화살표 다음 옵션으로 포커스를 이동해요. enter 포커스된 옵션의 선택 상태를 토글해요. space 포커스된 옵션의 선택 상태를 토글해요. home 첫 번째 옵션으로 포커스를 이동해요. end 마지막 옵션으로 포커스를 이동해요. shift + 아래쪽 화살표 다음 옵션으로 포커스를 이동하고 선택 상태를 토글해요. shift + 위쪽 화살표 이전 옵션으로 포커스를 이동하고 선택 상태를 토글해요. shift + space 가장 최근에 선택한 옵션과 포커스된 옵션 사이의 항목들을 선택해요. control + shift + home 포커스된 옵션과 첫 번째 옵션까지의 모든 옵션을 선택해요. control + shift + end 포커스된 옵션과 아래로 첫 번째 옵션까지의 모든 옵션을 선택해요. control + a 모든 옵션을 선택해요. 버튼 키보드 지원 키 기능 enter 버튼 동작을 실행해요. space 버튼 동작을 실행해요.
기본
OrderList는 value 프로퍼티와 함께 제어 입력(controlled input)으로 사용돼요. 리스트 항목의 콘텐츠는 리스트에 있는 객체를 파라미터로 받는 item 템플릿으로 정의해야 해요.
import { Component, OnInit, inject, signal } from '@angular/core';
import { OrderListModule } from 'primeng/orderlist';
import { ProductService } from '@/service/productservice';
import { Product } from '@/domain/product';
@Component({
template: `
<div class="card sm:flex sm:justify-center">
<p-orderlist [value]="products()" dataKey="id" [responsive]="true" breakpoint="575px">
<ng-template #item let-option>
{{ option.name }}
</ng-template>
</p-orderlist>
</div>
`,
standalone: true,
imports: [OrderListModule],
providers: [ProductService]
})
export class OrderlistBasicDemo implements OnInit {
private productService = inject(ProductService);
products = signal<Product[]>([]);
ngOnInit() {
this.productService.getProductsSmall().then((cars) => {
this.products.set(cars);
});
}
getSeverity(status: string) {
switch (status) {
case 'INSTOCK':
return 'success';
case 'LOWSTOCK':
return 'warning';
case 'OUTOFSTOCK':
return 'danger';
}
}
}
dragdrop-doc
dragdrop 프로퍼티를 활성화하면 드래그 앤 드롭으로 항목의 순서를 재정렬할 수 있어요. @angular/cdk 패키지에 의존해요.
import { Component, OnInit, inject, signal } from '@angular/core';
import { OrderListModule } from 'primeng/orderlist';
import { ProductService } from '@/service/productservice';
import { Product } from '@/domain/product';
@Component({
template: `
<div class="card sm:flex sm:justify-center">
<p-orderlist [value]="products()" dataKey="id" [dragdrop]="true" [responsive]="true" breakpoint="575px" scrollHeight="20rem">
<ng-template let-option let-selected="selected" #item>
<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/primeng/images/demo/product/{{ option.image }}" [alt]="option.name" />
<div class="flex-1 flex flex-col">
<span class="font-medium text-sm">{{ option.name }}</span>
<span
[ngClass]="{
'text-sm': true,
'text-surface-500': !selected,
'dark:text-surface-400': !selected,
'text-inherit': selected
}"
>{{ option.category }}</span
>
</div>
<span class="font-bold sm:ml-8">{{ '$' + option.price }}</span>
</div>
</ng-template>
</p-orderlist>
</div>
`,
standalone: true,
imports: [OrderListModule],
providers: [ProductService]
})
export class OrderlistDragdropDemo implements OnInit {
private productService = inject(ProductService);
products = signal<Product[]>([]);
ngOnInit() {
this.productService.getProductsSmall().then((cars) => {
this.products.set(cars);
});
}
getSeverity(status: string) {
switch (status) {
case 'INSTOCK':
return 'success';
case 'LOWSTOCK':
return 'warning';
case 'OUTOFSTOCK':
return 'danger';
}
}
}
필터
필터 값은 filterBy 프로퍼티로 설정한 객체의 프로퍼티와 비교해 확인돼요.
import { Component, OnInit, inject, signal } from '@angular/core';
import { OrderListModule } from 'primeng/orderlist';
import { ProductService } from '@/service/productservice';
import { Product } from '@/domain/product';
@Component({
template: `
<div class="card sm:flex sm:justify-center">
<p-orderlist [value]="products()" filterBy="name" filterPlaceholder="Filter by name" [responsive]="true" breakpoint="575px" scrollHeight="20rem" class="sm:min-w-96">
<ng-template let-option let-selected="selected" #item>
<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/primeng/images/demo/product/{{ option.image }}" [alt]="option.name" />
<div class="flex-1 flex flex-col">
<span class="font-medium text-sm">{{ option.name }}</span>
<span
[ngClass]="{
'text-sm': true,
'text-surface-500': !selected,
'dark:text-surface-400': !selected,
'text-inherit': selected
}"
>{{ option.category }}</span
>
</div>
<span class="font-bold sm:ml-8">{{ '$' + option.price }}</span>
</div>
</ng-template>
</p-orderlist>
</div>
`,
standalone: true,
imports: [OrderListModule],
providers: [ProductService]
})
export class OrderlistFilterDemo implements OnInit {
private productService = inject(ProductService);
products = signal<Product[]>([]);
ngOnInit() {
this.productService.getProductsSmall().then((cars) => {
this.products.set(cars);
});
}
getSeverity(status: string) {
switch (status) {
case 'INSTOCK':
return 'success';
case 'LOWSTOCK':
return 'warning';
case 'OUTOFSTOCK':
return 'danger';
}
}
}
템플릿
커스텀 콘텐츠를 지원하려면 아이템 인스턴스를 파라미터로 받는 item 템플릿을 정의하세요. 여기에 더해 추가 커스터마이징을 할 수 있도록 header 템플릿도 제공돼요.
import { Component, OnInit, inject, signal } from '@angular/core';
import { OrderListModule } from 'primeng/orderlist';
import { ProductService } from '@/service/productservice';
import { Product } from '@/domain/product';
@Component({
template: `
<div class="card sm:flex sm:justify-center">
<p-orderlist [value]="products()" dataKey="id" [responsive]="true" breakpoint="575px" scrollHeight="20rem">
<ng-template let-option let-selected="selected" #item>
<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/primeng/images/demo/product/{{ option.image }}" [alt]="option.name" />
<div class="flex-1 flex flex-col">
<span class="font-medium text-sm">{{ option.name }}</span>
<span
[ngClass]="{
'text-sm': true,
'text-surface-500': !selected,
'dark:text-surface-400': !selected,
'text-inherit': selected
}"
>{{ option.category }}</span
>
</div>
<span class="font-bold sm:ml-8">{{ '$' + option.price }}</span>
</div>
</ng-template>
</p-orderlist>
</div>
`,
standalone: true,
imports: [OrderListModule],
providers: [ProductService]
})
export class OrderlistTemplateDemo implements OnInit {
private productService = inject(ProductService);
products = signal<Product[]>([]);
ngOnInit() {
this.productService.getProductsSmall().then((cars) => {
this.products.set(cars);
});
}
getSeverity(status: string) {
switch (status) {
case 'INSTOCK':
return 'success';
case 'LOWSTOCK':
return 'warning';
case 'OUTOFSTOCK':
return 'danger';
}
}
}
Order List
OrderList는 컬렉션의 순서를 관리하는 데 사용돼요.
프로퍼티
| 이름 | 타입 | 기본값 | 설명 |
|---|---|---|---|
| dt | InputSignal | undefined | 컴포넌트의 스코프 디자인 토큰을 정의해요. |
| unstyled | InputSignal | undefined | 컴포넌트를 스타일 없이 렌더링할지 여부를 나타내요. |
| pt | InputSignal | undefined | 컴포넌트 내부의 DOM 요소들에 속성을 전달할 때 사용해요. |
| ptOptions | InputSignal | undefined | 컴포넌트의 passthrough(pt) 옵션을 구성할 때 사용해요. |
| header | string | - | 캡션에 표시될 텍스트예요. |
| styleClass | string | - | 컴포넌트의 스타일 클래스예요. (지원 중단됨) |
| tabindex | number | - | 탭 순서에서 요소의 인덱스예요. |
| ariaLabel | string | - | 접근성을 위해 입력을 라벨링하는 문자열을 정의해요. |
| ariaLabelledBy | string | - | 입력 필드를 라벨링하는 DOM 내 하나 이상의 ID를 지정해요. |
| listStyle | { [klass: string]: any } | - | 리스트 요소의 인라인 스타일이에요. |
| responsive | boolean | false | 컴포넌트가 반응형으로 동작해야 하는지를 나타내는 불리언 값이에요. |
| filterBy | string | - | 지정하면 keyup 시점에 아이템을 필터링할 입력 필드를 표시하고, 어떤 필드를 검색 대상으로 삼을지 결정해요. |
| filterPlaceholder | string | - | 필터 입력 필드의 placeholder예요. |
| filterLocale | string | - | 필터링에 사용할 로케일이에요. 기본 로케일은 호스트 환경의 현재 로케일이에요. |
| metaKeySelection | boolean | false | true이면 아이템을 선택하거나 선택 해제할 때 metaKey를 눌러야 하고, false로 설정하면 각 아이템을 개별적으로 토글해서 선택할 수 있어요. 터치 지원 기기에서는 metaKeySelection이 자동으로 꺼져요. |
| dragdrop | boolean | false | 드래그앤드롭 기반 재정렬을 활성화할지 여부예요. |
| controlsPosition | "right" | "left" | left | 리스트를 기준으로 버튼들의 위치를 정의해요. |
| ariaFilterLabel | string | - | 필터 입력을 라벨링하는 문자열을 정의해요. |
| filterMatchMode | "startsWith" | "contains" | "endsWith" | "equals" | "notEquals" | "in" | "lt" | "lte" | "gt" | "gte" | contains | 아이템을 어떻게 필터링할지 정의해요. |
| breakpoint | string | 960px | 컴포넌트가 동작을 변경해야 하는 화면 너비를 나타내요. |
| stripedRows | boolean | false | 행에 교대로 색상을 적용해 표시할지 여부예요. |
| disabled | boolean | false | 설정하면 컴포넌트가 비활성화 상태가 되어야 함을 지정해요. |
| trackBy | Function | ... | ngForTrackBy에 위임해서 DOM 연산을 최적화하는 함수예요. 기본 알고리즘은 객체 동일성을 검사해요. |
| scrollHeight | string | 14rem | 뷰포트의 높이예요. 리스트의 높이가 이 값을 초과하면 스크롤바가 표시돼요. |
| autoOptionFocus | boolean | true | 첫 번째로 보이는 요소나 선택된 요소에 포커스를 맞출지 여부예요. |
| dataKey | string | - | 데이터에서 레코드를 고유하게 식별하는 필드의 이름이에요. |
| selection | any[] | - | 현재 선택된 값들의 목록이에요. |
| value | any[] | - | 컴포넌트에 표시될 값들의 배열이에요. 아이템 목록의 데이터 소스 역할을 해요. |
| buttonProps | ButtonProps | ... | ButtonProps의 모든 프로퍼티를 Button 컴포넌트에 전달할 때 사용해요. |
| moveUpButtonProps | ButtonProps | - | ButtonProps의 모든 프로퍼티를 컴포넌트 내부의 위로 이동 버튼에 전달할 때 사용해요. |
| moveTopButtonProps | ButtonProps | - | ButtonProps의 모든 프로퍼티를 컴포넌트 내부의 맨 위로 이동 버튼에 전달할 때 사용해요. |
| moveDownButtonProps | ButtonProps | - | ButtonProps의 모든 프로퍼티를 컴포넌트 내부의 아래로 이동 버튼에 전달할 때 사용해요. |
| moveBottomButtonProps | ButtonProps | - | ButtonProps의 모든 프로퍼티를 컴포넌트 내부의 맨 아래로 이동 버튼에 전달할 때 사용해요. |
이벤트
| 이름 | 파라미터 | 설명 |
|---|---|---|
| selectionChange | value: any | 선택이 변경될 때 호출되는 콜백이에요. |
| onReorder | value: any | 리스트가 재정렬될 때 호출되는 콜백이에요. |
| onSelectionChange | event: OrderListSelectionChangeEvent | 선택이 변경될 때 호출되는 콜백이에요. |
| onFilterEvent | event: OrderListFilterEvent | 필터링이 발생할 때 호출되는 콜백이에요. |
| onFocus | event: Event | 리스트가 포커스를 받을 때 호출되는 콜백이에요. |
| onBlur | event: Event | 리스트가 포커스를 잃을 때 호출되는 콜백이에요. |
템플릿
| 이름 | 타입 | 설명 |
|---|---|---|
| item | TemplateRef | 커스텀 아이템 템플릿이에요. |
| emptymessage | TemplateRef | 커스텀 빈 템플릿이에요. |
| emptyfiltermessage | TemplateRef | 커스텀 빈 필터 템플릿이에요. |
| filter | TemplateRef | 커스텀 필터 템플릿이에요. |
| header | TemplateRef | 커스텀 헤더 템플릿이에요. |
| moveupicon | TemplateRef | 커스텀 위로 이동 아이콘 템플릿이에요. |
| movetopicon | TemplateRef | 커스텀 맨 위로 이동 아이콘 템플릿이에요. |
| movedownicon | TemplateRef | 커스텀 아래로 이동 아이콘 템플릿이에요. |
| movebottomicon | TemplateRef | 커스텀 맨 아래로 이동 아이콘 템플릿이에요. |
| filtericon | TemplateRef | 커스텀 필터 아이콘 템플릿이에요. |
메서드
| 이름 | 파라미터 | 반환 타입 | 설명 |
|---|---|---|---|
| resetFilter | void | 필터 초기화 시 호출되는 콜백이에요. |
패스스루 옵션
| 이름 | 타입 | 설명 |
|---|---|---|
| host | PassThroughOption<HTMLElement, I> | 호스트의 DOM 요소에 속성을 전달할 때 사용해요. |
| root | PassThroughOption<HTMLDivElement, I> | 루트의 DOM 요소에 속성을 전달할 때 사용해요. |
| controls | PassThroughOption<HTMLDivElement, I> | 컨트롤 컨테이너의 DOM 요소에 속성을 전달할 때 사용해요. |
| pcMoveUpButton | ButtonPassThrough | 위로 이동 버튼의 DOM 요소에 속성을 전달할 때 사용해요. |
| pcMoveTopButton | ButtonPassThrough | 맨 위로 이동 버튼의 DOM 요소에 속성을 전달할 때 사용해요. |
| pcMoveDownButton | ButtonPassThrough | 아래로 이동 버튼의 DOM 요소에 속성을 전달할 때 사용해요. |
| pcMoveBottomButton | ButtonPassThrough | 맨 아래로 이동 버튼의 DOM 요소에 속성을 전달할 때 사용해요. |
| pcListbox | ListBoxPassThrough | Listbox 컴포넌트에 속성을 전달할 때 사용해요. |
테마
CSS 클래스
| 클래스 | 설명 |
|---|---|
| p-orderlist | 루트 요소의 클래스 이름이에요. |
| p-orderlist-controls | 컨트롤 요소의 클래스 이름이에요. |
디자인 토큰
| 토큰 | CSS 변수 | 설명 |
|---|---|---|
| orderlist.gap | --p-orderlist-gap | 루트의 간격이에요. |
| orderlist.controls.gap | --p-orderlist-controls-gap | 컨트롤의 간격이에요. |
더 알아보기 (Learn more)
이 문서에는 원문에서 추출한 별도의 관련 문서 링크가 없어요.