mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
feat(design): popover 添加destroyOnClose props
This commit is contained in:
parent
0e44372a7e
commit
c73a27eb1a
@ -2,12 +2,14 @@
|
|||||||
<slot name="reference"></slot>
|
<slot name="reference"></slot>
|
||||||
<Teleport to="body">
|
<Teleport to="body">
|
||||||
<div
|
<div
|
||||||
v-if="popoverVisible"
|
v-if="popoverVisible || !destroyOnClose"
|
||||||
|
v-show="popoverVisible"
|
||||||
class="tmagic-design-popper"
|
class="tmagic-design-popper"
|
||||||
tabindex="-1"
|
|
||||||
ref="popperElementRef"
|
ref="popperElementRef"
|
||||||
|
:tabindex="tabindex"
|
||||||
:class="popperClass"
|
:class="popperClass"
|
||||||
:style="style"
|
:style="style"
|
||||||
|
@mouseenter.once="popperMouseenterHandler"
|
||||||
>
|
>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
<span class="tmagic-design-popper-arrow" data-popper-arrow></span>
|
<span class="tmagic-design-popper-arrow" data-popper-arrow></span>
|
||||||
@ -24,7 +26,9 @@ import { useZIndex } from './index';
|
|||||||
import type { PopoverProps } from './types';
|
import type { PopoverProps } from './types';
|
||||||
|
|
||||||
defineSlots<{
|
defineSlots<{
|
||||||
|
/** 触发 Popover 显示的 HTML 元素 */
|
||||||
reference(props: {}): any;
|
reference(props: {}): any;
|
||||||
|
/** Popover 内嵌 HTML 文本 */
|
||||||
default(props: {}): any;
|
default(props: {}): any;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
@ -37,6 +41,8 @@ const props = withDefaults(defineProps<PopoverProps>(), {
|
|||||||
trigger: 'hover',
|
trigger: 'hover',
|
||||||
disabled: false,
|
disabled: false,
|
||||||
visible: undefined,
|
visible: undefined,
|
||||||
|
tabindex: 0,
|
||||||
|
destroyOnClose: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const popoverVisible = ref(false);
|
const popoverVisible = ref(false);
|
||||||
@ -84,12 +90,11 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const zIndex = useZIndex();
|
const zIndex = useZIndex();
|
||||||
watch([referenceElementRef, popperElementRef], ([referenceElement, popperElement]) => {
|
watch([referenceElementRef, popperElementRef, popoverVisible], ([referenceElement, popperElement, popoverVisible]) => {
|
||||||
destroy();
|
destroy();
|
||||||
if (!referenceElement || !popperElement) return;
|
if (!referenceElement || !popperElement || !popoverVisible) return;
|
||||||
|
|
||||||
popperElement.style.zIndex = `${zIndex.nextZIndex()}`;
|
popperElement.style.zIndex = `${zIndex.nextZIndex()}`;
|
||||||
popperElement.focus();
|
|
||||||
|
|
||||||
instanceRef.value = createPopper(referenceElement, popperElement, {
|
instanceRef.value = createPopper(referenceElement, popperElement, {
|
||||||
placement: props.placement || 'bottom',
|
placement: props.placement || 'bottom',
|
||||||
@ -105,6 +110,10 @@ watch([referenceElementRef, popperElementRef], ([referenceElement, popperElement
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const popperMouseenterHandler = () => {
|
||||||
|
popperElementRef.value?.focus();
|
||||||
|
};
|
||||||
|
|
||||||
const clickHandler = () => {
|
const clickHandler = () => {
|
||||||
if (props.disabled) return;
|
if (props.disabled) return;
|
||||||
|
|
||||||
@ -129,9 +138,9 @@ const mouseleaveHandler = () => {
|
|||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
timer = setTimeout(() => {
|
timer = globalThis.setTimeout(() => {
|
||||||
popoverVisible.value = false;
|
popoverVisible.value = false;
|
||||||
}, 500);
|
}, 350);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (props.trigger === 'click' && typeof props.visible === 'undefined') {
|
if (props.trigger === 'click' && typeof props.visible === 'undefined') {
|
||||||
|
@ -230,6 +230,8 @@ export interface PopoverProps {
|
|||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
visible?: boolean;
|
visible?: boolean;
|
||||||
popperClass?: string;
|
popperClass?: string;
|
||||||
|
tabindex?: number;
|
||||||
|
destroyOnClose?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RadioProps {
|
export interface RadioProps {
|
||||||
|
@ -82,7 +82,7 @@ export interface EditorProps {
|
|||||||
/** 禁用属性配置面板右下角显示源码的按钮 */
|
/** 禁用属性配置面板右下角显示源码的按钮 */
|
||||||
disabledShowSrc?: boolean;
|
disabledShowSrc?: boolean;
|
||||||
/** 中间工作区域中画布渲染的内容 */
|
/** 中间工作区域中画布渲染的内容 */
|
||||||
render?: (stage: StageCore) => HTMLDivElement | Promise<HTMLDivElement>;
|
render?: (stage: StageCore) => HTMLDivElement | void | Promise<HTMLDivElement | void>;
|
||||||
/** 选中时会在画布上复制出一个大小相同的dom,实际拖拽的是这个dom,此方法用于干预这个dom的生成方式 */
|
/** 选中时会在画布上复制出一个大小相同的dom,实际拖拽的是这个dom,此方法用于干预这个dom的生成方式 */
|
||||||
updateDragEl?: UpdateDragEl;
|
updateDragEl?: UpdateDragEl;
|
||||||
/** 用于设置画布上的dom是否可以被选中 */
|
/** 用于设置画布上的dom是否可以被选中 */
|
||||||
|
@ -24,7 +24,13 @@
|
|||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<TMagicPopover popper-class="page-bar-popover" placement="top" :width="160" trigger="hover">
|
<TMagicPopover
|
||||||
|
popper-class="page-bar-popover"
|
||||||
|
placement="top"
|
||||||
|
trigger="hover"
|
||||||
|
:width="160"
|
||||||
|
:destroy-on-close="true"
|
||||||
|
>
|
||||||
<div>
|
<div>
|
||||||
<slot name="page-bar-popover" :page="item">
|
<slot name="page-bar-popover" :page="item">
|
||||||
<ToolButton
|
<ToolButton
|
||||||
|
@ -4,7 +4,13 @@
|
|||||||
id="m-editor-page-bar-list-icon"
|
id="m-editor-page-bar-list-icon"
|
||||||
class="m-editor-page-bar-item m-editor-page-bar-item-icon"
|
class="m-editor-page-bar-item m-editor-page-bar-item-icon"
|
||||||
>
|
>
|
||||||
<TMagicPopover popper-class="page-bar-popover" placement="top" :width="160" trigger="hover">
|
<TMagicPopover
|
||||||
|
popper-class="page-bar-popover"
|
||||||
|
placement="top"
|
||||||
|
trigger="hover"
|
||||||
|
:width="160"
|
||||||
|
:destroy-on-close="true"
|
||||||
|
>
|
||||||
<div>
|
<div>
|
||||||
<slot name="page-list-popover" :list="list">
|
<slot name="page-list-popover" :list="list">
|
||||||
<ToolButton
|
<ToolButton
|
||||||
|
@ -2,7 +2,13 @@
|
|||||||
<TMagicScrollbar class="data-source-list-panel m-editor-layer-panel">
|
<TMagicScrollbar class="data-source-list-panel m-editor-layer-panel">
|
||||||
<div class="search-wrapper">
|
<div class="search-wrapper">
|
||||||
<SearchInput @search="filterTextChangeHandler"></SearchInput>
|
<SearchInput @search="filterTextChangeHandler"></SearchInput>
|
||||||
<TMagicPopover v-if="editable" placement="right" trigger="hover" popper-class="data-source-list-panel-add-menu">
|
<TMagicPopover
|
||||||
|
v-if="editable"
|
||||||
|
placement="right"
|
||||||
|
trigger="hover"
|
||||||
|
popper-class="data-source-list-panel-add-menu"
|
||||||
|
:destroy-on-close="true"
|
||||||
|
>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<TMagicButton type="primary" size="small">新增</TMagicButton>
|
<TMagicButton type="primary" size="small">新增</TMagicButton>
|
||||||
</template>
|
</template>
|
||||||
|
@ -5,12 +5,13 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
.tmagic-design-button.m-editor-page-bar-switch-type-button {
|
.tmagic-design-button.m-editor-page-bar-switch-type-button {
|
||||||
margin-left: 7px;
|
margin-left: 10px;
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 1px;
|
top: 1px;
|
||||||
border-radius: 3px 3px 0 0;
|
border-radius: 3px 3px 0 0;
|
||||||
border: 1px solid $--border-color;
|
border: 1px solid $--border-color;
|
||||||
border-bottom: 1px solid transparent;
|
border-bottom: 1px solid transparent;
|
||||||
|
padding: 5px 10px;
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
background-color: #f3f3f3;
|
background-color: #f3f3f3;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
:placement="config.popover.placement"
|
:placement="config.popover.placement"
|
||||||
:width="config.popover.width"
|
:width="config.popover.width"
|
||||||
:trigger="config.popover.trigger"
|
:trigger="config.popover.trigger"
|
||||||
|
:destroy-on-close="config.popover.destroyOnClose ?? true"
|
||||||
>
|
>
|
||||||
<MTable
|
<MTable
|
||||||
v-if="config.popover.tableEmbed"
|
v-if="config.popover.tableEmbed"
|
||||||
|
@ -50,7 +50,7 @@ export interface ColumnConfig<T = any> {
|
|||||||
table?: ColumnConfig[];
|
table?: ColumnConfig[];
|
||||||
formatter?: 'datetime' | ((item: any, row: T) => any);
|
formatter?: 'datetime' | ((item: any, row: T) => any);
|
||||||
popover?: {
|
popover?: {
|
||||||
placement:
|
placement?:
|
||||||
| 'auto'
|
| 'auto'
|
||||||
| 'auto-start'
|
| 'auto-start'
|
||||||
| 'auto-end'
|
| 'auto-end'
|
||||||
@ -66,9 +66,10 @@ export interface ColumnConfig<T = any> {
|
|||||||
| 'right-end'
|
| 'right-end'
|
||||||
| 'left-start'
|
| 'left-start'
|
||||||
| 'left-end';
|
| 'left-end';
|
||||||
width: string | number;
|
width?: string | number;
|
||||||
trigger: 'hover' | 'click';
|
trigger?: 'hover' | 'click';
|
||||||
tableEmbed: boolean;
|
tableEmbed?: boolean;
|
||||||
|
destroyOnClose?: boolean;
|
||||||
};
|
};
|
||||||
sortable?: boolean | 'custom';
|
sortable?: boolean | 'custom';
|
||||||
action?: 'tip' | 'actionLink' | 'img' | 'link' | 'tag';
|
action?: 'tip' | 'actionLink' | 'img' | 'link' | 'tag';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user