Command palette

@yasinsensoy/native

React Native · Components

Transfer

Moving items between two lists (same API as the web Transfer): role permissions, team members, columns to show and so on.

5 exports

Live example

The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.

Preview

All permissions8
Add / edit usersusers.write
Delete usersusers.delete
View ordersorders.read
Issue refundsorders.refund
Reportsreports.read
Export reportsreports.export
Change settingssettings.write
Audit logaudit
Press Space to check, Enter to move to the other list, Ctrl+A to check all.
Role permissions2
View usersusers.read
Billingbilling
Press Space to check, Enter to move to the other list, Ctrl+A to check all.

Code

import { TransferField } from "@yasinsensoy/native";

<TransferField label="Role permissions" name="permissions" items={permissions}
  titles={["All permissions", "Role permissions"]} />

Events

  1. Events appear here when you interact with the preview.

Import

import { Transfer } from "@yasinsensoy/native";

Transfer

component

Moving items between two lists (same API as the web Transfer): role permissions, team members, columns to show and so on.

  • Selection: tap a row; the box in the header selects all visible ones. A long press moves the item to the other list immediately.
  • Search: separate in each list, ignoring diacritics (including Turkish letters).
  • Large lists: rows are rendered virtually (FlatList).
  • Ordering: with orderable the target order changes with ↑/↓.
  • One way: with oneWay items are only added and target items are removed with ×.
  • Narrow screens: on phones the lists stack and the arrows turn down/up.
  • Form: binds inside a Form via name.
Transfer(props: TransferProps): ReactElement<unknown, string | JSXElementConstructor<any>>

Examples

<Transfer items={permissions} defaultValue={["read"]} titles={["All permissions", "Role permissions"]} />
<Transfer items={columns} value={visible} onValueChange={setVisible} orderable oneWay />

TransferItem

interface

An item in the Transfer lists (same as web).

NameTypeDescription
valuestringUnique value; goes into the value array.
labelReactNodeDisplay name. If not text, keywords or value is used in search.
description?ReactNodeDescription under the name (email, code, role).
icon?IconPropIcon before the name.
disabled?booleanCannot be moved; if selected it stays in the target.
keywords?stringExtra text to match in search.

Side of a Transfer list: source or target (selected).

type TransferSide = "source" | "target"

Information passed to the Transfer renderItem function.

NameTypeDescription
sideTransferSideThe list the item is in.
checkedbooleanIs it checked?
querystringSearch text.

TransferProps

interface

Transfer props (same names as web).

Extends: FieldProps

NameTypeDefaultDescription
itemsreadonly TransferItem[]All items. Selected ones appear in the target list, the rest in the source.
value?readonly string[]Values of the selected items in controlled use, in their target order.
defaultValue?readonly string[]Initially selected items in uncontrolled use.
onValueChange?(value: string[], items: TransferItem[]) => voidWith the new values and items when the selection changes.
titles?readonly [ReactNode, ReactNode]["Kaynak", "Seçilenler"]List titles.
search?boolean | "auto""auto"Search boxes; "auto" with more than 8 items.
oneWay?booleanfalseItems only move from source to target; target items are removed with ×.
orderable?booleanfalseThe target order can be changed with ↑/↓ buttons.
max?numberAt most this many items can move to the target.
height?number240Height of each list (pixels).
renderItem?(item: TransferItem, context: TransferRenderContext) => ReactNodeRow content; defaults to icon, name and description.
footer?(side: TransferSide) => ReactNodeContent added below the list.
empty?(side: TransferSide) => ReactNodeContent shown in an empty list.
aria-label?stringScreen reader name; give it when there is no visible label.
style?StyleProp<ViewStyle>Container style.