@dt-frames/ui 1.0.11 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/curd/src/components/dialog.d.ts +34 -25
- package/es/components/curd/src/components/props.d.ts +6 -5
- package/es/components/curd/src/hooks/useCurd.d.ts +1 -0
- package/es/components/curd/src/types/curd.type.d.ts +4 -3
- package/es/components/forms/src/components/formButton.d.ts +1 -2
- package/es/components/forms/src/components/formIcon.d.ts +16 -11
- package/es/components/forms/src/components/formInputUseDialog.d.ts +903 -0
- package/es/components/forms/src/hooks/useFormActions.d.ts +2 -2
- package/es/components/forms/src/index.d.ts +2 -2
- package/es/components/forms/src/types/form.type.d.ts +6 -18
- package/es/components/index.d.ts +2 -2
- package/es/components/modal/src/components/modal.d.ts +2 -2
- package/es/components/modal/src/components/modalFooter.d.ts +10 -5
- package/es/components/modal/src/index.d.ts +16 -11
- package/es/components/modal/src/props.d.ts +2 -1
- package/es/components/modal/src/types/modal.type.d.ts +4 -1
- package/es/components/source/src/hooks/useFetch.d.ts +1 -1
- package/es/components/table/src/hooks/useCustomRow.d.ts +19 -0
- package/es/components/table/src/hooks/useTable.d.ts +2 -2
- package/es/components/table/src/index.d.ts +24 -5
- package/es/components/table/src/props.d.ts +5 -2
- package/es/components/table/src/types/table.type.d.ts +2 -2
- package/es/components/tree/src/props.d.ts +8 -1
- package/es/components/upload/index.d.ts +1 -2
- package/es/components/upload/src/helper.d.ts +1 -0
- package/es/components/upload/src/index.d.ts +34 -11
- package/es/components/upload/src/props.d.ts +4 -1
- package/es/components/upload/src/upload.d.ts +42 -11
- package/es/index.js +356 -200
- package/es/style/components/forms/index.less +23 -0
- package/es/style/components/icons/index.less +1 -1
- package/es/style/components/upload/index.less +3 -11
- package/package.json +1 -10
- package/vite.config.js +10 -0
- package/src/assets/data/icons/actions.ts +0 -427
- package/src/assets/data/icons/code.ts +0 -10
- package/src/assets/data/icons/commuticate.ts +0 -190
- package/src/assets/data/icons/currency.ts +0 -46
- package/src/assets/data/icons/devices.ts +0 -128
- package/src/assets/data/icons/edit.ts +0 -165
- package/src/assets/data/icons/file.ts +0 -104
- package/src/assets/data/icons/math.ts +0 -53
- package/src/assets/data/icons/message.ts +0 -75
- package/src/assets/data/icons/navigate.ts +0 -181
- package/src/assets/data/icons/other.ts +0 -333
- package/src/assets/data/icons.ts +0 -58
- package/src/assets/imgs/header/avatar.png +0 -0
- package/src/assets/imgs/logo/logo.png +0 -0
- package/src/assets/locales/en_US.json +0 -3
- package/src/assets/locales/zh_CN.json +0 -3
- package/src/assets/style/index.less +0 -10
- package/src/assets/style/reset.less +0 -17
- package/src/components/container/index.less +0 -85
- package/src/components/container/index.ts +0 -8
- package/src/components/container/src/bar.ts +0 -107
- package/src/components/container/src/lazy-container.vue +0 -9
- package/src/components/container/src/scroll-bar.vue +0 -117
- package/src/components/container/src/scroll-container.vue +0 -61
- package/src/components/curd/index.ts +0 -5
- package/src/components/curd/src/components/dialog.vue +0 -73
- package/src/components/curd/src/components/props.ts +0 -32
- package/src/components/curd/src/hooks/useCurd.tsx +0 -87
- package/src/components/curd/src/types/curd.type.ts +0 -31
- package/src/components/excel/index.ts +0 -6
- package/src/components/excel/src/export2Excel.ts +0 -44
- package/src/components/forms/index.less +0 -84
- package/src/components/forms/index.ts +0 -11
- package/src/components/forms/src/componentMap.ts +0 -44
- package/src/components/forms/src/components/formButton.vue +0 -150
- package/src/components/forms/src/components/formIcon.vue +0 -51
- package/src/components/forms/src/components/formItem.vue +0 -420
- package/src/components/forms/src/components/radioButton.vue +0 -58
- package/src/components/forms/src/const/form.const.ts +0 -7
- package/src/components/forms/src/hooks/helper.ts +0 -70
- package/src/components/forms/src/hooks/useForm.ts +0 -130
- package/src/components/forms/src/hooks/useFormActions.ts +0 -63
- package/src/components/forms/src/hooks/useFormEvents.ts +0 -248
- package/src/components/forms/src/hooks/useFormValue.ts +0 -49
- package/src/components/forms/src/hooks/useFormValues.ts +0 -131
- package/src/components/forms/src/hooks/useLabelWidth.ts +0 -57
- package/src/components/forms/src/index.vue +0 -310
- package/src/components/forms/src/prop.ts +0 -80
- package/src/components/forms/src/types/form.type.ts +0 -269
- package/src/components/icons/index.less +0 -101
- package/src/components/icons/index.ts +0 -7
- package/src/components/icons/src/pick-icon.vue +0 -119
- package/src/components/icons/src/svg-icon.vue +0 -117
- package/src/components/iframe/index.less +0 -3
- package/src/components/iframe/index.ts +0 -5
- package/src/components/iframe/src/index.less +0 -3
- package/src/components/iframe/src/index.vue +0 -38
- package/src/components/index.ts +0 -54
- package/src/components/modal/index.less +0 -60
- package/src/components/modal/index.ts +0 -8
- package/src/components/modal/src/components/close-icon.vue +0 -46
- package/src/components/modal/src/components/modal-wrap.vue +0 -128
- package/src/components/modal/src/components/modal.tsx +0 -30
- package/src/components/modal/src/components/modalFooter.vue +0 -38
- package/src/components/modal/src/hooks/useDrag.ts +0 -107
- package/src/components/modal/src/hooks/useFullScreen.ts +0 -29
- package/src/components/modal/src/hooks/useModal.ts +0 -194
- package/src/components/modal/src/index.vue +0 -173
- package/src/components/modal/src/props.ts +0 -43
- package/src/components/modal/src/types/modal.type.ts +0 -27
- package/src/components/router/base-router.vue +0 -11
- package/src/components/router/index.ts +0 -3
- package/src/components/source/index.ts +0 -1
- package/src/components/source/src/hooks/useFetch.ts +0 -42
- package/src/components/source/src/hooks/usePage.ts +0 -3
- package/src/components/source/src/hooks/useSource.ts +0 -214
- package/src/components/source/src/index.ts +0 -5
- package/src/components/source/src/types/source.type.ts +0 -58
- package/src/components/source/src/types/table.type.ts +0 -8
- package/src/components/table/index.less +0 -179
- package/src/components/table/index.ts +0 -7
- package/src/components/table/src/components/TableActions.vue +0 -108
- package/src/components/table/src/components/TableHeader.vue +0 -78
- package/src/components/table/src/components/TableRender.vue +0 -76
- package/src/components/table/src/components/editable/CellComponent.ts +0 -57
- package/src/components/table/src/components/editable/EditTableCell.vue +0 -181
- package/src/components/table/src/components/editable/componentMap.ts +0 -18
- package/src/components/table/src/components/editable/index.ts +0 -58
- package/src/components/table/src/components/setting/Column.vue +0 -354
- package/src/components/table/src/components/setting/Download.vue +0 -55
- package/src/components/table/src/components/setting/Fullscreen.vue +0 -43
- package/src/components/table/src/components/setting/Size.vue +0 -42
- package/src/components/table/src/components/setting/index.vue +0 -64
- package/src/components/table/src/const.ts +0 -13
- package/src/components/table/src/hooks/useColumns.ts +0 -326
- package/src/components/table/src/hooks/useCustomRow.ts +0 -0
- package/src/components/table/src/hooks/useDataSource.ts +0 -97
- package/src/components/table/src/hooks/useHeaderCode.ts +0 -89
- package/src/components/table/src/hooks/useLoading.ts +0 -29
- package/src/components/table/src/hooks/usePagination.ts +0 -76
- package/src/components/table/src/hooks/useRowSelection.ts +0 -145
- package/src/components/table/src/hooks/useRows.ts +0 -30
- package/src/components/table/src/hooks/useTable.ts +0 -90
- package/src/components/table/src/hooks/useTableHeader.ts +0 -48
- package/src/components/table/src/hooks/useTableInstance.ts +0 -29
- package/src/components/table/src/hooks/useTableScroll.ts +0 -229
- package/src/components/table/src/index.vue +0 -200
- package/src/components/table/src/props.ts +0 -157
- package/src/components/table/src/types/table.type.ts +0 -160
- package/src/components/table/src/types/tableHeader.type.ts +0 -27
- package/src/components/tree/index.less +0 -41
- package/src/components/tree/index.ts +0 -5
- package/src/components/tree/src/components/TreeHeader.vue +0 -97
- package/src/components/tree/src/hooks/useTree.ts +0 -239
- package/src/components/tree/src/index.vue +0 -392
- package/src/components/tree/src/props.ts +0 -133
- package/src/components/tree/src/type/tree.ts +0 -105
- package/src/components/tree/src/utils/tree.ts +0 -73
- package/src/components/type.ts +0 -0
- package/src/components/upload/index.less +0 -43
- package/src/components/upload/index.ts +0 -7
- package/src/components/upload/src/helper.ts +0 -32
- package/src/components/upload/src/index.vue +0 -38
- package/src/components/upload/src/props.ts +0 -48
- package/src/components/upload/src/upload.vue +0 -166
- package/src/directives/icon.ts +0 -36
- package/src/directives/index.ts +0 -26
- package/src/directives/permission.ts +0 -20
- package/src/global.d.ts +0 -8
- package/src/index.ts +0 -4
- package/src/theme/content/index.vue +0 -37
- package/src/theme/feature/back-top.vue +0 -11
- package/src/theme/feature/index.vue +0 -7
- package/src/theme/footer/index.less +0 -16
- package/src/theme/footer/index.vue +0 -24
- package/src/theme/header/components/bread-crumb.vue +0 -26
- package/src/theme/header/components/fullscreen.vue +0 -12
- package/src/theme/header/components/handler.ts +0 -81
- package/src/theme/header/components/index.ts +0 -21
- package/src/theme/header/components/lang-picker.vue +0 -36
- package/src/theme/header/components/logo.vue +0 -35
- package/src/theme/header/components/menu-search.vue +0 -62
- package/src/theme/header/components/notify.vue +0 -22
- package/src/theme/header/components/setting-theme.vue +0 -123
- package/src/theme/header/components/theme-drawer/enum.ts +0 -12
- package/src/theme/header/components/theme-drawer/feature.vue +0 -75
- package/src/theme/header/components/theme-drawer/index.ts +0 -7
- package/src/theme/header/components/theme-drawer/menu-type.vue +0 -40
- package/src/theme/header/components/theme-drawer/select-item.vue +0 -46
- package/src/theme/header/components/theme-drawer/switch-item.vue +0 -39
- package/src/theme/header/components/theme-drawer/theme-color.vue +0 -26
- package/src/theme/header/components/trigger.vue +0 -14
- package/src/theme/header/components/user-info.vue +0 -60
- package/src/theme/header/const/index.ts +0 -40
- package/src/theme/header/helper/menu-tree.ts +0 -64
- package/src/theme/header/index.less +0 -442
- package/src/theme/header/index.ts +0 -0
- package/src/theme/header/index.vue +0 -96
- package/src/theme/header/multiple-header.vue +0 -67
- package/src/theme/header/set-theme.less +0 -68
- package/src/theme/index.ts +0 -3
- package/src/theme/sider/components/basic-menu/basic-menu-item.vue +0 -14
- package/src/theme/sider/components/basic-menu/basic-menu.vue +0 -122
- package/src/theme/sider/components/basic-menu/basic-sub-menu-item.vue +0 -46
- package/src/theme/sider/components/basic-menu/menu-item-content.vue +0 -13
- package/src/theme/sider/components/drag-bar.vue +0 -26
- package/src/theme/sider/components/layout-menu.vue +0 -132
- package/src/theme/sider/components/props.ts +0 -97
- package/src/theme/sider/components/sider-trigger.vue +0 -24
- package/src/theme/sider/helper/sider.ts +0 -52
- package/src/theme/sider/helper/split-menu.ts +0 -146
- package/src/theme/sider/hooks/useDragLine.ts +0 -86
- package/src/theme/sider/hooks/useOpenKeys.ts +0 -57
- package/src/theme/sider/index.less +0 -203
- package/src/theme/sider/index.vue +0 -88
- package/src/theme/tabs/components/TabContent.vue +0 -36
- package/src/theme/tabs/components/TabRedo.vue +0 -18
- package/src/theme/tabs/hooks/useMultifyTabs.ts +0 -96
- package/src/theme/tabs/hooks/useTabDropdown.ts +0 -89
- package/src/theme/tabs/index.less +0 -165
- package/src/theme/tabs/index.vue +0 -98
- package/src/theme/tabs/types/tabs.type.ts +0 -8
- package/src/theme/theme.less +0 -67
- package/src/theme/theme.vue +0 -90
- package/src/theme/transition.less +0 -99
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { defineComponent, toRefs, unref } from "vue";
|
|
2
|
-
import { Modal } from 'ant-design-vue';
|
|
3
|
-
import { useAttrs, useSlots } from '@dt-frames/core';
|
|
4
|
-
import { basicProps } from '../props';
|
|
5
|
-
import { useDragMove } from "../hooks/useDrag";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export default defineComponent({
|
|
9
|
-
name: 'Modal',
|
|
10
|
-
inheritAttrs: false,
|
|
11
|
-
props: basicProps,
|
|
12
|
-
emits: ['cancel'],
|
|
13
|
-
setup( props, { slots } ){
|
|
14
|
-
const { visible, draggable, destroyOnClose } = toRefs(props);
|
|
15
|
-
const attrs = useAttrs();
|
|
16
|
-
|
|
17
|
-
useDragMove({
|
|
18
|
-
visible,
|
|
19
|
-
destroyOnClose,
|
|
20
|
-
draggable,
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const { extendSlots } = useSlots();
|
|
24
|
-
|
|
25
|
-
return () => {
|
|
26
|
-
const propsData = { ...unref(attrs), ...props, destroyOnClose: true } as any;
|
|
27
|
-
return <Modal {...propsData}>{extendSlots(slots as any)}</Modal>;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
})
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<slot name="appendFooter"></slot>
|
|
3
|
-
<FormButtons
|
|
4
|
-
:mode="'dialog'"
|
|
5
|
-
:buttonList="buttonActions"
|
|
6
|
-
@handle-method="handleMethod($event)"
|
|
7
|
-
></FormButtons>
|
|
8
|
-
</template>
|
|
9
|
-
|
|
10
|
-
<script lang="ts" setup>
|
|
11
|
-
import { FormButtons, ButtonProps } from '../../../forms';
|
|
12
|
-
|
|
13
|
-
const emits = defineEmits([
|
|
14
|
-
'handleSave',
|
|
15
|
-
'handleCancel'
|
|
16
|
-
])
|
|
17
|
-
|
|
18
|
-
const props = defineProps({
|
|
19
|
-
showSave: {
|
|
20
|
-
type: Boolean,
|
|
21
|
-
default: true
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
const buttonActions: ButtonProps[] = [
|
|
26
|
-
{ name: '保存', preIcon: 'mdi:content-save', type: 'primary', flag: 'OK' },
|
|
27
|
-
{ name: '关闭', preIcon: 'mdi:close', flag: 'CANCEL' },
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
// 处理按钮点击事件
|
|
31
|
-
function handleMethod(item: ButtonProps) {
|
|
32
|
-
switch( item.flag ) {
|
|
33
|
-
case 'OK': emits('handleSave'); break
|
|
34
|
-
case 'CANCEL': emits('handleCancel'); break
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
</script>
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { Ref, unref, watchEffect } from 'vue';
|
|
2
|
-
import { useTimeoutFn } from '@dt-frames/core';
|
|
3
|
-
|
|
4
|
-
export interface UseModalDragMoveContext {
|
|
5
|
-
draggable: Ref<boolean>;
|
|
6
|
-
destroyOnClose: Ref<boolean | undefined> | undefined;
|
|
7
|
-
visible: Ref<boolean>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function useDragMove(context: UseModalDragMoveContext) {
|
|
11
|
-
const getStyle = (dom: any, attr: any) => {
|
|
12
|
-
return getComputedStyle(dom)[attr];
|
|
13
|
-
};
|
|
14
|
-
const drag = (wrap: any) => {
|
|
15
|
-
if (!wrap) return;
|
|
16
|
-
wrap.setAttribute('data-drag', unref(context.draggable));
|
|
17
|
-
const dialogHeaderEl = wrap.querySelector('.ant-modal-header');
|
|
18
|
-
const dragDom = wrap.querySelector('.ant-modal');
|
|
19
|
-
|
|
20
|
-
if (!dialogHeaderEl || !dragDom || !unref(context.draggable)) return;
|
|
21
|
-
|
|
22
|
-
dialogHeaderEl.style.cursor = 'move';
|
|
23
|
-
|
|
24
|
-
dialogHeaderEl.onmousedown = (e: any) => {
|
|
25
|
-
if (!e) return;
|
|
26
|
-
// 鼠标按下,计算当前元素距离可视区的距离
|
|
27
|
-
const disX = e.clientX;
|
|
28
|
-
const disY = e.clientY;
|
|
29
|
-
const screenWidth = document.body.clientWidth; // body当前宽度
|
|
30
|
-
const screenHeight = document.documentElement.clientHeight; // 可见区域高度(应为body高度,可某些环境下无法获取)
|
|
31
|
-
|
|
32
|
-
const dragDomWidth = dragDom.offsetWidth; // 对话框宽度
|
|
33
|
-
const dragDomheight = dragDom.offsetHeight; // 对话框高度
|
|
34
|
-
|
|
35
|
-
const minDragDomLeft = dragDom.offsetLeft;
|
|
36
|
-
|
|
37
|
-
const maxDragDomLeft = screenWidth - dragDom.offsetLeft - dragDomWidth;
|
|
38
|
-
const minDragDomTop = dragDom.offsetTop;
|
|
39
|
-
const maxDragDomTop = screenHeight - dragDom.offsetTop - dragDomheight;
|
|
40
|
-
// 获取到的值带px 正则匹配替换
|
|
41
|
-
const domLeft = getStyle(dragDom, 'left');
|
|
42
|
-
const domTop = getStyle(dragDom, 'top');
|
|
43
|
-
let styL = +domLeft;
|
|
44
|
-
let styT = +domTop;
|
|
45
|
-
|
|
46
|
-
// 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px
|
|
47
|
-
if (domLeft.includes('%')) {
|
|
48
|
-
styL = +document.body.clientWidth * (+domLeft.replace(/%/g, '') / 100);
|
|
49
|
-
styT = +document.body.clientHeight * (+domTop.replace(/%/g, '') / 100);
|
|
50
|
-
} else {
|
|
51
|
-
styL = +domLeft.replace(/px/g, '');
|
|
52
|
-
styT = +domTop.replace(/px/g, '');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
document.onmousemove = function (e) {
|
|
56
|
-
// 通过事件委托,计算移动的距离
|
|
57
|
-
let left = e.clientX - disX;
|
|
58
|
-
let top = e.clientY - disY;
|
|
59
|
-
|
|
60
|
-
// 边界处理
|
|
61
|
-
if (-left > minDragDomLeft) {
|
|
62
|
-
left = -minDragDomLeft;
|
|
63
|
-
} else if (left > maxDragDomLeft) {
|
|
64
|
-
left = maxDragDomLeft;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (-top > minDragDomTop) {
|
|
68
|
-
top = -minDragDomTop;
|
|
69
|
-
} else if (top > maxDragDomTop) {
|
|
70
|
-
top = maxDragDomTop;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// 移动当前元素
|
|
74
|
-
dragDom.style.cssText += `;left:${left + styL}px;top:${top + styT}px;`;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
document.onmouseup = () => {
|
|
78
|
-
document.onmousemove = null;
|
|
79
|
-
document.onmouseup = null;
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const handleDrag = () => {
|
|
85
|
-
const dragWraps = document.querySelectorAll('.ant-modal-wrap');
|
|
86
|
-
for (const wrap of Array.from(dragWraps)) {
|
|
87
|
-
if (!wrap) continue;
|
|
88
|
-
const display = getStyle(wrap, 'display');
|
|
89
|
-
const draggable = wrap.getAttribute('data-drag');
|
|
90
|
-
if (display !== 'none') {
|
|
91
|
-
// 拖拽位置
|
|
92
|
-
if (draggable === null || unref(context.destroyOnClose)) {
|
|
93
|
-
drag(wrap);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
watchEffect(() => {
|
|
100
|
-
if (!unref(context.visible) || !unref(context.draggable)) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
useTimeoutFn(() => {
|
|
104
|
-
handleDrag();
|
|
105
|
-
}, 30);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ref, Ref, unref, computed } from "vue"
|
|
2
|
-
import { dispatchResize } from '@dt-frames/core'
|
|
3
|
-
|
|
4
|
-
interface FullScreenOptions{
|
|
5
|
-
wrapClassName: Ref<string | undefined>;
|
|
6
|
-
modalWrapperRef: Ref<any>;
|
|
7
|
-
extHeightRef: Ref<number>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function useFullScreen(options: FullScreenOptions) {
|
|
11
|
-
const fullScreenRef = ref(false);
|
|
12
|
-
|
|
13
|
-
const getWrapClassName = computed(() => {
|
|
14
|
-
const clsName = unref(options.wrapClassName) || '';
|
|
15
|
-
return unref(fullScreenRef) ? `fullscreen-modal ${clsName} ` : unref(clsName);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
function toggleFullScreen(e: Event) {
|
|
19
|
-
e && e.stopPropagation();
|
|
20
|
-
fullScreenRef.value = !unref(fullScreenRef);
|
|
21
|
-
dispatchResize()
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
fullScreenRef,
|
|
26
|
-
getWrapClassName,
|
|
27
|
-
toggleFullScreen
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { error, isFunction, Nullable, Recordable } from "@dt-frames/core";
|
|
2
|
-
import { ModalProps } from "@dt-frames/core"
|
|
3
|
-
import { isEqual } from 'lodash-es'
|
|
4
|
-
import { tryOnUnmounted } from '@vueuse/core'
|
|
5
|
-
import { ModalMethods, ReturnInnerMethods, ReturnMethods, UseModalInnerReturnType, UseModalReturnType } from '../types/modal.type';
|
|
6
|
-
import { computed, getCurrentInstance, nextTick, onUnmounted, reactive, ref, toRaw, unref, watch, watchEffect } from "vue";
|
|
7
|
-
|
|
8
|
-
const dataTransfer = reactive<any>({})
|
|
9
|
-
const cbTransfer = reactive<any>({})
|
|
10
|
-
const visibleData = reactive<{ [key: number]: boolean }>({})
|
|
11
|
-
|
|
12
|
-
export function useModalOut(): UseModalReturnType{
|
|
13
|
-
const modal = ref<Nullable<ModalMethods>>(null)
|
|
14
|
-
const loaded = ref<Nullable<boolean>>(true)
|
|
15
|
-
const uid = ref<string>('')
|
|
16
|
-
|
|
17
|
-
function register(modalMethod: ModalMethods, uuid: string) {
|
|
18
|
-
if( !getCurrentInstance() ) {
|
|
19
|
-
throw new Error('useModal只能在setup()或者函数中使用')
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
uid.value = uuid
|
|
23
|
-
|
|
24
|
-
onUnmounted(() => {
|
|
25
|
-
modal.value = null
|
|
26
|
-
loaded.value = false
|
|
27
|
-
dataTransfer[unref(uid)] = null
|
|
28
|
-
cbTransfer[unref(uid)] = (rsp?: Recordable) => { }
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
if( unref(loaded) && modalMethod === unref(modal) ) return
|
|
32
|
-
|
|
33
|
-
modal.value = modalMethod
|
|
34
|
-
loaded.value = true
|
|
35
|
-
modalMethod.emitVisible = (visible: boolean, uid: number) => {
|
|
36
|
-
visibleData[uid] = visible
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const getInstance = () => {
|
|
41
|
-
const instance = unref( modal )
|
|
42
|
-
|
|
43
|
-
if( !instance ) {
|
|
44
|
-
error('useModalOut 实例未定义')
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return instance
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const methods: ReturnMethods = {
|
|
51
|
-
// 设置弹框属性
|
|
52
|
-
setModalProps: ( props: Partial<ModalProps> ) => {
|
|
53
|
-
getInstance()?.setModalProps(props)
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
getVisible: computed(() => {
|
|
57
|
-
return visibleData[~~unref(uid)]
|
|
58
|
-
}),
|
|
59
|
-
|
|
60
|
-
redoModalHeight: () => {
|
|
61
|
-
getInstance()?.redoModalHeight?.()
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
openModal: (params?: Recordable, openOnSet = true) => {
|
|
65
|
-
getInstance()?.setModalProps({
|
|
66
|
-
visible: true
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
const { data, afterClose } = params || {}
|
|
70
|
-
|
|
71
|
-
const id = unref(uid)
|
|
72
|
-
|
|
73
|
-
// 设置回调
|
|
74
|
-
cbTransfer[unref(uid)] = (rsp?: Recordable) => {
|
|
75
|
-
if( afterClose && isFunction(afterClose)) {
|
|
76
|
-
afterClose(rsp)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if( !data ) return
|
|
81
|
-
|
|
82
|
-
if( openOnSet ) {
|
|
83
|
-
dataTransfer[id] = toRaw(data);
|
|
84
|
-
|
|
85
|
-
return
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const equal = isEqual(toRaw(dataTransfer[id]), toRaw(data))
|
|
89
|
-
if (!equal) {
|
|
90
|
-
dataTransfer[id] = toRaw(data);
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
closeModal: () => {
|
|
95
|
-
getInstance()?.setModalProps({ visible: false })
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return [register, methods]
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
export function useModal(props?: Partial<ModalProps>,callbackFn?: Function): UseModalInnerReturnType {
|
|
104
|
-
const modalInstanceRef = ref<Nullable<ModalMethods>>(null)
|
|
105
|
-
const currentInstance = getCurrentInstance()
|
|
106
|
-
const uidRef = ref<string>('')
|
|
107
|
-
|
|
108
|
-
const getInstance = () => {
|
|
109
|
-
const instance = unref(modalInstanceRef)
|
|
110
|
-
if( !instance ) {
|
|
111
|
-
error('useModal 实例未定义')
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return instance
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const register = ( modalInstance: ModalMethods, uuid: string) => {
|
|
118
|
-
tryOnUnmounted(() => {
|
|
119
|
-
modalInstanceRef.value = null;
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
uidRef.value = uuid
|
|
123
|
-
modalInstanceRef.value = modalInstance
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* 深度监听props的变化,首次监听
|
|
127
|
-
* 动态更改表单实例
|
|
128
|
-
*/
|
|
129
|
-
watch(
|
|
130
|
-
() => props,
|
|
131
|
-
() => props && modalInstance.setModalProps(props),
|
|
132
|
-
{
|
|
133
|
-
immediate: true,
|
|
134
|
-
deep: true
|
|
135
|
-
}
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
currentInstance?.emit('register', modalInstance, uuid)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
watchEffect(() => {
|
|
142
|
-
const data = dataTransfer[unref(uidRef)]
|
|
143
|
-
if (!data) return
|
|
144
|
-
if (!callbackFn || !isFunction(callbackFn)) return
|
|
145
|
-
nextTick(() => {
|
|
146
|
-
callbackFn(data);
|
|
147
|
-
})
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
const methods: ReturnInnerMethods = {
|
|
151
|
-
changeLoading: (loading = true) => {
|
|
152
|
-
getInstance()?.setModalProps({ loading })
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
getVisible: computed(() => visibleData[~~unref(uidRef)]),
|
|
156
|
-
|
|
157
|
-
// 关闭弹框进行回调
|
|
158
|
-
closeModal: (rsp?: Recordable) => {
|
|
159
|
-
if(cbTransfer[unref(uidRef)]) cbTransfer[unref(uidRef)](rsp)
|
|
160
|
-
getInstance()?.setModalProps({ visible: false })
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
openModal: <T = any>(visable = true, data?: T, openOnSet = true) => {
|
|
164
|
-
getInstance()?.setModalProps({
|
|
165
|
-
visible: visable
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
if( !data ) return
|
|
169
|
-
|
|
170
|
-
const id = unref(uidRef)
|
|
171
|
-
|
|
172
|
-
if( openOnSet ) {
|
|
173
|
-
dataTransfer[id] = toRaw(data);
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const equal = isEqual(toRaw(dataTransfer[id]), toRaw(data))
|
|
178
|
-
if (!equal) {
|
|
179
|
-
dataTransfer[id] = toRaw(data);
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
setModalProps: (props: Partial<ModalProps>) => {
|
|
184
|
-
getInstance()?.setModalProps(props);
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
redoModalHeight: () => {
|
|
188
|
-
const callRedo = getInstance()?.redoModalHeight;
|
|
189
|
-
callRedo && callRedo();
|
|
190
|
-
},
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return [register, methods]
|
|
194
|
-
}
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Modal v-bind="getBindValue" @cancel="handleCancel">
|
|
3
|
-
<template #closeIcon v-if="!$slots.closeIcon">
|
|
4
|
-
<CloseIcon
|
|
5
|
-
:canFullscreen="getBindValue.canFullscreen"
|
|
6
|
-
:fullScreen="fullScreenRef"
|
|
7
|
-
@cancel="handleCancel"
|
|
8
|
-
@fullscreen="toggleFullScreen"
|
|
9
|
-
/>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<template #title v-if="!$slots.title">
|
|
13
|
-
{{ getMergeProps.title }}
|
|
14
|
-
</template>
|
|
15
|
-
|
|
16
|
-
<template #footer v-if="!$slots.footer">
|
|
17
|
-
<!-- 默认的footer内容 -->
|
|
18
|
-
<ModalFooter :showSave="getBindValue.showSave" @handle-save="handleSave" @handle-cancel="handleCancel">
|
|
19
|
-
<template #[item]="data" v-for="item in Object.keys($slots)">
|
|
20
|
-
<slot :name="item" v-bind="data || {}"></slot>
|
|
21
|
-
</template>
|
|
22
|
-
</ModalFooter>
|
|
23
|
-
</template>
|
|
24
|
-
|
|
25
|
-
<ModalWrapper
|
|
26
|
-
:useWrapper="getBindValue.useWrapper"
|
|
27
|
-
:footerOffset="wrapperFooterOffset"
|
|
28
|
-
:fullScreen="fullScreenRef"
|
|
29
|
-
ref="modalWrapperRef"
|
|
30
|
-
:loading="getBindValue.loading"
|
|
31
|
-
:loading-tip="getBindValue.loadingTip"
|
|
32
|
-
:minHeight="getBindValue.minHeight"
|
|
33
|
-
:height="getWrapperHeight"
|
|
34
|
-
:visible="visibleRef"
|
|
35
|
-
:modalFooterHeight="footer !== undefined && !footer ? 0 : undefined"
|
|
36
|
-
v-bind="omit(getBindValue.wrapperProps, 'visible', 'height', 'modalFooterHeight')"
|
|
37
|
-
@ext-height="handleExtHeight"
|
|
38
|
-
@height-change="handleHeightChange"
|
|
39
|
-
>
|
|
40
|
-
<slot></slot>
|
|
41
|
-
</ModalWrapper>
|
|
42
|
-
|
|
43
|
-
<template #[item]="data" v-for="item in Object.keys(omit($slots, 'default'))">
|
|
44
|
-
<slot :name="item" v-bind="data || {}"></slot>
|
|
45
|
-
</template>
|
|
46
|
-
</Modal>
|
|
47
|
-
</template>
|
|
48
|
-
|
|
49
|
-
<script lang="ts" setup>
|
|
50
|
-
import { computed, unref, ref, watch, getCurrentInstance, nextTick } from 'vue';
|
|
51
|
-
import Modal from './components/modal';
|
|
52
|
-
import { omit } from 'lodash-es';
|
|
53
|
-
import { useFullScreen } from './hooks/useFullScreen';
|
|
54
|
-
import { basicProps } from './props';
|
|
55
|
-
import ModalWrapper from './components/modal-wrap.vue';
|
|
56
|
-
import ModalFooter from './components/modalFooter.vue'
|
|
57
|
-
|
|
58
|
-
import CloseIcon from './components/close-icon.vue';
|
|
59
|
-
import { isFunction, deepMerge, ModalProps, ModalMethods } from '@dt-frames/core';
|
|
60
|
-
|
|
61
|
-
const visibleRef = ref(false);
|
|
62
|
-
const propsRef = ref<Partial<ModalProps>>();
|
|
63
|
-
const modalWrapperRef = ref(null);
|
|
64
|
-
const extHeightRef = ref(0);
|
|
65
|
-
|
|
66
|
-
const props = defineProps( basicProps );
|
|
67
|
-
const emits = defineEmits(['visible-change', 'height-change', 'cancel', 'save', 'register', 'update:visible'])
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const modalMethods: ModalMethods = {
|
|
71
|
-
setModalProps,
|
|
72
|
-
emitVisible: undefined,
|
|
73
|
-
redoModalHeight: () => {
|
|
74
|
-
nextTick(() => {
|
|
75
|
-
if (unref(modalWrapperRef)) {
|
|
76
|
-
(unref(modalWrapperRef) as any).setModalHeight();
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const { getWrapClassName, toggleFullScreen, fullScreenRef } = useFullScreen({
|
|
83
|
-
wrapClassName: computed(() => (unref(propsRef) as any)?.wrapClassName),
|
|
84
|
-
extHeightRef,
|
|
85
|
-
modalWrapperRef
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const getMergeProps = computed(() => {
|
|
89
|
-
return {
|
|
90
|
-
...props,
|
|
91
|
-
...(unref(propsRef) as any)
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
const getBindValue = computed(() => {
|
|
96
|
-
const bindValue = {
|
|
97
|
-
...unref(getMergeProps),
|
|
98
|
-
...(unref(propsRef) as any),
|
|
99
|
-
visible: unref(visibleRef),
|
|
100
|
-
wrapClassName: unref(getWrapClassName),
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return omit(bindValue, unref(fullScreenRef) ? ['height', 'title'] : 'title');
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const getWrapperHeight = computed(() => {
|
|
107
|
-
if (unref(fullScreenRef)) return undefined;
|
|
108
|
-
return unref(getBindValue).height;
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const instance = getCurrentInstance();
|
|
112
|
-
if (instance) { emits('register', modalMethods, instance.uid); }
|
|
113
|
-
|
|
114
|
-
watch(() => unref(visibleRef), (v) => {
|
|
115
|
-
emits('visible-change', v);
|
|
116
|
-
emits('update:visible', v);
|
|
117
|
-
instance && modalMethods.emitVisible?.(v, instance.uid);
|
|
118
|
-
nextTick(() => {
|
|
119
|
-
if (props.scrollTop && v && unref(modalWrapperRef)) {
|
|
120
|
-
(unref(modalWrapperRef).$el as any).scrollTop = 0;
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
},{
|
|
124
|
-
immediate: false,
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
function handleHeightChange(height: string) {
|
|
128
|
-
emits('height-change', height);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function handleExtHeight(height: number) {
|
|
132
|
-
extHeightRef.value = height;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
function setModalProps(props: Partial<ModalProps>) {
|
|
137
|
-
|
|
138
|
-
propsRef.value = deepMerge(unref(propsRef) || ({} as any), props);
|
|
139
|
-
|
|
140
|
-
if (Reflect.has(props, 'visible')) {
|
|
141
|
-
visibleRef.value = !!props.visible;
|
|
142
|
-
}
|
|
143
|
-
if (Reflect.has(props, 'defaultFullscreen')) {
|
|
144
|
-
fullScreenRef.value = !!props.defaultFullscreen;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// 弹框保存
|
|
149
|
-
function handleSave() {
|
|
150
|
-
emits('save')
|
|
151
|
-
// handleCancel()
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// 弹框关闭
|
|
155
|
-
async function handleCancel(e: Event = null) {
|
|
156
|
-
if( e ) {
|
|
157
|
-
e?.stopPropagation();
|
|
158
|
-
|
|
159
|
-
// 过滤自定义关闭按钮的空白区域
|
|
160
|
-
if ((e.target as HTMLElement)?.classList?.contains('dt-basic-modal-close--custom')) return;
|
|
161
|
-
|
|
162
|
-
if (props.closeFunc && isFunction(props.closeFunc)) {
|
|
163
|
-
const isClose: boolean = await props.closeFunc();
|
|
164
|
-
visibleRef.value = !isClose;
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
visibleRef.value = false;
|
|
170
|
-
|
|
171
|
-
emits('cancel', e)
|
|
172
|
-
}
|
|
173
|
-
</script>
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { CSSProperties, PropType, VNodeChild } from "vue";
|
|
2
|
-
|
|
3
|
-
// 支持设置的属性
|
|
4
|
-
const modalProps = {
|
|
5
|
-
visible : { type: Boolean },
|
|
6
|
-
scrollTop : { type: Boolean, default: true },
|
|
7
|
-
height : { type: Number },
|
|
8
|
-
minHeight : { type: Number },
|
|
9
|
-
draggable : { type: Boolean, default: true },
|
|
10
|
-
closeFunc : Function
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const basicProps = Object.assign({}, modalProps, {
|
|
14
|
-
defaultFullscreen : { type: Boolean },
|
|
15
|
-
canFullscreen : { type: Boolean, default: true },
|
|
16
|
-
wrapperFooterOffset : { type: Number, default: 0 },
|
|
17
|
-
useWrapper : { type: Boolean, default: true },
|
|
18
|
-
loading : { type: Boolean },
|
|
19
|
-
loadingTip : { type: String },
|
|
20
|
-
closable : { type: Boolean, default: true },
|
|
21
|
-
destroyOnClose : { type: Boolean },
|
|
22
|
-
title : { type: String },
|
|
23
|
-
visible : { type: Boolean },
|
|
24
|
-
width : { type: String as PropType<Number | String> },
|
|
25
|
-
wrapClassName : { type: String },
|
|
26
|
-
zIndex : { type: Number },
|
|
27
|
-
centered : { type: Boolean },
|
|
28
|
-
showSave : { type: Boolean },
|
|
29
|
-
|
|
30
|
-
// 掩膜
|
|
31
|
-
mask : { type: Boolean, default: true },
|
|
32
|
-
maskClosable : { type: Boolean, default: true },
|
|
33
|
-
keyboard : { type: Boolean, default: true },
|
|
34
|
-
maskStyle : Object as PropType<CSSProperties>,
|
|
35
|
-
|
|
36
|
-
footer : Object as PropType<VNodeChild | JSX.Element>,
|
|
37
|
-
|
|
38
|
-
bodyStyle : Object as PropType<CSSProperties>,
|
|
39
|
-
|
|
40
|
-
wrapperProps : Object,
|
|
41
|
-
afterClose : Function,
|
|
42
|
-
getContainer : Function as PropType<() => any>
|
|
43
|
-
})
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ModalProps, Recordable } from "@dt-frames/core"
|
|
2
|
-
import { ComputedRef } from "vue"
|
|
3
|
-
|
|
4
|
-
export type ModalMethods = {
|
|
5
|
-
setModalProps: ( props: Partial<ModalProps> ) => void
|
|
6
|
-
emitVisible?: ( visable: boolean, uid: number ) => void
|
|
7
|
-
redoModalHeight?: () => void
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface ReturnMethods extends ModalMethods{
|
|
11
|
-
openModal: <T = any>(data?: T, openOnSet?: boolean) => void
|
|
12
|
-
closeModal: () => void
|
|
13
|
-
getVisible?: ComputedRef<boolean>
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface ReturnInnerMethods extends ModalMethods {
|
|
17
|
-
openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void
|
|
18
|
-
closeModal: (rsp?: Recordable) => void
|
|
19
|
-
changeLoading: (loading: boolean) => void
|
|
20
|
-
getVisible?: ComputedRef<boolean>
|
|
21
|
-
redoModalHeight: () => void
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type RegisterFn = (modalMethods: ModalMethods, uuid?: string) => void
|
|
25
|
-
|
|
26
|
-
export type UseModalReturnType = [RegisterFn, ReturnMethods]
|
|
27
|
-
export type UseModalInnerReturnType = [RegisterFn, ReturnInnerMethods];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './src/index'
|