vxe-pc-ui 0.2.0 → 0.4.0
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/anchor/index.js +2 -0
- package/es/anchor/src/anchor.js +18 -18
- package/es/anchor-link/index.js +2 -0
- package/es/breadcrumb/index.js +2 -0
- package/es/breadcrumb/src/breadcrumb.js +2 -2
- package/es/breadcrumb-item/index.js +2 -0
- package/es/button/index.js +2 -0
- package/es/button/src/button-group.js +2 -5
- package/es/button-group/index.js +2 -0
- package/es/checkbox/src/checkbox.js +8 -8
- package/es/checkbox/src/group.js +6 -6
- package/es/checkbox-group/index.js +1 -1
- package/es/col/index.js +2 -0
- package/es/components.js +3 -0
- package/es/form/index.js +2 -0
- package/es/form/src/form-config-item.js +3 -8
- package/es/form/src/form-item.js +3 -8
- package/es/form/src/form.js +5 -8
- package/es/form/src/render.js +2 -10
- package/es/form-design/index.js +2 -0
- package/es/form-gather/index.js +2 -0
- package/es/form-item/index.js +2 -0
- package/es/icon/index.js +2 -0
- package/es/input/index.js +1 -1
- package/es/input/style.css +5 -5
- package/es/input/style.min.css +1 -1
- package/es/layout-aside/index.js +2 -0
- package/es/layout-body/index.js +2 -0
- package/es/layout-container/index.js +2 -0
- package/es/layout-footer/index.js +2 -0
- package/es/layout-header/index.js +2 -0
- package/es/list/index.js +10 -0
- package/es/list/src/list.js +340 -0
- package/es/list/style.css +26 -0
- package/es/list/style.min.css +1 -0
- package/es/list-design/index.js +2 -0
- package/es/loading/index.js +2 -0
- package/es/modal/index.js +1 -1
- package/es/modal/src/modal.js +2 -5
- package/es/modal/style.css +1 -1
- package/es/modal/style.min.css +1 -1
- package/es/optgroup/index.js +1 -1
- package/es/option/index.js +1 -1
- package/es/pager/index.js +1 -1
- package/es/pager/src/pager.js +4 -4
- package/es/pager/style.css +2 -2
- package/es/pager/style.min.css +1 -1
- package/es/pulldown/index.js +1 -1
- package/es/pulldown/style.css +2 -2
- package/es/pulldown/style.min.css +1 -1
- package/es/radio/index.js +1 -1
- package/es/radio-button/index.js +1 -1
- package/es/radio-group/index.js +1 -1
- package/es/row/index.js +2 -0
- package/es/select/index.js +1 -1
- package/es/select/style.css +2 -2
- package/es/select/style.min.css +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/switch/index.js +1 -1
- package/es/switch/style.css +1 -1
- package/es/switch/style.min.css +1 -1
- package/es/tab-pane/index.js +2 -0
- package/es/tabs/index.js +2 -0
- package/es/tabs/src/tabs.js +50 -19
- package/es/tabs/style.css +49 -34
- package/es/tabs/style.min.css +1 -1
- package/es/textarea/index.js +1 -1
- package/es/textarea/style.css +2 -2
- package/es/textarea/style.min.css +1 -1
- package/es/tooltip/index.js +2 -0
- package/es/tooltip/src/tooltip.js +2 -7
- package/es/ui/src/core.js +1 -1
- package/es/ui/src/globalStore.js +64 -66
- package/es/ui/src/log.js +1 -1
- package/es/ui/src/resize.js +81 -0
- package/es/ui/src/store.js +8 -1
- package/es/vxe-input/style.css +5 -5
- package/es/vxe-input/style.min.css +1 -1
- package/es/vxe-list/index.js +3 -0
- package/es/vxe-list/style.css +26 -0
- package/es/vxe-list/style.min.css +1 -0
- package/es/vxe-modal/style.css +1 -1
- package/es/vxe-modal/style.min.css +1 -1
- package/es/vxe-pager/style.css +2 -2
- package/es/vxe-pager/style.min.css +1 -1
- package/es/vxe-pulldown/style.css +2 -2
- package/es/vxe-pulldown/style.min.css +1 -1
- package/es/vxe-select/style.css +2 -2
- package/es/vxe-select/style.min.css +1 -1
- package/es/vxe-switch/style.css +1 -1
- package/es/vxe-switch/style.min.css +1 -1
- package/es/vxe-tabs/style.css +49 -34
- package/es/vxe-tabs/style.min.css +1 -1
- package/es/vxe-textarea/style.css +2 -2
- package/es/vxe-textarea/style.min.css +1 -1
- package/lib/anchor/index.js +2 -0
- package/lib/anchor/index.min.js +1 -1
- package/lib/anchor/src/anchor.js +18 -18
- package/lib/anchor/src/anchor.min.js +1 -1
- package/lib/anchor-link/index.js +2 -0
- package/lib/anchor-link/index.min.js +1 -1
- package/lib/breadcrumb/index.js +2 -0
- package/lib/breadcrumb/index.min.js +1 -1
- package/lib/breadcrumb/src/breadcrumb.js +2 -2
- package/lib/breadcrumb/src/breadcrumb.min.js +1 -1
- package/lib/breadcrumb-item/index.js +2 -0
- package/lib/breadcrumb-item/index.min.js +1 -1
- package/lib/button/index.js +2 -0
- package/lib/button/index.min.js +1 -1
- package/lib/button/src/button-group.js +5 -7
- package/lib/button/src/button-group.min.js +1 -1
- package/lib/button-group/index.js +2 -0
- package/lib/button-group/index.min.js +1 -1
- package/lib/checkbox/src/checkbox.js +8 -8
- package/lib/checkbox/src/checkbox.min.js +1 -1
- package/lib/checkbox/src/group.js +6 -6
- package/lib/checkbox/src/group.min.js +1 -1
- package/lib/checkbox-group/index.js +1 -1
- package/lib/checkbox-group/index.min.js +1 -1
- package/lib/col/index.js +2 -0
- package/lib/col/index.min.js +1 -1
- package/lib/components.js +13 -1
- package/lib/components.min.js +1 -1
- package/lib/form/index.js +2 -0
- package/lib/form/index.min.js +1 -1
- package/lib/form/src/form-config-item.js +3 -4
- package/lib/form/src/form-config-item.min.js +1 -1
- package/lib/form/src/form-item.js +3 -4
- package/lib/form/src/form-item.min.js +1 -1
- package/lib/form/src/form.js +7 -8
- package/lib/form/src/form.min.js +1 -1
- package/lib/form/src/render.js +4 -8
- package/lib/form/src/render.min.js +1 -1
- package/lib/form-design/index.js +2 -0
- package/lib/form-design/index.min.js +1 -1
- package/lib/form-gather/index.js +2 -0
- package/lib/form-gather/index.min.js +1 -1
- package/lib/form-item/index.js +2 -0
- package/lib/form-item/index.min.js +1 -1
- package/lib/icon/index.js +2 -0
- package/lib/icon/index.min.js +1 -1
- package/lib/index.umd.js +737 -167
- package/lib/index.umd.min.js +1 -1
- package/lib/input/index.js +1 -1
- package/lib/input/index.min.js +1 -1
- package/lib/input/style/style.css +5 -5
- package/lib/input/style/style.min.css +1 -1
- package/lib/layout-aside/index.js +2 -0
- package/lib/layout-aside/index.min.js +1 -1
- package/lib/layout-body/index.js +2 -0
- package/lib/layout-body/index.min.js +1 -1
- package/lib/layout-container/index.js +2 -0
- package/lib/layout-container/index.min.js +1 -1
- package/lib/layout-footer/index.js +2 -0
- package/lib/layout-footer/index.min.js +1 -1
- package/lib/layout-header/index.js +2 -0
- package/lib/layout-header/index.min.js +1 -1
- package/lib/list/index.js +17 -0
- package/lib/list/index.min.js +1 -0
- package/lib/list/src/list.js +397 -0
- package/lib/list/src/list.min.js +1 -0
- package/lib/list/style/index.js +1 -0
- package/lib/list/style/style.css +26 -0
- package/lib/list/style/style.min.css +1 -0
- package/lib/list-design/index.js +2 -0
- package/lib/list-design/index.min.js +1 -1
- package/lib/loading/index.js +2 -0
- package/lib/loading/index.min.js +1 -1
- package/lib/modal/index.js +1 -5
- package/lib/modal/index.min.js +1 -1
- package/lib/modal/src/modal.js +3 -4
- package/lib/modal/src/modal.min.js +1 -1
- package/lib/modal/style/style.css +1 -1
- package/lib/modal/style/style.min.css +1 -1
- package/lib/optgroup/index.js +1 -1
- package/lib/optgroup/index.min.js +1 -1
- package/lib/option/index.js +1 -1
- package/lib/option/index.min.js +1 -1
- package/lib/pager/index.js +1 -1
- package/lib/pager/index.min.js +1 -1
- package/lib/pager/src/pager.js +6 -7
- package/lib/pager/src/pager.min.js +1 -1
- package/lib/pager/style/style.css +2 -2
- package/lib/pager/style/style.min.css +1 -1
- package/lib/pulldown/index.js +1 -1
- package/lib/pulldown/index.min.js +1 -1
- package/lib/pulldown/style/style.css +2 -2
- package/lib/pulldown/style/style.min.css +1 -1
- package/lib/radio/index.js +1 -1
- package/lib/radio/index.min.js +1 -1
- package/lib/radio-button/index.js +1 -1
- package/lib/radio-button/index.min.js +1 -1
- package/lib/radio-group/index.js +1 -1
- package/lib/radio-group/index.min.js +1 -1
- package/lib/row/index.js +2 -0
- package/lib/row/index.min.js +1 -1
- package/lib/select/index.js +1 -1
- package/lib/select/index.min.js +1 -1
- package/lib/select/style/style.css +2 -2
- package/lib/select/style/style.min.css +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/switch/index.js +1 -1
- package/lib/switch/index.min.js +1 -1
- package/lib/switch/style/style.css +1 -1
- package/lib/switch/style/style.min.css +1 -1
- package/lib/tab-pane/index.js +2 -0
- package/lib/tab-pane/index.min.js +1 -1
- package/lib/tabs/index.js +2 -0
- package/lib/tabs/index.min.js +1 -1
- package/lib/tabs/src/tabs.js +50 -12
- package/lib/tabs/src/tabs.min.js +1 -1
- package/lib/tabs/style/style.css +49 -34
- package/lib/tabs/style/style.min.css +1 -1
- package/lib/textarea/index.js +1 -1
- package/lib/textarea/index.min.js +1 -1
- package/lib/textarea/style/style.css +2 -2
- package/lib/textarea/style/style.min.css +1 -1
- package/lib/tooltip/index.js +2 -0
- package/lib/tooltip/index.min.js +1 -1
- package/lib/tooltip/src/tooltip.js +3 -4
- package/lib/tooltip/src/tooltip.min.js +1 -1
- package/lib/ui/src/core.js +1 -1
- package/lib/ui/src/core.min.js +1 -1
- package/lib/ui/src/globalStore.js +63 -65
- package/lib/ui/src/globalStore.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/ui/src/resize.js +96 -0
- package/lib/ui/src/resize.min.js +1 -0
- package/lib/ui/src/store.js +8 -1
- package/lib/ui/src/store.min.js +1 -1
- package/lib/vxe-input/style/style.css +5 -5
- package/lib/vxe-input/style/style.min.css +1 -1
- package/lib/vxe-list/index.js +22 -0
- package/lib/vxe-list/index.min.js +1 -0
- package/lib/vxe-list/style/index.js +1 -0
- package/lib/vxe-list/style/style.css +26 -0
- package/lib/vxe-list/style/style.min.css +1 -0
- package/lib/vxe-modal/style/style.css +1 -1
- package/lib/vxe-modal/style/style.min.css +1 -1
- package/lib/vxe-pager/style/style.css +2 -2
- package/lib/vxe-pager/style/style.min.css +1 -1
- package/lib/vxe-pulldown/style/style.css +2 -2
- package/lib/vxe-pulldown/style/style.min.css +1 -1
- package/lib/vxe-select/style/style.css +2 -2
- package/lib/vxe-select/style/style.min.css +1 -1
- package/lib/vxe-switch/style/style.css +1 -1
- package/lib/vxe-switch/style/style.min.css +1 -1
- package/lib/vxe-tabs/style/style.css +49 -34
- package/lib/vxe-tabs/style/style.min.css +1 -1
- package/lib/vxe-textarea/style/style.css +2 -2
- package/lib/vxe-textarea/style/style.min.css +1 -1
- package/package.json +1 -1
- package/packages/anchor/index.ts +3 -0
- package/packages/anchor/src/anchor.ts +23 -23
- package/packages/anchor-link/index.ts +3 -0
- package/packages/breadcrumb/index.ts +3 -0
- package/packages/breadcrumb/src/breadcrumb.ts +2 -2
- package/packages/breadcrumb-item/index.ts +3 -0
- package/packages/button/index.ts +3 -0
- package/packages/button-group/index.ts +3 -0
- package/packages/checkbox/index.ts +2 -2
- package/packages/checkbox/src/checkbox.ts +8 -8
- package/packages/checkbox/src/group.ts +6 -6
- package/packages/checkbox-group/index.ts +3 -4
- package/packages/col/index.ts +3 -0
- package/packages/components.ts +3 -0
- package/packages/form/index.ts +3 -0
- package/packages/form/src/form.ts +4 -4
- package/packages/form-design/index.ts +3 -0
- package/packages/form-gather/index.ts +3 -0
- package/packages/form-item/index.ts +3 -0
- package/packages/icon/index.ts +3 -0
- package/packages/input/index.ts +3 -4
- package/packages/layout-aside/index.ts +3 -0
- package/packages/layout-body/index.ts +3 -0
- package/packages/layout-container/index.ts +3 -0
- package/packages/layout-footer/index.ts +3 -0
- package/packages/layout-header/index.ts +3 -0
- package/packages/list/index.ts +14 -0
- package/packages/list/src/list.ts +372 -0
- package/packages/list-design/index.ts +3 -0
- package/packages/loading/index.ts +3 -0
- package/packages/optgroup/index.ts +3 -4
- package/packages/option/index.ts +3 -4
- package/packages/pager/index.ts +3 -4
- package/packages/pager/src/pager.ts +3 -3
- package/packages/pulldown/index.ts +3 -4
- package/packages/radio/index.ts +3 -4
- package/packages/radio-button/index.ts +3 -4
- package/packages/radio-group/index.ts +2 -3
- package/packages/row/index.ts +3 -0
- package/packages/select/index.ts +3 -4
- package/packages/switch/index.ts +1 -2
- package/packages/tab-pane/index.ts +3 -0
- package/packages/tabs/index.ts +3 -0
- package/packages/tabs/src/tabs.ts +49 -19
- package/packages/textarea/index.ts +3 -4
- package/packages/tooltip/index.ts +3 -0
- package/packages/ui/src/globalStore.ts +63 -65
- package/packages/ui/src/resize.ts +85 -0
- package/styles/all.scss +1 -0
- package/styles/components/input.scss +5 -5
- package/styles/components/list.scss +1 -1
- package/styles/components/modal.scss +1 -1
- package/styles/components/pager.scss +2 -2
- package/styles/components/pulldown.scss +2 -2
- package/styles/components/select.scss +2 -2
- package/styles/components/switch.scss +1 -1
- package/styles/components/tabs.scss +44 -34
- package/styles/components/textarea.scss +2 -2
- package/types/all.d.ts +1 -0
- package/types/components/list.d.ts +166 -0
- package/types/components/tab-pane.d.ts +1 -1
- package/types/components/tabs.d.ts +2 -2
- package/types/ui/global-config.d.ts +67 -25
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _vue = require("vue");
|
|
8
|
+
var _xeUtils = _interopRequireDefault(require("xe-utils"));
|
|
9
|
+
var _globalStore = _interopRequireDefault(require("../../ui/src/globalStore"));
|
|
10
|
+
var _size = require("../../hooks/size");
|
|
11
|
+
var _resize = require("../../ui/src/resize");
|
|
12
|
+
var _dom = require("../../ui/src/dom");
|
|
13
|
+
var _event = require("../../ui/src/event");
|
|
14
|
+
var _loading = _interopRequireDefault(require("../../loading/src/loading"));
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
var _default = exports.default = (0, _vue.defineComponent)({
|
|
17
|
+
name: 'VxeList',
|
|
18
|
+
props: {
|
|
19
|
+
data: Array,
|
|
20
|
+
height: [Number, String],
|
|
21
|
+
maxHeight: [Number, String],
|
|
22
|
+
loading: Boolean,
|
|
23
|
+
className: [String, Function],
|
|
24
|
+
size: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: () => _globalStore.default.list.size || _globalStore.default.size
|
|
27
|
+
},
|
|
28
|
+
autoResize: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: () => _globalStore.default.list.autoResize
|
|
31
|
+
},
|
|
32
|
+
syncResize: [Boolean, String, Number],
|
|
33
|
+
scrollY: Object
|
|
34
|
+
},
|
|
35
|
+
emits: ['scroll'],
|
|
36
|
+
setup(props, context) {
|
|
37
|
+
const {
|
|
38
|
+
slots,
|
|
39
|
+
emit
|
|
40
|
+
} = context;
|
|
41
|
+
const xID = _xeUtils.default.uniqueId();
|
|
42
|
+
const computeSize = (0, _size.useSize)(props);
|
|
43
|
+
const reactData = (0, _vue.reactive)({
|
|
44
|
+
scrollYLoad: false,
|
|
45
|
+
bodyHeight: 0,
|
|
46
|
+
rowHeight: 0,
|
|
47
|
+
topSpaceHeight: 0,
|
|
48
|
+
items: []
|
|
49
|
+
});
|
|
50
|
+
const refElem = (0, _vue.ref)();
|
|
51
|
+
const refVirtualWrapper = (0, _vue.ref)();
|
|
52
|
+
const refVirtualBody = (0, _vue.ref)();
|
|
53
|
+
const internalData = {
|
|
54
|
+
fullData: [],
|
|
55
|
+
lastScrollLeft: 0,
|
|
56
|
+
lastScrollTop: 0,
|
|
57
|
+
scrollYStore: {
|
|
58
|
+
startIndex: 0,
|
|
59
|
+
endIndex: 0,
|
|
60
|
+
visibleSize: 0,
|
|
61
|
+
offsetSize: 0,
|
|
62
|
+
rowHeight: 0
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const refMaps = {
|
|
66
|
+
refElem
|
|
67
|
+
};
|
|
68
|
+
const $xeList = {
|
|
69
|
+
xID,
|
|
70
|
+
props,
|
|
71
|
+
context,
|
|
72
|
+
reactData,
|
|
73
|
+
internalData,
|
|
74
|
+
getRefMaps: () => refMaps
|
|
75
|
+
};
|
|
76
|
+
let listMethods = {};
|
|
77
|
+
const computeSYOpts = (0, _vue.computed)(() => {
|
|
78
|
+
return Object.assign({}, _globalStore.default.list.scrollY, props.scrollY);
|
|
79
|
+
});
|
|
80
|
+
const computeStyles = (0, _vue.computed)(() => {
|
|
81
|
+
const {
|
|
82
|
+
height,
|
|
83
|
+
maxHeight
|
|
84
|
+
} = props;
|
|
85
|
+
const style = {};
|
|
86
|
+
if (height) {
|
|
87
|
+
style.height = `${isNaN(height) ? height : `${height}px`}`;
|
|
88
|
+
} else if (maxHeight) {
|
|
89
|
+
style.height = 'auto';
|
|
90
|
+
style.maxHeight = `${isNaN(maxHeight) ? maxHeight : `${maxHeight}px`}`;
|
|
91
|
+
}
|
|
92
|
+
return style;
|
|
93
|
+
});
|
|
94
|
+
const updateYSpace = () => {
|
|
95
|
+
const {
|
|
96
|
+
scrollYLoad
|
|
97
|
+
} = reactData;
|
|
98
|
+
const {
|
|
99
|
+
scrollYStore,
|
|
100
|
+
fullData
|
|
101
|
+
} = internalData;
|
|
102
|
+
reactData.bodyHeight = scrollYLoad ? fullData.length * scrollYStore.rowHeight : 0;
|
|
103
|
+
reactData.topSpaceHeight = scrollYLoad ? Math.max(scrollYStore.startIndex * scrollYStore.rowHeight, 0) : 0;
|
|
104
|
+
};
|
|
105
|
+
const handleData = () => {
|
|
106
|
+
const {
|
|
107
|
+
scrollYLoad
|
|
108
|
+
} = reactData;
|
|
109
|
+
const {
|
|
110
|
+
fullData,
|
|
111
|
+
scrollYStore
|
|
112
|
+
} = internalData;
|
|
113
|
+
reactData.items = scrollYLoad ? fullData.slice(scrollYStore.startIndex, scrollYStore.endIndex) : fullData.slice(0);
|
|
114
|
+
return (0, _vue.nextTick)();
|
|
115
|
+
};
|
|
116
|
+
const updateYData = () => {
|
|
117
|
+
handleData();
|
|
118
|
+
updateYSpace();
|
|
119
|
+
};
|
|
120
|
+
const computeScrollLoad = () => {
|
|
121
|
+
return (0, _vue.nextTick)().then(() => {
|
|
122
|
+
const {
|
|
123
|
+
scrollYLoad
|
|
124
|
+
} = reactData;
|
|
125
|
+
const {
|
|
126
|
+
scrollYStore
|
|
127
|
+
} = internalData;
|
|
128
|
+
const virtualBodyElem = refVirtualBody.value;
|
|
129
|
+
const sYOpts = computeSYOpts.value;
|
|
130
|
+
let rowHeight = 0;
|
|
131
|
+
let firstItemElem;
|
|
132
|
+
if (virtualBodyElem) {
|
|
133
|
+
if (sYOpts.sItem) {
|
|
134
|
+
firstItemElem = virtualBodyElem.querySelector(sYOpts.sItem);
|
|
135
|
+
}
|
|
136
|
+
if (!firstItemElem) {
|
|
137
|
+
firstItemElem = virtualBodyElem.children[0];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (firstItemElem) {
|
|
141
|
+
rowHeight = firstItemElem.offsetHeight;
|
|
142
|
+
}
|
|
143
|
+
rowHeight = Math.max(20, rowHeight);
|
|
144
|
+
scrollYStore.rowHeight = rowHeight;
|
|
145
|
+
// 计算 Y 逻辑
|
|
146
|
+
if (scrollYLoad) {
|
|
147
|
+
const scrollBodyElem = refVirtualWrapper.value;
|
|
148
|
+
const visibleYSize = Math.max(8, Math.ceil(scrollBodyElem.clientHeight / rowHeight));
|
|
149
|
+
const offsetYSize = sYOpts.oSize ? _xeUtils.default.toNumber(sYOpts.oSize) : _dom.browse.edge ? 10 : 0;
|
|
150
|
+
scrollYStore.offsetSize = offsetYSize;
|
|
151
|
+
scrollYStore.visibleSize = visibleYSize;
|
|
152
|
+
scrollYStore.endIndex = Math.max(scrollYStore.startIndex, visibleYSize + offsetYSize, scrollYStore.endIndex);
|
|
153
|
+
updateYData();
|
|
154
|
+
} else {
|
|
155
|
+
updateYSpace();
|
|
156
|
+
}
|
|
157
|
+
reactData.rowHeight = rowHeight;
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* 清除滚动条
|
|
162
|
+
*/
|
|
163
|
+
const clearScroll = () => {
|
|
164
|
+
const scrollBodyElem = refVirtualWrapper.value;
|
|
165
|
+
if (scrollBodyElem) {
|
|
166
|
+
scrollBodyElem.scrollTop = 0;
|
|
167
|
+
}
|
|
168
|
+
return (0, _vue.nextTick)();
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* 如果有滚动条,则滚动到对应的位置
|
|
172
|
+
* @param {Number} scrollLeft 左距离
|
|
173
|
+
* @param {Number} scrollTop 上距离
|
|
174
|
+
*/
|
|
175
|
+
const scrollTo = (scrollLeft, scrollTop) => {
|
|
176
|
+
const scrollBodyElem = refVirtualWrapper.value;
|
|
177
|
+
if (_xeUtils.default.isNumber(scrollLeft)) {
|
|
178
|
+
scrollBodyElem.scrollLeft = scrollLeft;
|
|
179
|
+
}
|
|
180
|
+
if (_xeUtils.default.isNumber(scrollTop)) {
|
|
181
|
+
scrollBodyElem.scrollTop = scrollTop;
|
|
182
|
+
}
|
|
183
|
+
if (reactData.scrollYLoad) {
|
|
184
|
+
return new Promise(resolve => {
|
|
185
|
+
setTimeout(() => {
|
|
186
|
+
(0, _vue.nextTick)(() => {
|
|
187
|
+
resolve();
|
|
188
|
+
});
|
|
189
|
+
}, 50);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return (0, _vue.nextTick)();
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* 刷新滚动条
|
|
196
|
+
*/
|
|
197
|
+
const refreshScroll = () => {
|
|
198
|
+
const {
|
|
199
|
+
lastScrollLeft,
|
|
200
|
+
lastScrollTop
|
|
201
|
+
} = internalData;
|
|
202
|
+
return clearScroll().then(() => {
|
|
203
|
+
if (lastScrollLeft || lastScrollTop) {
|
|
204
|
+
internalData.lastScrollLeft = 0;
|
|
205
|
+
internalData.lastScrollTop = 0;
|
|
206
|
+
return scrollTo(lastScrollLeft, lastScrollTop);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* 重新计算列表
|
|
212
|
+
*/
|
|
213
|
+
const recalculate = () => {
|
|
214
|
+
const el = refElem.value;
|
|
215
|
+
if (el.clientWidth && el.clientHeight) {
|
|
216
|
+
return computeScrollLoad();
|
|
217
|
+
}
|
|
218
|
+
return Promise.resolve();
|
|
219
|
+
};
|
|
220
|
+
const loadYData = evnt => {
|
|
221
|
+
const {
|
|
222
|
+
scrollYStore
|
|
223
|
+
} = internalData;
|
|
224
|
+
const {
|
|
225
|
+
startIndex,
|
|
226
|
+
endIndex,
|
|
227
|
+
visibleSize,
|
|
228
|
+
offsetSize,
|
|
229
|
+
rowHeight
|
|
230
|
+
} = scrollYStore;
|
|
231
|
+
const scrollBodyElem = evnt.target;
|
|
232
|
+
const scrollTop = scrollBodyElem.scrollTop;
|
|
233
|
+
const toVisibleIndex = Math.floor(scrollTop / rowHeight);
|
|
234
|
+
const offsetStartIndex = Math.max(0, toVisibleIndex - 1 - offsetSize);
|
|
235
|
+
const offsetEndIndex = toVisibleIndex + visibleSize + offsetSize;
|
|
236
|
+
if (toVisibleIndex <= startIndex || toVisibleIndex >= endIndex - visibleSize - 1) {
|
|
237
|
+
if (startIndex !== offsetStartIndex || endIndex !== offsetEndIndex) {
|
|
238
|
+
scrollYStore.startIndex = offsetStartIndex;
|
|
239
|
+
scrollYStore.endIndex = offsetEndIndex;
|
|
240
|
+
updateYData();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
const scrollEvent = evnt => {
|
|
245
|
+
const scrollBodyElem = evnt.target;
|
|
246
|
+
const scrollTop = scrollBodyElem.scrollTop;
|
|
247
|
+
const scrollLeft = scrollBodyElem.scrollLeft;
|
|
248
|
+
const isX = scrollLeft !== internalData.lastScrollLeft;
|
|
249
|
+
const isY = scrollTop !== internalData.lastScrollTop;
|
|
250
|
+
internalData.lastScrollTop = scrollTop;
|
|
251
|
+
internalData.lastScrollLeft = scrollLeft;
|
|
252
|
+
if (reactData.scrollYLoad) {
|
|
253
|
+
loadYData(evnt);
|
|
254
|
+
}
|
|
255
|
+
listMethods.dispatchEvent('scroll', {
|
|
256
|
+
scrollLeft,
|
|
257
|
+
scrollTop,
|
|
258
|
+
isX,
|
|
259
|
+
isY
|
|
260
|
+
}, evnt);
|
|
261
|
+
};
|
|
262
|
+
listMethods = {
|
|
263
|
+
dispatchEvent(type, params, evnt) {
|
|
264
|
+
emit(type, Object.assign({
|
|
265
|
+
$list: $xeList,
|
|
266
|
+
$event: evnt
|
|
267
|
+
}, params));
|
|
268
|
+
},
|
|
269
|
+
/**
|
|
270
|
+
* 加载数据
|
|
271
|
+
* @param {Array} datas 数据
|
|
272
|
+
*/
|
|
273
|
+
loadData(datas) {
|
|
274
|
+
const {
|
|
275
|
+
scrollYStore
|
|
276
|
+
} = internalData;
|
|
277
|
+
const sYOpts = computeSYOpts.value;
|
|
278
|
+
const fullData = datas || [];
|
|
279
|
+
Object.assign(scrollYStore, {
|
|
280
|
+
startIndex: 0,
|
|
281
|
+
endIndex: 1,
|
|
282
|
+
visibleSize: 0
|
|
283
|
+
});
|
|
284
|
+
internalData.fullData = fullData;
|
|
285
|
+
// 如果gt为0,则总是启用
|
|
286
|
+
reactData.scrollYLoad = !!sYOpts.enabled && sYOpts.gt > -1 && (sYOpts.gt === 0 || sYOpts.gt <= fullData.length);
|
|
287
|
+
handleData();
|
|
288
|
+
return computeScrollLoad().then(() => {
|
|
289
|
+
refreshScroll();
|
|
290
|
+
});
|
|
291
|
+
},
|
|
292
|
+
/**
|
|
293
|
+
* 重新加载数据
|
|
294
|
+
* @param {Array} datas 数据
|
|
295
|
+
*/
|
|
296
|
+
reloadData(datas) {
|
|
297
|
+
clearScroll();
|
|
298
|
+
return listMethods.loadData(datas);
|
|
299
|
+
},
|
|
300
|
+
recalculate,
|
|
301
|
+
scrollTo,
|
|
302
|
+
refreshScroll,
|
|
303
|
+
clearScroll
|
|
304
|
+
};
|
|
305
|
+
Object.assign($xeList, listMethods);
|
|
306
|
+
const dataFlag = (0, _vue.ref)(0);
|
|
307
|
+
(0, _vue.watch)(() => props.data ? props.data.length : -1, () => {
|
|
308
|
+
dataFlag.value++;
|
|
309
|
+
});
|
|
310
|
+
(0, _vue.watch)(() => props.data, () => {
|
|
311
|
+
dataFlag.value++;
|
|
312
|
+
});
|
|
313
|
+
(0, _vue.watch)(dataFlag, () => {
|
|
314
|
+
listMethods.loadData(props.data || []);
|
|
315
|
+
});
|
|
316
|
+
(0, _vue.watch)(() => props.syncResize, value => {
|
|
317
|
+
if (value) {
|
|
318
|
+
recalculate();
|
|
319
|
+
(0, _vue.nextTick)(() => setTimeout(() => recalculate()));
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
(0, _vue.onActivated)(() => {
|
|
323
|
+
recalculate().then(() => refreshScroll());
|
|
324
|
+
});
|
|
325
|
+
let resizeObserver;
|
|
326
|
+
(0, _vue.nextTick)(() => {
|
|
327
|
+
_event.GlobalEvent.on($xeList, 'resize', () => {
|
|
328
|
+
recalculate();
|
|
329
|
+
});
|
|
330
|
+
if (props.autoResize) {
|
|
331
|
+
const el = refElem.value;
|
|
332
|
+
resizeObserver = (0, _resize.createResizeEvent)(() => recalculate());
|
|
333
|
+
resizeObserver.observe(el);
|
|
334
|
+
}
|
|
335
|
+
listMethods.loadData(props.data || []);
|
|
336
|
+
});
|
|
337
|
+
(0, _vue.onUnmounted)(() => {
|
|
338
|
+
if (resizeObserver) {
|
|
339
|
+
resizeObserver.disconnect();
|
|
340
|
+
}
|
|
341
|
+
_event.GlobalEvent.off($xeList, 'resize');
|
|
342
|
+
});
|
|
343
|
+
const renderVN = () => {
|
|
344
|
+
const {
|
|
345
|
+
className,
|
|
346
|
+
loading
|
|
347
|
+
} = props;
|
|
348
|
+
const {
|
|
349
|
+
bodyHeight,
|
|
350
|
+
topSpaceHeight,
|
|
351
|
+
items
|
|
352
|
+
} = reactData;
|
|
353
|
+
const vSize = computeSize.value;
|
|
354
|
+
const styles = computeStyles.value;
|
|
355
|
+
return (0, _vue.h)('div', {
|
|
356
|
+
ref: refElem,
|
|
357
|
+
class: ['vxe-list', className ? _xeUtils.default.isFunction(className) ? className({
|
|
358
|
+
$list: $xeList
|
|
359
|
+
}) : className : '', {
|
|
360
|
+
[`size--${vSize}`]: vSize,
|
|
361
|
+
'is--loading': loading
|
|
362
|
+
}]
|
|
363
|
+
}, [(0, _vue.h)('div', {
|
|
364
|
+
ref: refVirtualWrapper,
|
|
365
|
+
class: 'vxe-list--virtual-wrapper',
|
|
366
|
+
style: styles,
|
|
367
|
+
onScroll: scrollEvent
|
|
368
|
+
}, [(0, _vue.h)('div', {
|
|
369
|
+
class: 'vxe-list--y-space',
|
|
370
|
+
style: {
|
|
371
|
+
height: bodyHeight ? `${bodyHeight}px` : ''
|
|
372
|
+
}
|
|
373
|
+
}), (0, _vue.h)('div', {
|
|
374
|
+
ref: refVirtualBody,
|
|
375
|
+
class: 'vxe-list--body',
|
|
376
|
+
style: {
|
|
377
|
+
marginTop: topSpaceHeight ? `${topSpaceHeight}px` : ''
|
|
378
|
+
}
|
|
379
|
+
}, slots.default ? slots.default({
|
|
380
|
+
items,
|
|
381
|
+
$list: $xeList
|
|
382
|
+
}) : [])]),
|
|
383
|
+
/**
|
|
384
|
+
* 加载中
|
|
385
|
+
*/
|
|
386
|
+
(0, _vue.h)(_loading.default, {
|
|
387
|
+
class: 'vxe-list--loading',
|
|
388
|
+
modelValue: loading
|
|
389
|
+
})]);
|
|
390
|
+
};
|
|
391
|
+
$xeList.renderVN = renderVN;
|
|
392
|
+
return $xeList;
|
|
393
|
+
},
|
|
394
|
+
render() {
|
|
395
|
+
return this.renderVN();
|
|
396
|
+
}
|
|
397
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _vue=require("vue"),_xeUtils=_interopRequireDefault(require("xe-utils")),_globalStore=_interopRequireDefault(require("../../ui/src/globalStore")),_size=require("../../hooks/size"),_resize=require("../../ui/src/resize"),_dom=require("../../ui/src/dom"),_event=require("../../ui/src/event"),_loading=_interopRequireDefault(require("../../loading/src/loading"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var _default=exports.default=(0,_vue.defineComponent)({name:"VxeList",props:{data:Array,height:[Number,String],maxHeight:[Number,String],loading:Boolean,className:[String,Function],size:{type:String,default:()=>_globalStore.default.list.size||_globalStore.default.size},autoResize:{type:Boolean,default:()=>_globalStore.default.list.autoResize},syncResize:[Boolean,String,Number],scrollY:Object},emits:["scroll"],setup(s,e){const{slots:u,emit:r}=e;var t=_xeUtils.default.uniqueId();const n=(0,_size.useSize)(s),c=(0,_vue.reactive)({scrollYLoad:!1,bodyHeight:0,rowHeight:0,topSpaceHeight:0,items:[]}),d=(0,_vue.ref)(),v=(0,_vue.ref)(),f=(0,_vue.ref)(),h={fullData:[],lastScrollLeft:0,lastScrollTop:0,scrollYStore:{startIndex:0,endIndex:0,visibleSize:0,offsetSize:0,rowHeight:0}},l={refElem:d},g={xID:t,props:s,context:e,reactData:c,internalData:h,getRefMaps:()=>l};let o={};const i=(0,_vue.computed)(()=>Object.assign({},_globalStore.default.list.scrollY,s.scrollY)),_=(0,_vue.computed)(()=>{var{height:e,maxHeight:t}=s,l={};return e?l.height=""+(isNaN(e)?e:e+"px"):t&&(l.height="auto",l.maxHeight=""+(isNaN(t)?t:t+"px")),l}),x=()=>{var e=c["scrollYLoad"],{scrollYStore:t,fullData:l}=h;c.bodyHeight=e?l.length*t.rowHeight:0,c.topSpaceHeight=e?Math.max(t.startIndex*t.rowHeight,0):0},a=()=>{var e=c["scrollYLoad"],{fullData:t,scrollYStore:l}=h;return c.items=e?t.slice(l.startIndex,l.endIndex):t.slice(0),(0,_vue.nextTick)()},p=()=>{a(),x()},S=()=>(0,_vue.nextTick)().then(()=>{var e=c["scrollYLoad"],t=h["scrollYStore"],l=f.value,r=i.value;let a=0,o;(o=l?(o=r.sItem?l.querySelector(r.sItem):o)||l.children[0]:o)&&(a=o.offsetHeight),a=Math.max(20,a),t.rowHeight=a,(e?(l=v.value,e=Math.max(8,Math.ceil(l.clientHeight/a)),l=r.oSize?_xeUtils.default.toNumber(r.oSize):_dom.browse.edge?10:0,t.offsetSize=l,t.visibleSize=e,t.endIndex=Math.max(t.startIndex,e+l,t.endIndex),p):x)(),c.rowHeight=a}),m=()=>{var e=v.value;return e&&(e.scrollTop=0),(0,_vue.nextTick)()},b=(e,t)=>{var l=v.value;return _xeUtils.default.isNumber(e)&&(l.scrollLeft=e),_xeUtils.default.isNumber(t)&&(l.scrollTop=t),c.scrollYLoad?new Promise(e=>{setTimeout(()=>{(0,_vue.nextTick)(()=>{e()})},50)}):(0,_vue.nextTick)()},z=()=>{const{lastScrollLeft:e,lastScrollTop:t}=h;return m().then(()=>{if(e||t)return h.lastScrollLeft=0,h.lastScrollTop=0,b(e,t)})},T=()=>{var e=d.value;return e.clientWidth&&e.clientHeight?S():Promise.resolve()},H=e=>{var t=h["scrollYStore"],{startIndex:l,endIndex:r,visibleSize:a,offsetSize:o,rowHeight:i}=t,e=e.target.scrollTop,e=Math.floor(e/i),i=Math.max(0,e-1-o),o=e+a+o;!(e<=l||r-a-1<=e)||l===i&&r===o||(t.startIndex=i,t.endIndex=o,p())},I=e=>{var t=e.target,l=t.scrollTop,t=t.scrollLeft,r=t!==h.lastScrollLeft,a=l!==h.lastScrollTop;h.lastScrollTop=l,h.lastScrollLeft=t,c.scrollYLoad&&H(e),o.dispatchEvent("scroll",{scrollLeft:t,scrollTop:l,isX:r,isY:a},e)},Y=(o={dispatchEvent(e,t,l){r(e,Object.assign({$list:g,$event:l},t))},loadData(e){var t=h["scrollYStore"],l=i.value,e=e||[];return Object.assign(t,{startIndex:0,endIndex:1,visibleSize:0}),h.fullData=e,c.scrollYLoad=!!l.enabled&&-1<l.gt&&(0===l.gt||l.gt<=e.length),a(),S().then(()=>{z()})},reloadData(e){return m(),o.loadData(e)},recalculate:T,scrollTo:b,refreshScroll:z,clearScroll:m},Object.assign(g,o),(0,_vue.ref)(0));(0,_vue.watch)(()=>s.data?s.data.length:-1,()=>{Y.value++}),(0,_vue.watch)(()=>s.data,()=>{Y.value++}),(0,_vue.watch)(Y,()=>{o.loadData(s.data||[])}),(0,_vue.watch)(()=>s.syncResize,e=>{e&&(T(),(0,_vue.nextTick)(()=>setTimeout(()=>T())))}),(0,_vue.onActivated)(()=>{T().then(()=>z())});let D;(0,_vue.nextTick)(()=>{var e;_event.GlobalEvent.on(g,"resize",()=>{T()}),s.autoResize&&(e=d.value,(D=(0,_resize.createResizeEvent)(()=>T())).observe(e)),o.loadData(s.data||[])}),(0,_vue.onUnmounted)(()=>{D&&D.disconnect(),_event.GlobalEvent.off(g,"resize")});return g.renderVN=()=>{var{className:e,loading:t}=s,{bodyHeight:l,topSpaceHeight:r,items:a}=c,o=n.value,i=_.value;return(0,_vue.h)("div",{ref:d,class:["vxe-list",e?_xeUtils.default.isFunction(e)?e({$list:g}):e:"",{["size--"+o]:o,"is--loading":t}]},[(0,_vue.h)("div",{ref:v,class:"vxe-list--virtual-wrapper",style:i,onScroll:I},[(0,_vue.h)("div",{class:"vxe-list--y-space",style:{height:l?l+"px":""}}),(0,_vue.h)("div",{ref:f,class:"vxe-list--body",style:{marginTop:r?r+"px":""}},u.default?u.default({items:a,$list:g}):[])]),(0,_vue.h)(_loading.default,{class:"vxe-list--loading",modelValue:t})])},g},render(){return this.renderVN()}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('./style.css')
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.vxe-list {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: block;
|
|
4
|
+
padding: 0;
|
|
5
|
+
color: var(--vxe-ui-font-color);
|
|
6
|
+
direction: ltr;
|
|
7
|
+
}
|
|
8
|
+
.vxe-list .vxe-list--virtual-wrapper {
|
|
9
|
+
position: relative;
|
|
10
|
+
overflow: auto;
|
|
11
|
+
}
|
|
12
|
+
.vxe-list .vxe-list--y-space {
|
|
13
|
+
width: 0;
|
|
14
|
+
float: left;
|
|
15
|
+
}
|
|
16
|
+
.vxe-list .vxe-list--virtual-wrapper,
|
|
17
|
+
.vxe-list .vxe-list--body {
|
|
18
|
+
padding: 0;
|
|
19
|
+
margin: 0;
|
|
20
|
+
border: 0;
|
|
21
|
+
outline: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.vxe-list--virtual-wrapper {
|
|
25
|
+
height: 100px;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.vxe-list{position:relative;display:block;padding:0;color:var(--vxe-ui-font-color);direction:ltr}.vxe-list .vxe-list--virtual-wrapper{position:relative;overflow:auto}.vxe-list .vxe-list--y-space{width:0;float:left}.vxe-list .vxe-list--body,.vxe-list .vxe-list--virtual-wrapper{padding:0;margin:0;border:0;outline:0}.vxe-list--virtual-wrapper{height:100px}
|
package/lib/list-design/index.js
CHANGED
|
@@ -5,11 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.ListDesign = void 0;
|
|
7
7
|
var _listDesign = _interopRequireDefault(require("./src/list-design"));
|
|
8
|
+
var _dynamics = require("../dynamics");
|
|
8
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
10
|
const VxeListDesign = Object.assign({}, _listDesign.default, {
|
|
10
11
|
install(app) {
|
|
11
12
|
app.component(_listDesign.default.name, _listDesign.default);
|
|
12
13
|
}
|
|
13
14
|
});
|
|
15
|
+
_dynamics.dynamicApp.component(_listDesign.default.name, _listDesign.default);
|
|
14
16
|
const ListDesign = exports.ListDesign = VxeListDesign;
|
|
15
17
|
var _default = exports.default = VxeListDesign;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ListDesign=void 0;var _listDesign=_interopRequireDefault(require("./src/list-design"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const VxeListDesign=Object.assign({},_listDesign.default,{install(e){e.component(_listDesign.default.name,_listDesign.default)}}),ListDesign=exports.ListDesign=VxeListDesign;var _default=exports.default=VxeListDesign;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ListDesign=void 0;var _listDesign=_interopRequireDefault(require("./src/list-design")),_dynamics=require("../dynamics");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const VxeListDesign=Object.assign({},_listDesign.default,{install(e){e.component(_listDesign.default.name,_listDesign.default)}}),ListDesign=(_dynamics.dynamicApp.component(_listDesign.default.name,_listDesign.default),exports.ListDesign=VxeListDesign);var _default=exports.default=VxeListDesign;
|
package/lib/loading/index.js
CHANGED
|
@@ -5,11 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.Loading = void 0;
|
|
7
7
|
var _loading = _interopRequireDefault(require("./src/loading"));
|
|
8
|
+
var _dynamics = require("../dynamics");
|
|
8
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
10
|
const VxeLoading = Object.assign({}, _loading.default, {
|
|
10
11
|
install(app) {
|
|
11
12
|
app.component(_loading.default.name, _loading.default);
|
|
12
13
|
}
|
|
13
14
|
});
|
|
15
|
+
_dynamics.dynamicApp.component(_loading.default.name, _loading.default);
|
|
14
16
|
const Loading = exports.Loading = VxeLoading;
|
|
15
17
|
var _default = exports.default = VxeLoading;
|
package/lib/loading/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Loading=void 0;var _loading=_interopRequireDefault(require("./src/loading"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const VxeLoading=Object.assign({},_loading.default,{install(e){e.component(_loading.default.name,_loading.default)}}),Loading=exports.Loading=VxeLoading;var _default=exports.default=VxeLoading;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Loading=void 0;var _loading=_interopRequireDefault(require("./src/loading")),_dynamics=require("../dynamics");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const VxeLoading=Object.assign({},_loading.default,{install(e){e.component(_loading.default.name,_loading.default)}}),Loading=(_dynamics.dynamicApp.component(_loading.default.name,_loading.default),exports.Loading=VxeLoading);var _default=exports.default=VxeLoading;
|
package/lib/modal/index.js
CHANGED
|
@@ -63,11 +63,7 @@ function handleOpen(defOpts, content, title, options) {
|
|
|
63
63
|
title
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
return openModal({
|
|
67
|
-
...defOpts,
|
|
68
|
-
...options,
|
|
69
|
-
...opts
|
|
70
|
-
});
|
|
66
|
+
return openModal(Object.assign(Object.assign(Object.assign({}, defOpts), options), opts));
|
|
71
67
|
}
|
|
72
68
|
function openAlert(content, title, options) {
|
|
73
69
|
return handleOpen({
|
package/lib/modal/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.modal=exports.default=exports.VxeModal=exports.Modal=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_modal=_interopRequireWildcard(require("./src/modal")),_core=_interopRequireDefault(require("../ui/src/core")),_dynamics=require("../dynamics");function _getRequireWildcardCache(e){var o
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.modal=exports.default=exports.VxeModal=exports.Modal=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_modal=_interopRequireWildcard(require("./src/modal")),_core=_interopRequireDefault(require("../ui/src/core")),_dynamics=require("../dynamics");function _getRequireWildcardCache(e){var t,o;return"function"!=typeof WeakMap?null:(t=new WeakMap,o=new WeakMap,(_getRequireWildcardCache=function(e){return e?o:t})(e))}function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};t=_getRequireWildcardCache(t);if(t&&t.has(e))return t.get(e);var o,a,n={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(o in e)"default"!==o&&{}.hasOwnProperty.call(e,o)&&((a=l?Object.getOwnPropertyDescriptor(e,o):null)&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]);return n.default=e,t&&t.set(e,n),n}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function openModal(t){return(0,_dynamics.checkDynamic)(),new Promise(o=>{if(t&&t.id&&_modal.allActivedModals.some(e=>e.props.id===t.id))o("exist");else{const a=t.onHide,n=Object.assign(t,{key:_xeUtils.default.uniqueId(),modelValue:!0,onHide(e){var t=_dynamics.dynamicStore.modals;a&&a(e),_dynamics.dynamicStore.modals=t.filter(e=>e.key!==n.key),o(e.type)}});_dynamics.dynamicStore.modals.push(n)}})}function getModal(t){return _xeUtils.default.find(_modal.allActivedModals,e=>e.props.id===t)}function closeModal(e){e=e?[getModal(e)]:_modal.allActivedModals;const t=[];return e.forEach(e=>{e&&t.push(e.close())}),Promise.all(t)}function handleOpen(e,t,o,a){let n;return n=_xeUtils.default.isObject(t)?t:{content:_xeUtils.default.toValueString(t),title:o},openModal(Object.assign(Object.assign(Object.assign({},e),a),n))}function openAlert(e,t,o){return handleOpen({type:"alert",showFooter:!0},e,t,o)}function openConfirm(e,t,o){return handleOpen({type:"confirm",status:"question",showFooter:!0},e,t,o)}function openMessage(e,t){return handleOpen({type:"message",mask:!1,lockView:!1,showHeader:!1},e,"",t)}const ModalController={get:getModal,close:closeModal,open:openModal,alert:openAlert,confirm:openConfirm,message:openMessage},modal=exports.modal=ModalController,VxeModal=exports.VxeModal=Object.assign(_modal.default,{install:function(e){e.component(_modal.default.name,_modal.default),_core.default.modal=ModalController}}),Modal=(_dynamics.dynamicApp.component(_modal.default.name,_modal.default),exports.Modal=VxeModal);var _default=exports.default=VxeModal;
|
package/lib/modal/src/modal.js
CHANGED
|
@@ -865,13 +865,12 @@ var _default = exports.default = (0, _vue.defineComponent)({
|
|
|
865
865
|
if (showZoom && props.dblclickZoom && props.type === 'modal') {
|
|
866
866
|
headerOns.onDblclick = toggleZoomEvent;
|
|
867
867
|
}
|
|
868
|
-
headVNs.push((0, _vue.h)('div', {
|
|
868
|
+
headVNs.push((0, _vue.h)('div', Object.assign({
|
|
869
869
|
class: ['vxe-modal--header', {
|
|
870
870
|
'is--draggable': draggable,
|
|
871
871
|
'is--ellipsis': !isMsg && props.showTitleOverflow
|
|
872
|
-
}]
|
|
873
|
-
|
|
874
|
-
}, headerSlot ? !reactData.inited || props.destroyOnClose && !reactData.visible ? [] : (0, _vn.getSlotVNs)(headerSlot({
|
|
872
|
+
}]
|
|
873
|
+
}, headerOns), headerSlot ? !reactData.inited || props.destroyOnClose && !reactData.visible ? [] : (0, _vn.getSlotVNs)(headerSlot({
|
|
875
874
|
$modal: $xemodal
|
|
876
875
|
})) : renderTitles()));
|
|
877
876
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.msgQueue=exports.default=exports.allActivedModals=void 0;var _vue=require("vue"),_xeUtils=_interopRequireDefault(require("xe-utils")),_size=require("../../hooks/size"),_dom=require("../../ui/src/dom"),_utils=require("../../ui/src/utils"),_log=require("../../ui/src/log"),_event=require("../../ui/src/event"),_globalStore=_interopRequireDefault(require("../../ui/src/globalStore")),_iconStore=_interopRequireDefault(require("../../ui/src/iconStore")),_button=_interopRequireDefault(require("../../button/src/button")),_index=_interopRequireDefault(require("../../loading/index")),_vn=require("../../ui/src/vn"),_i18n=require("../../ui/src/i18n");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const allActivedModals=exports.allActivedModals=[],msgQueue=exports.msgQueue=[];var _default=exports.default=(0,_vue.defineComponent)({name:"VxeModal",props:{modelValue:Boolean,id:String,type:{type:String,default:"modal"},loading:{type:Boolean,default:null},status:String,iconStatus:String,className:String,top:{type:[Number,String],default:()=>_globalStore.default.modal.top},position:[String,Object],title:String,duration:{type:[Number,String],default:()=>_globalStore.default.modal.duration},message:[Number,String],content:[Number,String],cancelButtonText:{type:String,default:()=>_globalStore.default.modal.cancelButtonText},confirmButtonText:{type:String,default:()=>_globalStore.default.modal.confirmButtonText},lockView:{type:Boolean,default:()=>_globalStore.default.modal.lockView},lockScroll:Boolean,mask:{type:Boolean,default:()=>_globalStore.default.modal.mask},maskClosable:{type:Boolean,default:()=>_globalStore.default.modal.maskClosable},escClosable:{type:Boolean,default:()=>_globalStore.default.modal.escClosable},resize:Boolean,showHeader:{type:Boolean,default:()=>_globalStore.default.modal.showHeader},showFooter:{type:Boolean,default:()=>_globalStore.default.modal.showFooter},showZoom:Boolean,showClose:{type:Boolean,default:()=>_globalStore.default.modal.showClose},dblclickZoom:{type:Boolean,default:()=>_globalStore.default.modal.dblclickZoom},width:[Number,String],height:[Number,String],minWidth:{type:[Number,String],default:()=>_globalStore.default.modal.minWidth},minHeight:{type:[Number,String],default:()=>_globalStore.default.modal.minHeight},zIndex:Number,marginSize:{type:[Number,String],default:()=>_globalStore.default.modal.marginSize},fullscreen:Boolean,draggable:{type:Boolean,default:()=>_globalStore.default.modal.draggable},remember:{type:Boolean,default:()=>_globalStore.default.modal.remember},destroyOnClose:{type:Boolean,default:()=>_globalStore.default.modal.destroyOnClose},showTitleOverflow:{type:Boolean,default:()=>_globalStore.default.modal.showTitleOverflow},transfer:{type:Boolean,default:()=>_globalStore.default.modal.transfer},storage:{type:Boolean,default:()=>_globalStore.default.modal.storage},storageKey:{type:String,default:()=>_globalStore.default.modal.storageKey},animat:{type:Boolean,default:()=>_globalStore.default.modal.animat},size:{type:String,default:()=>_globalStore.default.modal.size||_globalStore.default.size},beforeHideMethod:{type:Function,default:()=>_globalStore.default.modal.beforeHideMethod},slots:Object},emits:["update:modelValue","show","hide","before-hide","close","confirm","cancel","zoom"],setup(w,e){const{slots:f,emit:i}=e;var t=_xeUtils.default.uniqueId();const g=(0,_size.useSize)(w),N=(0,_vue.reactive)({inited:!1,visible:!1,contentVisible:!1,modalTop:0,modalZindex:0,zoomLocat:null,firstOpen:!0}),h=(0,_vue.ref)(),_=(0,_vue.ref)(),s=(0,_vue.ref)(),r=(0,_vue.ref)(),o={refElem:h},x={xID:t,props:w,context:e,reactData:N,getRefMaps:()=>o};let z={};const b=(0,_vue.computed)(()=>"message"===w.type),k=()=>{return _.value},n=()=>{var{width:e,height:t}=w,o=k();return o.style.width=""+(e?isNaN(e)?e:e+"px":""),o.style.height=""+(t?isNaN(t)?t:t+"px":""),(0,_vue.nextTick)()},u=()=>{var e=w["zIndex"],t=N["modalZindex"];e?N.modalZindex=e:t<(0,_utils.getLastZIndex)()&&(N.modalZindex=(0,_utils.nextZIndex)())},m=()=>(0,_vue.nextTick)().then(()=>{var e=w["position"],t=_xeUtils.default.toNumber(w.marginSize),o=k(),l=document.documentElement.clientWidth||document.body.clientWidth,a=document.documentElement.clientHeight||document.body.clientHeight,s="center"===e,{top:e,left:i}=_xeUtils.default.isString(e)?{top:e,left:e}:Object.assign({},e),r=s||"center"===e;let n="",u="";u=i&&!(s||"center"===i)?isNaN(i)?i:i+"px":Math.max(t,l/2-o.offsetWidth/2)+"px",n=e&&!r?isNaN(e)?e:e+"px":Math.max(t,a/2-o.offsetHeight/2)+"px",o.style.top=n,o.style.left=u}),c=()=>{(0,_vue.nextTick)(()=>{let o=0;msgQueue.forEach(e=>{var t=e.getBox();o+=_xeUtils.default.toNumber(e.props.top),e.reactData.modalTop=o,o+=t.clientHeight})})},d=()=>{-1<msgQueue.indexOf(x)&&_xeUtils.default.remove(msgQueue,e=>e===x),c()},p=e=>{const{remember:t,beforeHideMethod:o}=w;var l=N["visible"];const a=b.value,s={type:e};return l&&Promise.resolve(o?o(s):null).then(e=>{_xeUtils.default.isError(e)||(a&&d(),N.contentVisible=!1,t||(N.zoomLocat=null),_xeUtils.default.remove(allActivedModals,e=>e===x),z.dispatchEvent("before-hide",s),setTimeout(()=>{N.visible=!1,i("update:modelValue",!1),z.dispatchEvent("hide",s)},200))}).catch(e=>e),(0,_vue.nextTick)()},v=e=>{var t="close";z.dispatchEvent(t,{type:t},e),p(t)},l=e=>{var t="confirm";z.dispatchEvent(t,{type:t},e),p(t)},a=e=>{var t="cancel";z.dispatchEvent(t,{type:t},e),p(t)},y=e=>{var t=_globalStore.default.version,e=_xeUtils.default.toStringJSON(localStorage.getItem(e)||"");return e&&e._v===t?e:{_v:t}},T=()=>{var{id:e,remember:t,storage:o,storageKey:l}=w,a=N["zoomLocat"];e&&t&&o&&(t=k(),(o=y(l))[e]=[t.style.left,t.style.top,t.style.width,t.style.height].concat(a?[a.left,a.top,a.width,a.height]:[]).map(e=>e?_xeUtils.default.toNumber(e):"").join(","),localStorage.setItem(l,_xeUtils.default.toJSONString(o)))},S=()=>(0,_vue.nextTick)().then(()=>{var e,t,o,l;N.zoomLocat||(e=Math.max(0,_xeUtils.default.toNumber(w.marginSize)),t=k(),{visibleHeight:o,visibleWidth:l}=(0,_dom.getDomNode)(),N.zoomLocat={top:t.offsetTop,left:t.offsetLeft,width:t.offsetWidth+(t.style.width?0:1),height:t.offsetHeight+(t.style.height?0:1)},Object.assign(t.style,{top:e+"px",left:e+"px",width:l-2*e+"px",height:o-2*e+"px"}),T())}),O=()=>{const{duration:e,remember:d,showFooter:o}=w;var{inited:t,visible:l}=N,a=b.value;return t||(N.inited=!0),l||(d||n(),N.visible=!0,N.contentVisible=!1,u(),allActivedModals.push(x),setTimeout(()=>{N.contentVisible=!0,(0,_vue.nextTick)(()=>{o&&(e=s.value,t=r.value,e=e||t)&&e.focus();var e,t={type:""};i("update:modelValue",!0),z.dispatchEvent("show",t)})},10),a?(-1===msgQueue.indexOf(x)&&msgQueue.push(x),c(),-1!==e&&setTimeout(()=>p("close"),_xeUtils.default.toNumber(e))):(0,_vue.nextTick)(()=>{var e,t,o,l,a,s,i,r,n=w["fullscreen"],u=N["firstOpen"];d&&!u||m().then(()=>{setTimeout(()=>m(),20)}),u&&(N.firstOpen=!1,(()=>{var{id:e,remember:t,storage:o,storageKey:l}=w;return!!(e&&t&&o&&y(l)[e])})())?({id:u,remember:s,storage:i,storageKey:r}=w,u&&s&&i&&(s=y(r)[u])&&(i=k(),[r,u,s,e,t,o,l,a]=s.split(","),r&&(i.style.left=r+"px"),u&&(i.style.top=u+"px"),s&&(i.style.width=s+"px"),e&&(i.style.height=e+"px"),t)&&o&&(N.zoomLocat={left:t,top:o,width:l,height:a})):n&&(0,_vue.nextTick)(()=>S())})),(0,_vue.nextTick)()},B=e=>{var t=h.value;w.maskClosable&&e.target===t&&p("mask")},M=e=>{if((0,_event.hasEventKey)(e,_event.EVENT_KEYS.ESCAPE)){const t=_xeUtils.default.max(allActivedModals,e=>e.reactData.modalZindex);t&&setTimeout(()=>{t===x&&t.props.escClosable&&p("exit")},10)}},L=()=>!!N.zoomLocat,C=()=>(0,_vue.nextTick)().then(()=>{var e,t=N["zoomLocat"];t&&(e=k(),N.zoomLocat=null,Object.assign(e.style,{top:t.top+"px",left:t.left+"px",width:t.width+"px",height:t.height+"px"}),T())}),D=()=>(N.zoomLocat?C:S)().then(()=>L()),E=e=>{var t=N["zoomLocat"];const o={type:t?"revert":"max"};return D().then(()=>{z.dispatchEvent("zoom",o,e)})};const V=()=>{const t=N["modalZindex"];allActivedModals.some(e=>e.reactData.visible&&e.reactData.modalZindex>t)&&u()},U=e=>{const{remember:t,storage:o}=w;var l=N["zoomLocat"];const r=_xeUtils.default.toNumber(w.marginSize),n=k();if(!l&&0===e.button&&!(0,_dom.getEventTargetNode)(e,n,"trigger--btn").flag){e.preventDefault();const a=document.onmousemove,s=document.onmouseup,u=e.clientX-n.offsetLeft,d=e.clientY-n.offsetTop,{visibleHeight:m,visibleWidth:c}=(0,_dom.getDomNode)();document.onmousemove=e=>{e.preventDefault();var t=n.offsetWidth,o=n.offsetHeight,l=r,t=c-t-r-1,a=r,o=m-o-r-1;let s=e.clientX-u,i=e.clientY-d;(s=s>t?t:s)<l&&(s=l),(i=i>o?o:i)<a&&(i=a),n.style.left=s+"px",n.style.top=i+"px",n.className=n.className.replace(/\s?is--drag/,"")+" is--drag"},document.onmouseup=()=>{document.onmousemove=a,document.onmouseup=s,t&&o&&(0,_vue.nextTick)(()=>{T()}),setTimeout(()=>{n.className=n.className.replace(/\s?is--drag/,"")},50)}}},q=e=>{e.preventDefault();const{remember:s,storage:i}=w,{visibleHeight:r,visibleWidth:n}=(0,_dom.getDomNode)(),u=_xeUtils.default.toNumber(w.marginSize);const d=e.target.getAttribute("type"),m=_xeUtils.default.toNumber(w.minWidth),c=_xeUtils.default.toNumber(w.minHeight),p=n,v=r,f=k(),t=document.onmousemove,o=document.onmouseup,g=f.clientWidth,h=f.clientHeight,_=e.clientX,x=e.clientY,b=f.offsetTop,y=f.offsetLeft,S={type:"resize"};document.onmousemove=e=>{e.preventDefault();let t,o,l,a;switch(d){case"wl":t=_-e.clientX,l=t+g,y-t>u&&l>m&&(f.style.width=`${l<p?l:p}px`,f.style.left=y-t+"px");break;case"swst":t=_-e.clientX,o=x-e.clientY,l=t+g,a=o+h,y-t>u&&l>m&&(f.style.width=`${l<p?l:p}px`,f.style.left=y-t+"px"),b-o>u&&a>c&&(f.style.height=`${a<v?a:v}px`,f.style.top=b-o+"px");break;case"swlb":t=_-e.clientX,o=e.clientY-x,l=t+g,a=o+h,y-t>u&&l>m&&(f.style.width=`${l<p?l:p}px`,f.style.left=y-t+"px"),b+a+u<r&&a>c&&(f.style.height=`${a<v?a:v}px`);break;case"st":o=x-e.clientY,a=h+o,b-o>u&&a>c&&(f.style.height=`${a<v?a:v}px`,f.style.top=b-o+"px");break;case"wr":t=e.clientX-_,l=t+g,y+l+u<n&&l>m&&(f.style.width=`${l<p?l:p}px`);break;case"sest":t=e.clientX-_,o=x-e.clientY,l=t+g,a=o+h,y+l+u<n&&l>m&&(f.style.width=`${l<p?l:p}px`),b-o>u&&a>c&&(f.style.height=`${a<v?a:v}px`,f.style.top=b-o+"px");break;case"selb":t=e.clientX-_,o=e.clientY-x,l=t+g,a=o+h,y+l+u<n&&l>m&&(f.style.width=`${l<p?l:p}px`),b+a+u<r&&a>c&&(f.style.height=`${a<v?a:v}px`);break;case"sb":o=e.clientY-x,a=o+h,b+a+u<r&&a>c&&(f.style.height=`${a<v?a:v}px`)}f.className=f.className.replace(/\s?is--drag/,"")+" is--drag",s&&i&&T(),z.dispatchEvent("zoom",S,e)},document.onmouseup=()=>{N.zoomLocat=null,document.onmousemove=t,document.onmouseup=o,setTimeout(()=>{f.className=f.className.replace(/\s?is--drag/,"")},50)}},H=()=>{var{slots:e={},showClose:t,showZoom:o,title:l}=w,a=N["zoomLocat"],s=f.title||e.title,e=f.corner||e.corner,s=[(0,_vue.h)("div",{class:"vxe-modal--header-title"},s?(0,_vn.getSlotVNs)(s({$modal:x})):l?(0,_utils.getFuncText)(l):(0,_i18n.getI18n)("vxe.alert.title"))],l=[];return e&&l.push((0,_vue.h)("span",{class:"vxe-modal--corner-wrapper"},(0,_vn.getSlotVNs)(e({$modal:x})))),o&&l.push((0,_vue.h)("i",{class:["vxe-modal--zoom-btn","trigger--btn",a?_iconStore.default.MODAL_ZOOM_OUT:_iconStore.default.MODAL_ZOOM_IN],title:(0,_i18n.getI18n)("vxe.modal.zoom"+(a?"Out":"In")),onClick:E})),t&&l.push((0,_vue.h)("i",{class:["vxe-modal--close-btn","trigger--btn",_iconStore.default.MODAL_CLOSE],title:(0,_i18n.getI18n)("vxe.modal.close"),onClick:v})),s.push((0,_vue.h)("div",{class:"vxe-modal--header-right"},l)),s},$=()=>{var e=w["type"],t=[];return"confirm"===e&&t.push((0,_vue.h)(_button.default,{ref:r,content:w.cancelButtonText||(0,_i18n.getI18n)("vxe.button.cancel"),onClick:a})),t.push((0,_vue.h)(_button.default,{ref:s,status:"primary",content:w.confirmButtonText||(0,_i18n.getI18n)("vxe.button.confirm"),onClick:l})),t};z={dispatchEvent(e,t,o){i(e,Object.assign({$modal:x,$event:o},t))},open:O,close(){return p("close")},getBox:k,getPosition:()=>{if(!b.value){var e=k();if(e)return{top:e.offsetTop,left:e.offsetLeft}}return null},setPosition:(e,t)=>{var o;return b.value||(o=k(),_xeUtils.default.isNumber(e)&&(o.style.top=e+"px"),_xeUtils.default.isNumber(t)&&(o.style.left=t+"px")),(0,_vue.nextTick)()},isMaximized:L,zoom:D,maximize:S,revert:C},Object.assign(x,z),(0,_vue.watch)(()=>w.width,n),(0,_vue.watch)(()=>w.height,n),(0,_vue.watch)(()=>w.modelValue,e=>{e?O():p("model")}),(0,_vue.onMounted)(()=>{(0,_vue.nextTick)(()=>{w.storage&&!w.id&&(0,_log.errLog)("vxe.error.reqProp",["modal.id"]),w.modelValue&&O(),n()}),w.escClosable&&_event.GlobalEvent.on(x,"keydown",M)}),(0,_vue.onUnmounted)(()=>{_event.GlobalEvent.off(x,"keydown"),d()});return x.renderVN=()=>{var{className:e,type:t,animat:o,loading:l,status:a,lockScroll:s,lockView:i,mask:r,resize:n}=w,{inited:u,zoomLocat:d,modalTop:m,contentVisible:c,visible:p}=N,v=g.value;return(0,_vue.h)(_vue.Teleport,{to:"body",disabled:!w.transfer||!u},[(0,_vue.h)("div",{ref:h,class:["vxe-modal--wrapper","type--"+t,e||"",{["size--"+v]:v,["status--"+a]:a,"is--animat":o,"lock--scroll":s,"lock--view":i,"is--resize":n,"is--mask":r,"is--maximize":d,"is--visible":c,"is--active":p,"is--loading":l}],style:{zIndex:N.modalZindex,top:m?m+"px":null},onClick:B},[(0,_vue.h)("div",{ref:_,class:"vxe-modal--box",onMousedown:V},(()=>{var e,{slots:t={},showZoom:o,draggable:l}=w,a=b.value,t=f.header||t.header,s=[];return w.showHeader&&(e={},l&&(e.onMousedown=U),o&&w.dblclickZoom&&"modal"===w.type&&(e.onDblclick=E),s.push((0,_vue.h)("div",{class:["vxe-modal--header",{"is--draggable":l,"is--ellipsis":!a&&w.showTitleOverflow}],...e},t?!N.inited||w.destroyOnClose&&!N.visible?[]:(0,_vn.getSlotVNs)(t({$modal:x})):H()))),s})().concat((()=>{var{slots:e={},status:t,message:o}=w,o=w.content||o,l=b.value,e=f.default||e.default,a=[];return t&&a.push((0,_vue.h)("div",{class:"vxe-modal--status-wrapper"},[(0,_vue.h)("i",{class:["vxe-modal--status-icon",w.iconStatus||_iconStore.default[("MODAL_"+t).toLocaleUpperCase()]]})])),a.push((0,_vue.h)("div",{class:"vxe-modal--content"},e?!N.inited||w.destroyOnClose&&!N.visible?[]:(0,_vn.getSlotVNs)(e({$modal:x})):(0,_utils.getFuncText)(o))),l||a.push((0,_vue.h)(_index.default,{class:"vxe-modal--loading",modelValue:w.loading})),[(0,_vue.h)("div",{class:"vxe-modal--body"},a)]})(),(()=>{var{slots:e={}}=w,t=b.value,e=f.footer||e.footer,o=[];return w.showFooter&&o.push((0,_vue.h)("div",{class:"vxe-modal--footer"},e?!N.inited||w.destroyOnClose&&!N.visible?[]:(0,_vn.getSlotVNs)(e({$modal:x})):$())),!t&&w.resize&&o.push((0,_vue.h)("span",{class:"vxe-modal--resize"},["wl","wr","swst","sest","st","swlb","selb","sb"].map(e=>(0,_vue.h)("span",{class:e+"-resize",type:e,onMousedown:q})))),o})()))])])},x},render(){return this.renderVN()}});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.msgQueue=exports.default=exports.allActivedModals=void 0;var _vue=require("vue"),_xeUtils=_interopRequireDefault(require("xe-utils")),_size=require("../../hooks/size"),_dom=require("../../ui/src/dom"),_utils=require("../../ui/src/utils"),_log=require("../../ui/src/log"),_event=require("../../ui/src/event"),_globalStore=_interopRequireDefault(require("../../ui/src/globalStore")),_iconStore=_interopRequireDefault(require("../../ui/src/iconStore")),_button=_interopRequireDefault(require("../../button/src/button")),_index=_interopRequireDefault(require("../../loading/index")),_vn=require("../../ui/src/vn"),_i18n=require("../../ui/src/i18n");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const allActivedModals=exports.allActivedModals=[],msgQueue=exports.msgQueue=[];var _default=exports.default=(0,_vue.defineComponent)({name:"VxeModal",props:{modelValue:Boolean,id:String,type:{type:String,default:"modal"},loading:{type:Boolean,default:null},status:String,iconStatus:String,className:String,top:{type:[Number,String],default:()=>_globalStore.default.modal.top},position:[String,Object],title:String,duration:{type:[Number,String],default:()=>_globalStore.default.modal.duration},message:[Number,String],content:[Number,String],cancelButtonText:{type:String,default:()=>_globalStore.default.modal.cancelButtonText},confirmButtonText:{type:String,default:()=>_globalStore.default.modal.confirmButtonText},lockView:{type:Boolean,default:()=>_globalStore.default.modal.lockView},lockScroll:Boolean,mask:{type:Boolean,default:()=>_globalStore.default.modal.mask},maskClosable:{type:Boolean,default:()=>_globalStore.default.modal.maskClosable},escClosable:{type:Boolean,default:()=>_globalStore.default.modal.escClosable},resize:Boolean,showHeader:{type:Boolean,default:()=>_globalStore.default.modal.showHeader},showFooter:{type:Boolean,default:()=>_globalStore.default.modal.showFooter},showZoom:Boolean,showClose:{type:Boolean,default:()=>_globalStore.default.modal.showClose},dblclickZoom:{type:Boolean,default:()=>_globalStore.default.modal.dblclickZoom},width:[Number,String],height:[Number,String],minWidth:{type:[Number,String],default:()=>_globalStore.default.modal.minWidth},minHeight:{type:[Number,String],default:()=>_globalStore.default.modal.minHeight},zIndex:Number,marginSize:{type:[Number,String],default:()=>_globalStore.default.modal.marginSize},fullscreen:Boolean,draggable:{type:Boolean,default:()=>_globalStore.default.modal.draggable},remember:{type:Boolean,default:()=>_globalStore.default.modal.remember},destroyOnClose:{type:Boolean,default:()=>_globalStore.default.modal.destroyOnClose},showTitleOverflow:{type:Boolean,default:()=>_globalStore.default.modal.showTitleOverflow},transfer:{type:Boolean,default:()=>_globalStore.default.modal.transfer},storage:{type:Boolean,default:()=>_globalStore.default.modal.storage},storageKey:{type:String,default:()=>_globalStore.default.modal.storageKey},animat:{type:Boolean,default:()=>_globalStore.default.modal.animat},size:{type:String,default:()=>_globalStore.default.modal.size||_globalStore.default.size},beforeHideMethod:{type:Function,default:()=>_globalStore.default.modal.beforeHideMethod},slots:Object},emits:["update:modelValue","show","hide","before-hide","close","confirm","cancel","zoom"],setup(w,e){const{slots:f,emit:i}=e;var t=_xeUtils.default.uniqueId();const g=(0,_size.useSize)(w),N=(0,_vue.reactive)({inited:!1,visible:!1,contentVisible:!1,modalTop:0,modalZindex:0,zoomLocat:null,firstOpen:!0}),h=(0,_vue.ref)(),_=(0,_vue.ref)(),s=(0,_vue.ref)(),r=(0,_vue.ref)(),o={refElem:h},b={xID:t,props:w,context:e,reactData:N,getRefMaps:()=>o};let z={};const x=(0,_vue.computed)(()=>"message"===w.type),k=()=>{return _.value},n=()=>{var{width:e,height:t}=w,o=k();return o.style.width=""+(e?isNaN(e)?e:e+"px":""),o.style.height=""+(t?isNaN(t)?t:t+"px":""),(0,_vue.nextTick)()},u=()=>{var e=w["zIndex"],t=N["modalZindex"];e?N.modalZindex=e:t<(0,_utils.getLastZIndex)()&&(N.modalZindex=(0,_utils.nextZIndex)())},c=()=>(0,_vue.nextTick)().then(()=>{var e=w["position"],t=_xeUtils.default.toNumber(w.marginSize),o=k(),l=document.documentElement.clientWidth||document.body.clientWidth,a=document.documentElement.clientHeight||document.body.clientHeight,s="center"===e,{top:e,left:i}=_xeUtils.default.isString(e)?{top:e,left:e}:Object.assign({},e),r=s||"center"===e;let n="",u="";u=i&&!(s||"center"===i)?isNaN(i)?i:i+"px":Math.max(t,l/2-o.offsetWidth/2)+"px",n=e&&!r?isNaN(e)?e:e+"px":Math.max(t,a/2-o.offsetHeight/2)+"px",o.style.top=n,o.style.left=u}),m=()=>{(0,_vue.nextTick)(()=>{let o=0;msgQueue.forEach(e=>{var t=e.getBox();o+=_xeUtils.default.toNumber(e.props.top),e.reactData.modalTop=o,o+=t.clientHeight})})},d=()=>{-1<msgQueue.indexOf(b)&&_xeUtils.default.remove(msgQueue,e=>e===b),m()},p=e=>{const{remember:t,beforeHideMethod:o}=w;var l=N["visible"];const a=x.value,s={type:e};return l&&Promise.resolve(o?o(s):null).then(e=>{_xeUtils.default.isError(e)||(a&&d(),N.contentVisible=!1,t||(N.zoomLocat=null),_xeUtils.default.remove(allActivedModals,e=>e===b),z.dispatchEvent("before-hide",s),setTimeout(()=>{N.visible=!1,i("update:modelValue",!1),z.dispatchEvent("hide",s)},200))}).catch(e=>e),(0,_vue.nextTick)()},v=e=>{var t="close";z.dispatchEvent(t,{type:t},e),p(t)},l=e=>{var t="confirm";z.dispatchEvent(t,{type:t},e),p(t)},a=e=>{var t="cancel";z.dispatchEvent(t,{type:t},e),p(t)},y=e=>{var t=_globalStore.default.version,e=_xeUtils.default.toStringJSON(localStorage.getItem(e)||"");return e&&e._v===t?e:{_v:t}},T=()=>{var{id:e,remember:t,storage:o,storageKey:l}=w,a=N["zoomLocat"];e&&t&&o&&(t=k(),(o=y(l))[e]=[t.style.left,t.style.top,t.style.width,t.style.height].concat(a?[a.left,a.top,a.width,a.height]:[]).map(e=>e?_xeUtils.default.toNumber(e):"").join(","),localStorage.setItem(l,_xeUtils.default.toJSONString(o)))},S=()=>(0,_vue.nextTick)().then(()=>{var e,t,o,l;N.zoomLocat||(e=Math.max(0,_xeUtils.default.toNumber(w.marginSize)),t=k(),{visibleHeight:o,visibleWidth:l}=(0,_dom.getDomNode)(),N.zoomLocat={top:t.offsetTop,left:t.offsetLeft,width:t.offsetWidth+(t.style.width?0:1),height:t.offsetHeight+(t.style.height?0:1)},Object.assign(t.style,{top:e+"px",left:e+"px",width:l-2*e+"px",height:o-2*e+"px"}),T())}),O=()=>{const{duration:e,remember:d,showFooter:o}=w;var{inited:t,visible:l}=N,a=x.value;return t||(N.inited=!0),l||(d||n(),N.visible=!0,N.contentVisible=!1,u(),allActivedModals.push(b),setTimeout(()=>{N.contentVisible=!0,(0,_vue.nextTick)(()=>{o&&(e=s.value,t=r.value,e=e||t)&&e.focus();var e,t={type:""};i("update:modelValue",!0),z.dispatchEvent("show",t)})},10),a?(-1===msgQueue.indexOf(b)&&msgQueue.push(b),m(),-1!==e&&setTimeout(()=>p("close"),_xeUtils.default.toNumber(e))):(0,_vue.nextTick)(()=>{var e,t,o,l,a,s,i,r,n=w["fullscreen"],u=N["firstOpen"];d&&!u||c().then(()=>{setTimeout(()=>c(),20)}),u&&(N.firstOpen=!1,(()=>{var{id:e,remember:t,storage:o,storageKey:l}=w;return!!(e&&t&&o&&y(l)[e])})())?({id:u,remember:s,storage:i,storageKey:r}=w,u&&s&&i&&(s=y(r)[u])&&(i=k(),[r,u,s,e,t,o,l,a]=s.split(","),r&&(i.style.left=r+"px"),u&&(i.style.top=u+"px"),s&&(i.style.width=s+"px"),e&&(i.style.height=e+"px"),t)&&o&&(N.zoomLocat={left:t,top:o,width:l,height:a})):n&&(0,_vue.nextTick)(()=>S())})),(0,_vue.nextTick)()},B=e=>{var t=h.value;w.maskClosable&&e.target===t&&p("mask")},M=e=>{if((0,_event.hasEventKey)(e,_event.EVENT_KEYS.ESCAPE)){const t=_xeUtils.default.max(allActivedModals,e=>e.reactData.modalZindex);t&&setTimeout(()=>{t===b&&t.props.escClosable&&p("exit")},10)}},L=()=>!!N.zoomLocat,C=()=>(0,_vue.nextTick)().then(()=>{var e,t=N["zoomLocat"];t&&(e=k(),N.zoomLocat=null,Object.assign(e.style,{top:t.top+"px",left:t.left+"px",width:t.width+"px",height:t.height+"px"}),T())}),D=()=>(N.zoomLocat?C:S)().then(()=>L()),E=e=>{var t=N["zoomLocat"];const o={type:t?"revert":"max"};return D().then(()=>{z.dispatchEvent("zoom",o,e)})};const V=()=>{const t=N["modalZindex"];allActivedModals.some(e=>e.reactData.visible&&e.reactData.modalZindex>t)&&u()},U=e=>{const{remember:t,storage:o}=w;var l=N["zoomLocat"];const r=_xeUtils.default.toNumber(w.marginSize),n=k();if(!l&&0===e.button&&!(0,_dom.getEventTargetNode)(e,n,"trigger--btn").flag){e.preventDefault();const a=document.onmousemove,s=document.onmouseup,u=e.clientX-n.offsetLeft,d=e.clientY-n.offsetTop,{visibleHeight:c,visibleWidth:m}=(0,_dom.getDomNode)();document.onmousemove=e=>{e.preventDefault();var t=n.offsetWidth,o=n.offsetHeight,l=r,t=m-t-r-1,a=r,o=c-o-r-1;let s=e.clientX-u,i=e.clientY-d;(s=s>t?t:s)<l&&(s=l),(i=i>o?o:i)<a&&(i=a),n.style.left=s+"px",n.style.top=i+"px",n.className=n.className.replace(/\s?is--drag/,"")+" is--drag"},document.onmouseup=()=>{document.onmousemove=a,document.onmouseup=s,t&&o&&(0,_vue.nextTick)(()=>{T()}),setTimeout(()=>{n.className=n.className.replace(/\s?is--drag/,"")},50)}}},q=e=>{e.preventDefault();const{remember:s,storage:i}=w,{visibleHeight:r,visibleWidth:n}=(0,_dom.getDomNode)(),u=_xeUtils.default.toNumber(w.marginSize);const d=e.target.getAttribute("type"),c=_xeUtils.default.toNumber(w.minWidth),m=_xeUtils.default.toNumber(w.minHeight),p=n,v=r,f=k(),t=document.onmousemove,o=document.onmouseup,g=f.clientWidth,h=f.clientHeight,_=e.clientX,b=e.clientY,x=f.offsetTop,y=f.offsetLeft,S={type:"resize"};document.onmousemove=e=>{e.preventDefault();let t,o,l,a;switch(d){case"wl":t=_-e.clientX,l=t+g,y-t>u&&l>c&&(f.style.width=`${l<p?l:p}px`,f.style.left=y-t+"px");break;case"swst":t=_-e.clientX,o=b-e.clientY,l=t+g,a=o+h,y-t>u&&l>c&&(f.style.width=`${l<p?l:p}px`,f.style.left=y-t+"px"),x-o>u&&a>m&&(f.style.height=`${a<v?a:v}px`,f.style.top=x-o+"px");break;case"swlb":t=_-e.clientX,o=e.clientY-b,l=t+g,a=o+h,y-t>u&&l>c&&(f.style.width=`${l<p?l:p}px`,f.style.left=y-t+"px"),x+a+u<r&&a>m&&(f.style.height=`${a<v?a:v}px`);break;case"st":o=b-e.clientY,a=h+o,x-o>u&&a>m&&(f.style.height=`${a<v?a:v}px`,f.style.top=x-o+"px");break;case"wr":t=e.clientX-_,l=t+g,y+l+u<n&&l>c&&(f.style.width=`${l<p?l:p}px`);break;case"sest":t=e.clientX-_,o=b-e.clientY,l=t+g,a=o+h,y+l+u<n&&l>c&&(f.style.width=`${l<p?l:p}px`),x-o>u&&a>m&&(f.style.height=`${a<v?a:v}px`,f.style.top=x-o+"px");break;case"selb":t=e.clientX-_,o=e.clientY-b,l=t+g,a=o+h,y+l+u<n&&l>c&&(f.style.width=`${l<p?l:p}px`),x+a+u<r&&a>m&&(f.style.height=`${a<v?a:v}px`);break;case"sb":o=e.clientY-b,a=o+h,x+a+u<r&&a>m&&(f.style.height=`${a<v?a:v}px`)}f.className=f.className.replace(/\s?is--drag/,"")+" is--drag",s&&i&&T(),z.dispatchEvent("zoom",S,e)},document.onmouseup=()=>{N.zoomLocat=null,document.onmousemove=t,document.onmouseup=o,setTimeout(()=>{f.className=f.className.replace(/\s?is--drag/,"")},50)}},H=()=>{var{slots:e={},showClose:t,showZoom:o,title:l}=w,a=N["zoomLocat"],s=f.title||e.title,e=f.corner||e.corner,s=[(0,_vue.h)("div",{class:"vxe-modal--header-title"},s?(0,_vn.getSlotVNs)(s({$modal:b})):l?(0,_utils.getFuncText)(l):(0,_i18n.getI18n)("vxe.alert.title"))],l=[];return e&&l.push((0,_vue.h)("span",{class:"vxe-modal--corner-wrapper"},(0,_vn.getSlotVNs)(e({$modal:b})))),o&&l.push((0,_vue.h)("i",{class:["vxe-modal--zoom-btn","trigger--btn",a?_iconStore.default.MODAL_ZOOM_OUT:_iconStore.default.MODAL_ZOOM_IN],title:(0,_i18n.getI18n)("vxe.modal.zoom"+(a?"Out":"In")),onClick:E})),t&&l.push((0,_vue.h)("i",{class:["vxe-modal--close-btn","trigger--btn",_iconStore.default.MODAL_CLOSE],title:(0,_i18n.getI18n)("vxe.modal.close"),onClick:v})),s.push((0,_vue.h)("div",{class:"vxe-modal--header-right"},l)),s},$=()=>{var e=w["type"],t=[];return"confirm"===e&&t.push((0,_vue.h)(_button.default,{ref:r,content:w.cancelButtonText||(0,_i18n.getI18n)("vxe.button.cancel"),onClick:a})),t.push((0,_vue.h)(_button.default,{ref:s,status:"primary",content:w.confirmButtonText||(0,_i18n.getI18n)("vxe.button.confirm"),onClick:l})),t};z={dispatchEvent(e,t,o){i(e,Object.assign({$modal:b,$event:o},t))},open:O,close(){return p("close")},getBox:k,getPosition:()=>{if(!x.value){var e=k();if(e)return{top:e.offsetTop,left:e.offsetLeft}}return null},setPosition:(e,t)=>{var o;return x.value||(o=k(),_xeUtils.default.isNumber(e)&&(o.style.top=e+"px"),_xeUtils.default.isNumber(t)&&(o.style.left=t+"px")),(0,_vue.nextTick)()},isMaximized:L,zoom:D,maximize:S,revert:C},Object.assign(b,z),(0,_vue.watch)(()=>w.width,n),(0,_vue.watch)(()=>w.height,n),(0,_vue.watch)(()=>w.modelValue,e=>{e?O():p("model")}),(0,_vue.onMounted)(()=>{(0,_vue.nextTick)(()=>{w.storage&&!w.id&&(0,_log.errLog)("vxe.error.reqProp",["modal.id"]),w.modelValue&&O(),n()}),w.escClosable&&_event.GlobalEvent.on(b,"keydown",M)}),(0,_vue.onUnmounted)(()=>{_event.GlobalEvent.off(b,"keydown"),d()});return b.renderVN=()=>{var{className:e,type:t,animat:o,loading:l,status:a,lockScroll:s,lockView:i,mask:r,resize:n}=w,{inited:u,zoomLocat:d,modalTop:c,contentVisible:m,visible:p}=N,v=g.value;return(0,_vue.h)(_vue.Teleport,{to:"body",disabled:!w.transfer||!u},[(0,_vue.h)("div",{ref:h,class:["vxe-modal--wrapper","type--"+t,e||"",{["size--"+v]:v,["status--"+a]:a,"is--animat":o,"lock--scroll":s,"lock--view":i,"is--resize":n,"is--mask":r,"is--maximize":d,"is--visible":m,"is--active":p,"is--loading":l}],style:{zIndex:N.modalZindex,top:c?c+"px":null},onClick:B},[(0,_vue.h)("div",{ref:_,class:"vxe-modal--box",onMousedown:V},(()=>{var e,{slots:t={},showZoom:o,draggable:l}=w,a=x.value,t=f.header||t.header,s=[];return w.showHeader&&(e={},l&&(e.onMousedown=U),o&&w.dblclickZoom&&"modal"===w.type&&(e.onDblclick=E),s.push((0,_vue.h)("div",Object.assign({class:["vxe-modal--header",{"is--draggable":l,"is--ellipsis":!a&&w.showTitleOverflow}]},e),t?!N.inited||w.destroyOnClose&&!N.visible?[]:(0,_vn.getSlotVNs)(t({$modal:b})):H()))),s})().concat((()=>{var{slots:e={},status:t,message:o}=w,o=w.content||o,l=x.value,e=f.default||e.default,a=[];return t&&a.push((0,_vue.h)("div",{class:"vxe-modal--status-wrapper"},[(0,_vue.h)("i",{class:["vxe-modal--status-icon",w.iconStatus||_iconStore.default[("MODAL_"+t).toLocaleUpperCase()]]})])),a.push((0,_vue.h)("div",{class:"vxe-modal--content"},e?!N.inited||w.destroyOnClose&&!N.visible?[]:(0,_vn.getSlotVNs)(e({$modal:b})):(0,_utils.getFuncText)(o))),l||a.push((0,_vue.h)(_index.default,{class:"vxe-modal--loading",modelValue:w.loading})),[(0,_vue.h)("div",{class:"vxe-modal--body"},a)]})(),(()=>{var{slots:e={}}=w,t=x.value,e=f.footer||e.footer,o=[];return w.showFooter&&o.push((0,_vue.h)("div",{class:"vxe-modal--footer"},e?!N.inited||w.destroyOnClose&&!N.visible?[]:(0,_vn.getSlotVNs)(e({$modal:b})):$())),!t&&w.resize&&o.push((0,_vue.h)("span",{class:"vxe-modal--resize"},["wl","wr","swst","sest","st","swlb","selb","sb"].map(e=>(0,_vue.h)("span",{class:e+"-resize",type:e,onMousedown:q})))),o})()))])])},b},render(){return this.renderVN()}});
|