@fangzhongya/fang-ui 0.1.72 → 0.1.74
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/dist/components/index.cjs +112 -110
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +2 -0
- package/dist/components/index.scss +1 -0
- package/dist/components/index2.scss +1 -0
- package/dist/components/menus/src/menu-ll2.cjs +2 -1
- package/dist/components/menus/src/menu-ll2.js +2 -1
- package/dist/components/right-key-no/index.cjs +9 -0
- package/dist/components/right-key-no/index.css +52 -0
- package/dist/components/right-key-no/index.d.ts +5 -0
- package/dist/components/right-key-no/index.js +9 -0
- package/dist/components/right-key-no/index.scss +36 -0
- package/dist/components/right-key-no/src/data.cjs +71 -0
- package/dist/components/right-key-no/src/data.d.ts +96 -0
- package/dist/components/right-key-no/src/data.js +71 -0
- package/dist/components/right-key-no/src/index.cjs +4 -0
- package/dist/components/right-key-no/src/index.js +4 -0
- package/dist/components/right-key-no/src/index2.cjs +240 -0
- package/dist/components/right-key-no/src/index2.js +240 -0
- package/dist/components/right-key-no/style/index2.scss +1 -0
- package/dist/css/index.css +29 -0
- package/dist/css/right-key-no.css +52 -0
- package/dist/expand/{chunk-OJ66KIK7.cjs → chunk-KYX3DANL.cjs} +2 -0
- package/dist/expand/{chunk-WDSWWSNJ.js → chunk-PMWCTNN6.js} +2 -0
- package/dist/expand/components.cjs +5 -5
- package/dist/expand/components.js +1 -1
- package/dist/expand/config.cjs +2 -2
- package/dist/expand/config.js +1 -1
- package/dist/icons/index.json +1 -1
- package/dist/index.cjs +136 -134
- package/dist/index.css +29 -0
- package/dist/index.js +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/only.cjs +6 -0
- package/dist/utils/only.d.ts +1 -0
- package/dist/utils/only.js +6 -0
- package/package.json +3 -3
- /package/dist/components/{box-fun → box}/index.css +0 -0
- /package/dist/components/{global-config → draggable}/index.css +0 -0
- /package/dist/css/{box-fun.css → box.css} +0 -0
- /package/dist/css/{global-config.css → draggable.css} +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { buildProps } from "../../../utils/vues/buildProps.js";
|
|
2
|
+
import { dataProps as dataProps$1 } from "../../box-teleport/src/data.js";
|
|
3
|
+
const name = "right-key-no";
|
|
4
|
+
const dataProps = buildProps({
|
|
5
|
+
...dataProps$1,
|
|
6
|
+
/**
|
|
7
|
+
* @props { Array<string> } options= ( )
|
|
8
|
+
* 选择列表
|
|
9
|
+
*/
|
|
10
|
+
options: {
|
|
11
|
+
type: Array,
|
|
12
|
+
default() {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* @props { String } domClass='' ( DOMString )
|
|
18
|
+
* 可以右键的元素的样式
|
|
19
|
+
*/
|
|
20
|
+
domClass: {
|
|
21
|
+
type: [String],
|
|
22
|
+
default: ""
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* @props { Number } level=5
|
|
26
|
+
* 向上查询层级
|
|
27
|
+
*/
|
|
28
|
+
level: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: 5
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* @props { String, Function } label=label
|
|
34
|
+
* 列表中展示名称
|
|
35
|
+
*/
|
|
36
|
+
label: {
|
|
37
|
+
type: [String, Function],
|
|
38
|
+
default: "label"
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* @props { String } boxClass
|
|
42
|
+
* 添加弹框的样式
|
|
43
|
+
*/
|
|
44
|
+
boxClass: {
|
|
45
|
+
type: [String]
|
|
46
|
+
},
|
|
47
|
+
// /**
|
|
48
|
+
// * @props { String, Function } prop=value 列表中对比的内容
|
|
49
|
+
// */
|
|
50
|
+
// prop: {
|
|
51
|
+
// type: [String, Function],
|
|
52
|
+
// default: 'value',
|
|
53
|
+
// },
|
|
54
|
+
isSingle: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: false
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const dataEmits = ["click-key", "click-right"];
|
|
60
|
+
const dataSlot = {
|
|
61
|
+
default: "default",
|
|
62
|
+
list: "list"
|
|
63
|
+
};
|
|
64
|
+
const dataExpose = {};
|
|
65
|
+
export {
|
|
66
|
+
dataEmits,
|
|
67
|
+
dataExpose,
|
|
68
|
+
dataProps,
|
|
69
|
+
dataSlot,
|
|
70
|
+
name
|
|
71
|
+
};
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const getPrentClass = require("@fangzhongya/utils/css/getPrentClass");
|
|
5
|
+
const use = require("../../common/use.cjs");
|
|
6
|
+
const index$4 = require("../../icon/index.cjs");
|
|
7
|
+
const index$3 = require("../../box-teleport/index.cjs");
|
|
8
|
+
const data = require("./data.cjs");
|
|
9
|
+
const index$1 = require("../../../hooks/cssname/index.cjs");
|
|
10
|
+
const index = require("../../../hooks/locale/index.cjs");
|
|
11
|
+
const getBoxDom = require("../../../utils/vues/getBoxDom.cjs");
|
|
12
|
+
const index$2 = require("../../../hooks/props-default/index.cjs");
|
|
13
|
+
const _hoisted_1 = ["onClick"];
|
|
14
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
15
|
+
__name: "index",
|
|
16
|
+
props: index$2.getProps(data.dataProps),
|
|
17
|
+
emits: data.dataEmits,
|
|
18
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
19
|
+
const slots = vue.useSlots();
|
|
20
|
+
const { getLocale } = index.useLocale();
|
|
21
|
+
const cs = index$1.useCssName(data.name);
|
|
22
|
+
const prs = __props;
|
|
23
|
+
const props = index$2.usePropsDefault(data.name, prs, data.dataProps);
|
|
24
|
+
const emit = __emit;
|
|
25
|
+
const flag = vue.ref(false);
|
|
26
|
+
const refDom = vue.ref();
|
|
27
|
+
const refRightKeyBox = vue.ref();
|
|
28
|
+
const position = vue.ref({ x: 0, y: 0 });
|
|
29
|
+
const targetElement = vue.ref();
|
|
30
|
+
const boxStyle = vue.computed(() => {
|
|
31
|
+
if (!refRightKeyBox.value) return {};
|
|
32
|
+
const rect = refRightKeyBox.value.getBoundingClientRect();
|
|
33
|
+
const { innerWidth, innerHeight } = window;
|
|
34
|
+
let x = position.value.x;
|
|
35
|
+
let y = position.value.y;
|
|
36
|
+
if (x + rect.width > innerWidth) {
|
|
37
|
+
x = Math.max(0, x - rect.width);
|
|
38
|
+
}
|
|
39
|
+
if (y + rect.height > innerHeight) {
|
|
40
|
+
y = Math.max(0, y - rect.height);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
top: `${y}px`,
|
|
44
|
+
left: `${x}px`,
|
|
45
|
+
zIndex: 9999
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
function handleGlobalClick(event) {
|
|
49
|
+
var _a;
|
|
50
|
+
if (event.button === 2) return;
|
|
51
|
+
if (!((_a = refRightKeyBox.value) == null ? void 0 : _a.contains(event.target))) {
|
|
52
|
+
flag.value = false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function handleKeydown(event) {
|
|
56
|
+
if (event.key === "Escape" && flag.value) {
|
|
57
|
+
flag.value = false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function isDomClass(dom) {
|
|
61
|
+
if (!dom) return null;
|
|
62
|
+
const rootElement = getRootElement();
|
|
63
|
+
if (!rootElement) return null;
|
|
64
|
+
if (props.domClass) {
|
|
65
|
+
const element = getPrentClass.getPrentClass(
|
|
66
|
+
dom,
|
|
67
|
+
props.domClass,
|
|
68
|
+
props.level
|
|
69
|
+
);
|
|
70
|
+
if (element && rootElement.contains(element)) {
|
|
71
|
+
return element;
|
|
72
|
+
}
|
|
73
|
+
} else if (rootElement.contains(dom)) {
|
|
74
|
+
return dom;
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
function getRootElement() {
|
|
79
|
+
var _a, _b, _c;
|
|
80
|
+
if ((_a = refDom.value) == null ? void 0 : _a.$el) {
|
|
81
|
+
return refDom.value.$el;
|
|
82
|
+
} else if (refDom.value instanceof HTMLElement) {
|
|
83
|
+
return refDom.value;
|
|
84
|
+
} else if ((_b = refDom.value) == null ? void 0 : _b.nextSibling) {
|
|
85
|
+
return (_c = refDom.value) == null ? void 0 : _c.nextSibling;
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
function handleContextmenu(event) {
|
|
90
|
+
const target = isDomClass(event.target);
|
|
91
|
+
if (!target) {
|
|
92
|
+
flag.value = false;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
targetElement.value = target;
|
|
96
|
+
let x = event.clientX;
|
|
97
|
+
let y = event.clientY;
|
|
98
|
+
flag.value = true;
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
event.stopPropagation();
|
|
101
|
+
emit("click-right", target);
|
|
102
|
+
vue.nextTick(() => {
|
|
103
|
+
position.value = { x, y };
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function onClick(v) {
|
|
107
|
+
flag.value = false;
|
|
108
|
+
emit("click-key", v, targetElement.value);
|
|
109
|
+
}
|
|
110
|
+
const toDom = vue.ref();
|
|
111
|
+
vue.watch(
|
|
112
|
+
() => flag.value,
|
|
113
|
+
() => {
|
|
114
|
+
if (!refRightKeyBox.value) return;
|
|
115
|
+
if (props.isSingle && toDom.value) {
|
|
116
|
+
if (flag.value) {
|
|
117
|
+
toDom.value.querySelectorAll("." + cs.z("box")).forEach((v) => {
|
|
118
|
+
v.style.display = "none";
|
|
119
|
+
});
|
|
120
|
+
vue.nextTick(() => {
|
|
121
|
+
refRightKeyBox.value.style.display = "block";
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
refRightKeyBox.value.style.display = "none";
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
refRightKeyBox.value.style.display = flag.value ? "block" : "none";
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
function bindEvent() {
|
|
132
|
+
const rootElement = getRootElement();
|
|
133
|
+
if (rootElement) {
|
|
134
|
+
rootElement.addEventListener("contextmenu", handleContextmenu);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
vue.onMounted(() => {
|
|
138
|
+
toDom.value = getBoxDom.getBoxDom();
|
|
139
|
+
vue.nextTick(() => {
|
|
140
|
+
bindEvent();
|
|
141
|
+
});
|
|
142
|
+
document.addEventListener("click", handleGlobalClick, true);
|
|
143
|
+
document.addEventListener("keydown", handleKeydown);
|
|
144
|
+
window.addEventListener("resize", () => {
|
|
145
|
+
if (flag.value) {
|
|
146
|
+
flag.value = false;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
window.addEventListener(
|
|
150
|
+
"scroll",
|
|
151
|
+
() => {
|
|
152
|
+
if (flag.value) {
|
|
153
|
+
flag.value = false;
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
true
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
vue.onUnmounted(() => {
|
|
160
|
+
document.removeEventListener("click", handleGlobalClick, true);
|
|
161
|
+
document.removeEventListener("keydown", handleKeydown);
|
|
162
|
+
window.removeEventListener("resize", () => {
|
|
163
|
+
});
|
|
164
|
+
window.removeEventListener("scroll", () => {
|
|
165
|
+
}, true);
|
|
166
|
+
});
|
|
167
|
+
__expose({
|
|
168
|
+
...data.dataExpose,
|
|
169
|
+
// 提供关闭菜单的方法
|
|
170
|
+
close: () => {
|
|
171
|
+
flag.value = false;
|
|
172
|
+
},
|
|
173
|
+
// 提供打开菜单的方法
|
|
174
|
+
open: (x, y, target) => {
|
|
175
|
+
position.value = { x, y };
|
|
176
|
+
targetElement.value = target;
|
|
177
|
+
flag.value = true;
|
|
178
|
+
},
|
|
179
|
+
// 重新绑定事件(用于动态内容)
|
|
180
|
+
rebind: () => {
|
|
181
|
+
vue.nextTick(() => {
|
|
182
|
+
bindEvent();
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
return (_ctx, _cache) => {
|
|
187
|
+
return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
|
|
188
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(slots).default), {
|
|
189
|
+
class: vue.normalizeClass(vue.unref(cs).z()),
|
|
190
|
+
ref_key: "refDom",
|
|
191
|
+
ref: refDom
|
|
192
|
+
}, null, 8, ["class"])),
|
|
193
|
+
vue.createVNode(vue.unref(index$3.BoxTeleport), {
|
|
194
|
+
disabled: vue.unref(props).disabled,
|
|
195
|
+
to: vue.unref(props).to
|
|
196
|
+
}, {
|
|
197
|
+
default: vue.withCtx(() => [
|
|
198
|
+
vue.withDirectives(vue.createElementVNode("div", {
|
|
199
|
+
class: vue.normalizeClass([vue.unref(cs).z("box"), vue.unref(props).boxClass]),
|
|
200
|
+
ref_key: "refRightKeyBox",
|
|
201
|
+
ref: refRightKeyBox,
|
|
202
|
+
style: vue.normalizeStyle(boxStyle.value),
|
|
203
|
+
onClick: _cache[0] || (_cache[0] = vue.withModifiers(() => {
|
|
204
|
+
}, ["stop"]))
|
|
205
|
+
}, [
|
|
206
|
+
vue.createElementVNode("div", {
|
|
207
|
+
class: vue.normalizeClass(vue.unref(cs).z("box-list"))
|
|
208
|
+
}, [
|
|
209
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(props).options, (v, k) => {
|
|
210
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
211
|
+
key: k,
|
|
212
|
+
onClick: vue.withModifiers(($event) => onClick(v), ["stop"]),
|
|
213
|
+
class: vue.normalizeClass(vue.unref(cs).z("box-list-li"))
|
|
214
|
+
}, [
|
|
215
|
+
vue.renderSlot(_ctx.$slots, vue.unref(data.dataSlot).list, {
|
|
216
|
+
value: v,
|
|
217
|
+
index: k
|
|
218
|
+
}, () => [
|
|
219
|
+
v.icon ? (vue.openBlock(), vue.createBlock(vue.unref(index$4.Icon), { key: 0 }, {
|
|
220
|
+
default: vue.withCtx(() => [
|
|
221
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(v.icon)))
|
|
222
|
+
]),
|
|
223
|
+
_: 2
|
|
224
|
+
}, 1024)) : vue.createCommentVNode("", true),
|
|
225
|
+
vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(use.useVueValue)(v, vue.unref(props).label)), 1)
|
|
226
|
+
])
|
|
227
|
+
], 10, _hoisted_1);
|
|
228
|
+
}), 128))
|
|
229
|
+
], 2)
|
|
230
|
+
], 6), [
|
|
231
|
+
[vue.vShow, flag.value]
|
|
232
|
+
])
|
|
233
|
+
]),
|
|
234
|
+
_: 3
|
|
235
|
+
}, 8, ["disabled", "to"])
|
|
236
|
+
], 64);
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
exports.default = _sfc_main;
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { defineComponent, useSlots, ref, computed, nextTick, watch, onMounted, onUnmounted, createElementBlock, openBlock, Fragment, createBlock, createVNode, resolveDynamicComponent, unref, normalizeClass, withCtx, withDirectives, createElementVNode, withModifiers, normalizeStyle, renderList, renderSlot, createCommentVNode, toDisplayString, vShow } from "vue";
|
|
2
|
+
import { getPrentClass } from "@fangzhongya/utils/css/getPrentClass";
|
|
3
|
+
import { useVueValue } from "../../common/use.js";
|
|
4
|
+
import { Icon } from "../../icon/index.js";
|
|
5
|
+
import { BoxTeleport } from "../../box-teleport/index.js";
|
|
6
|
+
import { name, dataProps, dataExpose, dataSlot, dataEmits } from "./data.js";
|
|
7
|
+
import { useCssName } from "../../../hooks/cssname/index.js";
|
|
8
|
+
import { useLocale } from "../../../hooks/locale/index.js";
|
|
9
|
+
import { getBoxDom } from "../../../utils/vues/getBoxDom.js";
|
|
10
|
+
import { usePropsDefault, getProps } from "../../../hooks/props-default/index.js";
|
|
11
|
+
const _hoisted_1 = ["onClick"];
|
|
12
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
13
|
+
__name: "index",
|
|
14
|
+
props: getProps(dataProps),
|
|
15
|
+
emits: dataEmits,
|
|
16
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
17
|
+
const slots = useSlots();
|
|
18
|
+
const { getLocale } = useLocale();
|
|
19
|
+
const cs = useCssName(name);
|
|
20
|
+
const prs = __props;
|
|
21
|
+
const props = usePropsDefault(name, prs, dataProps);
|
|
22
|
+
const emit = __emit;
|
|
23
|
+
const flag = ref(false);
|
|
24
|
+
const refDom = ref();
|
|
25
|
+
const refRightKeyBox = ref();
|
|
26
|
+
const position = ref({ x: 0, y: 0 });
|
|
27
|
+
const targetElement = ref();
|
|
28
|
+
const boxStyle = computed(() => {
|
|
29
|
+
if (!refRightKeyBox.value) return {};
|
|
30
|
+
const rect = refRightKeyBox.value.getBoundingClientRect();
|
|
31
|
+
const { innerWidth, innerHeight } = window;
|
|
32
|
+
let x = position.value.x;
|
|
33
|
+
let y = position.value.y;
|
|
34
|
+
if (x + rect.width > innerWidth) {
|
|
35
|
+
x = Math.max(0, x - rect.width);
|
|
36
|
+
}
|
|
37
|
+
if (y + rect.height > innerHeight) {
|
|
38
|
+
y = Math.max(0, y - rect.height);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
top: `${y}px`,
|
|
42
|
+
left: `${x}px`,
|
|
43
|
+
zIndex: 9999
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
function handleGlobalClick(event) {
|
|
47
|
+
var _a;
|
|
48
|
+
if (event.button === 2) return;
|
|
49
|
+
if (!((_a = refRightKeyBox.value) == null ? void 0 : _a.contains(event.target))) {
|
|
50
|
+
flag.value = false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function handleKeydown(event) {
|
|
54
|
+
if (event.key === "Escape" && flag.value) {
|
|
55
|
+
flag.value = false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function isDomClass(dom) {
|
|
59
|
+
if (!dom) return null;
|
|
60
|
+
const rootElement = getRootElement();
|
|
61
|
+
if (!rootElement) return null;
|
|
62
|
+
if (props.domClass) {
|
|
63
|
+
const element = getPrentClass(
|
|
64
|
+
dom,
|
|
65
|
+
props.domClass,
|
|
66
|
+
props.level
|
|
67
|
+
);
|
|
68
|
+
if (element && rootElement.contains(element)) {
|
|
69
|
+
return element;
|
|
70
|
+
}
|
|
71
|
+
} else if (rootElement.contains(dom)) {
|
|
72
|
+
return dom;
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
function getRootElement() {
|
|
77
|
+
var _a, _b, _c;
|
|
78
|
+
if ((_a = refDom.value) == null ? void 0 : _a.$el) {
|
|
79
|
+
return refDom.value.$el;
|
|
80
|
+
} else if (refDom.value instanceof HTMLElement) {
|
|
81
|
+
return refDom.value;
|
|
82
|
+
} else if ((_b = refDom.value) == null ? void 0 : _b.nextSibling) {
|
|
83
|
+
return (_c = refDom.value) == null ? void 0 : _c.nextSibling;
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
function handleContextmenu(event) {
|
|
88
|
+
const target = isDomClass(event.target);
|
|
89
|
+
if (!target) {
|
|
90
|
+
flag.value = false;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
targetElement.value = target;
|
|
94
|
+
let x = event.clientX;
|
|
95
|
+
let y = event.clientY;
|
|
96
|
+
flag.value = true;
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
event.stopPropagation();
|
|
99
|
+
emit("click-right", target);
|
|
100
|
+
nextTick(() => {
|
|
101
|
+
position.value = { x, y };
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function onClick(v) {
|
|
105
|
+
flag.value = false;
|
|
106
|
+
emit("click-key", v, targetElement.value);
|
|
107
|
+
}
|
|
108
|
+
const toDom = ref();
|
|
109
|
+
watch(
|
|
110
|
+
() => flag.value,
|
|
111
|
+
() => {
|
|
112
|
+
if (!refRightKeyBox.value) return;
|
|
113
|
+
if (props.isSingle && toDom.value) {
|
|
114
|
+
if (flag.value) {
|
|
115
|
+
toDom.value.querySelectorAll("." + cs.z("box")).forEach((v) => {
|
|
116
|
+
v.style.display = "none";
|
|
117
|
+
});
|
|
118
|
+
nextTick(() => {
|
|
119
|
+
refRightKeyBox.value.style.display = "block";
|
|
120
|
+
});
|
|
121
|
+
} else {
|
|
122
|
+
refRightKeyBox.value.style.display = "none";
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
refRightKeyBox.value.style.display = flag.value ? "block" : "none";
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
function bindEvent() {
|
|
130
|
+
const rootElement = getRootElement();
|
|
131
|
+
if (rootElement) {
|
|
132
|
+
rootElement.addEventListener("contextmenu", handleContextmenu);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
onMounted(() => {
|
|
136
|
+
toDom.value = getBoxDom();
|
|
137
|
+
nextTick(() => {
|
|
138
|
+
bindEvent();
|
|
139
|
+
});
|
|
140
|
+
document.addEventListener("click", handleGlobalClick, true);
|
|
141
|
+
document.addEventListener("keydown", handleKeydown);
|
|
142
|
+
window.addEventListener("resize", () => {
|
|
143
|
+
if (flag.value) {
|
|
144
|
+
flag.value = false;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
window.addEventListener(
|
|
148
|
+
"scroll",
|
|
149
|
+
() => {
|
|
150
|
+
if (flag.value) {
|
|
151
|
+
flag.value = false;
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
true
|
|
155
|
+
);
|
|
156
|
+
});
|
|
157
|
+
onUnmounted(() => {
|
|
158
|
+
document.removeEventListener("click", handleGlobalClick, true);
|
|
159
|
+
document.removeEventListener("keydown", handleKeydown);
|
|
160
|
+
window.removeEventListener("resize", () => {
|
|
161
|
+
});
|
|
162
|
+
window.removeEventListener("scroll", () => {
|
|
163
|
+
}, true);
|
|
164
|
+
});
|
|
165
|
+
__expose({
|
|
166
|
+
...dataExpose,
|
|
167
|
+
// 提供关闭菜单的方法
|
|
168
|
+
close: () => {
|
|
169
|
+
flag.value = false;
|
|
170
|
+
},
|
|
171
|
+
// 提供打开菜单的方法
|
|
172
|
+
open: (x, y, target) => {
|
|
173
|
+
position.value = { x, y };
|
|
174
|
+
targetElement.value = target;
|
|
175
|
+
flag.value = true;
|
|
176
|
+
},
|
|
177
|
+
// 重新绑定事件(用于动态内容)
|
|
178
|
+
rebind: () => {
|
|
179
|
+
nextTick(() => {
|
|
180
|
+
bindEvent();
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
return (_ctx, _cache) => {
|
|
185
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
186
|
+
(openBlock(), createBlock(resolveDynamicComponent(unref(slots).default), {
|
|
187
|
+
class: normalizeClass(unref(cs).z()),
|
|
188
|
+
ref_key: "refDom",
|
|
189
|
+
ref: refDom
|
|
190
|
+
}, null, 8, ["class"])),
|
|
191
|
+
createVNode(unref(BoxTeleport), {
|
|
192
|
+
disabled: unref(props).disabled,
|
|
193
|
+
to: unref(props).to
|
|
194
|
+
}, {
|
|
195
|
+
default: withCtx(() => [
|
|
196
|
+
withDirectives(createElementVNode("div", {
|
|
197
|
+
class: normalizeClass([unref(cs).z("box"), unref(props).boxClass]),
|
|
198
|
+
ref_key: "refRightKeyBox",
|
|
199
|
+
ref: refRightKeyBox,
|
|
200
|
+
style: normalizeStyle(boxStyle.value),
|
|
201
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
202
|
+
}, ["stop"]))
|
|
203
|
+
}, [
|
|
204
|
+
createElementVNode("div", {
|
|
205
|
+
class: normalizeClass(unref(cs).z("box-list"))
|
|
206
|
+
}, [
|
|
207
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(props).options, (v, k) => {
|
|
208
|
+
return openBlock(), createElementBlock("div", {
|
|
209
|
+
key: k,
|
|
210
|
+
onClick: withModifiers(($event) => onClick(v), ["stop"]),
|
|
211
|
+
class: normalizeClass(unref(cs).z("box-list-li"))
|
|
212
|
+
}, [
|
|
213
|
+
renderSlot(_ctx.$slots, unref(dataSlot).list, {
|
|
214
|
+
value: v,
|
|
215
|
+
index: k
|
|
216
|
+
}, () => [
|
|
217
|
+
v.icon ? (openBlock(), createBlock(unref(Icon), { key: 0 }, {
|
|
218
|
+
default: withCtx(() => [
|
|
219
|
+
(openBlock(), createBlock(resolveDynamicComponent(v.icon)))
|
|
220
|
+
]),
|
|
221
|
+
_: 2
|
|
222
|
+
}, 1024)) : createCommentVNode("", true),
|
|
223
|
+
createElementVNode("span", null, toDisplayString(unref(useVueValue)(v, unref(props).label)), 1)
|
|
224
|
+
])
|
|
225
|
+
], 10, _hoisted_1);
|
|
226
|
+
}), 128))
|
|
227
|
+
], 2)
|
|
228
|
+
], 6), [
|
|
229
|
+
[vShow, flag.value]
|
|
230
|
+
])
|
|
231
|
+
]),
|
|
232
|
+
_: 3
|
|
233
|
+
}, 8, ["disabled", "to"])
|
|
234
|
+
], 64);
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
export {
|
|
239
|
+
_sfc_main as default
|
|
240
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@use '../index.scss' as *;
|
package/dist/css/index.css
CHANGED
|
@@ -790,6 +790,35 @@
|
|
|
790
790
|
justify-content: center;
|
|
791
791
|
}
|
|
792
792
|
|
|
793
|
+
.right-key-no-box {
|
|
794
|
+
width: 140px;
|
|
795
|
+
position: fixed;
|
|
796
|
+
padding: 10px;
|
|
797
|
+
z-index: 9999;
|
|
798
|
+
background: #ffffff;
|
|
799
|
+
border: 1px solid #cfd7e5;
|
|
800
|
+
border-radius: 8px;
|
|
801
|
+
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
802
|
+
}
|
|
803
|
+
.right-key-no-box-list-li:hover {
|
|
804
|
+
background: #ecf5ff;
|
|
805
|
+
color: #66b1ff;
|
|
806
|
+
}
|
|
807
|
+
.right-key-no-box-list-li {
|
|
808
|
+
white-space: nowrap;
|
|
809
|
+
display: flex;
|
|
810
|
+
align-items: center;
|
|
811
|
+
box-sizing: border-box;
|
|
812
|
+
height: 40px;
|
|
813
|
+
padding: 8px 14px 8px 10px;
|
|
814
|
+
border-radius: 4px;
|
|
815
|
+
font-size: 16px;
|
|
816
|
+
cursor: pointer;
|
|
817
|
+
}
|
|
818
|
+
.right-key-no-box-list-li i {
|
|
819
|
+
margin-right: 10px;
|
|
820
|
+
}
|
|
821
|
+
|
|
793
822
|
.right-key-box {
|
|
794
823
|
width: 140px;
|
|
795
824
|
position: fixed;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--on: rgb(91, 189, 246);
|
|
3
|
+
--color-primary: #409eff;
|
|
4
|
+
--bag-primary: #409eff;
|
|
5
|
+
--bag-primary-text: #ffffff;
|
|
6
|
+
--border: #eee;
|
|
7
|
+
--layout-panel-gap: 10px;
|
|
8
|
+
--layout-panel-padding: 20px;
|
|
9
|
+
--layout-form-item-padding-right: var(
|
|
10
|
+
--layout-panel-gap
|
|
11
|
+
);
|
|
12
|
+
--g-main-bg: var(--bg-color-page);
|
|
13
|
+
--lable-array-height: 20px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.com-footer {
|
|
17
|
+
border-top: 1px solid var(--border);
|
|
18
|
+
padding: 20px 20px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.com-lable-array {
|
|
22
|
+
line-height: var(--lable-array-height);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.right-key-no-box {
|
|
26
|
+
width: 140px;
|
|
27
|
+
position: fixed;
|
|
28
|
+
padding: 10px;
|
|
29
|
+
z-index: 9999;
|
|
30
|
+
background: #ffffff;
|
|
31
|
+
border: 1px solid #cfd7e5;
|
|
32
|
+
border-radius: 8px;
|
|
33
|
+
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
34
|
+
}
|
|
35
|
+
.right-key-no-box-list-li:hover {
|
|
36
|
+
background: #ecf5ff;
|
|
37
|
+
color: #66b1ff;
|
|
38
|
+
}
|
|
39
|
+
.right-key-no-box-list-li {
|
|
40
|
+
white-space: nowrap;
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
box-sizing: border-box;
|
|
44
|
+
height: 40px;
|
|
45
|
+
padding: 8px 14px 8px 10px;
|
|
46
|
+
border-radius: 4px;
|
|
47
|
+
font-size: 16px;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
}
|
|
50
|
+
.right-key-no-box-list-li i {
|
|
51
|
+
margin-right: 10px;
|
|
52
|
+
}
|
|
@@ -80,6 +80,7 @@ var config_default = {
|
|
|
80
80
|
"no-data",
|
|
81
81
|
"popup",
|
|
82
82
|
"right-key",
|
|
83
|
+
"right-key-no",
|
|
83
84
|
"seamless-scroll",
|
|
84
85
|
"stick-div",
|
|
85
86
|
"stick-edge",
|
|
@@ -171,6 +172,7 @@ var config_default = {
|
|
|
171
172
|
"no-data",
|
|
172
173
|
"popup",
|
|
173
174
|
"right-key",
|
|
175
|
+
"right-key-no",
|
|
174
176
|
"seamless-scroll",
|
|
175
177
|
"window",
|
|
176
178
|
"icon",
|
|
@@ -80,6 +80,7 @@ var config_default = {
|
|
|
80
80
|
"no-data",
|
|
81
81
|
"popup",
|
|
82
82
|
"right-key",
|
|
83
|
+
"right-key-no",
|
|
83
84
|
"seamless-scroll",
|
|
84
85
|
"stick-div",
|
|
85
86
|
"stick-edge",
|
|
@@ -171,6 +172,7 @@ var config_default = {
|
|
|
171
172
|
"no-data",
|
|
172
173
|
"popup",
|
|
173
174
|
"right-key",
|
|
175
|
+
"right-key-no",
|
|
174
176
|
"seamless-scroll",
|
|
175
177
|
"window",
|
|
176
178
|
"icon",
|