vue-openlayers-plugin 1.0.82 → 1.0.84
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/lib/BasemapPanel-1145a7ed.mjs +280 -0
- package/lib/CoordinateLocationDialog-be972ee5.mjs +263 -0
- package/lib/FilterPanel-9d55d20c.mjs +6 -0
- package/lib/LayerPanel-0272f4a3.mjs +6 -0
- package/lib/MapPrintDialog-3d0a2891.mjs +6 -0
- package/lib/MeasurementDialog-37a0bbb3.mjs +369 -0
- package/lib/MyMarkersDialog-61d5c30d.mjs +584 -0
- package/lib/RegionNavigationDialog-0808549f.mjs +1320 -0
- package/lib/ViewBookmarksDialog-107a29d1.mjs +723 -0
- package/lib/index-3d1e1ad0.mjs +839 -0
- package/lib/{index-61901e1f.mjs → index-6f94a7fa.mjs} +50494 -53897
- package/lib/index-91e9a4e6.mjs +756 -0
- package/lib/{index.es-c17b5917.mjs → index.es-03fbdea2.mjs} +1 -1
- package/lib/index.esm.js +65 -56
- package/lib/index.umd.js +73175 -71501
- package/lib/style.css +1705 -1704
- package/package.json +8 -4
- package/types/src/assets/index.d.ts +9 -0
- package/types/src/assets/index.d.ts.map +1 -0
- package/types/src/components/CustomDialog/CustomDialog.vue.d.ts +16 -16
- package/types/src/components/CustomDialog/icons/index.d.ts +14 -0
- package/types/src/components/CustomDialog/icons/index.d.ts.map +1 -0
- package/types/src/components/OlBaseLayerSwitcher.vue.d.ts +19 -0
- package/types/src/components/OlBaseLayerSwitcher.vue.d.ts.map +1 -0
- package/types/src/components/OlControlPanel.vue.d.ts +63 -0
- package/types/src/components/OlControlPanel.vue.d.ts.map +1 -0
- package/types/src/components/OlDialogs/BasemapPanel.vue.d.ts +20 -0
- package/types/src/components/OlDialogs/BasemapPanel.vue.d.ts.map +1 -0
- package/types/src/components/OlDialogs/CoordinateLocationDialog.vue.d.ts +21 -0
- package/types/src/components/OlDialogs/CoordinateLocationDialog.vue.d.ts.map +1 -0
- package/types/src/components/OlDialogs/DialogManager.d.ts +58 -0
- package/types/src/components/OlDialogs/DialogManager.d.ts.map +1 -0
- package/types/src/components/OlDialogs/FilterPanel.vue.d.ts +33 -0
- package/types/src/components/OlDialogs/FilterPanel.vue.d.ts.map +1 -0
- package/types/src/components/OlDialogs/LayerPanel.vue.d.ts +1345 -0
- package/types/src/components/OlDialogs/LayerPanel.vue.d.ts.map +1 -0
- package/types/src/components/OlDialogs/LayerStyleConfig.vue.d.ts +23 -0
- package/types/src/components/OlDialogs/LayerStyleConfig.vue.d.ts.map +1 -0
- package/types/src/components/OlDialogs/LayerTreeNode.vue.d.ts +28 -0
- package/types/src/components/OlDialogs/LayerTreeNode.vue.d.ts.map +1 -0
- package/types/src/components/OlDialogs/MapDrawingDialog/components/ListTab.vue.d.ts +3 -0
- package/types/src/components/OlDialogs/MapDrawingDialog/components/ListTab.vue.d.ts.map +1 -0
- package/types/src/components/OlDialogs/MapDrawingDialog/components/MarkTab.vue.d.ts +3 -0
- package/types/src/components/OlDialogs/MapDrawingDialog/components/MarkTab.vue.d.ts.map +1 -0
- package/types/src/components/OlDialogs/MapDrawingDialog/index.vue.d.ts +3 -0
- package/types/src/components/OlDialogs/MapDrawingDialog/index.vue.d.ts.map +1 -0
- package/types/src/components/OlDialogs/MapPrintDialog.vue.d.ts +24 -0
- package/types/src/components/OlDialogs/MapPrintDialog.vue.d.ts.map +1 -0
- package/types/src/components/OlDialogs/MeasurementDialog.vue.d.ts +41 -0
- package/types/src/components/OlDialogs/MeasurementDialog.vue.d.ts.map +1 -0
- package/types/src/components/OlDialogs/MyMarkersDialog.vue.d.ts +21 -0
- package/types/src/components/OlDialogs/MyMarkersDialog.vue.d.ts.map +1 -0
- package/types/src/components/OlDialogs/RegionNavigationDialog.vue.d.ts +25 -0
- package/types/src/components/OlDialogs/RegionNavigationDialog.vue.d.ts.map +1 -0
- package/types/src/components/OlDialogs/ViewBookmarksDialog.vue.d.ts +21 -0
- package/types/src/components/OlDialogs/ViewBookmarksDialog.vue.d.ts.map +1 -0
- package/types/src/components/OlDialogs/registry.d.ts +39 -0
- package/types/src/components/OlDialogs/registry.d.ts.map +1 -0
- package/types/src/components/OlDrawToolbar.vue.d.ts +61 -0
- package/types/src/components/OlDrawToolbar.vue.d.ts.map +1 -0
- package/types/src/components/OlLegendPanel.vue.d.ts +69 -0
- package/types/src/components/OlLegendPanel.vue.d.ts.map +1 -0
- package/types/src/components/OlMapContainer.vue.d.ts +112 -0
- package/types/src/components/OlMapContainer.vue.d.ts.map +1 -0
- package/types/src/components/OlMapPopup/ArrayPopup.vue.d.ts +47 -0
- package/types/src/components/OlMapPopup/ArrayPopup.vue.d.ts.map +1 -0
- package/types/src/components/OlMapPopup/BasePopup.vue.d.ts +63 -0
- package/types/src/components/OlMapPopup/BasePopup.vue.d.ts.map +1 -0
- package/types/src/components/OlMapPopup/HtmlPopup.vue.d.ts +45 -0
- package/types/src/components/OlMapPopup/HtmlPopup.vue.d.ts.map +1 -0
- package/types/src/components/OlMapPopup/ImagePopup.vue.d.ts +45 -0
- package/types/src/components/OlMapPopup/ImagePopup.vue.d.ts.map +1 -0
- package/types/src/components/OlMapPopup/index.d.ts +9 -0
- package/types/src/components/OlMapPopup/index.d.ts.map +1 -0
- package/types/src/components/OlMapPopup/types.d.ts +118 -0
- package/types/src/components/OlMapPopup/types.d.ts.map +1 -0
- package/types/src/components/OlMapSearch.vue.d.ts +126 -0
- package/types/src/components/OlMapSearch.vue.d.ts.map +1 -0
- package/types/src/components/OlMapTooltip.vue.d.ts +70 -0
- package/types/src/components/OlMapTooltip.vue.d.ts.map +1 -0
- package/types/src/core/EventBus.d.ts +66 -0
- package/types/src/core/EventBus.d.ts.map +1 -0
- package/types/src/core/EventManager.d.ts +147 -0
- package/types/src/core/EventManager.d.ts.map +1 -0
- package/types/src/core/FeatureHighlightManager.d.ts +103 -0
- package/types/src/core/FeatureHighlightManager.d.ts.map +1 -0
- package/types/src/core/GlobalStyleManager.d.ts +76 -0
- package/types/src/core/GlobalStyleManager.d.ts.map +1 -0
- package/types/src/core/LayerConfigManager.d.ts +66 -0
- package/types/src/core/LayerConfigManager.d.ts.map +1 -0
- package/types/src/core/LayerManager.d.ts +198 -0
- package/types/src/core/LayerManager.d.ts.map +1 -0
- package/types/src/core/LayerTreeManager.d.ts +125 -0
- package/types/src/core/LayerTreeManager.d.ts.map +1 -0
- package/types/src/core/MapManager.d.ts +203 -0
- package/types/src/core/MapManager.d.ts.map +1 -0
- package/types/src/core/MarkerDrawingAdapter.d.ts +125 -0
- package/types/src/core/MarkerDrawingAdapter.d.ts.map +1 -0
- package/types/src/core/PluginManager.d.ts +158 -0
- package/types/src/core/PluginManager.d.ts.map +1 -0
- package/types/src/core/PopupManager.d.ts +110 -0
- package/types/src/core/PopupManager.d.ts.map +1 -0
- package/types/src/core/SearchMarkerManager.d.ts +96 -0
- package/types/src/core/SearchMarkerManager.d.ts.map +1 -0
- package/types/src/core/TooltipHelper.d.ts +134 -0
- package/types/src/core/TooltipHelper.d.ts.map +1 -0
- package/types/src/core/amapSearchApi.d.ts +57 -0
- package/types/src/core/amapSearchApi.d.ts.map +1 -0
- package/types/src/core/basemapManager.d.ts +63 -0
- package/types/src/core/basemapManager.d.ts.map +1 -0
- package/types/src/core/configLoader.d.ts +159 -0
- package/types/src/core/configLoader.d.ts.map +1 -0
- package/types/src/core/drawing/BaseDrawing.d.ts +255 -0
- package/types/src/core/drawing/BaseDrawing.d.ts.map +1 -0
- package/types/src/core/drawing/DrawingManager.d.ts +394 -0
- package/types/src/core/drawing/DrawingManager.d.ts.map +1 -0
- package/types/src/core/drawing/IconDrawing.d.ts +188 -0
- package/types/src/core/drawing/IconDrawing.d.ts.map +1 -0
- package/types/src/core/drawing/ImageDrawing.d.ts +193 -0
- package/types/src/core/drawing/ImageDrawing.d.ts.map +1 -0
- package/types/src/core/drawing/LineDrawing.d.ts +193 -0
- package/types/src/core/drawing/LineDrawing.d.ts.map +1 -0
- package/types/src/core/drawing/MilitaryDrawing.d.ts +175 -0
- package/types/src/core/drawing/MilitaryDrawing.d.ts.map +1 -0
- package/types/src/core/drawing/MultiLineStringDrawing.d.ts +294 -0
- package/types/src/core/drawing/MultiLineStringDrawing.d.ts.map +1 -0
- package/types/src/core/drawing/MultiPointDrawing.d.ts +244 -0
- package/types/src/core/drawing/MultiPointDrawing.d.ts.map +1 -0
- package/types/src/core/drawing/MultiPolygonDrawing.d.ts +206 -0
- package/types/src/core/drawing/MultiPolygonDrawing.d.ts.map +1 -0
- package/types/src/core/drawing/PointDrawing.d.ts +175 -0
- package/types/src/core/drawing/PointDrawing.d.ts.map +1 -0
- package/types/src/core/drawing/PointWithTextDrawing.d.ts +183 -0
- package/types/src/core/drawing/PointWithTextDrawing.d.ts.map +1 -0
- package/types/src/core/drawing/PolygonDrawing.d.ts +240 -0
- package/types/src/core/drawing/PolygonDrawing.d.ts.map +1 -0
- package/types/src/core/drawing/TextDrawing.d.ts +164 -0
- package/types/src/core/drawing/TextDrawing.d.ts.map +1 -0
- package/types/src/core/drawing/index.d.ts +525 -0
- package/types/src/core/drawing/index.d.ts.map +1 -0
- package/types/src/core/geoJsonLocationTool.d.ts +116 -0
- package/types/src/core/geoJsonLocationTool.d.ts.map +1 -0
- package/types/src/core/layers/BaseLayer.d.ts +162 -0
- package/types/src/core/layers/BaseLayer.d.ts.map +1 -0
- package/types/src/core/layers/CanvasLayerHandler.d.ts +65 -0
- package/types/src/core/layers/CanvasLayerHandler.d.ts.map +1 -0
- package/types/src/core/layers/ClusterLayerHandler.d.ts +122 -0
- package/types/src/core/layers/ClusterLayerHandler.d.ts.map +1 -0
- package/types/src/core/layers/GMLLayerHandler.d.ts +107 -0
- package/types/src/core/layers/GMLLayerHandler.d.ts.map +1 -0
- package/types/src/core/layers/GeoJSONLayerHandler.d.ts +125 -0
- package/types/src/core/layers/GeoJSONLayerHandler.d.ts.map +1 -0
- package/types/src/core/layers/HeatmapLayerHandler.d.ts +86 -0
- package/types/src/core/layers/HeatmapLayerHandler.d.ts.map +1 -0
- package/types/src/core/layers/ImageVectorLayerHandler.d.ts +77 -0
- package/types/src/core/layers/ImageVectorLayerHandler.d.ts.map +1 -0
- package/types/src/core/layers/KMLLayerHandler.d.ts +95 -0
- package/types/src/core/layers/KMLLayerHandler.d.ts.map +1 -0
- package/types/src/core/layers/LayerFactory.d.ts +63 -0
- package/types/src/core/layers/LayerFactory.d.ts.map +1 -0
- package/types/src/core/layers/SuperMapServiceTester.d.ts +54 -0
- package/types/src/core/layers/SuperMapServiceTester.d.ts.map +1 -0
- package/types/src/core/layers/SuperMapTiledMapServiceHandler.d.ts +35 -0
- package/types/src/core/layers/SuperMapTiledMapServiceHandler.d.ts.map +1 -0
- package/types/src/core/layers/TiandituConfigHelper.d.ts +120 -0
- package/types/src/core/layers/TiandituConfigHelper.d.ts.map +1 -0
- package/types/src/core/layers/TiandituLayerHandler.d.ts +75 -0
- package/types/src/core/layers/TiandituLayerHandler.d.ts.map +1 -0
- package/types/src/core/layers/TileLayerHandler.d.ts +42 -0
- package/types/src/core/layers/TileLayerHandler.d.ts.map +1 -0
- package/types/src/core/layers/TileSuperMapRestHandler.d.ts +161 -0
- package/types/src/core/layers/TileSuperMapRestHandler.d.ts.map +1 -0
- package/types/src/core/layers/VectorTileLayerHandler.d.ts +126 -0
- package/types/src/core/layers/VectorTileLayerHandler.d.ts.map +1 -0
- package/types/src/core/layers/WFSLayerHandler.d.ts +80 -0
- package/types/src/core/layers/WFSLayerHandler.d.ts.map +1 -0
- package/types/src/core/layers/WKTLayerHandler.d.ts +123 -0
- package/types/src/core/layers/WKTLayerHandler.d.ts.map +1 -0
- package/types/src/core/layers/WMSLayerHandler.d.ts +78 -0
- package/types/src/core/layers/WMSLayerHandler.d.ts.map +1 -0
- package/types/src/core/layers/WMTSLayerHandler.d.ts +44 -0
- package/types/src/core/layers/WMTSLayerHandler.d.ts.map +1 -0
- package/types/src/core/layers/index.d.ts +20 -0
- package/types/src/core/layers/index.d.ts.map +1 -0
- package/types/src/core/layers/interfaces.d.ts +95 -0
- package/types/src/core/layers/interfaces.d.ts.map +1 -0
- package/types/src/core/mapOperationTool.d.ts +145 -0
- package/types/src/core/mapOperationTool.d.ts.map +1 -0
- package/types/src/core/measurementTool.d.ts +136 -0
- package/types/src/core/measurementTool.d.ts.map +1 -0
- package/types/src/core/overviewMapUtil.d.ts +62 -0
- package/types/src/core/overviewMapUtil.d.ts.map +1 -0
- package/types/src/core/proxyHelper.d.ts +66 -0
- package/types/src/core/proxyHelper.d.ts.map +1 -0
- package/types/src/core/storage.d.ts +139 -0
- package/types/src/core/storage.d.ts.map +1 -0
- package/types/src/core/styles/StyleFactory.d.ts +74 -0
- package/types/src/core/styles/StyleFactory.d.ts.map +1 -0
- package/types/src/core/styles/StyleManager.d.ts +77 -0
- package/types/src/core/styles/StyleManager.d.ts.map +1 -0
- package/types/src/core/styles/index.d.ts +67 -0
- package/types/src/core/styles/index.d.ts.map +1 -0
- package/types/src/core/styles/interfaces.d.ts +221 -0
- package/types/src/core/styles/interfaces.d.ts.map +1 -0
- package/types/src/core/tiandituSearchApi.d.ts +51 -0
- package/types/src/core/tiandituSearchApi.d.ts.map +1 -0
- package/types/src/data-old/testLayers.d.ts +84 -0
- package/types/src/data-old/testLayers.d.ts.map +1 -0
- package/types/src/examples-old/FilterExamples.d.ts +104 -0
- package/types/src/examples-old/FilterExamples.d.ts.map +1 -0
- package/types/src/hooks/useMap.d.ts +5 -0
- package/types/src/hooks/useMap.d.ts.map +1 -0
- package/types/src/services/searchService.d.ts +106 -0
- package/types/src/services/searchService.d.ts.map +1 -0
- package/types/src/test-old/FilterSystemTest.d.ts +57 -0
- package/types/src/test-old/FilterSystemTest.d.ts.map +1 -0
- package/types/src/types/index.d.ts +2 -11
- package/types/src/types/index.d.ts.map +1 -1
- package/types/src/types/map.d.ts +819 -0
- package/types/src/types/map.d.ts.map +1 -0
- package/types/src/types/plugin.d.ts +202 -0
- package/types/src/types/plugin.d.ts.map +1 -0
- package/types/src/utils/DiffusionAnimationHelper.d.ts +60 -0
- package/types/src/utils/DiffusionAnimationHelper.d.ts.map +1 -0
- package/types/src/utils/GifAnimationHelper.d.ts +31 -0
- package/types/src/utils/GifAnimationHelper.d.ts.map +1 -0
- package/types/src/utils/coordinateTransform.d.ts +28 -0
- package/types/src/utils/coordinateTransform.d.ts.map +1 -0
- package/types/src/utils/index.d.ts +8 -8
- package/types/src/utils/index.d.ts.map +1 -1
- package/types/src/utils/unitConverter.d.ts +36 -0
- package/types/src/utils/unitConverter.d.ts.map +1 -0
- package/types/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
import { nextTick, defineComponent, computed, ref, reactive, markRaw, watch, onMounted, onBeforeUnmount, toRefs, resolveComponent, openBlock, createBlock, Transition, withCtx, withDirectives, createVNode, createElementVNode, normalizeClass, normalizeStyle, withModifiers, createElementBlock, resolveDynamicComponent, createCommentVNode, toDisplayString, withKeys, renderSlot, vShow, createTextVNode, isVNode, render } from "vue";
|
|
2
|
+
import { w as componentSizes, x as obtainAllFocusableElements, y as getEventCode, E as EVENT_CODE, A as ElButton, B as ElFocusTrap, C as ElInput, D as ElOverlay, F as ElIcon, G as TypeComponents, H as useGlobalComponentSettings, I as loading_default, J as TypeComponentsMap, K as useId, L as useDraggable, N as isFunction, O as isString, P as useLockscreen, Q as _export_sfc, S as useSameTarget, U as isClient, V as hasOwn, W as isObject, X as isUndefined, Y as isElement, Z as debugWarn } from "./index-6f94a7fa.mjs";
|
|
3
|
+
const isValidComponentSize = (val) => ["", ...componentSizes].includes(val);
|
|
4
|
+
const FOCUSABLE_CHILDREN = "_trap-focus-children";
|
|
5
|
+
const FOCUS_STACK = [];
|
|
6
|
+
const FOCUS_HANDLER = (e) => {
|
|
7
|
+
var _a;
|
|
8
|
+
if (FOCUS_STACK.length === 0)
|
|
9
|
+
return;
|
|
10
|
+
const code = getEventCode(e);
|
|
11
|
+
const focusableElement = FOCUS_STACK[FOCUS_STACK.length - 1][FOCUSABLE_CHILDREN];
|
|
12
|
+
if (focusableElement.length > 0 && code === EVENT_CODE.tab) {
|
|
13
|
+
if (focusableElement.length === 1) {
|
|
14
|
+
e.preventDefault();
|
|
15
|
+
if (document.activeElement !== focusableElement[0]) {
|
|
16
|
+
focusableElement[0].focus();
|
|
17
|
+
}
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const goingBackward = e.shiftKey;
|
|
21
|
+
const isFirst = e.target === focusableElement[0];
|
|
22
|
+
const isLast = e.target === focusableElement[focusableElement.length - 1];
|
|
23
|
+
if (isFirst && goingBackward) {
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
focusableElement[focusableElement.length - 1].focus();
|
|
26
|
+
}
|
|
27
|
+
if (isLast && !goingBackward) {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
focusableElement[0].focus();
|
|
30
|
+
}
|
|
31
|
+
if (process.env.NODE_ENV === "test") {
|
|
32
|
+
const index = focusableElement.indexOf(e.target);
|
|
33
|
+
if (index !== -1) {
|
|
34
|
+
(_a = focusableElement[goingBackward ? index - 1 : index + 1]) == null ? void 0 : _a.focus();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const TrapFocus = {
|
|
40
|
+
beforeMount(el) {
|
|
41
|
+
el[FOCUSABLE_CHILDREN] = obtainAllFocusableElements(el);
|
|
42
|
+
FOCUS_STACK.push(el);
|
|
43
|
+
if (FOCUS_STACK.length <= 1) {
|
|
44
|
+
document.addEventListener("keydown", FOCUS_HANDLER);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
updated(el) {
|
|
48
|
+
nextTick(() => {
|
|
49
|
+
el[FOCUSABLE_CHILDREN] = obtainAllFocusableElements(el);
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
unmounted() {
|
|
53
|
+
FOCUS_STACK.shift();
|
|
54
|
+
if (FOCUS_STACK.length === 0) {
|
|
55
|
+
document.removeEventListener("keydown", FOCUS_HANDLER);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const _sfc_main = defineComponent({
|
|
60
|
+
name: "ElMessageBox",
|
|
61
|
+
directives: {
|
|
62
|
+
TrapFocus
|
|
63
|
+
},
|
|
64
|
+
components: {
|
|
65
|
+
ElButton,
|
|
66
|
+
ElFocusTrap,
|
|
67
|
+
ElInput,
|
|
68
|
+
ElOverlay,
|
|
69
|
+
ElIcon,
|
|
70
|
+
...TypeComponents
|
|
71
|
+
},
|
|
72
|
+
inheritAttrs: false,
|
|
73
|
+
props: {
|
|
74
|
+
buttonSize: {
|
|
75
|
+
type: String,
|
|
76
|
+
validator: isValidComponentSize
|
|
77
|
+
},
|
|
78
|
+
modal: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: true
|
|
81
|
+
},
|
|
82
|
+
lockScroll: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: true
|
|
85
|
+
},
|
|
86
|
+
showClose: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: true
|
|
89
|
+
},
|
|
90
|
+
closeOnClickModal: {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
default: true
|
|
93
|
+
},
|
|
94
|
+
closeOnPressEscape: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: true
|
|
97
|
+
},
|
|
98
|
+
closeOnHashChange: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: true
|
|
101
|
+
},
|
|
102
|
+
center: Boolean,
|
|
103
|
+
draggable: Boolean,
|
|
104
|
+
overflow: Boolean,
|
|
105
|
+
roundButton: Boolean,
|
|
106
|
+
container: {
|
|
107
|
+
type: String,
|
|
108
|
+
default: "body"
|
|
109
|
+
},
|
|
110
|
+
boxType: {
|
|
111
|
+
type: String,
|
|
112
|
+
default: ""
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
emits: ["vanish", "action"],
|
|
116
|
+
setup(props, { emit }) {
|
|
117
|
+
const {
|
|
118
|
+
locale,
|
|
119
|
+
zIndex,
|
|
120
|
+
ns,
|
|
121
|
+
size: btnSize
|
|
122
|
+
} = useGlobalComponentSettings(
|
|
123
|
+
"message-box",
|
|
124
|
+
computed(() => props.buttonSize)
|
|
125
|
+
);
|
|
126
|
+
const { t } = locale;
|
|
127
|
+
const { nextZIndex } = zIndex;
|
|
128
|
+
const visible = ref(false);
|
|
129
|
+
const state = reactive({
|
|
130
|
+
autofocus: true,
|
|
131
|
+
beforeClose: null,
|
|
132
|
+
callback: null,
|
|
133
|
+
cancelButtonText: "",
|
|
134
|
+
cancelButtonClass: "",
|
|
135
|
+
confirmButtonText: "",
|
|
136
|
+
confirmButtonClass: "",
|
|
137
|
+
customClass: "",
|
|
138
|
+
customStyle: {},
|
|
139
|
+
dangerouslyUseHTMLString: false,
|
|
140
|
+
distinguishCancelAndClose: false,
|
|
141
|
+
icon: "",
|
|
142
|
+
closeIcon: "",
|
|
143
|
+
inputPattern: null,
|
|
144
|
+
inputPlaceholder: "",
|
|
145
|
+
inputType: "text",
|
|
146
|
+
inputValue: "",
|
|
147
|
+
inputValidator: void 0,
|
|
148
|
+
inputErrorMessage: "",
|
|
149
|
+
message: "",
|
|
150
|
+
modalFade: true,
|
|
151
|
+
modalClass: "",
|
|
152
|
+
showCancelButton: false,
|
|
153
|
+
showConfirmButton: true,
|
|
154
|
+
type: "",
|
|
155
|
+
title: void 0,
|
|
156
|
+
showInput: false,
|
|
157
|
+
action: "",
|
|
158
|
+
confirmButtonLoading: false,
|
|
159
|
+
cancelButtonLoading: false,
|
|
160
|
+
confirmButtonLoadingIcon: markRaw(loading_default),
|
|
161
|
+
cancelButtonLoadingIcon: markRaw(loading_default),
|
|
162
|
+
confirmButtonDisabled: false,
|
|
163
|
+
editorErrorMessage: "",
|
|
164
|
+
validateError: false,
|
|
165
|
+
zIndex: nextZIndex()
|
|
166
|
+
});
|
|
167
|
+
const typeClass = computed(() => {
|
|
168
|
+
const type = state.type;
|
|
169
|
+
return { [ns.bm("icon", type)]: type && TypeComponentsMap[type] };
|
|
170
|
+
});
|
|
171
|
+
const contentId = useId();
|
|
172
|
+
const inputId = useId();
|
|
173
|
+
const iconComponent = computed(() => {
|
|
174
|
+
const type = state.type;
|
|
175
|
+
return state.icon || type && TypeComponentsMap[type] || "";
|
|
176
|
+
});
|
|
177
|
+
const hasMessage = computed(() => !!state.message);
|
|
178
|
+
const rootRef = ref();
|
|
179
|
+
const headerRef = ref();
|
|
180
|
+
const focusStartRef = ref();
|
|
181
|
+
const inputRef = ref();
|
|
182
|
+
const confirmRef = ref();
|
|
183
|
+
const confirmButtonClasses = computed(() => state.confirmButtonClass);
|
|
184
|
+
watch(
|
|
185
|
+
() => state.inputValue,
|
|
186
|
+
async (val) => {
|
|
187
|
+
await nextTick();
|
|
188
|
+
if (props.boxType === "prompt" && val) {
|
|
189
|
+
validate();
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
{ immediate: true }
|
|
193
|
+
);
|
|
194
|
+
watch(
|
|
195
|
+
() => visible.value,
|
|
196
|
+
(val) => {
|
|
197
|
+
var _a, _b;
|
|
198
|
+
if (val) {
|
|
199
|
+
if (props.boxType !== "prompt") {
|
|
200
|
+
if (state.autofocus) {
|
|
201
|
+
focusStartRef.value = (_b = (_a = confirmRef.value) == null ? void 0 : _a.$el) != null ? _b : rootRef.value;
|
|
202
|
+
} else {
|
|
203
|
+
focusStartRef.value = rootRef.value;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
state.zIndex = nextZIndex();
|
|
207
|
+
}
|
|
208
|
+
if (props.boxType !== "prompt")
|
|
209
|
+
return;
|
|
210
|
+
if (val) {
|
|
211
|
+
nextTick().then(() => {
|
|
212
|
+
var _a2;
|
|
213
|
+
if (inputRef.value && inputRef.value.$el) {
|
|
214
|
+
if (state.autofocus) {
|
|
215
|
+
focusStartRef.value = (_a2 = getInputElement()) != null ? _a2 : rootRef.value;
|
|
216
|
+
} else {
|
|
217
|
+
focusStartRef.value = rootRef.value;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
} else {
|
|
222
|
+
state.editorErrorMessage = "";
|
|
223
|
+
state.validateError = false;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
const draggable = computed(() => props.draggable);
|
|
228
|
+
const overflow = computed(() => props.overflow);
|
|
229
|
+
const { isDragging } = useDraggable(rootRef, headerRef, draggable, overflow);
|
|
230
|
+
onMounted(async () => {
|
|
231
|
+
await nextTick();
|
|
232
|
+
if (props.closeOnHashChange) {
|
|
233
|
+
window.addEventListener("hashchange", doClose);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
onBeforeUnmount(() => {
|
|
237
|
+
if (props.closeOnHashChange) {
|
|
238
|
+
window.removeEventListener("hashchange", doClose);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
function doClose() {
|
|
242
|
+
if (!visible.value)
|
|
243
|
+
return;
|
|
244
|
+
visible.value = false;
|
|
245
|
+
nextTick(() => {
|
|
246
|
+
if (state.action)
|
|
247
|
+
emit("action", state.action);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
const handleWrapperClick = () => {
|
|
251
|
+
if (props.closeOnClickModal) {
|
|
252
|
+
handleAction(state.distinguishCancelAndClose ? "close" : "cancel");
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
const overlayEvent = useSameTarget(handleWrapperClick);
|
|
256
|
+
const handleInputEnter = (e) => {
|
|
257
|
+
if (state.inputType !== "textarea") {
|
|
258
|
+
e.preventDefault();
|
|
259
|
+
return handleAction("confirm");
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
const handleAction = (action) => {
|
|
263
|
+
var _a;
|
|
264
|
+
if (props.boxType === "prompt" && action === "confirm" && !validate()) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
state.action = action;
|
|
268
|
+
if (state.beforeClose) {
|
|
269
|
+
(_a = state.beforeClose) == null ? void 0 : _a.call(state, action, state, doClose);
|
|
270
|
+
} else {
|
|
271
|
+
doClose();
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
const validate = () => {
|
|
275
|
+
if (props.boxType === "prompt") {
|
|
276
|
+
const inputPattern = state.inputPattern;
|
|
277
|
+
if (inputPattern && !inputPattern.test(state.inputValue || "")) {
|
|
278
|
+
state.editorErrorMessage = state.inputErrorMessage || t("el.messagebox.error");
|
|
279
|
+
state.validateError = true;
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
const inputValidator = state.inputValidator;
|
|
283
|
+
if (isFunction(inputValidator)) {
|
|
284
|
+
const validateResult = inputValidator(state.inputValue);
|
|
285
|
+
if (validateResult === false) {
|
|
286
|
+
state.editorErrorMessage = state.inputErrorMessage || t("el.messagebox.error");
|
|
287
|
+
state.validateError = true;
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
if (isString(validateResult)) {
|
|
291
|
+
state.editorErrorMessage = validateResult;
|
|
292
|
+
state.validateError = true;
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
state.editorErrorMessage = "";
|
|
298
|
+
state.validateError = false;
|
|
299
|
+
return true;
|
|
300
|
+
};
|
|
301
|
+
const getInputElement = () => {
|
|
302
|
+
var _a, _b;
|
|
303
|
+
const inputRefs = (_a = inputRef.value) == null ? void 0 : _a.$refs;
|
|
304
|
+
return (_b = inputRefs == null ? void 0 : inputRefs.input) != null ? _b : inputRefs == null ? void 0 : inputRefs.textarea;
|
|
305
|
+
};
|
|
306
|
+
const handleClose = () => {
|
|
307
|
+
handleAction("close");
|
|
308
|
+
};
|
|
309
|
+
const onCloseRequested = () => {
|
|
310
|
+
if (props.closeOnPressEscape) {
|
|
311
|
+
handleClose();
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
if (props.lockScroll) {
|
|
315
|
+
useLockscreen(visible, { ns });
|
|
316
|
+
}
|
|
317
|
+
return {
|
|
318
|
+
...toRefs(state),
|
|
319
|
+
ns,
|
|
320
|
+
overlayEvent,
|
|
321
|
+
visible,
|
|
322
|
+
hasMessage,
|
|
323
|
+
typeClass,
|
|
324
|
+
contentId,
|
|
325
|
+
inputId,
|
|
326
|
+
btnSize,
|
|
327
|
+
iconComponent,
|
|
328
|
+
confirmButtonClasses,
|
|
329
|
+
rootRef,
|
|
330
|
+
focusStartRef,
|
|
331
|
+
headerRef,
|
|
332
|
+
inputRef,
|
|
333
|
+
isDragging,
|
|
334
|
+
confirmRef,
|
|
335
|
+
doClose,
|
|
336
|
+
handleClose,
|
|
337
|
+
onCloseRequested,
|
|
338
|
+
handleWrapperClick,
|
|
339
|
+
handleInputEnter,
|
|
340
|
+
handleAction,
|
|
341
|
+
t
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
const _hoisted_1 = ["aria-label", "aria-describedby"];
|
|
346
|
+
const _hoisted_2 = ["aria-label"];
|
|
347
|
+
const _hoisted_3 = ["id"];
|
|
348
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
349
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
350
|
+
const _component_el_input = resolveComponent("el-input");
|
|
351
|
+
const _component_el_button = resolveComponent("el-button");
|
|
352
|
+
const _component_el_focus_trap = resolveComponent("el-focus-trap");
|
|
353
|
+
const _component_el_overlay = resolveComponent("el-overlay");
|
|
354
|
+
return openBlock(), createBlock(Transition, {
|
|
355
|
+
name: "fade-in-linear",
|
|
356
|
+
onAfterLeave: _cache[11] || (_cache[11] = ($event) => _ctx.$emit("vanish")),
|
|
357
|
+
persisted: ""
|
|
358
|
+
}, {
|
|
359
|
+
default: withCtx(() => [
|
|
360
|
+
withDirectives(createVNode(_component_el_overlay, {
|
|
361
|
+
"z-index": _ctx.zIndex,
|
|
362
|
+
"overlay-class": [_ctx.ns.is("message-box"), _ctx.modalClass],
|
|
363
|
+
mask: _ctx.modal
|
|
364
|
+
}, {
|
|
365
|
+
default: withCtx(() => [
|
|
366
|
+
createElementVNode("div", {
|
|
367
|
+
role: "dialog",
|
|
368
|
+
"aria-label": _ctx.title,
|
|
369
|
+
"aria-modal": "true",
|
|
370
|
+
"aria-describedby": !_ctx.showInput ? _ctx.contentId : void 0,
|
|
371
|
+
class: normalizeClass(`${_ctx.ns.namespace.value}-overlay-message-box`),
|
|
372
|
+
onClick: _cache[8] || (_cache[8] = (...args) => _ctx.overlayEvent.onClick && _ctx.overlayEvent.onClick(...args)),
|
|
373
|
+
onMousedown: _cache[9] || (_cache[9] = (...args) => _ctx.overlayEvent.onMousedown && _ctx.overlayEvent.onMousedown(...args)),
|
|
374
|
+
onMouseup: _cache[10] || (_cache[10] = (...args) => _ctx.overlayEvent.onMouseup && _ctx.overlayEvent.onMouseup(...args))
|
|
375
|
+
}, [
|
|
376
|
+
createVNode(_component_el_focus_trap, {
|
|
377
|
+
loop: "",
|
|
378
|
+
trapped: _ctx.visible,
|
|
379
|
+
"focus-trap-el": _ctx.rootRef,
|
|
380
|
+
"focus-start-el": _ctx.focusStartRef,
|
|
381
|
+
onReleaseRequested: _ctx.onCloseRequested
|
|
382
|
+
}, {
|
|
383
|
+
default: withCtx(() => [
|
|
384
|
+
createElementVNode(
|
|
385
|
+
"div",
|
|
386
|
+
{
|
|
387
|
+
ref: "rootRef",
|
|
388
|
+
class: normalizeClass([
|
|
389
|
+
_ctx.ns.b(),
|
|
390
|
+
_ctx.customClass,
|
|
391
|
+
_ctx.ns.is("draggable", _ctx.draggable),
|
|
392
|
+
_ctx.ns.is("dragging", _ctx.isDragging),
|
|
393
|
+
{ [_ctx.ns.m("center")]: _ctx.center }
|
|
394
|
+
]),
|
|
395
|
+
style: normalizeStyle(_ctx.customStyle),
|
|
396
|
+
tabindex: "-1",
|
|
397
|
+
onClick: _cache[7] || (_cache[7] = withModifiers(() => {
|
|
398
|
+
}, ["stop"]))
|
|
399
|
+
},
|
|
400
|
+
[
|
|
401
|
+
_ctx.title !== null && _ctx.title !== void 0 ? (openBlock(), createElementBlock(
|
|
402
|
+
"div",
|
|
403
|
+
{
|
|
404
|
+
key: 0,
|
|
405
|
+
ref: "headerRef",
|
|
406
|
+
class: normalizeClass([_ctx.ns.e("header"), { "show-close": _ctx.showClose }])
|
|
407
|
+
},
|
|
408
|
+
[
|
|
409
|
+
createElementVNode(
|
|
410
|
+
"div",
|
|
411
|
+
{
|
|
412
|
+
class: normalizeClass(_ctx.ns.e("title"))
|
|
413
|
+
},
|
|
414
|
+
[
|
|
415
|
+
_ctx.iconComponent && _ctx.center ? (openBlock(), createBlock(_component_el_icon, {
|
|
416
|
+
key: 0,
|
|
417
|
+
class: normalizeClass([_ctx.ns.e("status"), _ctx.typeClass])
|
|
418
|
+
}, {
|
|
419
|
+
default: withCtx(() => [
|
|
420
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.iconComponent)))
|
|
421
|
+
]),
|
|
422
|
+
_: 1
|
|
423
|
+
}, 8, ["class"])) : createCommentVNode("v-if", true),
|
|
424
|
+
createElementVNode(
|
|
425
|
+
"span",
|
|
426
|
+
null,
|
|
427
|
+
toDisplayString(_ctx.title),
|
|
428
|
+
1
|
|
429
|
+
)
|
|
430
|
+
],
|
|
431
|
+
2
|
|
432
|
+
),
|
|
433
|
+
_ctx.showClose ? (openBlock(), createElementBlock("button", {
|
|
434
|
+
key: 0,
|
|
435
|
+
type: "button",
|
|
436
|
+
class: normalizeClass(_ctx.ns.e("headerbtn")),
|
|
437
|
+
"aria-label": _ctx.t("el.messagebox.close"),
|
|
438
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.handleAction(_ctx.distinguishCancelAndClose ? "close" : "cancel")),
|
|
439
|
+
onKeydown: _cache[1] || (_cache[1] = withKeys(withModifiers(($event) => _ctx.handleAction(_ctx.distinguishCancelAndClose ? "close" : "cancel"), ["prevent"]), ["enter"]))
|
|
440
|
+
}, [
|
|
441
|
+
createVNode(_component_el_icon, {
|
|
442
|
+
class: normalizeClass(_ctx.ns.e("close"))
|
|
443
|
+
}, {
|
|
444
|
+
default: withCtx(() => [
|
|
445
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.closeIcon || "close")))
|
|
446
|
+
]),
|
|
447
|
+
_: 1
|
|
448
|
+
}, 8, ["class"])
|
|
449
|
+
], 42, _hoisted_2)) : createCommentVNode("v-if", true)
|
|
450
|
+
],
|
|
451
|
+
2
|
|
452
|
+
)) : createCommentVNode("v-if", true),
|
|
453
|
+
createElementVNode("div", {
|
|
454
|
+
id: _ctx.contentId,
|
|
455
|
+
class: normalizeClass(_ctx.ns.e("content"))
|
|
456
|
+
}, [
|
|
457
|
+
createElementVNode(
|
|
458
|
+
"div",
|
|
459
|
+
{
|
|
460
|
+
class: normalizeClass(_ctx.ns.e("container"))
|
|
461
|
+
},
|
|
462
|
+
[
|
|
463
|
+
_ctx.iconComponent && !_ctx.center && _ctx.hasMessage ? (openBlock(), createBlock(_component_el_icon, {
|
|
464
|
+
key: 0,
|
|
465
|
+
class: normalizeClass([_ctx.ns.e("status"), _ctx.typeClass])
|
|
466
|
+
}, {
|
|
467
|
+
default: withCtx(() => [
|
|
468
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.iconComponent)))
|
|
469
|
+
]),
|
|
470
|
+
_: 1
|
|
471
|
+
}, 8, ["class"])) : createCommentVNode("v-if", true),
|
|
472
|
+
_ctx.hasMessage ? (openBlock(), createElementBlock(
|
|
473
|
+
"div",
|
|
474
|
+
{
|
|
475
|
+
key: 1,
|
|
476
|
+
class: normalizeClass(_ctx.ns.e("message"))
|
|
477
|
+
},
|
|
478
|
+
[
|
|
479
|
+
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
480
|
+
!_ctx.dangerouslyUseHTMLString ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.showInput ? "label" : "p"), {
|
|
481
|
+
key: 0,
|
|
482
|
+
for: _ctx.showInput ? _ctx.inputId : void 0,
|
|
483
|
+
textContent: toDisplayString(_ctx.message)
|
|
484
|
+
}, null, 8, ["for", "textContent"])) : (openBlock(), createBlock(resolveDynamicComponent(_ctx.showInput ? "label" : "p"), {
|
|
485
|
+
key: 1,
|
|
486
|
+
for: _ctx.showInput ? _ctx.inputId : void 0,
|
|
487
|
+
innerHTML: _ctx.message
|
|
488
|
+
}, null, 8, ["for", "innerHTML"]))
|
|
489
|
+
])
|
|
490
|
+
],
|
|
491
|
+
2
|
|
492
|
+
)) : createCommentVNode("v-if", true)
|
|
493
|
+
],
|
|
494
|
+
2
|
|
495
|
+
),
|
|
496
|
+
withDirectives(createElementVNode(
|
|
497
|
+
"div",
|
|
498
|
+
{
|
|
499
|
+
class: normalizeClass(_ctx.ns.e("input"))
|
|
500
|
+
},
|
|
501
|
+
[
|
|
502
|
+
createVNode(_component_el_input, {
|
|
503
|
+
id: _ctx.inputId,
|
|
504
|
+
ref: "inputRef",
|
|
505
|
+
modelValue: _ctx.inputValue,
|
|
506
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => _ctx.inputValue = $event),
|
|
507
|
+
type: _ctx.inputType,
|
|
508
|
+
placeholder: _ctx.inputPlaceholder,
|
|
509
|
+
"aria-invalid": _ctx.validateError,
|
|
510
|
+
class: normalizeClass({ invalid: _ctx.validateError }),
|
|
511
|
+
onKeydown: withKeys(_ctx.handleInputEnter, ["enter"])
|
|
512
|
+
}, null, 8, ["id", "modelValue", "type", "placeholder", "aria-invalid", "class", "onKeydown"]),
|
|
513
|
+
createElementVNode(
|
|
514
|
+
"div",
|
|
515
|
+
{
|
|
516
|
+
class: normalizeClass(_ctx.ns.e("errormsg")),
|
|
517
|
+
style: normalizeStyle({
|
|
518
|
+
visibility: !!_ctx.editorErrorMessage ? "visible" : "hidden"
|
|
519
|
+
})
|
|
520
|
+
},
|
|
521
|
+
toDisplayString(_ctx.editorErrorMessage),
|
|
522
|
+
7
|
|
523
|
+
)
|
|
524
|
+
],
|
|
525
|
+
2
|
|
526
|
+
), [
|
|
527
|
+
[vShow, _ctx.showInput]
|
|
528
|
+
])
|
|
529
|
+
], 10, _hoisted_3),
|
|
530
|
+
createElementVNode(
|
|
531
|
+
"div",
|
|
532
|
+
{
|
|
533
|
+
class: normalizeClass(_ctx.ns.e("btns"))
|
|
534
|
+
},
|
|
535
|
+
[
|
|
536
|
+
_ctx.showCancelButton ? (openBlock(), createBlock(_component_el_button, {
|
|
537
|
+
key: 0,
|
|
538
|
+
loading: _ctx.cancelButtonLoading,
|
|
539
|
+
"loading-icon": _ctx.cancelButtonLoadingIcon,
|
|
540
|
+
class: normalizeClass([_ctx.cancelButtonClass]),
|
|
541
|
+
round: _ctx.roundButton,
|
|
542
|
+
size: _ctx.btnSize,
|
|
543
|
+
onClick: _cache[3] || (_cache[3] = ($event) => _ctx.handleAction("cancel")),
|
|
544
|
+
onKeydown: _cache[4] || (_cache[4] = withKeys(withModifiers(($event) => _ctx.handleAction("cancel"), ["prevent"]), ["enter"]))
|
|
545
|
+
}, {
|
|
546
|
+
default: withCtx(() => [
|
|
547
|
+
createTextVNode(
|
|
548
|
+
toDisplayString(_ctx.cancelButtonText || _ctx.t("el.messagebox.cancel")),
|
|
549
|
+
1
|
|
550
|
+
)
|
|
551
|
+
]),
|
|
552
|
+
_: 1
|
|
553
|
+
}, 8, ["loading", "loading-icon", "class", "round", "size"])) : createCommentVNode("v-if", true),
|
|
554
|
+
withDirectives(createVNode(_component_el_button, {
|
|
555
|
+
ref: "confirmRef",
|
|
556
|
+
type: "primary",
|
|
557
|
+
loading: _ctx.confirmButtonLoading,
|
|
558
|
+
"loading-icon": _ctx.confirmButtonLoadingIcon,
|
|
559
|
+
class: normalizeClass([_ctx.confirmButtonClasses]),
|
|
560
|
+
round: _ctx.roundButton,
|
|
561
|
+
disabled: _ctx.confirmButtonDisabled,
|
|
562
|
+
size: _ctx.btnSize,
|
|
563
|
+
onClick: _cache[5] || (_cache[5] = ($event) => _ctx.handleAction("confirm")),
|
|
564
|
+
onKeydown: _cache[6] || (_cache[6] = withKeys(withModifiers(($event) => _ctx.handleAction("confirm"), ["prevent"]), ["enter"]))
|
|
565
|
+
}, {
|
|
566
|
+
default: withCtx(() => [
|
|
567
|
+
createTextVNode(
|
|
568
|
+
toDisplayString(_ctx.confirmButtonText || _ctx.t("el.messagebox.confirm")),
|
|
569
|
+
1
|
|
570
|
+
)
|
|
571
|
+
]),
|
|
572
|
+
_: 1
|
|
573
|
+
}, 8, ["loading", "loading-icon", "class", "round", "disabled", "size"]), [
|
|
574
|
+
[vShow, _ctx.showConfirmButton]
|
|
575
|
+
])
|
|
576
|
+
],
|
|
577
|
+
2
|
|
578
|
+
)
|
|
579
|
+
],
|
|
580
|
+
6
|
|
581
|
+
)
|
|
582
|
+
]),
|
|
583
|
+
_: 3
|
|
584
|
+
}, 8, ["trapped", "focus-trap-el", "focus-start-el", "onReleaseRequested"])
|
|
585
|
+
], 42, _hoisted_1)
|
|
586
|
+
]),
|
|
587
|
+
_: 3
|
|
588
|
+
}, 8, ["z-index", "overlay-class", "mask"]), [
|
|
589
|
+
[vShow, _ctx.visible]
|
|
590
|
+
])
|
|
591
|
+
]),
|
|
592
|
+
_: 3
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
var MessageBoxConstructor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/element-plus/element-plus/packages/components/message-box/src/index.vue"]]);
|
|
596
|
+
const messageInstance = /* @__PURE__ */ new Map();
|
|
597
|
+
const getAppendToElement = (props) => {
|
|
598
|
+
let appendTo = document.body;
|
|
599
|
+
if (props.appendTo) {
|
|
600
|
+
if (isString(props.appendTo)) {
|
|
601
|
+
appendTo = document.querySelector(props.appendTo);
|
|
602
|
+
}
|
|
603
|
+
if (isElement(props.appendTo)) {
|
|
604
|
+
appendTo = props.appendTo;
|
|
605
|
+
}
|
|
606
|
+
if (!isElement(appendTo)) {
|
|
607
|
+
debugWarn(
|
|
608
|
+
"ElMessageBox",
|
|
609
|
+
"the appendTo option is not an HTMLElement. Falling back to document.body."
|
|
610
|
+
);
|
|
611
|
+
appendTo = document.body;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return appendTo;
|
|
615
|
+
};
|
|
616
|
+
const initInstance = (props, container, appContext = null) => {
|
|
617
|
+
const vnode = createVNode(
|
|
618
|
+
MessageBoxConstructor,
|
|
619
|
+
props,
|
|
620
|
+
isFunction(props.message) || isVNode(props.message) ? {
|
|
621
|
+
default: isFunction(props.message) ? props.message : () => props.message
|
|
622
|
+
} : null
|
|
623
|
+
);
|
|
624
|
+
vnode.appContext = appContext;
|
|
625
|
+
render(vnode, container);
|
|
626
|
+
getAppendToElement(props).appendChild(container.firstElementChild);
|
|
627
|
+
return vnode.component;
|
|
628
|
+
};
|
|
629
|
+
const genContainer = () => {
|
|
630
|
+
return document.createElement("div");
|
|
631
|
+
};
|
|
632
|
+
const showMessage = (options, appContext) => {
|
|
633
|
+
const container = genContainer();
|
|
634
|
+
options.onVanish = () => {
|
|
635
|
+
render(null, container);
|
|
636
|
+
messageInstance.delete(vm);
|
|
637
|
+
};
|
|
638
|
+
options.onAction = (action) => {
|
|
639
|
+
const currentMsg = messageInstance.get(vm);
|
|
640
|
+
let resolve;
|
|
641
|
+
if (options.showInput) {
|
|
642
|
+
resolve = { value: vm.inputValue, action };
|
|
643
|
+
} else {
|
|
644
|
+
resolve = action;
|
|
645
|
+
}
|
|
646
|
+
if (options.callback) {
|
|
647
|
+
options.callback(resolve, instance.proxy);
|
|
648
|
+
} else {
|
|
649
|
+
if (action === "cancel" || action === "close") {
|
|
650
|
+
if (options.distinguishCancelAndClose && action !== "cancel") {
|
|
651
|
+
currentMsg.reject("close");
|
|
652
|
+
} else {
|
|
653
|
+
currentMsg.reject("cancel");
|
|
654
|
+
}
|
|
655
|
+
} else {
|
|
656
|
+
currentMsg.resolve(resolve);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
const instance = initInstance(options, container, appContext);
|
|
661
|
+
const vm = instance.proxy;
|
|
662
|
+
for (const prop in options) {
|
|
663
|
+
if (hasOwn(options, prop) && !hasOwn(vm.$props, prop)) {
|
|
664
|
+
if (prop === "closeIcon" && isObject(options[prop])) {
|
|
665
|
+
vm[prop] = markRaw(options[prop]);
|
|
666
|
+
} else {
|
|
667
|
+
vm[prop] = options[prop];
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
vm.visible = true;
|
|
672
|
+
return vm;
|
|
673
|
+
};
|
|
674
|
+
function MessageBox(options, appContext = null) {
|
|
675
|
+
if (!isClient)
|
|
676
|
+
return Promise.reject();
|
|
677
|
+
let callback;
|
|
678
|
+
if (isString(options) || isVNode(options)) {
|
|
679
|
+
options = {
|
|
680
|
+
message: options
|
|
681
|
+
};
|
|
682
|
+
} else {
|
|
683
|
+
callback = options.callback;
|
|
684
|
+
}
|
|
685
|
+
return new Promise((resolve, reject) => {
|
|
686
|
+
const vm = showMessage(
|
|
687
|
+
options,
|
|
688
|
+
appContext != null ? appContext : MessageBox._context
|
|
689
|
+
);
|
|
690
|
+
messageInstance.set(vm, {
|
|
691
|
+
options,
|
|
692
|
+
callback,
|
|
693
|
+
resolve,
|
|
694
|
+
reject
|
|
695
|
+
});
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
const MESSAGE_BOX_VARIANTS = ["alert", "confirm", "prompt"];
|
|
699
|
+
const MESSAGE_BOX_DEFAULT_OPTS = {
|
|
700
|
+
alert: { closeOnPressEscape: false, closeOnClickModal: false },
|
|
701
|
+
confirm: { showCancelButton: true },
|
|
702
|
+
prompt: { showCancelButton: true, showInput: true }
|
|
703
|
+
};
|
|
704
|
+
MESSAGE_BOX_VARIANTS.forEach((boxType) => {
|
|
705
|
+
MessageBox[boxType] = messageBoxFactory(
|
|
706
|
+
boxType
|
|
707
|
+
);
|
|
708
|
+
});
|
|
709
|
+
function messageBoxFactory(boxType) {
|
|
710
|
+
return (message, title, options, appContext) => {
|
|
711
|
+
let titleOrOpts = "";
|
|
712
|
+
if (isObject(title)) {
|
|
713
|
+
options = title;
|
|
714
|
+
titleOrOpts = "";
|
|
715
|
+
} else if (isUndefined(title)) {
|
|
716
|
+
titleOrOpts = "";
|
|
717
|
+
} else {
|
|
718
|
+
titleOrOpts = title;
|
|
719
|
+
}
|
|
720
|
+
return MessageBox(
|
|
721
|
+
Object.assign(
|
|
722
|
+
{
|
|
723
|
+
title: titleOrOpts,
|
|
724
|
+
message,
|
|
725
|
+
type: "",
|
|
726
|
+
...MESSAGE_BOX_DEFAULT_OPTS[boxType]
|
|
727
|
+
},
|
|
728
|
+
options,
|
|
729
|
+
{
|
|
730
|
+
boxType
|
|
731
|
+
}
|
|
732
|
+
),
|
|
733
|
+
appContext
|
|
734
|
+
);
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
MessageBox.close = () => {
|
|
738
|
+
messageInstance.forEach((_, vm) => {
|
|
739
|
+
vm.doClose();
|
|
740
|
+
});
|
|
741
|
+
messageInstance.clear();
|
|
742
|
+
};
|
|
743
|
+
MessageBox._context = null;
|
|
744
|
+
const _MessageBox = MessageBox;
|
|
745
|
+
_MessageBox.install = (app) => {
|
|
746
|
+
_MessageBox._context = app._context;
|
|
747
|
+
app.config.globalProperties.$msgbox = _MessageBox;
|
|
748
|
+
app.config.globalProperties.$messageBox = _MessageBox;
|
|
749
|
+
app.config.globalProperties.$alert = _MessageBox.alert;
|
|
750
|
+
app.config.globalProperties.$confirm = _MessageBox.confirm;
|
|
751
|
+
app.config.globalProperties.$prompt = _MessageBox.prompt;
|
|
752
|
+
};
|
|
753
|
+
const ElMessageBox = _MessageBox;
|
|
754
|
+
export {
|
|
755
|
+
ElMessageBox as E
|
|
756
|
+
};
|