-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add select all label; refactor to own component
- Loading branch information
jfrer
committed
Jul 12, 2024
1 parent
b4f790d
commit 9639690
Showing
2 changed files
with
53 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<script setup lang="ts"> | ||
import { Icon } from '@iconify/vue' | ||
import MultiSelect from "primevue/multiselect" | ||
import { computed, ref } from 'vue' | ||
import { useI18n } from "vue-i18n" | ||
import type { DropdownOption } from '@/types' | ||
const { t } = useI18n() | ||
const props = defineProps<{ | ||
filter?: boolean | ||
allSelectedLabel?: string | ||
options: DropdownOption[] | ||
}>() | ||
const allItemsSelected = ref(true) | ||
const dropdownLabel = computed(() => { | ||
if (allItemsSelected.value) { | ||
return props.allSelectedLabel | ||
} | ||
return undefined | ||
}) | ||
</script> | ||
<template> | ||
<MultiSelect | ||
@change="allItemsSelected = $event.value.length === options.length" | ||
:filter="filter?? false" | ||
:selected-items-label="dropdownLabel" | ||
:options="options" | ||
option-label="label" | ||
:pt="{ | ||
filterContainer: { | ||
class: { 'ml-20': props.filter } | ||
} | ||
}"> | ||
<template #headercheckboxicon="{ allSelected }"> | ||
<Icon v-show="allSelected" icon="prime:check" class="p-checkbox-icon h-5 w-5" data-pc-section="headercheckboxicon"/> | ||
<span :class="['ml-[7.5rem] absolute w-20 z-[1001]', allSelected ? 'text-[#1D4ED8]' : 'text-black']">{{ t('select_all') }}</span> | ||
</template> | ||
</MultiSelect> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters