vue-devui 1.0.0-beta.9 → 1.0.0-rc.1
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/README.md +100 -72
- package/accordion/index.es.js +525 -39
- package/accordion/index.umd.js +1 -1
- package/accordion/style.css +1 -1
- package/alert/index.es.js +34 -37
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/{time-axis → auto-complete}/index.d.ts +0 -0
- package/auto-complete/index.es.js +983 -0
- package/auto-complete/index.umd.js +1 -0
- package/auto-complete/package.json +7 -0
- package/auto-complete/style.css +1 -0
- package/back-top/index.es.js +5 -3
- package/back-top/index.umd.js +1 -1
- package/badge/index.es.js +13 -19
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/breadcrumb/index.es.js +2 -1
- package/button/index.es.js +296 -117
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/carousel/index.es.js +43 -57
- package/carousel/index.umd.js +1 -1
- package/cascader/index.es.js +5412 -784
- package/cascader/index.umd.js +27 -1
- package/cascader/style.css +1 -1
- package/checkbox/style.css +1 -1
- package/{toast → color-picker}/index.d.ts +0 -0
- package/color-picker/index.es.js +8196 -0
- package/color-picker/index.umd.js +27 -0
- package/color-picker/package.json +7 -0
- package/color-picker/style.css +1 -0
- package/comment/index.es.js +42 -13
- package/comment/index.umd.js +1 -1
- package/comment/style.css +1 -1
- package/countdown/index.es.js +27 -17
- package/countdown/index.umd.js +1 -1
- package/countdown/style.css +1 -1
- package/date-picker/index.es.js +48 -66
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/dragdrop/index.es.js +135 -10
- package/dragdrop/index.umd.js +1 -1
- package/drawer/index.es.js +169 -223
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +463 -300
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +293 -5660
- package/editable-select/index.umd.js +1 -27
- package/editable-select/style.css +1 -1
- package/form/index.es.js +6210 -531
- package/form/index.umd.js +27 -1
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +112 -133
- package/fullscreen/index.umd.js +1 -1
- package/fullscreen/style.css +1 -1
- package/gantt/index.es.js +6 -18
- package/gantt/index.umd.js +1 -1
- package/gantt/style.css +1 -1
- package/grid/index.es.js +1 -1
- package/grid/style.css +1 -1
- package/icon/index.es.js +39 -56
- package/icon/index.umd.js +1 -1
- package/image-preview/index.es.js +35 -16
- package/image-preview/index.umd.js +1 -1
- package/input/index.es.js +4 -5
- package/input/index.umd.js +1 -1
- package/input/style.css +1 -1
- package/input-icon/index.es.js +42 -41
- package/input-icon/index.umd.js +1 -1
- package/input-icon/style.css +1 -1
- package/input-number/index.es.js +46 -56
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/list/index.d.ts +7 -0
- package/list/index.es.js +39 -0
- package/list/index.umd.js +1 -0
- package/{toast → list}/package.json +1 -1
- package/list/style.css +1 -0
- package/loading/index.es.js +2 -2
- package/modal/index.es.js +304 -765
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/nav-sprite/index.es.js +1 -675
- package/nav-sprite/index.umd.js +1 -1
- package/notification/index.d.ts +7 -0
- package/notification/index.es.js +284 -0
- package/notification/index.umd.js +1 -0
- package/notification/package.json +7 -0
- package/notification/style.css +1 -0
- package/nuxt/components/Accordion.js +3 -0
- package/nuxt/components/Alert.js +3 -0
- package/nuxt/components/Anchor.js +3 -0
- package/nuxt/components/Aside.js +3 -0
- package/nuxt/components/AutoComplete.js +3 -0
- package/nuxt/components/Avatar.js +3 -0
- package/nuxt/components/BackTop.js +3 -0
- package/nuxt/components/Badge.js +3 -0
- package/nuxt/components/Breadcrumb.js +3 -0
- package/nuxt/components/Button.js +3 -0
- package/nuxt/components/Card.js +3 -0
- package/nuxt/components/Carousel.js +3 -0
- package/nuxt/components/CarouselItem.js +3 -0
- package/nuxt/components/Cascader.js +3 -0
- package/nuxt/components/Checkbox.js +3 -0
- package/nuxt/components/Col.js +3 -0
- package/nuxt/components/ColorPicker.js +3 -0
- package/nuxt/components/Column.js +3 -0
- package/nuxt/components/Comment.js +3 -0
- package/nuxt/components/Content.js +3 -0
- package/nuxt/components/Countdown.js +3 -0
- package/nuxt/components/DatePicker.js +3 -0
- package/nuxt/components/Drawer.js +3 -0
- package/nuxt/components/DrawerService.js +3 -0
- package/nuxt/components/Dropdown.js +3 -0
- package/nuxt/components/DropdownMenu.js +3 -0
- package/nuxt/components/EditableSelect.js +3 -0
- package/nuxt/components/FixedOverlay.js +3 -0
- package/nuxt/components/FlexibleOverlay.js +3 -0
- package/nuxt/components/Footer.js +3 -0
- package/nuxt/components/Form.js +3 -0
- package/nuxt/components/FormControl.js +3 -0
- package/nuxt/components/FormItem.js +3 -0
- package/nuxt/components/FormLabel.js +3 -0
- package/nuxt/components/FormOperation.js +3 -0
- package/nuxt/components/Fullscreen.js +3 -0
- package/nuxt/components/Gantt.js +3 -0
- package/nuxt/components/Header.js +3 -0
- package/nuxt/components/IFileOptions.js +3 -0
- package/nuxt/components/IUploadOptions.js +3 -0
- package/nuxt/components/Icon.js +2 -0
- package/nuxt/components/ImagePreviewService.js +3 -0
- package/nuxt/components/Input.js +3 -0
- package/nuxt/components/InputIcon.js +3 -0
- package/nuxt/components/InputNumber.js +3 -0
- package/nuxt/components/Layout.js +3 -0
- package/nuxt/components/List.js +3 -0
- package/nuxt/components/ListItem.js +3 -0
- package/nuxt/components/Loading.js +3 -0
- package/nuxt/components/LoadingService.js +3 -0
- package/nuxt/components/Modal.js +3 -0
- package/nuxt/components/NavSprite.js +2 -0
- package/nuxt/components/Notification.js +3 -0
- package/nuxt/components/NotificationService.js +3 -0
- package/nuxt/components/Pagination.js +3 -0
- package/nuxt/components/Panel.js +3 -0
- package/nuxt/components/PanelBody.js +3 -0
- package/nuxt/components/PanelFooter.js +3 -0
- package/nuxt/components/PanelHeader.js +3 -0
- package/nuxt/components/Popover.js +3 -0
- package/nuxt/components/Progress.js +3 -0
- package/nuxt/components/QuadrantDiagram.js +3 -0
- package/nuxt/components/Radio.js +3 -0
- package/nuxt/components/RadioGroup.js +3 -0
- package/nuxt/components/Rate.js +3 -0
- package/nuxt/components/ReadTip.js +3 -0
- package/nuxt/components/Result.js +3 -0
- package/nuxt/components/Row.js +3 -0
- package/nuxt/components/Search.js +3 -0
- package/nuxt/components/Select.js +3 -0
- package/nuxt/components/Skeleton.js +3 -0
- package/nuxt/components/SkeletonItem.js +3 -0
- package/nuxt/components/Slider.js +3 -0
- package/nuxt/components/Splitter.js +3 -0
- package/nuxt/components/Statistic.js +3 -0
- package/nuxt/components/Status.js +3 -0
- package/nuxt/components/StepsGuide.js +3 -0
- package/nuxt/components/StickSlider.js +3 -0
- package/nuxt/components/Sticky.js +2 -0
- package/nuxt/components/Switch.js +3 -0
- package/nuxt/components/Table.js +3 -0
- package/nuxt/components/Tabs.js +3 -0
- package/nuxt/components/Tag.js +3 -0
- package/nuxt/components/TagInput.js +3 -0
- package/nuxt/components/Textarea.js +3 -0
- package/nuxt/components/TimePicker.js +3 -0
- package/nuxt/components/Timeline.js +3 -0
- package/nuxt/components/TimelineItem.js +3 -0
- package/nuxt/components/Tooltip.js +3 -0
- package/nuxt/components/Transfer.js +3 -0
- package/nuxt/components/Tree.js +3 -0
- package/nuxt/components/TreeSelect.js +3 -0
- package/nuxt/components/Upload.js +3 -0
- package/nuxt/components/UploadStatus.js +3 -0
- package/nuxt/components/alertProps.js +3 -0
- package/nuxt/components/badgeProps.js +3 -0
- package/nuxt/components/buttonProps.js +3 -0
- package/nuxt/components/dropdownMenuProps.js +3 -0
- package/nuxt/components/fixedOverlayProps.js +3 -0
- package/nuxt/components/flexibleOverlayProps.js +3 -0
- package/nuxt/components/fullscreenProps.js +3 -0
- package/nuxt/components/iconProps.js +2 -0
- package/nuxt/components/notificationProps.js +3 -0
- package/nuxt/components/overlayEmits.js +3 -0
- package/nuxt/components/overlayProps.js +3 -0
- package/nuxt/components/paginationProps.js +3 -0
- package/nuxt/components/panelProps.js +3 -0
- package/nuxt/components/popoverProps.js +3 -0
- package/nuxt/components/searchProps.js +3 -0
- package/nuxt/components/tooltipProps.js +3 -0
- package/nuxt/components/uploadProps.js +3 -0
- package/nuxt/index.js +13 -0
- package/overlay/index.es.js +156 -205
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +12 -55
- package/pagination/index.es.js +11 -13
- package/pagination/index.umd.js +1 -1
- package/pagination/style.css +1 -1
- package/panel/index.es.js +48 -35
- package/panel/index.umd.js +1 -1
- package/popover/index.es.js +5954 -189
- package/popover/index.umd.js +27 -1
- package/popover/style.css +1 -1
- package/progress/index.es.js +8 -8
- package/progress/index.umd.js +3 -3
- package/quadrant-diagram/index.es.js +5405 -166
- package/quadrant-diagram/index.umd.js +27 -1
- package/radio/index.es.js +8 -14
- package/radio/index.umd.js +1 -1
- package/radio/style.css +1 -1
- package/read-tip/index.es.js +6 -3
- package/read-tip/style.css +1 -1
- package/result/index.es.js +38 -52
- package/result/index.umd.js +1 -1
- package/ripple/index.es.js +10 -6
- package/search/index.es.js +5428 -200
- package/search/index.umd.js +27 -1
- package/search/style.css +1 -1
- package/select/index.es.js +43 -42
- package/select/index.umd.js +1 -1
- package/select/style.css +1 -1
- package/skeleton/index.es.js +17 -17
- package/skeleton/index.umd.js +1 -1
- package/slider/index.es.js +4 -6
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +5896 -39
- package/splitter/index.umd.js +27 -1
- package/splitter/style.css +1 -1
- package/statistic/index.es.js +19 -32
- package/statistic/index.umd.js +1 -1
- package/statistic/style.css +1 -1
- package/status/index.es.js +1 -4
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/steps-guide/index.es.js +6 -3
- package/sticky/index.umd.js +1 -1
- package/style.css +1 -1
- package/table/index.es.js +753 -358
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/tabs/index.es.js +3 -4
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.es.js +4 -3
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/tag-input/index.es.js +4 -14
- package/tag-input/index.umd.js +1 -1
- package/textarea/style.css +1 -1
- package/{theme → theme/theme.scss} +0 -0
- package/time-picker/index.es.js +309 -123
- package/time-picker/index.umd.js +1 -1
- package/time-picker/style.css +1 -1
- package/timeline/index.d.ts +7 -0
- package/{time-axis → timeline}/index.es.js +65 -77
- package/timeline/index.umd.js +1 -0
- package/{time-axis → timeline}/package.json +1 -1
- package/timeline/style.css +1 -0
- package/tooltip/index.es.js +5805 -141
- package/tooltip/index.umd.js +27 -1
- package/tooltip/style.css +1 -1
- package/transfer/index.es.js +6521 -630
- package/transfer/index.umd.js +27 -1
- package/transfer/style.css +1 -1
- package/tree/index.es.js +5781 -193
- package/tree/index.umd.js +27 -1
- package/tree/style.css +1 -1
- package/tree-select/index.es.js +138 -39
- package/tree-select/index.umd.js +1 -1
- package/tree-select/style.css +1 -1
- package/upload/index.es.js +450 -2669
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +14414 -14096
- package/vue-devui.umd.js +19 -19
- package/time-axis/index.umd.js +0 -1
- package/time-axis/style.css +0 -1
- package/toast/index.es.js +0 -2059
- package/toast/index.umd.js +0 -1
- package/toast/style.css +0 -1
package/dragdrop/index.es.js
CHANGED
|
@@ -1,22 +1,146 @@
|
|
|
1
|
+
const shadowId = "shadow0611";
|
|
2
|
+
function getElementStyle(id, styleName) {
|
|
3
|
+
return document.getElementById(id).currentStyle ? document.getElementById(id).currentStyle[styleName] : window.getComputedStyle(document.getElementById(id), styleName);
|
|
4
|
+
}
|
|
5
|
+
function createShadow(originId) {
|
|
6
|
+
const shadow = document.createElement("div");
|
|
7
|
+
shadow.id = shadowId;
|
|
8
|
+
shadow.style.background = "rgb(206, 215, 255)";
|
|
9
|
+
shadow.style.width = getElementStyle(originId, "width");
|
|
10
|
+
shadow.style.height = "20px";
|
|
11
|
+
return shadow;
|
|
12
|
+
}
|
|
13
|
+
function changeDragState(el, originId, dragStart, drag, dragover, drop, shouldCreateShadow, dragFlag) {
|
|
14
|
+
el.dataset.originId = originId;
|
|
15
|
+
el.dataset.dragStart = dragStart;
|
|
16
|
+
el.dataset.dragover = dragover;
|
|
17
|
+
el.dataset.drop = drop;
|
|
18
|
+
el.dataset.shouldCreateShadow = shouldCreateShadow;
|
|
19
|
+
el.dataset.dragFlag = dragFlag;
|
|
20
|
+
}
|
|
21
|
+
function computeCompareElementHeight(compareElement) {
|
|
22
|
+
return compareElement.getBoundingClientRect().top + Math.floor(compareElement.offsetHeight / 2);
|
|
23
|
+
}
|
|
24
|
+
function createInsertSortableShadow(sortDropArea, mouseObject, originId) {
|
|
25
|
+
const sortDropAreaArr = [...sortDropArea.children];
|
|
26
|
+
if (sortDropAreaArr.length == 0) {
|
|
27
|
+
if (!document.getElementById(shadowId)) {
|
|
28
|
+
const shadowElement = createShadow(originId);
|
|
29
|
+
sortDropArea.appendChild(shadowElement);
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
for (let index2 = 0; index2 < sortDropAreaArr.length; index2++) {
|
|
33
|
+
const compareHeight = computeCompareElementHeight(sortDropAreaArr[index2]);
|
|
34
|
+
document.getElementById(shadowId) ? sortDropArea.removeChild(document.getElementById(shadowId)) : null;
|
|
35
|
+
if (index2 == sortDropAreaArr.length - 1) {
|
|
36
|
+
sortDropArea.appendChild(createShadow(originId));
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
if (Math.floor(mouseObject.clientY) <= compareHeight) {
|
|
40
|
+
sortDropArea.insertBefore(createShadow(originId), sortDropAreaArr[index2]);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function insertDragElement(dropAreaContainer, dragId, mouseObject) {
|
|
47
|
+
for (let index2 = 0; index2 < [...dropAreaContainer.children].length; index2++) {
|
|
48
|
+
if (index2 == [...dropAreaContainer.children].length - 1) {
|
|
49
|
+
dropAreaContainer.appendChild(document.getElementById(dragId));
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
if (Math.floor(mouseObject.clientY) <= computeCompareElementHeight([...dropAreaContainer.children][index2])) {
|
|
53
|
+
dropAreaContainer.insertBefore(document.getElementById(dragId), [...dropAreaContainer.children][index2]);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function deleteInsertedSortableShadow(dropSortArea) {
|
|
59
|
+
if (dropSortArea) {
|
|
60
|
+
if (document.getElementById(shadowId)) {
|
|
61
|
+
if (dropSortArea.contains(document.getElementById(shadowId))) {
|
|
62
|
+
dropSortArea.removeChild(document.getElementById(shadowId));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
1
67
|
var DraggableDirective = {
|
|
2
|
-
mounted(el) {
|
|
68
|
+
mounted(el, binding) {
|
|
3
69
|
el.setAttribute("draggable", "true");
|
|
4
70
|
el.style.cursor = "grab";
|
|
5
|
-
el.addEventListener("
|
|
6
|
-
|
|
7
|
-
|
|
71
|
+
el.addEventListener("drag", () => {
|
|
72
|
+
changeDragState(el, el.id, "true", "true", "false", "false", "false", "true");
|
|
73
|
+
if (binding.instance.$root.dropElement && document.getElementById(shadowId)) {
|
|
74
|
+
deleteInsertedSortableShadow(binding.instance.$root.dropElement);
|
|
75
|
+
binding.instance.$root.dropElement = null;
|
|
76
|
+
}
|
|
77
|
+
}, false);
|
|
78
|
+
el.addEventListener("dragstart", () => {
|
|
79
|
+
changeDragState(el, el.id, "true", "true", "false", "false", "false", "false");
|
|
80
|
+
binding.instance.$root.identity = el.id;
|
|
81
|
+
el.dataset.dragArea = el.parentNode.className;
|
|
82
|
+
}, false);
|
|
8
83
|
}
|
|
9
84
|
};
|
|
10
85
|
var DroppableDirective = {
|
|
11
|
-
mounted(el) {
|
|
86
|
+
mounted(el, binding) {
|
|
12
87
|
el.addEventListener("dragover", (event) => {
|
|
13
88
|
event.preventDefault();
|
|
14
|
-
|
|
89
|
+
const dragId = binding.instance.$root.identity;
|
|
90
|
+
changeDragState(document.getElementById(dragId), dragId, "true", "false", "true", "false", "false", "false");
|
|
91
|
+
document.getElementById(dragId).dataset.dropArea = [...el.childNodes][1].className;
|
|
92
|
+
}, false);
|
|
15
93
|
el.addEventListener("drop", (event) => {
|
|
16
|
-
|
|
17
|
-
const
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
const dragId = binding.instance.$root.identity;
|
|
96
|
+
if (document.getElementById(dragId).dataset.dropArea == document.getElementById(dragId).dataset.dragArea) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const childrenArr = [...Array.from(el.children)[1].children];
|
|
100
|
+
if (childrenArr.length > 0) {
|
|
101
|
+
for (let index2 = 0; index2 < childrenArr.length; index2++) {
|
|
102
|
+
const childrenYRange = childrenArr[index2].getBoundingClientRect().top + childrenArr[index2].offsetHeight / 2;
|
|
103
|
+
if (parseFloat(event.clientY) < parseFloat(childrenYRange)) {
|
|
104
|
+
el.children[1].insertBefore(document.getElementById(dragId), childrenArr[index2]);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
if (index2 === childrenArr.length - 1) {
|
|
108
|
+
el.children[1].appendChild(document.getElementById(dragId));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
el.childNodes[1].appendChild(document.getElementById(dragId));
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
var SortableDirective = {
|
|
118
|
+
mounted(el, binding) {
|
|
119
|
+
el.addEventListener("dragover", function(event) {
|
|
120
|
+
event.preventDefault();
|
|
18
121
|
const targetNode = event.target;
|
|
19
|
-
|
|
122
|
+
const dragId = binding.instance.$root.identity;
|
|
123
|
+
if (!binding.instance.$root.dropElement) {
|
|
124
|
+
binding.instance.$root.dropElement = [...el.childNodes][1];
|
|
125
|
+
}
|
|
126
|
+
changeDragState(document.getElementById(binding.instance.$root.identity), binding.instance.$root.identity, "true", "false", "true", "false", "true", "false");
|
|
127
|
+
const { dragover, shouldCreateShadow } = document.getElementById(dragId).dataset;
|
|
128
|
+
if (dragover == "true") {
|
|
129
|
+
if (shouldCreateShadow == "true") {
|
|
130
|
+
createInsertSortableShadow([...targetNode.children][1], event, dragId);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
el.addEventListener("drop", function(event) {
|
|
135
|
+
const dropArea = [...el.childNodes][1];
|
|
136
|
+
const dragId = binding.instance.$root.identity;
|
|
137
|
+
dropArea.removeChild(document.getElementById(shadowId));
|
|
138
|
+
if ([...dropArea.childNodes].length == 0) {
|
|
139
|
+
dropArea.appendChild(document.getElementById(dragId));
|
|
140
|
+
} else {
|
|
141
|
+
insertDragElement(dropArea, dragId, event);
|
|
142
|
+
}
|
|
143
|
+
changeDragState(document.getElementById(dragId), dragId, "false", "false", "false", "true", "false", "false");
|
|
20
144
|
});
|
|
21
145
|
}
|
|
22
146
|
};
|
|
@@ -27,6 +151,7 @@ var index = {
|
|
|
27
151
|
install(app) {
|
|
28
152
|
app.directive("DDraggable", DraggableDirective);
|
|
29
153
|
app.directive("DDroppable", DroppableDirective);
|
|
154
|
+
app.directive("DSortable", SortableDirective);
|
|
30
155
|
}
|
|
31
156
|
};
|
|
32
|
-
export { DraggableDirective, DroppableDirective, index as default };
|
|
157
|
+
export { DraggableDirective, DroppableDirective, SortableDirective, index as default };
|
package/dragdrop/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(l,r){typeof exports=="object"&&typeof module!="undefined"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(l=typeof globalThis!="undefined"?globalThis:l||self,r(l.index={}))})(this,function(l){"use strict";const r="shadow0611";function h(e,t){return document.getElementById(e).currentStyle?document.getElementById(e).currentStyle[t]:window.getComputedStyle(document.getElementById(e),t)}function s(e){const t=document.createElement("div");return t.id=r,t.style.background="rgb(206, 215, 255)",t.style.width=h(e,"width"),t.style.height="20px",t}function i(e,t,a,n,d,o,c,I){e.dataset.originId=t,e.dataset.dragStart=a,e.dataset.dragover=d,e.dataset.drop=o,e.dataset.shouldCreateShadow=c,e.dataset.dragFlag=I}function u(e){return e.getBoundingClientRect().top+Math.floor(e.offsetHeight/2)}function y(e,t,a){const n=[...e.children];if(n.length==0){if(!document.getElementById(r)){const d=s(a);e.appendChild(d)}}else for(let d=0;d<n.length;d++){const o=u(n[d]);if(document.getElementById(r)&&e.removeChild(document.getElementById(r)),d==n.length-1){e.appendChild(s(a));break}if(Math.floor(t.clientY)<=o){e.insertBefore(s(a),n[d]);break}}}function E(e,t,a){for(let n=0;n<[...e.children].length;n++){if(n==[...e.children].length-1){e.appendChild(document.getElementById(t));break}if(Math.floor(a.clientY)<=u([...e.children][n])){e.insertBefore(document.getElementById(t),[...e.children][n]);break}}}function p(e){e&&document.getElementById(r)&&e.contains(document.getElementById(r))&&e.removeChild(document.getElementById(r))}var f={mounted(e,t){e.setAttribute("draggable","true"),e.style.cursor="grab",e.addEventListener("drag",()=>{i(e,e.id,"true","true","false","false","false","true"),t.instance.$root.dropElement&&document.getElementById(r)&&(p(t.instance.$root.dropElement),t.instance.$root.dropElement=null)},!1),e.addEventListener("dragstart",()=>{i(e,e.id,"true","true","false","false","false","false"),t.instance.$root.identity=e.id,e.dataset.dragArea=e.parentNode.className},!1)}},m={mounted(e,t){e.addEventListener("dragover",a=>{a.preventDefault();const n=t.instance.$root.identity;i(document.getElementById(n),n,"true","false","true","false","false","false"),document.getElementById(n).dataset.dropArea=[...e.childNodes][1].className},!1),e.addEventListener("drop",a=>{a.preventDefault();const n=t.instance.$root.identity;if(document.getElementById(n).dataset.dropArea==document.getElementById(n).dataset.dragArea)return;const d=[...Array.from(e.children)[1].children];if(d.length>0)for(let o=0;o<d.length;o++){const c=d[o].getBoundingClientRect().top+d[o].offsetHeight/2;if(parseFloat(a.clientY)<parseFloat(c)){e.children[1].insertBefore(document.getElementById(n),d[o]);break}o===d.length-1&&e.children[1].appendChild(document.getElementById(n))}else e.childNodes[1].appendChild(document.getElementById(n))})}},g={mounted(e,t){e.addEventListener("dragover",function(a){a.preventDefault();const n=a.target,d=t.instance.$root.identity;t.instance.$root.dropElement||(t.instance.$root.dropElement=[...e.childNodes][1]),i(document.getElementById(t.instance.$root.identity),t.instance.$root.identity,"true","false","true","false","true","false");const{dragover:o,shouldCreateShadow:c}=document.getElementById(d).dataset;o=="true"&&c=="true"&&y([...n.children][1],a,d)}),e.addEventListener("drop",function(a){const n=[...e.childNodes][1],d=t.instance.$root.identity;n.removeChild(document.getElementById(r)),[...n.childNodes].length==0?n.appendChild(document.getElementById(d)):E(n,d,a),i(document.getElementById(d),d,"false","false","false","true","false","false")})}},B={title:"Dragdrop \u62D6\u62FD",category:"\u901A\u7528",status:"10%",install(e){e.directive("DDraggable",f),e.directive("DDroppable",m),e.directive("DSortable",g)}};l.DraggableDirective=f,l.DroppableDirective=m,l.SortableDirective=g,l.default=B,Object.defineProperty(l,"__esModule",{value:!0}),l[Symbol.toStringTag]="Module"});
|
package/drawer/index.es.js
CHANGED
|
@@ -14,13 +14,10 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
-
import { defineComponent,
|
|
17
|
+
import { defineComponent, createVNode, Transition, ref, computed, watch, onUnmounted, Teleport, mergeProps, reactive, createApp, isVNode } from "vue";
|
|
18
|
+
import { onClickOutside } from "@vueuse/core";
|
|
18
19
|
const drawerProps = {
|
|
19
|
-
|
|
20
|
-
type: String,
|
|
21
|
-
default: "300px"
|
|
22
|
-
},
|
|
23
|
-
visible: {
|
|
20
|
+
modelValue: {
|
|
24
21
|
type: Boolean,
|
|
25
22
|
default: false
|
|
26
23
|
},
|
|
@@ -28,7 +25,7 @@ const drawerProps = {
|
|
|
28
25
|
type: Number,
|
|
29
26
|
default: 1e3
|
|
30
27
|
},
|
|
31
|
-
|
|
28
|
+
showOverlay: {
|
|
32
29
|
type: Boolean,
|
|
33
30
|
default: true
|
|
34
31
|
},
|
|
@@ -38,251 +35,200 @@ const drawerProps = {
|
|
|
38
35
|
},
|
|
39
36
|
position: {
|
|
40
37
|
type: String,
|
|
41
|
-
default: "
|
|
38
|
+
default: "right"
|
|
42
39
|
},
|
|
43
|
-
|
|
40
|
+
lockScroll: {
|
|
44
41
|
type: Boolean,
|
|
45
42
|
default: true
|
|
46
43
|
},
|
|
47
|
-
|
|
48
|
-
type:
|
|
44
|
+
closeOnClickOverlay: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: true
|
|
47
|
+
},
|
|
48
|
+
beforeClose: {
|
|
49
|
+
type: Function
|
|
49
50
|
}
|
|
50
51
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
setup(props, ctx) {
|
|
56
|
-
const isFullScreen = ref(false);
|
|
57
|
-
const visible = inject("visible");
|
|
58
|
-
const fullScreenClassName = computed(() => isFullScreen.value ? "icon icon-minimize" : "icon icon-maxmize");
|
|
59
|
-
const handleFullScreen = (e) => {
|
|
60
|
-
e.stopPropagation();
|
|
61
|
-
isFullScreen.value = !isFullScreen.value;
|
|
62
|
-
ctx.emit("toggleFullScreen");
|
|
63
|
-
};
|
|
64
|
-
const handleDrawerClose = () => {
|
|
65
|
-
ctx.emit("close");
|
|
66
|
-
};
|
|
67
|
-
return {
|
|
68
|
-
fullScreenClassName,
|
|
69
|
-
visible,
|
|
70
|
-
handleFullScreen,
|
|
71
|
-
handleDrawerClose
|
|
72
|
-
};
|
|
73
|
-
},
|
|
74
|
-
render() {
|
|
75
|
-
const {
|
|
76
|
-
handleFullScreen,
|
|
77
|
-
handleDrawerClose,
|
|
78
|
-
visible,
|
|
79
|
-
fullScreenClassName
|
|
80
|
-
} = this;
|
|
81
|
-
if (!visible)
|
|
82
|
-
return null;
|
|
83
|
-
return createVNode("div", {
|
|
84
|
-
"class": "devui-drawer-header"
|
|
85
|
-
}, [createVNode("div", {
|
|
86
|
-
"class": "devui-drawer-header-item"
|
|
87
|
-
}, [createVNode("span", {
|
|
88
|
-
"class": "devui-drawer-header-item icon icon-more-operate"
|
|
89
|
-
}, null)]), createVNode("div", {
|
|
90
|
-
"class": "devui-drawer-header-item",
|
|
91
|
-
"onClick": handleFullScreen
|
|
92
|
-
}, [createVNode("span", {
|
|
93
|
-
"class": fullScreenClassName
|
|
94
|
-
}, null)]), createVNode("div", {
|
|
95
|
-
"class": "devui-drawer-header-item",
|
|
96
|
-
"onClick": handleDrawerClose
|
|
97
|
-
}, [createVNode("span", {
|
|
98
|
-
"class": "icon icon-close"
|
|
99
|
-
}, null)])]);
|
|
52
|
+
const drawerOverlayProps = {
|
|
53
|
+
visible: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: false
|
|
100
56
|
}
|
|
101
|
-
}
|
|
102
|
-
var
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
57
|
+
};
|
|
58
|
+
var drawerOverlay = "";
|
|
59
|
+
var DrawerOverlay = defineComponent({
|
|
60
|
+
name: "DDrawerOverlay",
|
|
61
|
+
props: drawerOverlayProps,
|
|
62
|
+
emits: ["click"],
|
|
63
|
+
setup(props, ctx) {
|
|
64
|
+
const handleClick = (e) => {
|
|
65
|
+
ctx.emit("click", e);
|
|
108
66
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
visible
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
67
|
+
return () => createVNode(Transition, {
|
|
68
|
+
"name": "drawer-overlay-fade"
|
|
69
|
+
}, {
|
|
70
|
+
default: () => [props.visible && createVNode("div", {
|
|
71
|
+
"class": "devui-drawer-overlay",
|
|
72
|
+
"onClick": handleClick
|
|
73
|
+
}, null)]
|
|
74
|
+
});
|
|
117
75
|
}
|
|
118
76
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
"right": 0
|
|
135
|
-
} : {
|
|
136
|
-
"left": 0
|
|
137
|
-
});
|
|
138
|
-
const navWidth = computed(() => isFullScreen.value ? "100vw" : width.value);
|
|
139
|
-
const clickContent = (e) => {
|
|
140
|
-
e.stopPropagation();
|
|
141
|
-
};
|
|
142
|
-
const handleDrawerClose = () => {
|
|
143
|
-
if (!backdropCloseable.value)
|
|
144
|
-
return;
|
|
145
|
-
closeDrawer();
|
|
146
|
-
};
|
|
147
|
-
return {
|
|
148
|
-
zindex,
|
|
149
|
-
slots,
|
|
150
|
-
isCover,
|
|
151
|
-
navRight,
|
|
152
|
-
navWidth,
|
|
153
|
-
visible,
|
|
154
|
-
clickContent,
|
|
155
|
-
handleDrawerClose
|
|
77
|
+
function lockScroll() {
|
|
78
|
+
if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
|
|
79
|
+
const scrollTop = document.documentElement.scrollTop;
|
|
80
|
+
const style = document.documentElement.getAttribute("style");
|
|
81
|
+
document.documentElement.style.position = "fixed";
|
|
82
|
+
document.documentElement.style.top = `-${scrollTop}px`;
|
|
83
|
+
document.documentElement.style.width = document.documentElement.style.width || "100%";
|
|
84
|
+
document.documentElement.style.overflowY = "scroll";
|
|
85
|
+
return () => {
|
|
86
|
+
if (style) {
|
|
87
|
+
document.documentElement.setAttribute("style", style);
|
|
88
|
+
} else {
|
|
89
|
+
document.documentElement.removeAttribute("style");
|
|
90
|
+
}
|
|
91
|
+
document.documentElement.scrollTop = scrollTop;
|
|
156
92
|
};
|
|
157
|
-
},
|
|
158
|
-
render() {
|
|
159
|
-
const {
|
|
160
|
-
zindex,
|
|
161
|
-
slots,
|
|
162
|
-
isCover,
|
|
163
|
-
navRight,
|
|
164
|
-
navWidth,
|
|
165
|
-
visible,
|
|
166
|
-
handleDrawerClose
|
|
167
|
-
} = this;
|
|
168
|
-
if (!visible)
|
|
169
|
-
return null;
|
|
170
|
-
return createVNode("div", {
|
|
171
|
-
"class": "devui-drawer",
|
|
172
|
-
"style": {
|
|
173
|
-
zIndex: zindex
|
|
174
|
-
},
|
|
175
|
-
"onClick": handleDrawerClose
|
|
176
|
-
}, [isCover ? createVNode("div", {
|
|
177
|
-
"class": "devui-overlay-backdrop"
|
|
178
|
-
}, null) : null, createVNode("div", {
|
|
179
|
-
"class": "devui-overlay-wrapper"
|
|
180
|
-
}, [createVNode("div", {
|
|
181
|
-
"class": "devui-drawer-nav",
|
|
182
|
-
"style": __spreadValues({
|
|
183
|
-
"width": navWidth
|
|
184
|
-
}, navRight)
|
|
185
|
-
}, [createVNode("div", {
|
|
186
|
-
"class": "devui-drawer-content",
|
|
187
|
-
"onClick": this.clickContent
|
|
188
|
-
}, [slots.default ? slots.default() : null])])])]);
|
|
189
93
|
}
|
|
190
|
-
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
function useDrawer(props, emit) {
|
|
97
|
+
const drawerRef = ref();
|
|
98
|
+
const drawerClasses = computed(() => ({
|
|
99
|
+
"devui-drawer": true,
|
|
100
|
+
[`devui-drawer-${props.position}`]: true
|
|
101
|
+
}));
|
|
102
|
+
const close = () => {
|
|
103
|
+
emit("update:modelValue", false);
|
|
104
|
+
emit("close");
|
|
105
|
+
};
|
|
106
|
+
let lockScrollCb;
|
|
107
|
+
const execClose = () => {
|
|
108
|
+
props.beforeClose ? props.beforeClose(close) : close();
|
|
109
|
+
};
|
|
110
|
+
const handleOverlayClick = () => {
|
|
111
|
+
props.closeOnClickOverlay && execClose();
|
|
112
|
+
};
|
|
113
|
+
const handleEscClose = (e) => {
|
|
114
|
+
e.code === "Escape" && execClose();
|
|
115
|
+
};
|
|
116
|
+
onClickOutside(drawerRef, execClose);
|
|
117
|
+
const removeBodyAdditions = () => {
|
|
118
|
+
lockScrollCb == null ? void 0 : lockScrollCb();
|
|
119
|
+
document.removeEventListener("keyup", handleEscClose);
|
|
120
|
+
};
|
|
121
|
+
watch(() => props.modelValue, (val) => {
|
|
122
|
+
if (val) {
|
|
123
|
+
emit("open");
|
|
124
|
+
props.lockScroll && (lockScrollCb = lockScroll());
|
|
125
|
+
props.escKeyCloseable && document.addEventListener("keyup", handleEscClose);
|
|
126
|
+
} else {
|
|
127
|
+
removeBodyAdditions();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
onUnmounted(removeBodyAdditions);
|
|
131
|
+
return { drawerRef, drawerClasses, handleOverlayClick };
|
|
132
|
+
}
|
|
133
|
+
var drawer = "";
|
|
191
134
|
var Drawer = defineComponent({
|
|
192
135
|
name: "DDrawer",
|
|
136
|
+
inheritAttrs: false,
|
|
193
137
|
props: drawerProps,
|
|
194
|
-
emits: ["close", "update:
|
|
138
|
+
emits: ["close", "update:modelValue", "open"],
|
|
195
139
|
setup(props, {
|
|
196
140
|
emit,
|
|
197
|
-
slots
|
|
141
|
+
slots,
|
|
142
|
+
attrs
|
|
198
143
|
}) {
|
|
199
144
|
const {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
position,
|
|
206
|
-
backdropCloseable
|
|
207
|
-
} = toRefs(props);
|
|
208
|
-
const isFullScreen = ref(false);
|
|
209
|
-
const fullScreenEvent = () => {
|
|
210
|
-
isFullScreen.value = !isFullScreen.value;
|
|
211
|
-
};
|
|
212
|
-
const closeDrawer = async () => {
|
|
213
|
-
var _a;
|
|
214
|
-
const beforeHidden = props.beforeHidden;
|
|
215
|
-
let result = (_a = typeof beforeHidden === "function" ? beforeHidden() : beforeHidden) != null ? _a : true;
|
|
216
|
-
if (result instanceof Promise) {
|
|
217
|
-
console.log(result);
|
|
218
|
-
result = await result;
|
|
219
|
-
}
|
|
220
|
-
if (result)
|
|
221
|
-
return;
|
|
222
|
-
emit("update:visible", false);
|
|
223
|
-
emit("close");
|
|
224
|
-
};
|
|
225
|
-
const escCloseDrawer = (e) => {
|
|
226
|
-
if (e.code === "Escape") {
|
|
227
|
-
closeDrawer();
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
watch(visible, (val) => {
|
|
231
|
-
if (val) {
|
|
232
|
-
emit("afterOpened");
|
|
233
|
-
isFullScreen.value = false;
|
|
234
|
-
}
|
|
235
|
-
if (escKeyCloseable && val) {
|
|
236
|
-
document.addEventListener("keyup", escCloseDrawer);
|
|
237
|
-
} else {
|
|
238
|
-
document.removeEventListener("keyup", escCloseDrawer);
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
provide("closeDrawer", closeDrawer);
|
|
242
|
-
provide("zindex", zIndex);
|
|
243
|
-
provide("isCover", isCover);
|
|
244
|
-
provide("position", position);
|
|
245
|
-
provide("width", width);
|
|
246
|
-
provide("visible", visible);
|
|
247
|
-
provide("isFullScreen", isFullScreen);
|
|
248
|
-
provide("backdropCloseable", backdropCloseable);
|
|
249
|
-
onUnmounted(() => {
|
|
250
|
-
document.removeEventListener("keyup", escCloseDrawer);
|
|
251
|
-
});
|
|
252
|
-
return {
|
|
253
|
-
isFullScreen,
|
|
254
|
-
visible,
|
|
255
|
-
slots,
|
|
256
|
-
fullScreenEvent,
|
|
257
|
-
closeDrawer
|
|
258
|
-
};
|
|
259
|
-
},
|
|
260
|
-
render() {
|
|
261
|
-
const fullScreenEvent = this.fullScreenEvent;
|
|
262
|
-
const closeDrawer = this.closeDrawer;
|
|
263
|
-
if (!this.visible)
|
|
264
|
-
return null;
|
|
265
|
-
return createVNode(Teleport, {
|
|
145
|
+
drawerRef,
|
|
146
|
+
drawerClasses,
|
|
147
|
+
handleOverlayClick
|
|
148
|
+
} = useDrawer(props, emit);
|
|
149
|
+
return () => createVNode(Teleport, {
|
|
266
150
|
"to": "body"
|
|
267
151
|
}, {
|
|
268
|
-
default: () => [createVNode(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
},
|
|
152
|
+
default: () => [props.showOverlay && createVNode(DrawerOverlay, {
|
|
153
|
+
"visible": props.modelValue,
|
|
154
|
+
"style": {
|
|
155
|
+
zIndex: props.zIndex
|
|
156
|
+
},
|
|
157
|
+
"onClick": handleOverlayClick
|
|
158
|
+
}, null), createVNode(Transition, {
|
|
159
|
+
"name": `drawer-fly-${props.position}`
|
|
160
|
+
}, {
|
|
161
|
+
default: () => {
|
|
162
|
+
var _a;
|
|
163
|
+
return [props.modelValue && createVNode("div", mergeProps({
|
|
164
|
+
"ref": drawerRef,
|
|
165
|
+
"class": drawerClasses.value,
|
|
166
|
+
"style": {
|
|
167
|
+
zIndex: props.zIndex + 1
|
|
168
|
+
}
|
|
169
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
|
|
170
|
+
}
|
|
273
171
|
})]
|
|
274
172
|
});
|
|
275
173
|
}
|
|
276
174
|
});
|
|
277
|
-
|
|
278
|
-
|
|
175
|
+
function _isSlot(s) {
|
|
176
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
177
|
+
}
|
|
178
|
+
const defaultOptions = {
|
|
179
|
+
modelValue: false,
|
|
180
|
+
content: "",
|
|
181
|
+
zIndex: 1e3,
|
|
182
|
+
showOverlay: true,
|
|
183
|
+
escKeyCloseable: true,
|
|
184
|
+
position: "right",
|
|
185
|
+
lockScroll: true,
|
|
186
|
+
closeOnClickOverlay: true
|
|
279
187
|
};
|
|
188
|
+
function initInstance(state) {
|
|
189
|
+
const container = document.createElement("div");
|
|
190
|
+
const content = state.content;
|
|
191
|
+
delete state.content;
|
|
192
|
+
const app = createApp({
|
|
193
|
+
setup() {
|
|
194
|
+
const handleVisibleChange = () => {
|
|
195
|
+
state.modelValue = false;
|
|
196
|
+
};
|
|
197
|
+
onUnmounted(() => {
|
|
198
|
+
console.log(111);
|
|
199
|
+
document.body.removeChild(container);
|
|
200
|
+
});
|
|
201
|
+
return () => createVNode(Drawer, mergeProps(state, {
|
|
202
|
+
"onUpdate:modelValue": handleVisibleChange
|
|
203
|
+
}), _isSlot(content) ? content : {
|
|
204
|
+
default: () => [content]
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
document.body.appendChild(container);
|
|
209
|
+
app.mount(container);
|
|
210
|
+
return app;
|
|
211
|
+
}
|
|
212
|
+
class DrawerService {
|
|
213
|
+
open(options) {
|
|
214
|
+
const state = reactive(__spreadValues(__spreadValues({}, defaultOptions), options));
|
|
215
|
+
const app = initInstance(state);
|
|
216
|
+
state.modelValue = true;
|
|
217
|
+
return {
|
|
218
|
+
close: () => {
|
|
219
|
+
state.modelValue = false;
|
|
220
|
+
app.unmount();
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
280
225
|
var index = {
|
|
281
226
|
title: "Drawer \u62BD\u5C49\u677F",
|
|
282
227
|
category: "\u53CD\u9988",
|
|
283
|
-
status: "
|
|
228
|
+
status: "75%",
|
|
284
229
|
install(app) {
|
|
285
|
-
app.
|
|
230
|
+
app.component(Drawer.name, Drawer);
|
|
231
|
+
app.config.globalProperties.$drawerService = new DrawerService();
|
|
286
232
|
}
|
|
287
233
|
};
|
|
288
|
-
export { Drawer, index as default };
|
|
234
|
+
export { Drawer, DrawerService, index as default };
|
package/drawer/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var x=Object.defineProperty;var C=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var v=(o,e,r)=>e in o?x(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r,f=(o,e)=>{for(var r in e||(e={}))N.call(e,r)&&v(o,r,e[r]);if(C)for(var r of C(e))T.call(e,r)&&v(o,r,e[r]);return o};(function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/core"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o.index={},o.Vue,o.core))})(this,function(o,e,r){"use strict";const h={modelValue:{type:Boolean,default:!1},zIndex:{type:Number,default:1e3},showOverlay:{type:Boolean,default:!0},escKeyCloseable:{type:Boolean,default:!0},position:{type:String,default:"right"},lockScroll:{type:Boolean,default:!0},closeOnClickOverlay:{type:Boolean,default:!0},beforeClose:{type:Function}},b={visible:{type:Boolean,default:!1}};var B="",V=e.defineComponent({name:"DDrawerOverlay",props:b,emits:["click"],setup(t,n){const l=d=>{n.emit("click",d)};return()=>e.createVNode(e.Transition,{name:"drawer-overlay-fade"},{default:()=>[t.visible&&e.createVNode("div",{class:"devui-drawer-overlay",onClick:l},null)]})}});function O(){if(document.documentElement.scrollHeight>document.documentElement.clientHeight){const t=document.documentElement.scrollTop,n=document.documentElement.getAttribute("style");return document.documentElement.style.position="fixed",document.documentElement.style.top=`-${t}px`,document.documentElement.style.width=document.documentElement.style.width||"100%",document.documentElement.style.overflowY="scroll",()=>{n?document.documentElement.setAttribute("style",n):document.documentElement.removeAttribute("style"),document.documentElement.scrollTop=t}}}function E(t,n){const l=e.ref(),d=e.computed(()=>({"devui-drawer":!0,[`devui-drawer-${t.position}`]:!0})),c=()=>{n("update:modelValue",!1),n("close")};let a;const u=()=>{t.beforeClose?t.beforeClose(c):c()},s=()=>{t.closeOnClickOverlay&&u()},p=m=>{m.code==="Escape"&&u()};r.onClickOutside(l,u);const w=()=>{a==null||a(),document.removeEventListener("keyup",p)};return e.watch(()=>t.modelValue,m=>{m?(n("open"),t.lockScroll&&(a=O()),t.escKeyCloseable&&document.addEventListener("keyup",p)):w()}),e.onUnmounted(w),{drawerRef:l,drawerClasses:d,handleOverlayClick:s}}var I="",i=e.defineComponent({name:"DDrawer",inheritAttrs:!1,props:h,emits:["close","update:modelValue","open"],setup(t,{emit:n,slots:l,attrs:d}){const{drawerRef:c,drawerClasses:a,handleOverlayClick:u}=E(t,n);return()=>e.createVNode(e.Teleport,{to:"body"},{default:()=>[t.showOverlay&&e.createVNode(V,{visible:t.modelValue,style:{zIndex:t.zIndex},onClick:u},null),e.createVNode(e.Transition,{name:`drawer-fly-${t.position}`},{default:()=>{var s;return[t.modelValue&&e.createVNode("div",e.mergeProps({ref:c,class:a.value,style:{zIndex:t.zIndex+1}},d),[(s=l.default)==null?void 0:s.call(l)])]}})]})}});function k(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!e.isVNode(t)}const g={modelValue:!1,content:"",zIndex:1e3,showOverlay:!0,escKeyCloseable:!0,position:"right",lockScroll:!0,closeOnClickOverlay:!0};function D(t){const n=document.createElement("div"),l=t.content;delete t.content;const d=e.createApp({setup(){const c=()=>{t.modelValue=!1};return e.onUnmounted(()=>{console.log(111),document.body.removeChild(n)}),()=>e.createVNode(i,e.mergeProps(t,{"onUpdate:modelValue":c}),k(l)?l:{default:()=>[l]})}});return document.body.appendChild(n),d.mount(n),d}class y{open(n){const l=e.reactive(f(f({},g),n)),d=D(l);return l.modelValue=!0,{close:()=>{l.modelValue=!1,d.unmount()}}}}var S={title:"Drawer \u62BD\u5C49\u677F",category:"\u53CD\u9988",status:"75%",install(t){t.component(i.name,i),t.config.globalProperties.$drawerService=new y}};o.Drawer=i,o.DrawerService=y,o.default=S,Object.defineProperty(o,"__esModule",{value:!0}),o[Symbol.toStringTag]="Module"});
|