This commit is contained in:
dap
2025-01-15 15:22:21 +08:00
53 changed files with 267 additions and 126 deletions

View File

@@ -81,3 +81,7 @@
transform: translateY(0);
}
}
.z-popup {
z-index: var(--popup-z-index);
}

View File

@@ -1,4 +1,6 @@
:root {
/** 弹出层的基础层级 **/
--popup-z-index: 2000;
--font-family: -apple-system, blinkmacsystemfont, 'Segoe UI', roboto,
'Helvetica Neue', arial, 'Noto Sans', sans-serif, 'Apple Color Emoji',
'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';

View File

@@ -97,6 +97,10 @@ interface RouteMeta {
* 菜单可以看到但是访问会被重定向到403
*/
menuVisibleWithForbidden?: boolean;
/**
* 不使用基础布局(仅在顶级生效)
*/
noBasicLayout?: boolean;
/**
* 在新窗口打开
*/
@@ -116,10 +120,13 @@ interface RouteMeta {
}
// 定义递归类型以将 RouteRecordRaw 的 component 属性更改为 string
type RouteRecordStringComponent<T = string> = {
type RouteRecordStringComponent<T = string> = Omit<
RouteRecordRaw,
'children' | 'component'
> & {
children?: RouteRecordStringComponent<T>[];
component: T;
} & Omit<RouteRecordRaw, 'children' | 'component'>;
};
type ComponentRecordType = Record<string, () => Promise<Component>>;

View File

@@ -371,6 +371,9 @@ export class FormApi {
if (format === null) {
values[startTimeKey] = startTime;
values[endTimeKey] = endTime;
} else if (isFunction(format)) {
values[startTimeKey] = format(startTime, startTimeKey);
values[endTimeKey] = format(endTime, endTimeKey);
} else {
const [startTimeFormat, endTimeFormat] = Array.isArray(format)
? format

View File

@@ -4,7 +4,7 @@ import type { ZodTypeAny } from 'zod';
import type { Component, HtmlHTMLAttributes, Ref } from 'vue';
import type { VbenButtonProps } from '@vben-core/shadcn-ui';
import type { ClassType, MaybeComputedRef, Nullable } from '@vben-core/typings';
import type { ClassType, MaybeComputedRef } from '@vben-core/typings';
import type { FormApi } from './form-api';
@@ -224,7 +224,12 @@ export type HandleResetFn = (
export type FieldMappingTime = [
string,
[string, string],
([string, string] | Nullable<string>)?,
(
| ((value: any, fieldName: string) => any)
| [string, string]
| null
| string
)?,
][];
export interface FormSchema<

View File

@@ -1,3 +1,3 @@
export type * from './drawer';
export { default as VbenDrawer } from './drawer.vue';
export { useVbenDrawer } from './use-drawer';
export { setDefaultDrawerProps, useVbenDrawer } from './use-drawer';

View File

@@ -4,7 +4,6 @@ import type {
ExtendedDrawerApi,
} from './drawer';
import { useStore } from '@vben-core/shared/store';
import {
defineComponent,
h,
@@ -15,11 +14,19 @@ import {
ref,
} from 'vue';
import VbenDrawer from './drawer.vue';
import { useStore } from '@vben-core/shared/store';
import { DrawerApi } from './drawer-api';
import VbenDrawer from './drawer.vue';
const USER_DRAWER_INJECT_KEY = Symbol('VBEN_DRAWER_INJECT');
const DEFAULT_DRAWER_PROPS: Partial<DrawerProps> = {};
export function setDefaultDrawerProps(props: Partial<DrawerProps>) {
Object.assign(DEFAULT_DRAWER_PROPS, props);
}
export function useVbenDrawer<
TParentDrawerProps extends DrawerProps = DrawerProps,
>(options: DrawerApiOptions = {}) {
@@ -68,6 +75,7 @@ export function useVbenDrawer<
const injectData = inject<any>(USER_DRAWER_INJECT_KEY, {});
const mergedOptions = {
...DEFAULT_DRAWER_PROPS,
...injectData.options,
...options,
} as DrawerApiOptions;

View File

@@ -1,3 +1,3 @@
export type * from './modal';
export { default as VbenModal } from './modal.vue';
export { useVbenModal } from './use-modal';
export { setDefaultModalProps, useVbenModal } from './use-modal';

View File

@@ -1,6 +1,5 @@
import type { ExtendedModalApi, ModalApiOptions, ModalProps } from './modal';
import { useStore } from '@vben-core/shared/store';
import {
defineComponent,
h,
@@ -11,11 +10,19 @@ import {
ref,
} from 'vue';
import VbenModal from './modal.vue';
import { useStore } from '@vben-core/shared/store';
import { ModalApi } from './modal-api';
import VbenModal from './modal.vue';
const USER_MODAL_INJECT_KEY = Symbol('VBEN_MODAL_INJECT');
const DEFAULT_MODAL_PROPS: Partial<ModalProps> = {};
export function setDefaultModalProps(props: Partial<ModalProps>) {
Object.assign(DEFAULT_MODAL_PROPS, props);
}
export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
options: ModalApiOptions = {},
) {
@@ -67,6 +74,7 @@ export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
const injectData = inject<any>(USER_MODAL_INJECT_KEY, {});
const mergedOptions = {
...DEFAULT_MODAL_PROPS,
...injectData.options,
...options,
} as ModalApiOptions;

View File

@@ -32,7 +32,7 @@ const { handleClick, visible } = useBackTop(props);
<VbenButton
v-if="visible"
:style="backTopStyle"
class="dark:bg-accent dark:hover:bg-heavy bg-background hover:bg-heavy data shadow-float fixed bottom-10 z-[1000] size-10 rounded-full duration-500"
class="dark:bg-accent dark:hover:bg-heavy bg-background hover:bg-heavy data shadow-float z-popup fixed bottom-10 size-10 rounded-full duration-500"
size="icon"
variant="icon"
@click="handleClick"

View File

@@ -1,16 +1,18 @@
<script setup lang="ts">
import type { ClassType } from '@vben-core/typings';
import type {
ContextMenuContentProps,
ContextMenuRootEmits,
ContextMenuRootProps,
} from 'radix-vue';
import type { ClassType } from '@vben-core/typings';
import type { IContextMenuItem } from './interface';
import { useForwardPropsEmits } from 'radix-vue';
import { computed } from 'vue';
import { useForwardPropsEmits } from 'radix-vue';
import {
ContextMenu,
ContextMenuContent,
@@ -21,14 +23,14 @@ import {
} from '../../ui/context-menu';
const props = defineProps<
{
ContextMenuRootProps & {
class?: ClassType;
contentClass?: ClassType;
contentProps?: ContextMenuContentProps;
handlerData?: Record<string, any>;
itemClass?: ClassType;
menus: (data: any) => IContextMenuItem[];
} & ContextMenuRootProps
}
>();
const emits = defineEmits<ContextMenuRootEmits>();
@@ -67,7 +69,7 @@ function handleClick(menu: IContextMenuItem) {
<ContextMenuContent
:class="contentClass"
v-bind="contentProps"
class="side-content z-[1000]"
class="side-content z-popup"
>
<template v-for="menu in menusView" :key="menu.key">
<ContextMenuItem

View File

@@ -1,14 +1,16 @@
<script setup lang="ts">
import type { ClassType } from '@vben-core/typings';
import type {
HoverCardContentProps,
HoverCardRootEmits,
HoverCardRootProps,
} from 'radix-vue';
import { useForwardPropsEmits } from 'radix-vue';
import type { ClassType } from '@vben-core/typings';
import { computed } from 'vue';
import { useForwardPropsEmits } from 'radix-vue';
import { HoverCard, HoverCardContent, HoverCardTrigger } from '../../ui';
interface Props extends HoverCardRootProps {
@@ -45,7 +47,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
<HoverCardContent
:class="contentClass"
v-bind="contentProps"
class="side-content z-[1000]"
class="side-content z-popup"
>
<slot></slot>
</HoverCardContent>

View File

@@ -1,14 +1,16 @@
<script setup lang="ts">
import type { ClassType } from '@vben-core/typings';
import type {
PopoverContentProps,
PopoverRootEmits,
PopoverRootProps,
} from 'radix-vue';
import { useForwardPropsEmits } from 'radix-vue';
import type { ClassType } from '@vben-core/typings';
import { computed } from 'vue';
import { useForwardPropsEmits } from 'radix-vue';
import {
PopoverContent,
Popover as PopoverRoot,
@@ -46,7 +48,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
<PopoverContent
:class="contentClass"
class="side-content z-[1000]"
class="side-content z-popup"
v-bind="contentProps"
>
<slot></slot>

View File

@@ -4,15 +4,17 @@ import type {
ContextMenuContentProps,
} from 'radix-vue';
import { computed } from 'vue';
import { cn } from '@vben-core/shared/utils';
import {
ContextMenuContent,
ContextMenuPortal,
useForwardPropsEmits,
} from 'radix-vue';
import { computed } from 'vue';
const props = defineProps<{ class?: any } & ContextMenuContentProps>();
const props = defineProps<ContextMenuContentProps & { class?: any }>();
const emits = defineEmits<ContextMenuContentEmits>();
const delegatedProps = computed(() => {
@@ -30,7 +32,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
v-bind="forwarded"
:class="
cn(
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-border z-[1000] min-w-32 overflow-hidden rounded-md border p-1 shadow-md',
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-border z-popup min-w-32 overflow-hidden rounded-md border p-1 shadow-md',
props.class,
)
"

View File

@@ -30,7 +30,7 @@ const props = withDefaults(
zIndex?: number;
}
>(),
{ appendTo: 'body', showClose: true, zIndex: 1000 },
{ appendTo: 'body', showClose: true },
);
const emits = defineEmits<
DialogContentEmits & { close: []; closed: []; opened: [] }
@@ -84,7 +84,7 @@ defineExpose({
<DialogOverlay
v-if="open && modal"
:style="{
zIndex,
...(zIndex ? { zIndex } : {}),
position,
backdropFilter:
overlayBlur && overlayBlur > 0 ? `blur(${overlayBlur}px)` : 'none',
@@ -94,12 +94,12 @@ defineExpose({
</Transition>
<DialogContent
ref="contentRef"
:style="{ zIndex, position }"
:style="{ ...(zIndex ? { zIndex } : {}), position }"
@animationend="onAnimationEnd"
v-bind="forwarded"
:class="
cn(
'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-top-[48%] w-full p-6 shadow-lg outline-none sm:rounded-xl',
'z-popup bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-top-[48%] w-full p-6 shadow-lg outline-none sm:rounded-xl',
props.class,
)
"

View File

@@ -7,5 +7,5 @@ useScrollLock();
const id = inject('DISMISSABLE_MODAL_ID');
</script>
<template>
<div :data-dismissable-modal="id" class="bg-overlay inset-0"></div>
<div :data-dismissable-modal="id" class="bg-overlay z-popup inset-0"></div>
</template>

View File

@@ -4,16 +4,18 @@ import type {
DropdownMenuContentProps,
} from 'radix-vue';
import { computed } from 'vue';
import { cn } from '@vben-core/shared/utils';
import {
DropdownMenuContent,
DropdownMenuPortal,
useForwardPropsEmits,
} from 'radix-vue';
import { computed } from 'vue';
const props = withDefaults(
defineProps<{ class?: any } & DropdownMenuContentProps>(),
defineProps<DropdownMenuContentProps & { class?: any }>(),
{
sideOffset: 4,
},
@@ -35,7 +37,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
v-bind="forwarded"
:class="
cn(
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-border z-[1000] min-w-32 overflow-hidden rounded-md border p-1 shadow-md',
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-border z-popup min-w-32 overflow-hidden rounded-md border p-1 shadow-md',
props.class,
)
"

View File

@@ -1,12 +1,14 @@
<script setup lang="ts">
import type { HoverCardContentProps } from 'radix-vue';
import { cn } from '@vben-core/shared/utils';
import { HoverCardContent, HoverCardPortal, useForwardProps } from 'radix-vue';
import { computed } from 'vue';
import { cn } from '@vben-core/shared/utils';
import { HoverCardContent, HoverCardPortal, useForwardProps } from 'radix-vue';
const props = withDefaults(
defineProps<{ class?: any } & HoverCardContentProps>(),
defineProps<HoverCardContentProps & { class?: any }>(),
{
sideOffset: 4,
},
@@ -27,7 +29,7 @@ const forwardedProps = useForwardProps(delegatedProps);
v-bind="forwardedProps"
:class="
cn(
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-border z-[1000] w-64 rounded-md border p-4 shadow-md outline-none',
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-border z-popup w-64 rounded-md border p-4 shadow-md outline-none',
props.class,
)
"

View File

@@ -1,14 +1,16 @@
<script setup lang="ts">
import type { SelectContentEmits, SelectContentProps } from 'radix-vue';
import { computed } from 'vue';
import { cn } from '@vben-core/shared/utils';
import {
SelectContent,
SelectPortal,
SelectViewport,
useForwardPropsEmits,
} from 'radix-vue';
import { computed } from 'vue';
import SelectScrollDownButton from './SelectScrollDownButton.vue';
import SelectScrollUpButton from './SelectScrollUpButton.vue';
@@ -18,7 +20,7 @@ defineOptions({
});
const props = withDefaults(
defineProps<{ class?: any } & SelectContentProps>(),
defineProps<SelectContentProps & { class?: any }>(),
{
position: 'popper',
},
@@ -40,7 +42,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
v-bind="{ ...forwarded, ...$attrs }"
:class="
cn(
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-border relative z-[1000] max-h-96 min-w-32 overflow-hidden rounded-md border shadow-md',
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-border z-popup relative max-h-96 min-w-32 overflow-hidden rounded-md border shadow-md',
position === 'popper' &&
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
props.class,

View File

@@ -28,7 +28,6 @@ defineOptions({
const props = withDefaults(defineProps<SheetContentProps>(), {
appendTo: 'body',
zIndex: 1000,
});
const emits = defineEmits<
@@ -79,7 +78,7 @@ function onAnimationEnd(event: AnimationEvent) {
<SheetOverlay
v-if="open && modal"
:style="{
zIndex,
...(zIndex ? { zIndex } : {}),
position,
backdropFilter:
overlayBlur && overlayBlur > 0 ? `blur(${overlayBlur}px)` : 'none',
@@ -88,9 +87,9 @@ function onAnimationEnd(event: AnimationEvent) {
</Transition>
<DialogContent
ref="contentRef"
:class="cn(sheetVariants({ side }), props.class)"
:class="cn('z-popup', sheetVariants({ side }), props.class)"
:style="{
zIndex,
...(zIndex ? { zIndex } : {}),
position,
}"
@animationend="onAnimationEnd"

View File

@@ -7,5 +7,5 @@ useScrollLock();
const id = inject('DISMISSABLE_DRAWER_ID');
</script>
<template>
<div :data-dismissable-drawer="id" class="bg-overlay inset-0"></div>
<div :data-dismissable-drawer="id" class="bg-overlay z-popup inset-0"></div>
</template>

View File

@@ -1,16 +1,18 @@
<script setup lang="ts">
import type { TooltipContentEmits, TooltipContentProps } from 'radix-vue';
import { cn } from '@vben-core/shared/utils';
import { TooltipContent, TooltipPortal, useForwardPropsEmits } from 'radix-vue';
import { computed } from 'vue';
import { cn } from '@vben-core/shared/utils';
import { TooltipContent, TooltipPortal, useForwardPropsEmits } from 'radix-vue';
defineOptions({
inheritAttrs: false,
});
const props = withDefaults(
defineProps<{ class?: any } & TooltipContentProps>(),
defineProps<TooltipContentProps & { class?: any }>(),
{
class: '',
side: 'right',
@@ -35,7 +37,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
v-bind="{ ...forwarded, ...$attrs }"
:class="
cn(
'bg-accent text-accent-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-border shadow-float z-[1000] overflow-hidden rounded-sm border px-4 py-2 text-xs',
'z-popup bg-accent text-accent-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-border shadow-float overflow-hidden rounded-sm border px-4 py-2 text-xs',
props.class,
)
"