fix: drawer component header does not take effect (#4844)
parent
8617d3dd1e
commit
4005023fd4
|
@ -3,19 +3,5 @@ import { defineBuildConfig } from 'unbuild';
|
||||||
export default defineBuildConfig({
|
export default defineBuildConfig({
|
||||||
clean: true,
|
clean: true,
|
||||||
declaration: true,
|
declaration: true,
|
||||||
entries: [
|
entries: ['src/index'],
|
||||||
{
|
|
||||||
builder: 'mkdist',
|
|
||||||
input: './src',
|
|
||||||
loaders: ['vue'],
|
|
||||||
pattern: ['**/*.vue'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
builder: 'mkdist',
|
|
||||||
format: 'esm',
|
|
||||||
input: './src',
|
|
||||||
loaders: ['js'],
|
|
||||||
pattern: ['**/*.ts'],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
export { default as EmptyIcon } from './components/empty.vue';
|
|
||||||
export * from './create-icon';
|
export * from './create-icon';
|
||||||
|
|
||||||
export * from './lucide';
|
export * from './lucide';
|
||||||
|
|
|
@ -41,7 +41,6 @@ export {
|
||||||
Minimize,
|
Minimize,
|
||||||
Minimize2,
|
Minimize2,
|
||||||
MoonStar,
|
MoonStar,
|
||||||
Package2,
|
|
||||||
Palette,
|
Palette,
|
||||||
PanelLeft,
|
PanelLeft,
|
||||||
PanelRight,
|
PanelRight,
|
||||||
|
|
|
@ -132,7 +132,7 @@ function handleFocusOutside(e: Event) {
|
||||||
@pointer-down-outside="pointerDownOutside"
|
@pointer-down-outside="pointerDownOutside"
|
||||||
>
|
>
|
||||||
<SheetHeader
|
<SheetHeader
|
||||||
v-show="showHeader"
|
v-if="showHeader"
|
||||||
:class="
|
:class="
|
||||||
cn(
|
cn(
|
||||||
'!flex flex-row items-center justify-between border-b px-6 py-5',
|
'!flex flex-row items-center justify-between border-b px-6 py-5',
|
||||||
|
@ -179,6 +179,12 @@ function handleFocusOutside(e: Event) {
|
||||||
</div>
|
</div>
|
||||||
</SheetHeader>
|
</SheetHeader>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<VisuallyHidden>
|
||||||
|
<SheetTitle />
|
||||||
|
<SheetDescription />
|
||||||
|
</VisuallyHidden>
|
||||||
|
</template>
|
||||||
<div
|
<div
|
||||||
ref="wrapperRef"
|
ref="wrapperRef"
|
||||||
:class="
|
:class="
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch, watchEffect } from 'vue';
|
import { ref, useTemplateRef, watch, watchEffect } from 'vue';
|
||||||
|
|
||||||
import { usePagination } from '@vben/hooks';
|
import { usePagination } from '@vben/hooks';
|
||||||
import { Grip, Package2 } from '@vben/icons';
|
import { EmptyIcon, Grip } from '@vben/icons';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Pagination,
|
Pagination,
|
||||||
|
@ -38,9 +38,9 @@ const emit = defineEmits<{
|
||||||
'update:value': [string];
|
'update:value': [string];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const refTrigger = useTemplateRef<HTMLElement>('refTrigger');
|
||||||
const currentSelect = ref('');
|
const currentSelect = ref('');
|
||||||
const currentList = ref(props.icons);
|
const currentList = ref(props.icons);
|
||||||
const refTrigger = ref<HTMLDivElement>();
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.icons,
|
() => props.icons,
|
||||||
|
@ -50,7 +50,7 @@ watch(
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
const { getPaginationList, getTotal, setCurrentPage } = usePagination(
|
const { paginationList, total, setCurrentPage } = usePagination(
|
||||||
currentList,
|
currentList,
|
||||||
props.pageSize,
|
props.pageSize,
|
||||||
);
|
);
|
||||||
|
@ -75,47 +75,57 @@ const handlePageChange = (page: number) => {
|
||||||
setCurrentPage(page);
|
setCurrentPage(page);
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeOpenState = () => {
|
function changeOpenState() {
|
||||||
if (refTrigger.value) {
|
refTrigger.value?.click?.();
|
||||||
refTrigger.value.click();
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
defineExpose({ changeOpenState });
|
defineExpose({ changeOpenState });
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VbenPopover
|
<VbenPopover
|
||||||
:content-props="{ align: 'end', alignOffset: -11, sideOffset: 8 }"
|
:content-props="{ align: 'end', alignOffset: -11, sideOffset: 8 }"
|
||||||
content-class="p-0 py-4"
|
content-class="p-0 pt-3"
|
||||||
>
|
>
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<div ref="refTrigger">
|
<div ref="refTrigger">
|
||||||
<VbenIcon :icon="currentSelect || Grip" class="size-6" />
|
<VbenIcon :icon="currentSelect || Grip" class="size-5" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div v-if="getPaginationList.length > 0">
|
<template v-if="paginationList.length > 0">
|
||||||
<div class="grid max-h-[360px] w-full grid-cols-6 justify-items-center">
|
<div class="grid max-h-[360px] w-full grid-cols-6 justify-items-center">
|
||||||
<VbenIconButton
|
<VbenIconButton
|
||||||
v-for="(item, index) in getPaginationList"
|
v-for="(item, index) in paginationList"
|
||||||
:key="index"
|
:key="index"
|
||||||
:tooltip="item"
|
:tooltip="item"
|
||||||
tooltip-side="top"
|
tooltip-side="top"
|
||||||
@click="handleClick(item)"
|
@click="handleClick(item)"
|
||||||
>
|
>
|
||||||
<VbenIcon :icon="item" />
|
<VbenIcon
|
||||||
|
:class="{
|
||||||
|
'text-primary transition-all': currentSelect === item,
|
||||||
|
}"
|
||||||
|
:icon="item"
|
||||||
|
/>
|
||||||
</VbenIconButton>
|
</VbenIconButton>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="getTotal >= pageSize" class="flex-center pt-1">
|
<div
|
||||||
|
v-if="total >= pageSize"
|
||||||
|
class="flex-center flex justify-end overflow-hidden border-t py-2 pr-3"
|
||||||
|
>
|
||||||
<Pagination
|
<Pagination
|
||||||
v-slot="{ page }"
|
v-slot="{ page }"
|
||||||
:items-per-page="36"
|
:items-per-page="36"
|
||||||
:sibling-count="1"
|
:sibling-count="1"
|
||||||
:total="getTotal"
|
:total="total"
|
||||||
show-edges
|
show-edges
|
||||||
|
size="small"
|
||||||
@update:page="handlePageChange"
|
@update:page="handlePageChange"
|
||||||
>
|
>
|
||||||
<PaginationList v-slot="{ items }" class="flex items-center gap-1">
|
<PaginationList
|
||||||
|
v-slot="{ items }"
|
||||||
|
class="flex w-full items-center gap-1"
|
||||||
|
>
|
||||||
<PaginationFirst class="size-5" />
|
<PaginationFirst class="size-5" />
|
||||||
<PaginationPrev class="size-5" />
|
<PaginationPrev class="size-5" />
|
||||||
<template v-for="(item, index) in items">
|
<template v-for="(item, index) in items">
|
||||||
|
@ -144,12 +154,12 @@ defineExpose({ changeOpenState });
|
||||||
</PaginationList>
|
</PaginationList>
|
||||||
</Pagination>
|
</Pagination>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
|
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div class="flex-col-center text-muted-foreground min-h-[150px] w-full">
|
<div class="flex-col-center text-muted-foreground min-h-[150px] w-full">
|
||||||
<Package2 />
|
<EmptyIcon class="size-10" />
|
||||||
<div>{{ $t('common.noData') }}</div>
|
<div class="mt-1 text-sm">{{ $t('common.noData') }}</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</VbenPopover>
|
</VbenPopover>
|
||||||
|
|
|
@ -29,11 +29,11 @@ export function usePagination<T = any>(list: Ref<T[]>, pageSize: number) {
|
||||||
Math.ceil(unref(list).length / unref(pageSizeRef)),
|
Math.ceil(unref(list).length / unref(pageSizeRef)),
|
||||||
);
|
);
|
||||||
|
|
||||||
const getPaginationList = computed(() => {
|
const paginationList = computed(() => {
|
||||||
return pagination(unref(list), unref(currentPage), unref(pageSizeRef));
|
return pagination(unref(list), unref(currentPage), unref(pageSizeRef));
|
||||||
});
|
});
|
||||||
|
|
||||||
const getTotal = computed(() => {
|
const total = computed(() => {
|
||||||
return unref(list).length;
|
return unref(list).length;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -53,5 +53,5 @@ export function usePagination<T = any>(list: Ref<T[]>, pageSize: number) {
|
||||||
currentPage.value = 1;
|
currentPage.value = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { setCurrentPage, getTotal, setPageSize, getPaginationList };
|
return { setCurrentPage, total, setPageSize, paginationList };
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
export * from './iconify/index.js';
|
export * from './iconify/index.js';
|
||||||
|
export { default as EmptyIcon } from './icons/empty-icon.vue';
|
||||||
export * from './svg/index.js';
|
export * from './svg/index.js';
|
||||||
|
|
Loading…
Reference in New Issue