feat: visible to open

pull/28/head
xingyu 2023-08-04 19:12:01 +08:00
parent 78245e1e4e
commit fd06e829c1
33 changed files with 144 additions and 144 deletions

View File

@ -24,7 +24,7 @@ export default defineComponent({
default: () => <SearchOutlined />, default: () => <SearchOutlined />,
}} }}
</Tooltip> </Tooltip>
<AppSearchModal onClose={changeModal.bind(null, false)} visible={unref(showModal)} /> <AppSearchModal onClose={changeModal.bind(null, false)} open={unref(showModal)} />
</div> </div>
) )
} }

View File

@ -11,7 +11,7 @@ import { useI18n } from '@/hooks/web/useI18n'
import { useAppInject } from '@/hooks/web/useAppInject' import { useAppInject } from '@/hooks/web/useAppInject'
const props = defineProps({ const props = defineProps({
visible: { type: Boolean }, open: { type: Boolean },
}) })
const emit = defineEmits(['close']) const emit = defineEmits(['close'])
@ -38,9 +38,9 @@ const getClass = computed(() => {
}) })
watch( watch(
() => props.visible, () => props.open,
(visible: boolean) => { (open: boolean) => {
visible open
&& nextTick(() => { && nextTick(() => {
unref(inputRef)?.focus() unref(inputRef)?.focus()
}) })
@ -56,7 +56,7 @@ function handleClose() {
<template> <template>
<Teleport to="body"> <Teleport to="body">
<transition name="zoom-fade" mode="out-in"> <transition name="zoom-fade" mode="out-in">
<div v-if="visible" :class="getClass" @click.stop> <div v-if="open" :class="getClass" @click.stop>
<div v-click-outside="handleClose" :class="`${prefixCls}-content`"> <div v-click-outside="handleClose" :class="`${prefixCls}-content`">
<div :class="`${prefixCls}-input__wrapper`"> <div :class="`${prefixCls}-input__wrapper`">
<a-input ref="inputRef" :class="`${prefixCls}-input`" :placeholder="t('common.searchText')" allow-clear @change="handleSearch"> <a-input ref="inputRef" :class="`${prefixCls}-input`" :placeholder="t('common.searchText')" allow-clear @change="handleSearch">

View File

@ -85,8 +85,8 @@ export default defineComponent({
} }
function renderMenuItem(items: ContextMenuItem[]) { function renderMenuItem(items: ContextMenuItem[]) {
const visibleItems = items.filter(item => !item.hidden) const openItems = items.filter(item => !item.hidden)
return visibleItems.map((item) => { return openItems.map((item) => {
const { disabled, label, children, divider = false } = item const { disabled, label, children, divider = false } = item
const contentProps = { const contentProps = {

View File

@ -16,9 +16,9 @@ import { useAttrs } from '@/hooks/core/useAttrs'
defineOptions({ inheritAttrs: false }) defineOptions({ inheritAttrs: false })
const props = defineProps(basicProps) const props = defineProps(basicProps)
const emit = defineEmits(['visible-change', 'ok', 'close', 'register']) const emit = defineEmits(['open-change', 'ok', 'close', 'register'])
const visibleRef = ref(false) const openRef = ref(false)
const attrs = useAttrs() const attrs = useAttrs()
const propsRef = ref<Partial<Nullable<DrawerProps>>>(null) const propsRef = ref<Partial<Nullable<DrawerProps>>>(null)
@ -27,7 +27,7 @@ const { prefixVar, prefixCls } = useDesign('basic-drawer')
const drawerInstance: DrawerInstance = { const drawerInstance: DrawerInstance = {
setDrawerProps, setDrawerProps,
emitVisible: undefined, emitOpen: undefined,
} }
const instance = getCurrentInstance() const instance = getCurrentInstance()
@ -43,7 +43,7 @@ const getProps = computed((): DrawerProps => {
placement: 'right', placement: 'right',
...unref(attrs), ...unref(attrs),
...unref(getMergeProps), ...unref(getMergeProps),
visible: unref(visibleRef), open: unref(openRef),
} }
opt.title = undefined opt.title = undefined
const { isDetail, width, wrapClassName, getContainer } = opt const { isDetail, width, wrapClassName, getContainer } = opt
@ -89,20 +89,20 @@ const getLoading = computed(() => {
}) })
watch( watch(
() => props.visible, () => props.open,
(newVal, oldVal) => { (newVal, oldVal) => {
if (newVal !== oldVal) if (newVal !== oldVal)
visibleRef.value = newVal openRef.value = newVal
}, },
{ deep: true }, { deep: true },
) )
watch( watch(
() => visibleRef.value, () => openRef.value,
(visible) => { (open) => {
nextTick(() => { nextTick(() => {
emit('visible-change', visible) emit('open-change', open)
instance && drawerInstance.emitVisible?.(visible, instance.uid) instance && drawerInstance.emitOpen?.(open, instance.uid)
}) })
}, },
) )
@ -113,18 +113,18 @@ async function onClose(e: Recordable) {
emit('close', e) emit('close', e)
if (closeFunc && isFunction(closeFunc)) { if (closeFunc && isFunction(closeFunc)) {
const res = await closeFunc() const res = await closeFunc()
visibleRef.value = !res openRef.value = !res
return return
} }
visibleRef.value = false openRef.value = false
} }
function setDrawerProps(props: Partial<DrawerProps>): void { function setDrawerProps(props: Partial<DrawerProps>): void {
// Keep the last setDrawerProps // Keep the last setDrawerProps
propsRef.value = deepMerge(unref(propsRef) || ({} as any), props) propsRef.value = deepMerge(unref(propsRef) || ({} as any), props)
if (Reflect.has(props, 'visible')) if (Reflect.has(props, 'open'))
visibleRef.value = !!props.visible openRef.value = !!props.open
} }
function handleOk() { function handleOk() {

View File

@ -28,7 +28,7 @@ export const basicProps = {
title: { type: String, default: '' }, title: { type: String, default: '' },
loadingText: { type: String }, loadingText: { type: String },
showDetailBack: { type: Boolean, default: true }, showDetailBack: { type: Boolean, default: true },
visible: { type: Boolean }, open: { type: Boolean },
loading: { type: Boolean }, loading: { type: Boolean },
maskClosable: { type: Boolean, default: true }, maskClosable: { type: Boolean, default: true },
getContainer: { getContainer: {

View File

@ -4,13 +4,13 @@ import type { ScrollContainerOptions } from '@/components/Container'
export interface DrawerInstance { export interface DrawerInstance {
setDrawerProps: (props: Partial<DrawerProps> | boolean) => void setDrawerProps: (props: Partial<DrawerProps> | boolean) => void
emitVisible?: (visible: boolean, uid: number) => void emitOpen?: (open: boolean, uid: number) => void
} }
export interface ReturnMethods extends DrawerInstance { export interface ReturnMethods extends DrawerInstance {
openDrawer: <T = any>(visible?: boolean, data?: T, openOnSet?: boolean) => void openDrawer: <T = any>(open?: boolean, data?: T, openOnSet?: boolean) => void
closeDrawer: () => void closeDrawer: () => void
getVisible?: ComputedRef<boolean> getOpen?: ComputedRef<boolean>
} }
export type RegisterFn = (drawerInstance: DrawerInstance, uuid?: string) => void export type RegisterFn = (drawerInstance: DrawerInstance, uuid?: string) => void
@ -19,7 +19,7 @@ export interface ReturnInnerMethods extends DrawerInstance {
closeDrawer: () => void closeDrawer: () => void
changeLoading: (loading: boolean) => void changeLoading: (loading: boolean) => void
changeOkLoading: (loading: boolean) => void changeOkLoading: (loading: boolean) => void
getVisible?: ComputedRef<boolean> getOpen?: ComputedRef<boolean>
} }
export type UseDrawerReturnType = [RegisterFn, ReturnMethods] export type UseDrawerReturnType = [RegisterFn, ReturnMethods]
@ -73,7 +73,7 @@ export interface DrawerProps extends DrawerFooterProps {
isDetail?: boolean isDetail?: boolean
loading?: boolean loading?: boolean
showDetailBack?: boolean showDetailBack?: boolean
visible?: boolean open?: boolean
/** /**
* Built-in ScrollContainer component configuration * Built-in ScrollContainer component configuration
* @type ScrollContainerOptions * @type ScrollContainerOptions
@ -82,7 +82,7 @@ export interface DrawerProps extends DrawerFooterProps {
closeFunc?: () => Promise<any> closeFunc?: () => Promise<any>
triggerWindowResize?: boolean triggerWindowResize?: boolean
/** /**
* Whether a close (x) button is visible on top right of the Drawer dialog or not. * Whether a close (x) button is open on top right of the Drawer dialog or not.
* @default true * @default true
* @type boolean * @type boolean
*/ */
@ -179,7 +179,7 @@ export interface DrawerProps extends DrawerFooterProps {
* @type string * @type string
*/ */
placement?: 'top' | 'right' | 'bottom' | 'left' placement?: 'top' | 'right' | 'bottom' | 'left'
afterVisibleChange?: (visible?: boolean) => void afterOpenChange?: (open?: boolean) => void
keyboard?: boolean keyboard?: boolean
/** /**
* Specify a callback that will be called when a user clicks mask, close button or Cancel button. * Specify a callback that will be called when a user clicks mask, close button or Cancel button.

View File

@ -8,7 +8,7 @@ import { error } from '@/utils/log'
const dataTransferRef = reactive<any>({}) const dataTransferRef = reactive<any>({})
const visibleData = reactive<{ [key: number]: boolean }>({}) const openData = reactive<{ [key: number]: boolean }>({})
/** /**
* @description: Applicable to separate drawer and call outside * @description: Applicable to separate drawer and call outside
@ -36,8 +36,8 @@ export function useDrawer(): UseDrawerReturnType {
drawer.value = drawerInstance drawer.value = drawerInstance
loaded.value = true loaded.value = true
drawerInstance.emitVisible = (visible: boolean, uid: number) => { drawerInstance.emitOpen = (open: boolean, uid: number) => {
visibleData[uid] = visible openData[uid] = open
} }
} }
@ -54,13 +54,13 @@ export function useDrawer(): UseDrawerReturnType {
getInstance()?.setDrawerProps(props) getInstance()?.setDrawerProps(props)
}, },
getVisible: computed((): boolean => { getOpen: computed((): boolean => {
return visibleData[~~unref(uid)] return openData[~~unref(uid)]
}), }),
openDrawer: <T = any>(visible = true, data?: T, openOnSet = true): void => { openDrawer: <T = any>(open = true, data?: T, openOnSet = true): void => {
getInstance()?.setDrawerProps({ getInstance()?.setDrawerProps({
visible, open,
}) })
if (!data) if (!data)
return return
@ -75,7 +75,7 @@ export function useDrawer(): UseDrawerReturnType {
dataTransferRef[unref(uid)] = toRaw(data) dataTransferRef[unref(uid)] = toRaw(data)
}, },
closeDrawer: () => { closeDrawer: () => {
getInstance()?.setDrawerProps({ visible: false }) getInstance()?.setDrawerProps({ open: false })
}, },
} }
@ -131,12 +131,12 @@ export function useDrawerInner(callbackFn?: Fn): UseDrawerInnerReturnType {
changeOkLoading: (loading = true) => { changeOkLoading: (loading = true) => {
getInstance()?.setDrawerProps({ confirmLoading: loading }) getInstance()?.setDrawerProps({ confirmLoading: loading })
}, },
getVisible: computed((): boolean => { getOpen: computed((): boolean => {
return visibleData[~~unref(uidRef)] return openData[~~unref(uidRef)]
}), }),
closeDrawer: () => { closeDrawer: () => {
getInstance()?.setDrawerProps({ visible: false }) getInstance()?.setDrawerProps({ open: false })
}, },
setDrawerProps: (props: Partial<DrawerProps>) => { setDrawerProps: (props: Partial<DrawerProps>) => {

View File

@ -107,8 +107,8 @@ async function fetch() {
} }
} }
async function handleFetch(visible) { async function handleFetch(open) {
if (visible) { if (open) {
if (props.alwaysLoad) { if (props.alwaysLoad) {
await fetch() await fetch()
} }
@ -129,7 +129,7 @@ function handleChange(_, ...args) {
</script> </script>
<template> <template>
<Select v-bind="$attrs" v-model:value="state" :options="getOptions" @dropdown-visible-change="handleFetch" @change="handleChange"> <Select v-bind="$attrs" v-model:value="state" :options="getOptions" @dropdown-open-change="handleFetch" @change="handleChange">
<template v-for="item in Object.keys($slots)" #[item]="data"> <template v-for="item in Object.keys($slots)" #[item]="data">
<slot :name="item" v-bind="data || {}" /> <slot :name="item" v-bind="data || {}" />
</template> </template>

View File

@ -28,7 +28,7 @@ const props = defineProps({
returnUrl: propTypes.bool.def(true), returnUrl: propTypes.bool.def(true),
// //
maxCount: propTypes.number.def(0), maxCount: propTypes.number.def(0),
buttonVisible: propTypes.bool.def(true), buttonOpen: propTypes.bool.def(true),
multiple: propTypes.bool.def(true), multiple: propTypes.bool.def(true),
// //
mover: propTypes.bool.def(true), mover: propTypes.bool.def(true),
@ -288,7 +288,7 @@ function getFileName(path) {
</div> </div>
</div> </div>
</template> </template>
<a-button v-else-if="buttonVisible" :disabled="isMaxCount || disabled"> <a-button v-else-if="buttonOpen" :disabled="isMaxCount || disabled">
<Icon icon="ant-design:upload-outlined" /> <Icon icon="ant-design:upload-outlined" />
<span>{{ text }}</span> <span>{{ text }}</span>
</a-button> </a-button>

View File

@ -45,13 +45,13 @@ export default defineComponent({
components: { PreviewCode, Modal }, components: { PreviewCode, Modal },
setup() { setup() {
const state = reactive({ const state = reactive({
visible: false, open: false,
jsonData: {} as IFormConfig jsonData: {} as IFormConfig
}) })
const showModal = (formConfig: IFormConfig) => { const showModal = (formConfig: IFormConfig) => {
formConfig.schemas && formatRules(formConfig.schemas) formConfig.schemas && formatRules(formConfig.schemas)
state.visible = true state.open = true
state.jsonData = formConfig state.jsonData = formConfig
} }
@ -67,8 +67,8 @@ export default defineComponent({
<Modal <Modal
title="代码" title="代码"
:footer="null" :footer="null"
:visible="visible" :open="open"
@cancel="visible = false" @cancel="open = false"
wrapClassName="v-code-modal" wrapClassName="v-code-modal"
style="top: 20px" style="top: 20px"
width="850px" width="850px"

View File

@ -27,7 +27,7 @@ export default defineComponent({
const myEditor = ref(null) const myEditor = ref(null)
const state = reactive({ const state = reactive({
visible: false, open: false,
json: `{ json: `{
"schemas": [ "schemas": [
{ {
@ -54,10 +54,10 @@ export default defineComponent({
}) })
const { formDesignMethods } = useFormDesignState() const { formDesignMethods } = useFormDesignState()
const handleCancel = () => { const handleCancel = () => {
state.visible = false state.open = false
} }
const showModal = () => { const showModal = () => {
state.visible = true state.open = true
} }
const handleImportJson = () => { const handleImportJson = () => {
// JSON // JSON
@ -106,7 +106,7 @@ export default defineComponent({
<template> <template>
<Modal <Modal
title="JSON数据" title="JSON数据"
:visible="visible" :open="open"
cancel-text="关闭" cancel-text="关闭"
:destroy-on-close="true" :destroy-on-close="true"
wrap-class-name="v-code-modal" wrap-class-name="v-code-modal"

View File

@ -17,10 +17,10 @@ export default defineComponent({
emits: ['cancel'], emits: ['cancel'],
setup(_props, { emit }) { setup(_props, { emit }) {
const state = reactive<{ const state = reactive<{
visible: boolean open: boolean
jsonData: IFormConfig jsonData: IFormConfig
}>({ }>({
visible: false, // json open: false, // json
jsonData: {} as IFormConfig, // json jsonData: {} as IFormConfig, // json
}) })
/** /**
@ -30,7 +30,7 @@ export default defineComponent({
const showModal = (jsonData: IFormConfig) => { const showModal = (jsonData: IFormConfig) => {
formatRules(jsonData.schemas) formatRules(jsonData.schemas)
state.jsonData = jsonData state.jsonData = jsonData
state.visible = true state.open = true
} }
// json // json
@ -40,7 +40,7 @@ export default defineComponent({
// //
const handleCancel = () => { const handleCancel = () => {
state.visible = false state.open = false
emit('cancel') emit('cancel')
} }
@ -53,7 +53,7 @@ export default defineComponent({
<Modal <Modal
title="JSON数据" title="JSON数据"
:footer="null" :footer="null"
:visible="visible" :open="open"
:destroy-on-close="true" :destroy-on-close="true"
wrap-class-name="v-code-modal" wrap-class-name="v-code-modal"
style="top: 20px" style="top: 20px"

View File

@ -22,7 +22,7 @@ export default defineComponent({
}, },
setup(props) { setup(props) {
const state = reactive({ const state = reactive({
visible: false, open: false,
}) })
const myEditor = ref(null) const myEditor = ref(null)

View File

@ -761,7 +761,7 @@ const componentAttrs: IBaseComponentProps = {
}, },
}, },
{ {
name: 'tooltipVisible', name: 'tooltipOpen',
label: '始终显示Tooltip', label: '始终显示Tooltip',
component: 'Checkbox', component: 'Checkbox',
}, },

View File

@ -23,13 +23,13 @@ export default defineComponent({
const jsonModal = ref<IToolbarMethods | null>(null) const jsonModal = ref<IToolbarMethods | null>(null)
const state = reactive<{ const state = reactive<{
formModel: IAnyObject formModel: IAnyObject
visible: boolean open: boolean
formConfig: IFormConfig formConfig: IFormConfig
fApi: IVFormMethods fApi: IVFormMethods
}>({ }>({
formModel: {}, formModel: {},
formConfig: {} as IFormConfig, formConfig: {} as IFormConfig,
visible: false, open: false,
fApi: {} as IVFormMethods, fApi: {} as IVFormMethods,
}) })
@ -41,7 +41,7 @@ export default defineComponent({
// console.log('showModal-', jsonData); // console.log('showModal-', jsonData);
formatRules(jsonData.schemas) formatRules(jsonData.schemas)
state.formConfig = jsonData state.formConfig = jsonData
state.visible = true state.open = true
} }
/** /**
@ -49,7 +49,7 @@ export default defineComponent({
* @return {Promise<void>} * @return {Promise<void>}
*/ */
const handleCancel = () => { const handleCancel = () => {
state.visible = false state.open = false
state.formModel = {} state.formModel = {}
} }
const handleGetData = async () => { const handleGetData = async () => {
@ -79,7 +79,7 @@ export default defineComponent({
<template> <template>
<Modal <Modal
title="预览(支持布局)" title="预览(支持布局)"
:visible="visible" :open="open"
ok-text="获取数据" ok-text="获取数据"
cancel-text="关闭" cancel-text="关闭"
style="top: 20px" style="top: 20px"

View File

@ -13,12 +13,12 @@ import { BasicForm, useForm } from '@/components/Form/index'
const jsonModal = ref<IToolbarMethods | null>(null) const jsonModal = ref<IToolbarMethods | null>(null)
const state = reactive<{ const state = reactive<{
formModel: IAnyObject formModel: IAnyObject
visible: boolean open: boolean
formConfig: IFormConfig formConfig: IFormConfig
}>({ }>({
formModel: {}, formModel: {},
formConfig: {} as IFormConfig, formConfig: {} as IFormConfig,
visible: false, open: false,
}) })
const attrs = computed(() => { const attrs = computed(() => {
@ -33,14 +33,14 @@ const attrs = computed(() => {
*/ */
function showModal(jsonData: IFormConfig) { function showModal(jsonData: IFormConfig) {
state.formConfig = jsonData state.formConfig = jsonData
state.visible = true state.open = true
} }
// //
const [registerForm, { validate }] = useForm() const [registerForm, { validate }] = useForm()
function handleCancel() { function handleCancel() {
state.visible = false state.open = false
} }
/** /**
* 获取表单数据 * 获取表单数据
@ -57,7 +57,7 @@ defineExpose({ showModal })
<template> <template>
<Modal <Modal
title="预览(不支持布局)" title="预览(不支持布局)"
:visible="state.visible" :open="state.open"
ok-text="获取数据" ok-text="获取数据"
cancel-text="关闭" cancel-text="关闭"
style="top: 20px" style="top: 20px"

View File

@ -49,7 +49,7 @@ const isSvgMode = props.mode === 'svg'
const icons = isSvgMode ? getSvgIcons() : getIcons() const icons = isSvgMode ? getSvgIcons() : getIcons()
const currentSelect = ref('') const currentSelect = ref('')
const visible = ref(false) const open = ref(false)
const currentList = ref(icons) const currentList = ref(icons)
const { t } = useI18n() const { t } = useI18n()
@ -109,7 +109,7 @@ function handleSearchChange(e: ChangeEvent) {
<template> <template>
<AInput v-model:value="currentSelect" disabled :style="{ width }" :placeholder="t('component.icon.placeholder')" :class="prefixCls"> <AInput v-model:value="currentSelect" disabled :style="{ width }" :placeholder="t('component.icon.placeholder')" :class="prefixCls">
<template #addonAfter> <template #addonAfter>
<APopover v-model="visible" placement="bottomLeft" trigger="click" :overlay-class-name="`${prefixCls}-popover`"> <APopover v-model="open" placement="bottomLeft" trigger="click" :overlay-class-name="`${prefixCls}-popover`">
<template #title> <template #title>
<div class="flex justify-between"> <div class="flex justify-between">
<AInput :placeholder="t('component.icon.search')" allow-clear @change="debounceHandleSearchChange" /> <AInput :placeholder="t('component.icon.search')" allow-clear @change="debounceHandleSearchChange" />

View File

@ -17,9 +17,9 @@ import { useDesign } from '@/hooks/web/useDesign'
defineOptions({ name: 'BasicModal', inheritAttrs: false }) defineOptions({ name: 'BasicModal', inheritAttrs: false })
const props = defineProps(basicProps) const props = defineProps(basicProps)
const emit = defineEmits(['visible-change', 'height-change', 'cancel', 'ok', 'register', 'update:visible']) const emit = defineEmits(['open-change', 'height-change', 'cancel', 'ok', 'register', 'update:open'])
const attrs = useAttrs() const attrs = useAttrs()
const visibleRef = ref(false) const openRef = ref(false)
const propsRef = ref<Partial<ModalProps> | null>(null) const propsRef = ref<Partial<ModalProps> | null>(null)
const modalWrapperRef = ref<any>(null) const modalWrapperRef = ref<any>(null)
const { prefixCls } = useDesign('basic-modal') const { prefixCls } = useDesign('basic-modal')
@ -28,7 +28,7 @@ const { prefixCls } = useDesign('basic-modal')
const extHeightRef = ref(0) const extHeightRef = ref(0)
const modalMethods: ModalMethods = { const modalMethods: ModalMethods = {
setModalProps, setModalProps,
emitVisible: undefined, emitOpen: undefined,
redoModalHeight: () => { redoModalHeight: () => {
nextTick(() => { nextTick(() => {
if (unref(modalWrapperRef)) { if (unref(modalWrapperRef)) {
@ -60,7 +60,7 @@ const { handleFullScreen, getWrapClassName, fullScreenRef } = useFullScreen({
const getProps = computed((): Recordable => { const getProps = computed((): Recordable => {
const opt = { const opt = {
...unref(getMergeProps), ...unref(getMergeProps),
visible: unref(visibleRef), open: unref(openRef),
okButtonProps: undefined, okButtonProps: undefined,
cancelButtonProps: undefined, cancelButtonProps: undefined,
title: undefined, title: undefined,
@ -75,7 +75,7 @@ const getBindValue = computed((): Recordable => {
const attr = { const attr = {
...attrs, ...attrs,
...unref(getMergeProps), ...unref(getMergeProps),
visible: unref(visibleRef), open: unref(openRef),
} }
attr.wrapClassName = `${attr?.wrapClassName || ''} ${unref(getWrapClassName)}` attr.wrapClassName = `${attr?.wrapClassName || ''} ${unref(getWrapClassName)}`
if (unref(fullScreenRef)) if (unref(fullScreenRef))
@ -91,16 +91,16 @@ const getWrapperHeight = computed(() => {
}) })
watchEffect(() => { watchEffect(() => {
visibleRef.value = !!props.visible openRef.value = !!props.open
fullScreenRef.value = !!props.defaultFullscreen fullScreenRef.value = !!props.defaultFullscreen
}) })
watch( watch(
() => unref(visibleRef), () => unref(openRef),
(v) => { (v) => {
emit('visible-change', v) emit('open-change', v)
emit('update:visible', v) emit('update:open', v)
instance && modalMethods.emitVisible?.(v, instance.uid) instance && modalMethods.emitOpen?.(v, instance.uid)
nextTick(() => { nextTick(() => {
if (props.scrollTop && v && unref(modalWrapperRef)) { if (props.scrollTop && v && unref(modalWrapperRef)) {
;(unref(modalWrapperRef) as any).scrollTop() ;(unref(modalWrapperRef) as any).scrollTop()
@ -120,11 +120,11 @@ async function handleCancel(e: Event) {
return return
if (props.closeFunc && isFunction(props.closeFunc)) { if (props.closeFunc && isFunction(props.closeFunc)) {
const isClose: boolean = await props.closeFunc() const isClose: boolean = await props.closeFunc()
visibleRef.value = !isClose openRef.value = !isClose
return return
} }
visibleRef.value = false openRef.value = false
emit('cancel', e) emit('cancel', e)
} }
@ -134,8 +134,8 @@ async function handleCancel(e: Event) {
function setModalProps(props: Partial<ModalProps>): void { function setModalProps(props: Partial<ModalProps>): void {
// Keep the last setModalProps // Keep the last setModalProps
propsRef.value = deepMerge(unref(propsRef) || ({} as any), props) propsRef.value = deepMerge(unref(propsRef) || ({} as any), props)
if (Reflect.has(props, 'visible')) if (Reflect.has(props, 'open'))
visibleRef.value = !!props.visible openRef.value = !!props.open
if (Reflect.has(props, 'defaultFullscreen')) if (Reflect.has(props, 'defaultFullscreen'))
fullScreenRef.value = !!props.defaultFullscreen fullScreenRef.value = !!props.defaultFullscreen
@ -193,9 +193,9 @@ function handleTitleDbClick(e) {
:loading-tip="getProps.loadingTip" :loading-tip="getProps.loadingTip"
:min-height="getProps.minHeight" :min-height="getProps.minHeight"
:height="getWrapperHeight" :height="getWrapperHeight"
:visible="visibleRef" :open="openRef"
:modal-footer-height="footer !== undefined && !footer ? 0 : undefined" :modal-footer-height="footer !== undefined && !footer ? 0 : undefined"
v-bind="omit(getProps.wrapperProps, 'visible', 'height', 'modalFooterHeight')" v-bind="omit(getProps.wrapperProps, 'open', 'height', 'modalFooterHeight')"
@ext-height="handleExtHeight" @ext-height="handleExtHeight"
@height-change="handleHeightChange" @height-change="handleHeightChange"
> >

View File

@ -11,10 +11,10 @@ export default defineComponent({
props: basicProps, props: basicProps,
emits: ['cancel'], emits: ['cancel'],
setup(props, { slots, emit }) { setup(props, { slots, emit }) {
const { visible, draggable, destroyOnClose } = toRefs(props) const { open, draggable, destroyOnClose } = toRefs(props)
const attrs = useAttrs() const attrs = useAttrs()
useModalDragMove({ useModalDragMove({
visible, open,
destroyOnClose, destroyOnClose,
draggable, draggable,
}) })

View File

@ -16,7 +16,7 @@ const props = defineProps({
minHeight: { type: Number, default: 200 }, minHeight: { type: Number, default: 200 },
height: { type: Number }, height: { type: Number },
footerOffset: { type: Number, default: 0 }, footerOffset: { type: Number, default: 0 },
visible: { type: Boolean }, open: { type: Boolean },
fullScreen: { type: Boolean }, fullScreen: { type: Boolean },
loadingTip: { type: String }, loadingTip: { type: String },
}) })
@ -89,8 +89,8 @@ async function scrollTop() {
async function setModalHeight() { async function setModalHeight() {
// , // ,
// ,使visible // ,使open
if (!props.visible) if (!props.open)
return return
const wrapperRefDom = unref(wrapperRef) const wrapperRefDom = unref(wrapperRef)
if (!wrapperRefDom) if (!wrapperRefDom)

View File

@ -8,7 +8,7 @@ import { error } from '@/utils/log'
const dataTransfer = reactive<any>({}) const dataTransfer = reactive<any>({})
const visibleData = reactive<{ [key: number]: boolean }>({}) const openData = reactive<{ [key: number]: boolean }>({})
/** /**
* @description: Applicable to independent modal and call outside * @description: Applicable to independent modal and call outside
@ -34,8 +34,8 @@ export function useModal(): UseModalReturnType {
modal.value = modalMethod modal.value = modalMethod
loaded.value = true loaded.value = true
modalMethod.emitVisible = (visible: boolean, uid: number) => { modalMethod.emitOpen = (open: boolean, uid: number) => {
visibleData[uid] = visible openData[uid] = open
} }
} }
@ -52,17 +52,17 @@ export function useModal(): UseModalReturnType {
getInstance()?.setModalProps(props) getInstance()?.setModalProps(props)
}, },
getVisible: computed((): boolean => { getOpen: computed((): boolean => {
return visibleData[~~unref(uid)] return openData[~~unref(uid)]
}), }),
redoModalHeight: () => { redoModalHeight: () => {
getInstance()?.redoModalHeight?.() getInstance()?.redoModalHeight?.()
}, },
openModal: <T = any>(visible = true, data?: T, openOnSet = true): void => { openModal: <T = any>(open = true, data?: T, openOnSet = true): void => {
getInstance()?.setModalProps({ getInstance()?.setModalProps({
visible, open,
}) })
if (!data) if (!data)
@ -79,7 +79,7 @@ export function useModal(): UseModalReturnType {
}, },
closeModal: () => { closeModal: () => {
getInstance()?.setModalProps({ visible: false }) getInstance()?.setModalProps({ open: false })
}, },
} }
return [register, methods] return [register, methods]
@ -125,8 +125,8 @@ export function useModalInner(callbackFn?: Fn): UseModalInnerReturnType {
changeLoading: (loading = true) => { changeLoading: (loading = true) => {
getInstance()?.setModalProps({ loading }) getInstance()?.setModalProps({ loading })
}, },
getVisible: computed((): boolean => { getOpen: computed((): boolean => {
return visibleData[~~unref(uidRef)] return openData[~~unref(uidRef)]
}), }),
changeOkLoading: (loading = true) => { changeOkLoading: (loading = true) => {
@ -134,7 +134,7 @@ export function useModalInner(callbackFn?: Fn): UseModalInnerReturnType {
}, },
closeModal: () => { closeModal: () => {
getInstance()?.setModalProps({ visible: false }) getInstance()?.setModalProps({ open: false })
}, },
setModalProps: (props: Partial<ModalProps>) => { setModalProps: (props: Partial<ModalProps>) => {

View File

@ -5,7 +5,7 @@ import { useTimeoutFn } from '@vueuse/core'
export interface UseModalDragMoveContext { export interface UseModalDragMoveContext {
draggable: Ref<boolean> draggable: Ref<boolean>
destroyOnClose: Ref<boolean | undefined> | undefined destroyOnClose: Ref<boolean | undefined> | undefined
visible: Ref<boolean> open: Ref<boolean>
} }
export function useModalDragMove(context: UseModalDragMoveContext) { export function useModalDragMove(context: UseModalDragMoveContext) {
@ -100,7 +100,7 @@ export function useModalDragMove(context: UseModalDragMoveContext) {
} }
watchEffect(() => { watchEffect(() => {
if (!unref(context.visible) || !unref(context.draggable)) if (!unref(context.open) || !unref(context.draggable))
return return
useTimeoutFn(() => { useTimeoutFn(() => {

View File

@ -6,7 +6,7 @@ import { useI18n } from '@/hooks/web/useI18n'
const { t } = useI18n() const { t } = useI18n()
export const modalProps = { export const modalProps = {
visible: { type: Boolean }, open: { type: Boolean },
scrollTop: { type: Boolean, default: true }, scrollTop: { type: Boolean, default: true },
height: { type: Number }, height: { type: Number },
minHeight: { type: Number }, minHeight: { type: Number },
@ -73,7 +73,7 @@ export const basicProps = Object.assign({}, modalProps, {
title: { type: String }, title: { type: String },
visible: { type: Boolean }, open: { type: Boolean },
width: { type: [String, Number] as PropType<string | number>, default: '40%' }, width: { type: [String, Number] as PropType<string | number>, default: '40%' },

View File

@ -6,7 +6,7 @@ import type { CSSProperties, ComputedRef, VNodeChild } from 'vue'
*/ */
export interface ModalMethods { export interface ModalMethods {
setModalProps: (props: Partial<ModalProps>) => void setModalProps: (props: Partial<ModalProps>) => void
emitVisible?: (visible: boolean, uid: number) => void emitOpen?: (open: boolean, uid: number) => void
redoModalHeight?: () => void redoModalHeight?: () => void
} }
@ -15,7 +15,7 @@ export type RegisterFn = (modalMethods: ModalMethods, uuid?: string) => void
export interface ReturnMethods extends ModalMethods { export interface ReturnMethods extends ModalMethods {
openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void
closeModal: () => void closeModal: () => void
getVisible?: ComputedRef<boolean> getOpen?: ComputedRef<boolean>
} }
export type UseModalReturnType = [RegisterFn, ReturnMethods] export type UseModalReturnType = [RegisterFn, ReturnMethods]
@ -24,7 +24,7 @@ export interface ReturnInnerMethods extends ModalMethods {
closeModal: () => void closeModal: () => void
changeLoading: (loading: boolean) => void changeLoading: (loading: boolean) => void
changeOkLoading: (loading: boolean) => void changeOkLoading: (loading: boolean) => void
getVisible?: ComputedRef<boolean> getOpen?: ComputedRef<boolean>
redoModalHeight: () => void redoModalHeight: () => void
} }
@ -41,7 +41,7 @@ export interface ModalProps {
// 是否可以进行全屏 // 是否可以进行全屏
canFullscreen?: boolean canFullscreen?: boolean
defaultFullscreen?: boolean defaultFullscreen?: boolean
visible?: boolean open?: boolean
// 温馨提醒信息 // 温馨提醒信息
helpMessage: string | string[] helpMessage: string | string[]
@ -204,7 +204,7 @@ export interface ModalWrapperProps {
modalFooterHeight: number modalFooterHeight: number
minHeight: number minHeight: number
height: number height: number
visible: boolean open: boolean
fullScreen: boolean fullScreen: boolean
useWrapper: boolean useWrapper: boolean
} }

View File

@ -15,8 +15,8 @@ interface ImageProps {
preview?: preview?:
| boolean | boolean
| { | {
visible?: boolean open?: boolean
onVisibleChange?: (visible: boolean, prevVisible: boolean) => void onOpenChange?: (open: boolean, prevOpen: boolean) => void
getContainer: string | HTMLElement | (() => HTMLElement) getContainer: string | HTMLElement | (() => HTMLElement)
} }
} }

View File

@ -46,8 +46,8 @@ export interface ImageProps {
preview?: preview?:
| boolean | boolean
| { | {
visible?: boolean open?: boolean
onVisibleChange?: (visible: boolean, prevVisible: boolean) => void onOpenChange?: (open: boolean, prevOpen: boolean) => void
getContainer: string | HTMLElement | (() => HTMLElement) getContainer: string | HTMLElement | (() => HTMLElement)
} }
} }

View File

@ -218,8 +218,8 @@ onBeforeMount(() => {
}) })
}) })
function handleVisibleChange(visible: boolean) { function handleOpenChange(open: boolean) {
state.opened = visible state.opened = open
} }
// provide // provide
@ -254,10 +254,10 @@ provide<SubMenuProvider>(`subMenu:${instance?.uid}`, {
v-else v-else
placement="right" placement="right"
:overlay-class-name="`${prefixCls}-menu-popover`" :overlay-class-name="`${prefixCls}-menu-popover`"
:visible="getIsOpend" :open="getIsOpend"
:overlay-style="getOverlayStyle" :overlay-style="getOverlayStyle"
:align="{ offset: [0, 0] }" :align="{ offset: [0, 0] }"
@visible-change="handleVisibleChange" @open-change="handleOpenChange"
> >
<div :class="getSubClass" v-bind="getEvents(false)"> <div :class="getSubClass" v-bind="getEvents(false)">
<div <div

View File

@ -7,13 +7,13 @@ import { componentMap } from '@/components/Table/src/componentMap'
export interface ComponentProps { export interface ComponentProps {
component: ComponentType component: ComponentType
rule: boolean rule: boolean
popoverVisible: boolean popoverOpen: boolean
ruleMessage: string ruleMessage: string
getPopupContainer?: Fn getPopupContainer?: Fn
} }
export const CellComponent: FunctionalComponent = ( export const CellComponent: FunctionalComponent = (
{ component = 'Input', rule = true, ruleMessage, popoverVisible, getPopupContainer }: ComponentProps, { component = 'Input', rule = true, ruleMessage, popoverOpen, getPopupContainer }: ComponentProps,
{ attrs }, { attrs },
) => { ) => {
const Comp = componentMap.get(component) as typeof defineComponent const Comp = componentMap.get(component) as typeof defineComponent
@ -26,7 +26,7 @@ export const CellComponent: FunctionalComponent = (
Popover, Popover,
{ {
overlayClassName: 'edit-cell-rule-popover', overlayClassName: 'edit-cell-rule-popover',
visible: !!popoverVisible, open: !!popoverOpen,
...(getPopupContainer ? { getPopupContainer } : {}), ...(getPopupContainer ? { getPopupContainer } : {}),
}, },
{ {

View File

@ -42,7 +42,7 @@ export default defineComponent({
const table = useTableContext() const table = useTableContext()
const isEdit = ref(false) const isEdit = ref(false)
const elRef = ref() const elRef = ref()
const ruleVisible = ref(false) const ruleOpen = ref(false)
const ruleMessage = ref('') const ruleMessage = ref('')
const optionsRef = ref<LabelValueOptions>([]) const optionsRef = ref<LabelValueOptions>([])
const currentValueRef = ref<any>(props.value) const currentValueRef = ref<any>(props.value)
@ -54,8 +54,8 @@ export default defineComponent({
const getComponent = computed(() => props.column?.editComponent || 'Input') const getComponent = computed(() => props.column?.editComponent || 'Input')
const getRule = computed(() => props.column?.editRule) const getRule = computed(() => props.column?.editRule)
const getRuleVisible = computed(() => { const getRuleOpen = computed(() => {
return unref(ruleMessage) && unref(ruleVisible) return unref(ruleMessage) && unref(ruleOpen)
}) })
const getIsCheckComp = computed(() => { const getIsCheckComp = computed(() => {
@ -211,7 +211,7 @@ export default defineComponent({
if (editRule) { if (editRule) {
if (isBoolean(editRule) && !currentValue && !isNumber(currentValue)) { if (isBoolean(editRule) && !currentValue && !isNumber(currentValue)) {
ruleVisible.value = true ruleOpen.value = true
const component = unref(getComponent) const component = unref(getComponent)
ruleMessage.value = createPlaceholderMessage(component) ruleMessage.value = createPlaceholderMessage(component)
return false return false
@ -220,7 +220,7 @@ export default defineComponent({
const res = await editRule(currentValue, record as Recordable) const res = await editRule(currentValue, record as Recordable)
if (res) { if (res) {
ruleMessage.value = res ruleMessage.value = res
ruleVisible.value = true ruleOpen.value = true
return false return false
} }
else { else {
@ -383,7 +383,7 @@ export default defineComponent({
getRule, getRule,
onClickOutside, onClickOutside,
ruleMessage, ruleMessage,
getRuleVisible, getRuleOpen,
getComponentProps, getComponentProps,
handleOptionsChange, handleOptionsChange,
getWrapperStyle, getWrapperStyle,
@ -422,7 +422,7 @@ export default defineComponent({
{...this.getComponentProps} {...this.getComponentProps}
component={this.getComponent} component={this.getComponent}
style={this.getWrapperStyle} style={this.getWrapperStyle}
popoverVisible={this.getRuleVisible} popoverOpen={this.getRuleOpen}
rule={this.getRule} rule={this.getRule}
ruleMessage={this.ruleMessage} ruleMessage={this.ruleMessage}
class={this.getWrapperClass} class={this.getWrapperClass}

View File

@ -135,7 +135,7 @@ async function init(isReset = false) {
// //
state.checkAll = checkList.length === columns.length state.checkAll = checkList.length === columns.length
inited = false inited = false
handleVisibleChange() handleOpenChange()
state.checkedList = checkList state.checkedList = checkList
} }
@ -190,7 +190,7 @@ function reset() {
} }
// Open the pop-up window for drag and drop initialization // Open the pop-up window for drag and drop initialization
function handleVisibleChange() { function handleOpenChange() {
if (inited) if (inited)
return return
nextTick(() => { nextTick(() => {
@ -277,9 +277,9 @@ function setColumns(columns: BasicColumn[] | string[]) {
isSetColumnsFromThis = true isSetColumnsFromThis = true
table.setColumns(columns) table.setColumns(columns)
const data: ColumnChangeParam[] = unref(plainSortOptions).map((col) => { const data: ColumnChangeParam[] = unref(plainSortOptions).map((col) => {
const visible const open
= columns.findIndex((c: BasicColumn | string) => c === col.value || (typeof c !== 'string' && c.dataIndex === col.value)) !== -1 = columns.findIndex((c: BasicColumn | string) => c === col.value || (typeof c !== 'string' && c.dataIndex === col.value)) !== -1
return { dataIndex: col.value, fixed: col.fixed, visible } return { dataIndex: col.value, fixed: col.fixed, open }
}) })
emit('columns-change', data) emit('columns-change', data)
@ -307,7 +307,7 @@ function updateSortOption(column: BasicColumn) {
trigger="click" trigger="click"
:overlay-class-name="`${prefixCls}__cloumn-list`" :overlay-class-name="`${prefixCls}__cloumn-list`"
:get-popup-container="getPopupContainer" :get-popup-container="getPopupContainer"
@visible-change="handleVisibleChange" @open-change="handleOpenChange"
> >
<template #title> <template #title>
<div :class="`${prefixCls}__popover-title`"> <div :class="`${prefixCls}__popover-title`">

View File

@ -22,7 +22,7 @@ export interface FilterDropdownProps {
clearFilters?: () => void clearFilters?: () => void
filters?: ColumnFilterItem[] filters?: ColumnFilterItem[]
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement
visible?: boolean open?: boolean
} }
export declare type CustomRenderFunction<T> = (record: RecordProps<T>) => VNodeChild | JSX.Element export declare type CustomRenderFunction<T> = (record: RecordProps<T>) => VNodeChild | JSX.Element
@ -74,10 +74,10 @@ export interface ColumnProps<T> {
filterDropdown?: VNodeChild | JSX.Element | ((props: FilterDropdownProps) => VNodeChild | JSX.Element) filterDropdown?: VNodeChild | JSX.Element | ((props: FilterDropdownProps) => VNodeChild | JSX.Element)
/** /**
* Whether filterDropdown is visible * Whether filterDropdown is open
* @type boolean * @type boolean
*/ */
filterDropdownVisible?: boolean filterDropdownOpen?: boolean
/** /**
* Whether the dataSource is filtered * Whether the dataSource is filtered
@ -181,10 +181,10 @@ export interface ColumnProps<T> {
onFilter?: (value: any, record: T) => boolean onFilter?: (value: any, record: T) => boolean
/** /**
* Callback executed when filterDropdownVisible is changed, Use as a filterDropdownVisible event when using template or jsx * Callback executed when filterDropdownOpen is changed, Use as a filterDropdownOpen event when using template or jsx
* @type Function * @type Function
*/ */
onFilterDropdownVisibleChange?: (visible: boolean) => void onFilterDropdownOpenChange?: (open: boolean) => void
/** /**
* When using columns, you can setting this property to configure the properties that support the slot, * When using columns, you can setting this property to configure the properties that support the slot,

View File

@ -455,7 +455,7 @@ export interface BasicColumn extends ColumnProps<Recordable> {
export interface ColumnChangeParam { export interface ColumnChangeParam {
dataIndex: string dataIndex: string
fixed: boolean | 'left' | 'right' | undefined fixed: boolean | 'left' | 'right' | undefined
visible: boolean open: boolean
} }
export interface InnerHandlers { export interface InnerHandlers {

View File

@ -27,7 +27,7 @@ function handleClose() {
:class="prefixCls" :class="prefixCls"
:width="getMenuWidth" :width="getMenuWidth"
:get-container="null" :get-container="null"
:visible="!getCollapsed" :open="!getCollapsed"
@close="handleClose" @close="handleClose"
> >
<Sider /> <Sider />