TransferList
Included in RC.12
Available in Mavis 0.1.0-rc.12 for Vue + Vite, Nuxt and NativeScript. Keep the Mavis packages at the same version.
<MTransferList v-model="selectedIds" :options="options" label="Expedition kit" />| Prop | Type | Default | Contract |
|---|---|---|---|
options | readonly ChoiceOption[] | required | Unique value, label and optional disabled. |
modelValue | readonly ChoiceValue[] | [] | Selected identities; application owns acceptance of changes. |
animated / disabled | boolean | true / false | Jolt list layout and input availability. |
availableLabel / selectedLabel / searchLabel / addLabel / removeLabel / emptyLabel | string | English | Panel names, filtering and movement actions. |
Checkboxes work with Tab/Space; movement has explicit buttons, so no dragging is required. Filtering preserves checked items: the action transfers all checked, enabled items on that side, including those hidden by the filter. Disabled items cannot move. Unknown selected ids are preserved for application-owned asynchronous catalogs. Both lists become columns below 620px/DIP.
When options move, the list they left closes the gap and they arrive in the other list one after another, while that list's count gives a small bump. Options already on screen and the move buttons never move under the pointer. Jolt cannot copy a checkbox, so a moved option does not leave behind a fading copy. :animated="false" and reduced motion keep every change and drop the movement.
<script setup lang="ts">
import { computed, ref } from 'vue'
import { useCatalogLocale } from '../locale'
const props = defineProps<{ lang?: 'en' | 'pt' }>()
const { locale } = useCatalogLocale(() => props.lang)
const pt = computed(() => (props.lang ?? locale.value) === 'pt')
const t = (en: string, br: string) => (pt.value ? br : en)
import type { ChoiceValue } from '@getcortexlabs/mavis-core'
const selected = ref<ChoiceValue[]>(['camera']),
animated = ref(true)
const options = computed(() => [
{ value: 'camera', label: t('Camera', 'Câmera') },
{ value: 'notebook', label: t('Field notebook', 'Caderno de campo') },
{ value: 'compass', label: t('Compass', 'Bússola') },
{ value: 'water', label: t('Water bottle', 'Garrafa de água') },
{ value: 'radio', label: t('Radio · unavailable', 'Rádio · indisponível'), disabled: true },
])
</script>
<template>
<MColumn gap="lg"
><MText text="FIELD NOTES / PACK LIGHT" variant="overline" tone="primary" /><MText
:text="t('Take only what moves you.', 'Leve só o que te move.')"
variant="title" /><MTransferList
v-model="selected"
:options="options"
:animated="animated"
:label="t('Your expedition kit', 'Seu kit de expedição')"
:availableLabel="t('On the shelf', 'Na prateleira')"
:selectedLabel="t('In your bag', 'Na mochila')"
:searchLabel="t('Filter', 'Filtrar')"
:addLabel="t('Pack selected', 'Guardar selecionados')"
:removeLabel="t('Leave selected', 'Retirar selecionados')"
:emptyLabel="t('No matches', 'Nenhum resultado')" /><MText
id="transfer-values"
:text="selected.join(', ')"
variant="caption" /><MSwitch
v-model="animated"
:label="t('Animate changes', 'Animar mudanças')"
/></MColumn>
</template>On Web, iOS and Android, an option transferred between the two lists can travel from its old position to the new one. A change to the controlled value uses the same transition as the transfer buttons. Set :animated="false" for an immediate transfer.
Desktop
The lists sit side by side when the window has room and stack when it narrows. A transferred option travels from its previous position to its destination in either layout. Set animated to false for immediate moves. See Desktop components.