Skip to content

SwitchableListWithSidebar

O componente SwitchableListWithSidebar é uma versão do SwitchableList encapsulada em um sidebar, permitindo uma interface mais compacta e modular. É perfeito para aplicações onde você precisa manter o editor de listas em um painel lateral.

Nota: Veja também a documentação do componente base em SwitchableList

Exemplo

Clique para visualizar o código
vue
<script setup>
import { ref } from 'vue';
import LxSwitchableListWithSidebar from '@/components/LxSwitch/LxSwitchableListWithSidebar.vue';

const isOpen = ref(false);
const selectedItems = ref([]);

const items = [
	{ id: 'item1', label: 'Item 1', checked: true },
	{ id: 'item2', label: 'Item 2', checked: true },
	{ id: 'item3', label: 'Item 3', checked: false },
	{ id: 'item4', label: 'Item 4', checked: false },
	{ id: 'item5', label: 'Item 5', checked: false }
];

const handleSave = (newItems) => {
	selectedItems.value = newItems.filter((item) => item.checked);
	isOpen.value = false;
};
</script>

<template>
	<div>
		<button class="btn btn-primary btn-sm" @click="isOpen = true">Selecionar Itens</button>

		<ul class="mt-3">
			<li v-for="item in selectedItems" :key="item.id">{{ item.label }}</li>
		</ul>

		<LxSwitchableListWithSidebar v-if="isOpen" id="example-items" title="Selecionar Itens" close-on-backdrop :items="items" @save="handleSave" @close="isOpen = false" />
	</div>
</template>

<style scoped>
ul {
	margin: 0;
	padding-left: 1.5rem;
}
</style>

Props

PropertyDescriçãoTipoPadrão
titleTítulo do topo do sidebarStringSelecionar itens
showSidebarFooterExibe o footer com botõesBooleantrue
itemsArray de itens para exibiçãoArrayVer SwitchableList
maxSelectionsLimite de items que podem ser selecionadosNumberVer SwitchableList
selectedOnTopMostra items selecionados no topoBooleanVer SwitchableList
sizeTamanho dos labels e switchesStringVer SwitchableList
headerConfigConfigurações do headerObjectVer SwitchableList
itemConfigConfigurações de propriedades dos itemsObjectVer SwitchableList
textConfigTextos customizáveisObjectVer SwitchableList
behaviorConfigComportamentos do componenteObjectVer SwitchableList

Emits

EventDescrição
@saveDisparado quando usuário clica em "Salvar"
@closeDisparado quando usuário fecha o sidebar

Casos de Uso

O SwitchableListWithSidebar é ideal para:

  • Edição em Sidebar: Manter a seleção isolada em um painel lateral
  • Fluxo de Trabalho Compacto: Não interferir no conteúdo principal da página
  • Gerenciamento de Permissões: Interface dedicada para atribuir/revogar permissões
  • Configurações do Usuário: Personalizar preferências em um painel deslizante
  • Filtros Avançados: Manter filtros em um sidebar para economizar espaço

Desenvolvido pelo time Linx Microvix