Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: drawer component header does not take effect #4844

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions packages/@core/base/icons/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,5 @@ import { defineBuildConfig } from 'unbuild';
export default defineBuildConfig({
clean: true,
declaration: true,
entries: [
{
builder: 'mkdist',
input: './src',
loaders: ['vue'],
pattern: ['**/*.vue'],
},
{
builder: 'mkdist',
format: 'esm',
input: './src',
loaders: ['js'],
pattern: ['**/*.ts'],
},
],
entries: ['src/index'],
});
1 change: 0 additions & 1 deletion packages/@core/base/icons/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as EmptyIcon } from './components/empty.vue';
export * from './create-icon';

export * from './lucide';
Expand Down
1 change: 0 additions & 1 deletion packages/@core/base/icons/src/lucide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export {
Minimize,
Minimize2,
MoonStar,
Package2,
Palette,
PanelLeft,
PanelRight,
Expand Down
8 changes: 7 additions & 1 deletion packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function handleFocusOutside(e: Event) {
@pointer-down-outside="pointerDownOutside"
>
<SheetHeader
v-show="showHeader"
v-if="showHeader"
:class="
cn(
'!flex flex-row items-center justify-between border-b px-6 py-5',
Expand Down Expand Up @@ -179,6 +179,12 @@ function handleFocusOutside(e: Event) {
</div>
</SheetHeader>

<template v-else>
<VisuallyHidden>
<SheetTitle />
<SheetDescription />
</VisuallyHidden>
</template>
<div
ref="wrapperRef"
:class="
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import { ref, watch, watchEffect } from 'vue';
import { ref, useTemplateRef, watch, watchEffect } from 'vue';

import { usePagination } from '@vben/hooks';
import { Grip, Package2 } from '@vben/icons';
import { EmptyIcon, Grip } from '@vben/icons';
import {
Button,
Pagination,
Expand Down Expand Up @@ -38,9 +38,9 @@ const emit = defineEmits<{
'update:value': [string];
}>();

const refTrigger = useTemplateRef<HTMLElement>('refTrigger');
const currentSelect = ref('');
const currentList = ref(props.icons);
const refTrigger = ref<HTMLDivElement>();

watch(
() => props.icons,
Expand All @@ -50,7 +50,7 @@ watch(
{ immediate: true },
);

const { getPaginationList, getTotal, setCurrentPage } = usePagination(
const { paginationList, total, setCurrentPage } = usePagination(
currentList,
props.pageSize,
);
Expand All @@ -75,47 +75,57 @@ const handlePageChange = (page: number) => {
setCurrentPage(page);
};

const changeOpenState = () => {
if (refTrigger.value) {
refTrigger.value.click();
}
};
function changeOpenState() {
refTrigger.value?.click?.();
}

defineExpose({ changeOpenState });
</script>
<template>
<VbenPopover
:content-props="{ align: 'end', alignOffset: -11, sideOffset: 8 }"
content-class="p-0 py-4"
content-class="p-0 pt-3"
>
<template #trigger>
<div ref="refTrigger">
<VbenIcon :icon="currentSelect || Grip" class="size-6" />
<VbenIcon :icon="currentSelect || Grip" class="size-5" />
</div>
</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">
<VbenIconButton
v-for="(item, index) in getPaginationList"
v-for="(item, index) in paginationList"
:key="index"
:tooltip="item"
tooltip-side="top"
@click="handleClick(item)"
>
<VbenIcon :icon="item" />
<VbenIcon
:class="{
'text-primary transition-all': currentSelect === item,
}"
:icon="item"
/>
</VbenIconButton>
</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
v-slot="{ page }"
:items-per-page="36"
:sibling-count="1"
:total="getTotal"
:total="total"
show-edges
size="small"
@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" />
<PaginationPrev class="size-5" />
<template v-for="(item, index) in items">
Expand Down Expand Up @@ -144,12 +154,12 @@ defineExpose({ changeOpenState });
</PaginationList>
</Pagination>
</div>
</div>
</template>

<template v-else>
<div class="flex-col-center text-muted-foreground min-h-[150px] w-full">
<Package2 />
<div>{{ $t('common.noData') }}</div>
<EmptyIcon class="size-10" />
<div class="mt-1 text-sm">{{ $t('common.noData') }}</div>
</div>
</template>
</VbenPopover>
Expand Down
6 changes: 3 additions & 3 deletions packages/effects/hooks/src/use-pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ export function usePagination<T = any>(list: Ref<T[]>, pageSize: number) {
Math.ceil(unref(list).length / unref(pageSizeRef)),
);

const getPaginationList = computed(() => {
const paginationList = computed(() => {
return pagination(unref(list), unref(currentPage), unref(pageSizeRef));
});

const getTotal = computed(() => {
const total = computed(() => {
return unref(list).length;
});

Expand All @@ -53,5 +53,5 @@ export function usePagination<T = any>(list: Ref<T[]>, pageSize: number) {
currentPage.value = 1;
}

return { setCurrentPage, getTotal, setPageSize, getPaginationList };
return { setCurrentPage, total, setPageSize, paginationList };
}
1 change: 1 addition & 0 deletions packages/icons/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './iconify/index.js';
export { default as EmptyIcon } from './icons/empty-icon.vue';
export * from './svg/index.js';