vue-devui 1.0.0-beta.8 → 1.0.0-rc.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/README.md +81 -66
- package/accordion/index.es.js +522 -39
- package/accordion/index.umd.js +1 -1
- package/accordion/style.css +1 -1
- package/alert/index.es.js +6 -7
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/{toast → auto-complete}/index.d.ts +0 -0
- package/auto-complete/index.es.js +976 -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 +1 -1
- package/back-top/index.umd.js +1 -1
- package/badge/index.es.js +12 -18
- package/badge/index.umd.js +1 -1
- package/button/index.es.js +262 -82
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/carousel/index.es.js +7 -6
- package/carousel/index.umd.js +1 -1
- package/cascader/index.es.js +5392 -772
- package/cascader/index.umd.js +27 -1
- package/checkbox/style.css +1 -1
- package/color-picker/index.d.ts +7 -0
- package/color-picker/index.es.js +8187 -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 -18
- package/countdown/index.umd.js +1 -1
- package/countdown/style.css +1 -1
- package/date-picker/index.es.js +10 -11
- 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 +408 -300
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +275 -5610
- package/editable-select/index.umd.js +1 -27
- package/editable-select/style.css +1 -1
- package/form/index.es.js +6129 -461
- package/form/index.umd.js +27 -1
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +110 -118
- 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 +2 -1
- package/icon/index.umd.js +1 -1
- package/image-preview/index.es.js +77 -19
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +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 +6 -6
- package/input-icon/index.umd.js +1 -1
- package/input-icon/style.css +1 -1
- package/input-number/index.es.js +2 -1
- package/input-number/index.umd.js +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 +293 -759
- 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 +286 -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/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/TimeAxis.js +3 -0
- package/nuxt/components/TimeAxisItem.js +3 -0
- package/nuxt/components/TimePicker.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/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/notificationProps.js +3 -0
- package/nuxt/components/overlayEmits.js +3 -0
- package/nuxt/components/overlayProps.js +3 -0
- package/nuxt/components/popoverProps.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 +142 -198
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +10 -18
- package/pagination/index.es.js +1 -1
- package/pagination/style.css +1 -1
- package/panel/index.es.js +3 -3
- package/panel/index.umd.js +1 -1
- package/popover/index.es.js +5947 -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 +5 -5
- package/radio/index.umd.js +1 -1
- package/radio/style.css +1 -1
- package/read-tip/index.es.js +17 -4
- package/read-tip/index.umd.js +1 -1
- package/read-tip/style.css +1 -1
- package/result/index.es.js +2 -1
- package/result/index.umd.js +1 -1
- package/ripple/index.es.js +1 -1
- package/search/index.es.js +5432 -198
- package/search/index.umd.js +27 -1
- package/search/style.css +1 -1
- package/select/index.es.js +3 -2
- package/select/index.umd.js +1 -1
- package/select/style.css +1 -1
- package/slider/index.es.js +2 -5
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +5881 -36
- package/splitter/index.umd.js +27 -1
- package/splitter/style.css +1 -1
- package/statistic/index.d.ts +7 -0
- package/statistic/index.es.js +267 -0
- package/statistic/index.umd.js +1 -0
- package/statistic/package.json +7 -0
- package/statistic/style.css +1 -0
- package/status/index.es.js +1 -1
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/steps-guide/index.es.js +8 -6
- package/steps-guide/index.umd.js +1 -1
- package/sticky/index.umd.js +1 -1
- package/style.css +1 -1
- package/table/index.es.js +698 -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 +2 -2
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/tag-input/index.es.js +0 -12
- package/tag-input/index.umd.js +1 -1
- package/textarea/style.css +1 -1
- package/{theme → theme/theme.scss} +0 -0
- package/time-axis/index.es.js +2 -1
- package/time-axis/index.umd.js +1 -1
- package/time-picker/index.es.js +269 -84
- package/time-picker/index.umd.js +1 -1
- package/time-picker/style.css +1 -1
- package/tooltip/index.es.js +5798 -141
- package/tooltip/index.umd.js +27 -1
- package/tooltip/style.css +1 -1
- package/transfer/index.es.js +6522 -635
- package/transfer/index.umd.js +27 -1
- package/transfer/style.css +1 -1
- package/tree/index.es.js +5775 -192
- package/tree/index.umd.js +27 -1
- package/tree/style.css +1 -1
- package/tree-select/index.es.js +130 -35
- package/tree-select/index.umd.js +1 -1
- package/tree-select/style.css +1 -1
- package/upload/index.es.js +463 -2680
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +14630 -14010
- package/vue-devui.umd.js +18 -18
- package/toast/index.es.js +0 -2059
- package/toast/index.umd.js +0 -1
- package/toast/style.css +0 -1
|
@@ -0,0 +1,976 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __publicField = (obj, key, value) => {
|
|
18
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
19
|
+
return value;
|
|
20
|
+
};
|
|
21
|
+
import { ref, nextTick, defineComponent, createVNode, h, render, inject, withDirectives, createTextVNode, resolveDirective, vShow, watch, onUnmounted, unref, mergeProps, toRefs, provide, reactive, isVNode, Transition } from "vue";
|
|
22
|
+
import { offset, autoPlacement, arrow, computePosition } from "@floating-ui/dom";
|
|
23
|
+
const defaultFormatter = (item) => item ? item.label || item.toString() : "";
|
|
24
|
+
const defaultValueParse = (item) => item;
|
|
25
|
+
const autoCompleteProps = {
|
|
26
|
+
modelValue: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: ""
|
|
29
|
+
},
|
|
30
|
+
source: {
|
|
31
|
+
type: Array,
|
|
32
|
+
default: null
|
|
33
|
+
},
|
|
34
|
+
allowEmptyValueSearch: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
38
|
+
appendToBody: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: false
|
|
41
|
+
},
|
|
42
|
+
appendToBodyDirections: {
|
|
43
|
+
type: Object,
|
|
44
|
+
default: () => ({
|
|
45
|
+
originX: "left",
|
|
46
|
+
originY: "bottom",
|
|
47
|
+
overlayX: "left",
|
|
48
|
+
overlayY: "top"
|
|
49
|
+
})
|
|
50
|
+
},
|
|
51
|
+
disabled: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: false
|
|
54
|
+
},
|
|
55
|
+
delay: {
|
|
56
|
+
type: Number,
|
|
57
|
+
default: 300
|
|
58
|
+
},
|
|
59
|
+
disabledKey: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: null
|
|
62
|
+
},
|
|
63
|
+
formatter: {
|
|
64
|
+
type: Function,
|
|
65
|
+
default: defaultFormatter
|
|
66
|
+
},
|
|
67
|
+
isSearching: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: false
|
|
70
|
+
},
|
|
71
|
+
sceneType: {
|
|
72
|
+
type: String,
|
|
73
|
+
default: null
|
|
74
|
+
},
|
|
75
|
+
searchFn: {
|
|
76
|
+
type: Function,
|
|
77
|
+
default: null
|
|
78
|
+
},
|
|
79
|
+
tipsText: {
|
|
80
|
+
type: String,
|
|
81
|
+
default: "\u6700\u8FD1\u8F93\u5165"
|
|
82
|
+
},
|
|
83
|
+
latestSource: {
|
|
84
|
+
type: Array,
|
|
85
|
+
default: null
|
|
86
|
+
},
|
|
87
|
+
valueParser: {
|
|
88
|
+
type: Function,
|
|
89
|
+
default: defaultValueParse
|
|
90
|
+
},
|
|
91
|
+
enableLazyLoad: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: false
|
|
94
|
+
},
|
|
95
|
+
dAutoCompleteWidth: {
|
|
96
|
+
type: Number,
|
|
97
|
+
default: null
|
|
98
|
+
},
|
|
99
|
+
showAnimation: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
default: true
|
|
102
|
+
},
|
|
103
|
+
maxHeight: {
|
|
104
|
+
type: Number,
|
|
105
|
+
default: 300
|
|
106
|
+
},
|
|
107
|
+
transInputFocusEmit: {
|
|
108
|
+
type: Function,
|
|
109
|
+
default: null
|
|
110
|
+
},
|
|
111
|
+
selectValue: {
|
|
112
|
+
type: Function,
|
|
113
|
+
default: null
|
|
114
|
+
},
|
|
115
|
+
loadMore: {
|
|
116
|
+
type: Function,
|
|
117
|
+
default: null
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const DropdownPropsKey = Symbol("DropdownPropsKey");
|
|
121
|
+
function useCustomTemplate(ctx2, modelValue) {
|
|
122
|
+
const itemTemplate = (item, index2) => {
|
|
123
|
+
const arr = { item, index: index2 };
|
|
124
|
+
if (ctx2.slots.itemTemplate) {
|
|
125
|
+
return ctx2.slots.itemTemplate(arr);
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
};
|
|
129
|
+
const noResultItemTemplate = () => {
|
|
130
|
+
if (ctx2.slots.noResultItemTemplate) {
|
|
131
|
+
return ctx2.slots.noResultItemTemplate(modelValue.value);
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
};
|
|
135
|
+
const searchingTemplate = () => {
|
|
136
|
+
if (ctx2.slots.searchingTemplate) {
|
|
137
|
+
return ctx2.slots.searchingTemplate(modelValue.value);
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
};
|
|
141
|
+
const customRenderSolts = () => {
|
|
142
|
+
const slots = {};
|
|
143
|
+
if (ctx2.slots.itemTemplate) {
|
|
144
|
+
slots["itemTemplate"] = itemTemplate;
|
|
145
|
+
}
|
|
146
|
+
if (ctx2.slots.noResultItemTemplate) {
|
|
147
|
+
slots["noResultItemTemplate"] = noResultItemTemplate;
|
|
148
|
+
}
|
|
149
|
+
if (ctx2.slots.searchingTemplate) {
|
|
150
|
+
slots["searchingTemplate"] = searchingTemplate;
|
|
151
|
+
}
|
|
152
|
+
return slots;
|
|
153
|
+
};
|
|
154
|
+
return { customRenderSolts };
|
|
155
|
+
}
|
|
156
|
+
function useSearchFn(ctx2, allowEmptyValueSearch, source, searchFn, formatter) {
|
|
157
|
+
const searchList = ref([]);
|
|
158
|
+
const showNoResultItemTemplate = ref(false);
|
|
159
|
+
const handleSearch = async (term, enableLazyLoad) => {
|
|
160
|
+
if (term == "" && !allowEmptyValueSearch.value) {
|
|
161
|
+
searchList.value = [];
|
|
162
|
+
showNoResultItemTemplate.value = false;
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
let arr = [];
|
|
166
|
+
term = term.toLowerCase();
|
|
167
|
+
if (enableLazyLoad) {
|
|
168
|
+
arr = source.value;
|
|
169
|
+
} else if (!searchFn.value) {
|
|
170
|
+
source.value.forEach((item) => {
|
|
171
|
+
let cur = formatter.value(item);
|
|
172
|
+
cur = cur.toLowerCase();
|
|
173
|
+
if (cur.startsWith(term)) {
|
|
174
|
+
arr.push(item);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
} else {
|
|
178
|
+
arr = await searchFn.value(term);
|
|
179
|
+
}
|
|
180
|
+
searchList.value = arr;
|
|
181
|
+
if (searchList.value.length == 0) {
|
|
182
|
+
showNoResultItemTemplate.value = true;
|
|
183
|
+
} else {
|
|
184
|
+
showNoResultItemTemplate.value = false;
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
const recentlyFocus = (latestSource) => {
|
|
188
|
+
if (latestSource) {
|
|
189
|
+
searchList.value = latestSource;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
return {
|
|
193
|
+
handleSearch,
|
|
194
|
+
recentlyFocus,
|
|
195
|
+
searchList,
|
|
196
|
+
showNoResultItemTemplate
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function useInputHandle(ctx2, searchList, showNoResultItemTemplate, modelValue, disabled, delay, handleSearch, transInputFocusEmit, recentlyFocus, latestSource) {
|
|
200
|
+
const visible = ref(false);
|
|
201
|
+
const inputRef = ref();
|
|
202
|
+
const searchStatus = ref(false);
|
|
203
|
+
const debounce = (cb, time) => {
|
|
204
|
+
let timer;
|
|
205
|
+
return (...args) => {
|
|
206
|
+
if (timer) {
|
|
207
|
+
clearTimeout(timer);
|
|
208
|
+
}
|
|
209
|
+
timer = setTimeout(async () => {
|
|
210
|
+
searchStatus.value = true;
|
|
211
|
+
await cb(...args);
|
|
212
|
+
searchStatus.value = false;
|
|
213
|
+
}, time);
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
const onInputCb = async (value) => {
|
|
217
|
+
await handleSearch(value);
|
|
218
|
+
visible.value = true;
|
|
219
|
+
};
|
|
220
|
+
const onInputDebounce = debounce(onInputCb, delay.value);
|
|
221
|
+
const onInput = (e) => {
|
|
222
|
+
const inp = e.target;
|
|
223
|
+
searchStatus.value = false;
|
|
224
|
+
showNoResultItemTemplate.value = false;
|
|
225
|
+
ctx2.emit("update:modelValue", inp.value);
|
|
226
|
+
onInputDebounce(inp.value);
|
|
227
|
+
};
|
|
228
|
+
const onFocus = () => {
|
|
229
|
+
handleSearch(modelValue.value);
|
|
230
|
+
recentlyFocus(latestSource.value);
|
|
231
|
+
transInputFocusEmit.value && transInputFocusEmit.value();
|
|
232
|
+
};
|
|
233
|
+
const handleClose = () => {
|
|
234
|
+
visible.value = false;
|
|
235
|
+
searchStatus.value = false;
|
|
236
|
+
showNoResultItemTemplate.value = false;
|
|
237
|
+
};
|
|
238
|
+
const toggleMenu = () => {
|
|
239
|
+
if (!disabled.value) {
|
|
240
|
+
if (visible.value) {
|
|
241
|
+
handleClose();
|
|
242
|
+
} else {
|
|
243
|
+
visible.value = true;
|
|
244
|
+
if (ctx2.slots.noResultItemTemplate && searchList.value.length == 0 && modelValue.value.trim() != "") {
|
|
245
|
+
showNoResultItemTemplate.value = true;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
return {
|
|
251
|
+
handleClose,
|
|
252
|
+
toggleMenu,
|
|
253
|
+
onInput,
|
|
254
|
+
onFocus,
|
|
255
|
+
inputRef,
|
|
256
|
+
visible,
|
|
257
|
+
searchStatus
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function useSelectHandle(ctx2, searchList, selectValue, handleSearch, formatter, handleClose) {
|
|
261
|
+
const selectedIndex = ref(0);
|
|
262
|
+
const getListIndex = (item) => {
|
|
263
|
+
if (searchList.value.length == 0) {
|
|
264
|
+
return 0;
|
|
265
|
+
}
|
|
266
|
+
const ind = searchList.value.indexOf(item);
|
|
267
|
+
return ind == -1 ? 0 : ind;
|
|
268
|
+
};
|
|
269
|
+
const selectOptionClick = async (item) => {
|
|
270
|
+
const cur = formatter.value(item);
|
|
271
|
+
ctx2.emit("update:modelValue", cur);
|
|
272
|
+
handleClose();
|
|
273
|
+
await handleSearch(cur);
|
|
274
|
+
selectedIndex.value = getListIndex(cur);
|
|
275
|
+
selectValue.value && selectValue.value();
|
|
276
|
+
};
|
|
277
|
+
return {
|
|
278
|
+
selectedIndex,
|
|
279
|
+
selectOptionClick
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function useLazyHandle(props, ctx2, handleSearch) {
|
|
283
|
+
const showLoading = ref(false);
|
|
284
|
+
const dropDownRef = ref();
|
|
285
|
+
const loadMore = () => {
|
|
286
|
+
if (!props.enableLazyLoad && showLoading)
|
|
287
|
+
return;
|
|
288
|
+
const dropDownValue = dropDownRef.value;
|
|
289
|
+
const height = dropDownValue.scrollHeight;
|
|
290
|
+
const scrollTop = dropDownValue.clientHeight + dropDownValue.scrollTop;
|
|
291
|
+
if (scrollTop >= height && scrollTop >= props.maxHeight) {
|
|
292
|
+
props.loadMore();
|
|
293
|
+
showLoading.value = true;
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
ctx2.expose({ loadFinish });
|
|
297
|
+
async function loadFinish() {
|
|
298
|
+
await handleSearch(props.modelValue, props.enableLazyLoad);
|
|
299
|
+
showLoading.value = false;
|
|
300
|
+
}
|
|
301
|
+
return {
|
|
302
|
+
showLoading,
|
|
303
|
+
dropDownRef,
|
|
304
|
+
loadMore
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
function useKeyBoardHandle(dropDownRef, visible, searchList, selectedIndex, searchStatus, showNoResultItemTemplate, selectOptionClick, handleClose) {
|
|
308
|
+
var _a;
|
|
309
|
+
const hoverIndex = ref((_a = selectedIndex.value) != null ? _a : 0);
|
|
310
|
+
const scrollToActive = (index2) => {
|
|
311
|
+
const ul = dropDownRef.value;
|
|
312
|
+
const li = ul.children[index2];
|
|
313
|
+
nextTick(() => {
|
|
314
|
+
if (li.scrollIntoViewIfNeeded) {
|
|
315
|
+
li.scrollIntoViewIfNeeded(false);
|
|
316
|
+
} else {
|
|
317
|
+
const containerInfo = ul.getBoundingClientRect();
|
|
318
|
+
const elementInfo = li.getBoundingClientRect();
|
|
319
|
+
if (elementInfo.bottom > containerInfo.bottom || elementInfo.top < containerInfo.top) {
|
|
320
|
+
li.scrollIntoView(false);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
const handlekeyDown = (e) => {
|
|
326
|
+
var _a2;
|
|
327
|
+
const keyCode = e.key || e.code;
|
|
328
|
+
if (keyCode === "Escape" && (visible.value && searchList.value.length || searchStatus.value || showNoResultItemTemplate.value)) {
|
|
329
|
+
handleClose();
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const status = visible.value && searchList.value.length && !searchStatus.value && !showNoResultItemTemplate.value;
|
|
333
|
+
if (keyCode === "ArrowDown" && status) {
|
|
334
|
+
if (hoverIndex.value === searchList.value.length - 1) {
|
|
335
|
+
hoverIndex.value = 0;
|
|
336
|
+
scrollToActive(hoverIndex.value);
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
hoverIndex.value = hoverIndex.value + 1;
|
|
340
|
+
scrollToActive(hoverIndex.value);
|
|
341
|
+
} else if (keyCode === "ArrowUp" && status) {
|
|
342
|
+
if (hoverIndex.value === 0) {
|
|
343
|
+
hoverIndex.value = searchList.value.length - 1;
|
|
344
|
+
scrollToActive(hoverIndex.value);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
hoverIndex.value = hoverIndex.value - 1;
|
|
348
|
+
scrollToActive(hoverIndex.value);
|
|
349
|
+
}
|
|
350
|
+
if (keyCode === "Enter" && status) {
|
|
351
|
+
selectOptionClick(searchList.value[hoverIndex.value]);
|
|
352
|
+
hoverIndex.value = (_a2 = selectedIndex.value) != null ? _a2 : 0;
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
return {
|
|
357
|
+
hoverIndex,
|
|
358
|
+
handlekeyDown
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
var autoComplete = "";
|
|
362
|
+
class View {
|
|
363
|
+
constructor() {
|
|
364
|
+
__publicField(this, "top", "50%");
|
|
365
|
+
__publicField(this, "left", "50%");
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
const componentProps = {
|
|
369
|
+
message: String,
|
|
370
|
+
backdrop: Boolean,
|
|
371
|
+
view: {
|
|
372
|
+
type: Object,
|
|
373
|
+
default: () => new View()
|
|
374
|
+
},
|
|
375
|
+
zIndex: Number,
|
|
376
|
+
isFull: {
|
|
377
|
+
type: Boolean,
|
|
378
|
+
default: false
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
class LoadingProps {
|
|
382
|
+
constructor() {
|
|
383
|
+
__publicField(this, "target");
|
|
384
|
+
__publicField(this, "message");
|
|
385
|
+
__publicField(this, "loadingTemplateRef");
|
|
386
|
+
__publicField(this, "backdrop", true);
|
|
387
|
+
__publicField(this, "positionType", "relative");
|
|
388
|
+
__publicField(this, "view", new View());
|
|
389
|
+
__publicField(this, "zIndex");
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
var loading = "";
|
|
393
|
+
var Loading = defineComponent({
|
|
394
|
+
name: "DLoading",
|
|
395
|
+
inheritAttrs: false,
|
|
396
|
+
props: componentProps,
|
|
397
|
+
setup(props) {
|
|
398
|
+
const style = {
|
|
399
|
+
top: props.view.top,
|
|
400
|
+
left: props.view.left,
|
|
401
|
+
zIndex: props.zIndex
|
|
402
|
+
};
|
|
403
|
+
if (!props.message) {
|
|
404
|
+
style.background = "none";
|
|
405
|
+
}
|
|
406
|
+
const isShow = ref(false);
|
|
407
|
+
const open = () => {
|
|
408
|
+
isShow.value = true;
|
|
409
|
+
};
|
|
410
|
+
const close = () => {
|
|
411
|
+
isShow.value = false;
|
|
412
|
+
};
|
|
413
|
+
return {
|
|
414
|
+
style,
|
|
415
|
+
isShow,
|
|
416
|
+
open,
|
|
417
|
+
close
|
|
418
|
+
};
|
|
419
|
+
},
|
|
420
|
+
render() {
|
|
421
|
+
var _a;
|
|
422
|
+
const {
|
|
423
|
+
isShow,
|
|
424
|
+
isFull,
|
|
425
|
+
backdrop,
|
|
426
|
+
style,
|
|
427
|
+
message,
|
|
428
|
+
$slots
|
|
429
|
+
} = this;
|
|
430
|
+
return isShow && createVNode("div", {
|
|
431
|
+
"class": ["devui-loading-contanier", isFull ? "devui-loading--full" : ""]
|
|
432
|
+
}, [((_a = $slots.default) == null ? void 0 : _a.call($slots)) || createVNode("div", {
|
|
433
|
+
"class": "devui-loading-wrapper"
|
|
434
|
+
}, [backdrop ? createVNode("div", {
|
|
435
|
+
"class": "devui-loading-mask"
|
|
436
|
+
}, null) : null, createVNode("div", {
|
|
437
|
+
"style": style,
|
|
438
|
+
"class": "devui-loading-area"
|
|
439
|
+
}, [createVNode("div", {
|
|
440
|
+
"class": "devui-busy-default-spinner"
|
|
441
|
+
}, [createVNode("div", {
|
|
442
|
+
"class": "devui-loading-bar1"
|
|
443
|
+
}, null), createVNode("div", {
|
|
444
|
+
"class": "devui-loading-bar2"
|
|
445
|
+
}, null), createVNode("div", {
|
|
446
|
+
"class": "devui-loading-bar3"
|
|
447
|
+
}, null), createVNode("div", {
|
|
448
|
+
"class": "devui-loading-bar4"
|
|
449
|
+
}, null)]), message ? createVNode("span", {
|
|
450
|
+
"class": "devui-loading-text"
|
|
451
|
+
}, [message]) : null])])]);
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
const COMPONENT_CONTAINER_SYMBOL = Symbol("dev_component_container");
|
|
455
|
+
function createComponent(Component, props, children = null) {
|
|
456
|
+
const vnode = h(Component, __spreadValues({}, props), children);
|
|
457
|
+
const container = document.createElement("div");
|
|
458
|
+
vnode[COMPONENT_CONTAINER_SYMBOL] = container;
|
|
459
|
+
render(vnode, container);
|
|
460
|
+
return vnode.component;
|
|
461
|
+
}
|
|
462
|
+
function unmountComponent(ComponnetInstance) {
|
|
463
|
+
render(null, ComponnetInstance == null ? void 0 : ComponnetInstance.vnode[COMPONENT_CONTAINER_SYMBOL]);
|
|
464
|
+
}
|
|
465
|
+
const loadingConstructor = defineComponent(Loading);
|
|
466
|
+
const cacheInstance = /* @__PURE__ */ new WeakSet();
|
|
467
|
+
const isEmpty = (val) => {
|
|
468
|
+
if (!val)
|
|
469
|
+
return true;
|
|
470
|
+
if (Array.isArray(val))
|
|
471
|
+
return val.length === 0;
|
|
472
|
+
if (val instanceof Set || val instanceof Map)
|
|
473
|
+
return val.size === 0;
|
|
474
|
+
if (val instanceof Promise)
|
|
475
|
+
return false;
|
|
476
|
+
if (typeof val === "object") {
|
|
477
|
+
try {
|
|
478
|
+
return Object.keys(val).length === 0;
|
|
479
|
+
} catch (e) {
|
|
480
|
+
return false;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
return false;
|
|
484
|
+
};
|
|
485
|
+
const getType = (vari) => {
|
|
486
|
+
return Object.prototype.toString.call(vari).slice(8, -1).toLowerCase();
|
|
487
|
+
};
|
|
488
|
+
const isPromise = (value) => {
|
|
489
|
+
const type = getType(value);
|
|
490
|
+
switch (type) {
|
|
491
|
+
case "promise":
|
|
492
|
+
return [value];
|
|
493
|
+
case "array":
|
|
494
|
+
if (value.some((val) => getType(val) !== "promise")) {
|
|
495
|
+
console.error(new TypeError("Binding values should all be of type Promise"));
|
|
496
|
+
return "error";
|
|
497
|
+
}
|
|
498
|
+
return value;
|
|
499
|
+
default:
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
const unmount = (el) => {
|
|
504
|
+
cacheInstance.delete(el);
|
|
505
|
+
el.instance.proxy.close();
|
|
506
|
+
unmountComponent(el.instance);
|
|
507
|
+
};
|
|
508
|
+
const toggleLoading = (el, binding) => {
|
|
509
|
+
if (binding.value) {
|
|
510
|
+
const vals = isPromise(binding.value);
|
|
511
|
+
if (vals === "error")
|
|
512
|
+
return;
|
|
513
|
+
el.instance.proxy.open();
|
|
514
|
+
el.appendChild(el.mask);
|
|
515
|
+
cacheInstance.add(el);
|
|
516
|
+
if (vals) {
|
|
517
|
+
Promise.all(vals).catch((err) => {
|
|
518
|
+
console.error(new Error("Promise handling errors"), err);
|
|
519
|
+
}).finally(() => {
|
|
520
|
+
unmount(el);
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
} else {
|
|
524
|
+
unmount(el);
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
const removeAttribute = (el) => {
|
|
528
|
+
el.removeAttribute("zindex");
|
|
529
|
+
el.removeAttribute("positiontype");
|
|
530
|
+
el.removeAttribute("backdrop");
|
|
531
|
+
el.removeAttribute("message");
|
|
532
|
+
el.removeAttribute("view");
|
|
533
|
+
el.removeAttribute("loadingtemplateref");
|
|
534
|
+
};
|
|
535
|
+
const handleProps = (el, vprops) => {
|
|
536
|
+
const props = __spreadValues(__spreadValues({}, new LoadingProps()), vprops);
|
|
537
|
+
const loadingTemplateRef = props.loadingTemplateRef;
|
|
538
|
+
const loadingInstance = createComponent(loadingConstructor, __spreadValues({}, props), loadingTemplateRef ? () => loadingTemplateRef : null);
|
|
539
|
+
el.style.position = props.positionType;
|
|
540
|
+
el.options = props;
|
|
541
|
+
el.instance = loadingInstance;
|
|
542
|
+
el.mask = loadingInstance.proxy.$el;
|
|
543
|
+
};
|
|
544
|
+
const loadingDirective = {
|
|
545
|
+
mounted: function(el, binding, vnode) {
|
|
546
|
+
handleProps(el, vnode.props);
|
|
547
|
+
removeAttribute(el);
|
|
548
|
+
!isEmpty(binding.value) && toggleLoading(el, binding);
|
|
549
|
+
},
|
|
550
|
+
updated: function(el, binding, vnode) {
|
|
551
|
+
if (!isEmpty(binding.value) && cacheInstance.has(el) || isEmpty(binding.value) && !cacheInstance.has(el))
|
|
552
|
+
return;
|
|
553
|
+
!cacheInstance.has(el) && handleProps(el, vnode.props);
|
|
554
|
+
removeAttribute(el);
|
|
555
|
+
toggleLoading(el, binding);
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
var DAutoCompleteDropdown = defineComponent({
|
|
559
|
+
name: "DAutoCompleteDropdown",
|
|
560
|
+
directives: {
|
|
561
|
+
dLoading: loadingDirective
|
|
562
|
+
},
|
|
563
|
+
setup(props, ctx2) {
|
|
564
|
+
const propsData = inject(DropdownPropsKey);
|
|
565
|
+
const {
|
|
566
|
+
visible,
|
|
567
|
+
selectedIndex,
|
|
568
|
+
selectOptionClick,
|
|
569
|
+
searchList,
|
|
570
|
+
searchStatus,
|
|
571
|
+
dropDownRef,
|
|
572
|
+
loadMore,
|
|
573
|
+
showLoading,
|
|
574
|
+
showNoResultItemTemplate,
|
|
575
|
+
latestSource,
|
|
576
|
+
modelValue,
|
|
577
|
+
hoverIndex
|
|
578
|
+
} = propsData;
|
|
579
|
+
const {
|
|
580
|
+
disabled,
|
|
581
|
+
maxHeight,
|
|
582
|
+
appendToBody,
|
|
583
|
+
formatter,
|
|
584
|
+
disabledKey,
|
|
585
|
+
isSearching
|
|
586
|
+
} = propsData.props;
|
|
587
|
+
const onSelect = (item) => {
|
|
588
|
+
if (item[disabledKey]) {
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
selectOptionClick(item);
|
|
592
|
+
};
|
|
593
|
+
return () => {
|
|
594
|
+
return withDirectives(createVNode("div", {
|
|
595
|
+
"class": ["devui-dropdown-menu", appendToBody && "devui-dropdown-menu-cdk", disabled && "disabled", latestSource.value && "devui-dropdown-latestSource"]
|
|
596
|
+
}, [createVNode("ul", {
|
|
597
|
+
"ref": dropDownRef,
|
|
598
|
+
"class": "devui-list-unstyled scroll-height",
|
|
599
|
+
"style": {
|
|
600
|
+
maxHeight: `${maxHeight}px`
|
|
601
|
+
},
|
|
602
|
+
"onScroll": loadMore
|
|
603
|
+
}, [isSearching && ctx2.slots.searchingTemplate && searchStatus.value && createVNode("li", {
|
|
604
|
+
"class": "devui-is-searching-template"
|
|
605
|
+
}, [createVNode("div", {
|
|
606
|
+
"class": "devui-no-data-tip"
|
|
607
|
+
}, [ctx2.slots.searchingTemplate()])]), latestSource.value && !modelValue.value && createVNode("li", {
|
|
608
|
+
"class": "devui-popup-tips"
|
|
609
|
+
}, [createTextVNode("\u6700\u8FD1\u8F93\u5165")]), !showNoResultItemTemplate.value && !searchStatus.value && searchList != null && searchList.value.length > 0 && searchList.value.map((item, index2) => {
|
|
610
|
+
return createVNode("li", {
|
|
611
|
+
"onClick": () => onSelect(item),
|
|
612
|
+
"class": ["devui-dropdown-item", selectedIndex.value == index2 && "selected", {
|
|
613
|
+
"disabled": disabledKey && item[disabledKey]
|
|
614
|
+
}, {
|
|
615
|
+
"devui-dropdown-bg": hoverIndex.value == index2
|
|
616
|
+
}],
|
|
617
|
+
"title": formatter(item),
|
|
618
|
+
"key": formatter(item)
|
|
619
|
+
}, [ctx2.slots.itemTemplate ? ctx2.slots.itemTemplate(item, index2) : formatter(item)]);
|
|
620
|
+
}), !searchStatus.value && searchList.value.length == 0 && ctx2.slots.noResultItemTemplate && showNoResultItemTemplate.value && createVNode("li", {
|
|
621
|
+
"class": "devui-no-result-template"
|
|
622
|
+
}, [createVNode("div", {
|
|
623
|
+
"class": "devui-no-data-tip"
|
|
624
|
+
}, [ctx2.slots.noResultItemTemplate()])])])]), [[resolveDirective("dLoading"), showLoading.value], [vShow, visible.value && searchList.value.length > 0 || ctx2.slots.noResultItemTemplate && showNoResultItemTemplate.value || isSearching && ctx2.slots.searchingTemplate && searchStatus.value]]);
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
const inBrowser = typeof window !== "undefined";
|
|
629
|
+
function on(element, eventName, handler) {
|
|
630
|
+
if (document.addEventListener) {
|
|
631
|
+
if (element && eventName && handler) {
|
|
632
|
+
element.addEventListener(eventName, handler, false);
|
|
633
|
+
}
|
|
634
|
+
} else {
|
|
635
|
+
if (element && eventName && handler) {
|
|
636
|
+
element.attachEvent("on" + eventName, handler);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
const ctx = Symbol("@@clickoutside");
|
|
641
|
+
const nodeList = /* @__PURE__ */ new Map();
|
|
642
|
+
let startClick;
|
|
643
|
+
let nid = 0;
|
|
644
|
+
let isFirst = true;
|
|
645
|
+
function createDocumentHandler(el, binding, vnode) {
|
|
646
|
+
if (inBrowser && isFirst) {
|
|
647
|
+
isFirst = false;
|
|
648
|
+
on(document, "mousedown", (e) => {
|
|
649
|
+
startClick = e;
|
|
650
|
+
});
|
|
651
|
+
on(document, "mouseup", (e) => {
|
|
652
|
+
for (const [id, node] of nodeList) {
|
|
653
|
+
node[ctx].documentHandler(e, startClick);
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
return function(mouseup, mousedown) {
|
|
658
|
+
if (!vnode || !binding.instance || !mouseup.target || !mousedown.target || el.contains(mouseup.target) || el.contains(mousedown.target) || el === mouseup.target) {
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
el[ctx].bindingFn && el[ctx].bindingFn();
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
const clickoutsideDirective = {
|
|
665
|
+
beforeMount: function(el, binding, vnode) {
|
|
666
|
+
nid++;
|
|
667
|
+
nodeList.set(nid, el);
|
|
668
|
+
el[ctx] = {
|
|
669
|
+
nid,
|
|
670
|
+
documentHandler: createDocumentHandler(el, binding, vnode),
|
|
671
|
+
bindingFn: binding.value
|
|
672
|
+
};
|
|
673
|
+
},
|
|
674
|
+
updated: function(el, binding, vnode) {
|
|
675
|
+
el[ctx].documentHandler = createDocumentHandler(el, binding, vnode);
|
|
676
|
+
el[ctx].bindingFn = binding.value;
|
|
677
|
+
},
|
|
678
|
+
unmounted: function(el) {
|
|
679
|
+
nodeList.delete(el[ctx].nid);
|
|
680
|
+
delete el[ctx];
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
const flexibleOverlayProps = {
|
|
684
|
+
modelValue: {
|
|
685
|
+
type: Boolean,
|
|
686
|
+
default: false
|
|
687
|
+
},
|
|
688
|
+
origin: {
|
|
689
|
+
type: Object,
|
|
690
|
+
require: true
|
|
691
|
+
},
|
|
692
|
+
position: {
|
|
693
|
+
type: Array,
|
|
694
|
+
default: ["bottom"]
|
|
695
|
+
},
|
|
696
|
+
offset: {
|
|
697
|
+
type: [Number, Object],
|
|
698
|
+
default: 8
|
|
699
|
+
},
|
|
700
|
+
align: {
|
|
701
|
+
type: String,
|
|
702
|
+
default: null
|
|
703
|
+
},
|
|
704
|
+
showArrow: {
|
|
705
|
+
type: Boolean,
|
|
706
|
+
default: false
|
|
707
|
+
},
|
|
708
|
+
isArrowCenter: {
|
|
709
|
+
type: Boolean,
|
|
710
|
+
default: true
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
function getScrollParent(element) {
|
|
714
|
+
const overflowRegex = /(auto|scroll|hidden)/;
|
|
715
|
+
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
716
|
+
const style = window.getComputedStyle(parent);
|
|
717
|
+
if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
718
|
+
return parent;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return window;
|
|
722
|
+
}
|
|
723
|
+
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
724
|
+
let { x, y } = point;
|
|
725
|
+
if (!isArrowCenter) {
|
|
726
|
+
const { width, height } = originRect;
|
|
727
|
+
if (x && placement.includes("start")) {
|
|
728
|
+
x = 12;
|
|
729
|
+
}
|
|
730
|
+
if (x && placement.includes("end")) {
|
|
731
|
+
x = Math.round(width - 24);
|
|
732
|
+
}
|
|
733
|
+
if (y && placement.includes("start")) {
|
|
734
|
+
y = 10;
|
|
735
|
+
}
|
|
736
|
+
if (y && placement.includes("end")) {
|
|
737
|
+
y = height - 14;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
return { x, y };
|
|
741
|
+
}
|
|
742
|
+
function useOverlay(props, emit) {
|
|
743
|
+
const overlayRef = ref();
|
|
744
|
+
const arrowRef = ref();
|
|
745
|
+
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
746
|
+
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
747
|
+
const staticSide = {
|
|
748
|
+
top: "bottom",
|
|
749
|
+
right: "left",
|
|
750
|
+
bottom: "top",
|
|
751
|
+
left: "right"
|
|
752
|
+
}[placement.split("-")[0]];
|
|
753
|
+
Object.assign(arrowEl.style, {
|
|
754
|
+
left: x ? `${x}px` : "",
|
|
755
|
+
top: y ? `${y}px` : "",
|
|
756
|
+
right: "",
|
|
757
|
+
bottom: "",
|
|
758
|
+
[staticSide]: "-4px"
|
|
759
|
+
});
|
|
760
|
+
};
|
|
761
|
+
const updatePosition = async () => {
|
|
762
|
+
const hostEl = props.origin;
|
|
763
|
+
const overlayEl = unref(overlayRef.value);
|
|
764
|
+
const arrowEl = unref(arrowRef.value);
|
|
765
|
+
const middleware = [
|
|
766
|
+
offset(props.offset),
|
|
767
|
+
autoPlacement({
|
|
768
|
+
alignment: props.align,
|
|
769
|
+
allowedPlacements: props.position
|
|
770
|
+
})
|
|
771
|
+
];
|
|
772
|
+
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
773
|
+
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
774
|
+
strategy: "fixed",
|
|
775
|
+
middleware
|
|
776
|
+
});
|
|
777
|
+
emit("positionChange", placement);
|
|
778
|
+
Object.assign(overlayEl.style, { top: `${y}px`, left: `${x}px` });
|
|
779
|
+
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
780
|
+
};
|
|
781
|
+
watch(() => props.modelValue, () => {
|
|
782
|
+
const originParent = getScrollParent(props.origin);
|
|
783
|
+
if (props.modelValue && props.origin) {
|
|
784
|
+
nextTick(updatePosition);
|
|
785
|
+
originParent.addEventListener("scroll", updatePosition);
|
|
786
|
+
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
787
|
+
window.addEventListener("resize", updatePosition);
|
|
788
|
+
} else {
|
|
789
|
+
originParent.removeEventListener("scroll", updatePosition);
|
|
790
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
791
|
+
window.removeEventListener("resize", updatePosition);
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
onUnmounted(() => {
|
|
795
|
+
const originParent = getScrollParent(props.origin);
|
|
796
|
+
originParent.removeEventListener("scroll", updatePosition);
|
|
797
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
798
|
+
window.removeEventListener("resize", updatePosition);
|
|
799
|
+
});
|
|
800
|
+
return { arrowRef, overlayRef };
|
|
801
|
+
}
|
|
802
|
+
var flexibleOverlay = "";
|
|
803
|
+
const FlexibleOverlay = defineComponent({
|
|
804
|
+
name: "DFlexibleOverlay",
|
|
805
|
+
inheritAttrs: false,
|
|
806
|
+
props: flexibleOverlayProps,
|
|
807
|
+
emits: ["update:modelValue", "positionChange"],
|
|
808
|
+
setup(props, {
|
|
809
|
+
slots,
|
|
810
|
+
attrs,
|
|
811
|
+
emit
|
|
812
|
+
}) {
|
|
813
|
+
const {
|
|
814
|
+
arrowRef,
|
|
815
|
+
overlayRef
|
|
816
|
+
} = useOverlay(props, emit);
|
|
817
|
+
return () => {
|
|
818
|
+
var _a;
|
|
819
|
+
return props.modelValue && createVNode("div", mergeProps({
|
|
820
|
+
"ref": overlayRef,
|
|
821
|
+
"class": "devui-flexible-overlay"
|
|
822
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
823
|
+
"ref": arrowRef,
|
|
824
|
+
"class": "devui-flexible-overlay-arrow"
|
|
825
|
+
}, null)]);
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
function _isSlot(s) {
|
|
830
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
831
|
+
}
|
|
832
|
+
var AutoComplete = defineComponent({
|
|
833
|
+
name: "DAutoComplete",
|
|
834
|
+
directives: {
|
|
835
|
+
ClickOutside: clickoutsideDirective
|
|
836
|
+
},
|
|
837
|
+
props: autoCompleteProps,
|
|
838
|
+
emits: ["update:modelValue"],
|
|
839
|
+
setup(props, ctx2) {
|
|
840
|
+
const {
|
|
841
|
+
disabled,
|
|
842
|
+
modelValue,
|
|
843
|
+
appendToBody,
|
|
844
|
+
dAutoCompleteWidth,
|
|
845
|
+
delay,
|
|
846
|
+
allowEmptyValueSearch,
|
|
847
|
+
formatter,
|
|
848
|
+
transInputFocusEmit,
|
|
849
|
+
selectValue,
|
|
850
|
+
source,
|
|
851
|
+
searchFn,
|
|
852
|
+
appendToBodyDirections,
|
|
853
|
+
latestSource,
|
|
854
|
+
showAnimation
|
|
855
|
+
} = toRefs(props);
|
|
856
|
+
const {
|
|
857
|
+
handleSearch,
|
|
858
|
+
searchList,
|
|
859
|
+
showNoResultItemTemplate,
|
|
860
|
+
recentlyFocus
|
|
861
|
+
} = useSearchFn(ctx2, allowEmptyValueSearch, source, searchFn, formatter);
|
|
862
|
+
const {
|
|
863
|
+
onInput,
|
|
864
|
+
onFocus,
|
|
865
|
+
inputRef,
|
|
866
|
+
visible,
|
|
867
|
+
searchStatus,
|
|
868
|
+
handleClose,
|
|
869
|
+
toggleMenu
|
|
870
|
+
} = useInputHandle(ctx2, searchList, showNoResultItemTemplate, modelValue, disabled, delay, handleSearch, transInputFocusEmit, recentlyFocus, latestSource);
|
|
871
|
+
const {
|
|
872
|
+
selectedIndex,
|
|
873
|
+
selectOptionClick
|
|
874
|
+
} = useSelectHandle(ctx2, searchList, selectValue, handleSearch, formatter, handleClose);
|
|
875
|
+
const {
|
|
876
|
+
showLoading,
|
|
877
|
+
dropDownRef,
|
|
878
|
+
loadMore
|
|
879
|
+
} = useLazyHandle(props, ctx2, handleSearch);
|
|
880
|
+
const {
|
|
881
|
+
customRenderSolts
|
|
882
|
+
} = useCustomTemplate(ctx2, modelValue);
|
|
883
|
+
const {
|
|
884
|
+
hoverIndex,
|
|
885
|
+
handlekeyDown
|
|
886
|
+
} = useKeyBoardHandle(dropDownRef, visible, searchList, selectedIndex, searchStatus, showNoResultItemTemplate, selectOptionClick, handleClose);
|
|
887
|
+
provide(DropdownPropsKey, {
|
|
888
|
+
props,
|
|
889
|
+
visible,
|
|
890
|
+
term: "",
|
|
891
|
+
searchList,
|
|
892
|
+
selectedIndex,
|
|
893
|
+
searchStatus,
|
|
894
|
+
selectOptionClick,
|
|
895
|
+
dropDownRef,
|
|
896
|
+
showLoading,
|
|
897
|
+
loadMore,
|
|
898
|
+
latestSource,
|
|
899
|
+
modelValue,
|
|
900
|
+
showNoResultItemTemplate,
|
|
901
|
+
hoverIndex
|
|
902
|
+
});
|
|
903
|
+
const origin = ref();
|
|
904
|
+
const position = reactive({
|
|
905
|
+
appendToBodyDirections: {}
|
|
906
|
+
});
|
|
907
|
+
position.appendToBodyDirections = appendToBodyDirections;
|
|
908
|
+
const renderDropdown = () => {
|
|
909
|
+
if (appendToBody.value) {
|
|
910
|
+
let _slot;
|
|
911
|
+
return createVNode(FlexibleOverlay, {
|
|
912
|
+
"hasBackdrop": false,
|
|
913
|
+
"origin": origin,
|
|
914
|
+
"position": position.appendToBodyDirections,
|
|
915
|
+
"visible": visible.value,
|
|
916
|
+
"onUpdate:visible": ($event) => visible.value = $event
|
|
917
|
+
}, {
|
|
918
|
+
default: () => [createVNode("div", {
|
|
919
|
+
"class": "devui-dropdown devui-auto-complete-menu",
|
|
920
|
+
"style": {
|
|
921
|
+
width: dAutoCompleteWidth.value > 0 && dAutoCompleteWidth.value + "px"
|
|
922
|
+
}
|
|
923
|
+
}, [createVNode(DAutoCompleteDropdown, null, _isSlot(_slot = customRenderSolts()) ? _slot : {
|
|
924
|
+
default: () => [_slot]
|
|
925
|
+
})])]
|
|
926
|
+
});
|
|
927
|
+
} else {
|
|
928
|
+
let _slot2;
|
|
929
|
+
return createVNode("div", {
|
|
930
|
+
"class": "devui-dropdown",
|
|
931
|
+
"style": {
|
|
932
|
+
width: dAutoCompleteWidth.value > 0 && dAutoCompleteWidth.value + "px"
|
|
933
|
+
}
|
|
934
|
+
}, [createVNode(Transition, {
|
|
935
|
+
"name": showAnimation ? "fade" : ""
|
|
936
|
+
}, {
|
|
937
|
+
default: () => [createVNode(DAutoCompleteDropdown, null, _isSlot(_slot2 = customRenderSolts()) ? _slot2 : {
|
|
938
|
+
default: () => [_slot2]
|
|
939
|
+
})]
|
|
940
|
+
})]);
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
return () => {
|
|
944
|
+
return withDirectives(createVNode("div", {
|
|
945
|
+
"class": ["devui-auto-complete", "devui-form-group", "devui-has-feedback", visible.value && "devui-select-open"],
|
|
946
|
+
"ref": origin,
|
|
947
|
+
"style": {
|
|
948
|
+
width: dAutoCompleteWidth.value > 0 && dAutoCompleteWidth.value + "px"
|
|
949
|
+
}
|
|
950
|
+
}, [createVNode("input", {
|
|
951
|
+
"disabled": disabled.value,
|
|
952
|
+
"type": "text",
|
|
953
|
+
"onClick": toggleMenu,
|
|
954
|
+
"class": ["devui-form-control", "devui-dropdown-origin", "devui-dropdown-origin-open", disabled.value && "disabled"],
|
|
955
|
+
"placeholder": "Search",
|
|
956
|
+
"onInput": onInput,
|
|
957
|
+
"onFocus": onFocus,
|
|
958
|
+
"value": modelValue.value,
|
|
959
|
+
"ref": inputRef,
|
|
960
|
+
"onKeydown": handlekeyDown
|
|
961
|
+
}, null), renderDropdown()]), [[resolveDirective("click-outside"), handleClose]]);
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
});
|
|
965
|
+
AutoComplete.install = function(app) {
|
|
966
|
+
app.component(AutoComplete.name, AutoComplete);
|
|
967
|
+
};
|
|
968
|
+
var index = {
|
|
969
|
+
title: "AutoComplete \u81EA\u52A8\u8865\u5168",
|
|
970
|
+
category: "\u6570\u636E\u5F55\u5165",
|
|
971
|
+
status: "100%",
|
|
972
|
+
install(app) {
|
|
973
|
+
app.use(AutoComplete);
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
export { AutoComplete, index as default };
|