lew-ui 2.7.46 → 2.7.47
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/LICENSE +21 -21
- package/dist/LewContextMenu-Cg9aKaqV.js +219 -0
- package/dist/components/general/avatar/index.d.ts +0 -1
- package/dist/components/general/avatar/src/LewAvatar.vue.d.ts +5 -8
- package/dist/components/general/avatar/src/props.d.ts +1 -0
- package/dist/components/general/image/index.d.ts +0 -1
- package/dist/index-DkcjzNyl.js +37170 -0
- package/dist/index.css +1 -1
- package/dist/index.js +225 -37555
- package/dist/index.umd.cjs +14 -20
- package/package.json +1 -2
- package/dist/components/general/avatar/src/emits.d.ts +0 -4
- package/dist/components/general/image/src/emits.d.ts +0 -5
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 lew
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 lew
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { defineComponent, computed, shallowRef, onMounted, nextTick, onBeforeUnmount, createBlock, openBlock, unref, withCtx, createElementBlock, Fragment, renderList, normalizeClass, createElementVNode, normalizeStyle, createCommentVNode, createVNode, createApp, h, defineAsyncComponent } from "vue";
|
|
2
|
+
import { c as contextMenuProps, g as getUniqueId, L as LewFlex, C as CommonIcon, _ as _sfc_main$1, a as LewEmpty, i as isFunction, b as initLewContextMenu, t as tippy, d as _export_sfc } from "./index-DkcjzNyl.js";
|
|
3
|
+
const contextMenuEmits = {
|
|
4
|
+
change: (item) => item
|
|
5
|
+
};
|
|
6
|
+
const _hoisted_1 = ["onClick"];
|
|
7
|
+
const _hoisted_2 = {
|
|
8
|
+
key: 0,
|
|
9
|
+
class: "lew-context-menu-checkable"
|
|
10
|
+
};
|
|
11
|
+
const _hoisted_3 = { class: "lew-context-menu-label" };
|
|
12
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
13
|
+
__name: "LewContextMenu",
|
|
14
|
+
props: contextMenuProps,
|
|
15
|
+
emits: contextMenuEmits,
|
|
16
|
+
setup(__props, { emit: __emit }) {
|
|
17
|
+
const props = __props;
|
|
18
|
+
const emit = __emit;
|
|
19
|
+
const _options = computed(() => props.options);
|
|
20
|
+
const hasCheckableItems = computed(() => _options.value.some((item) => item.checkable));
|
|
21
|
+
const hasChildrenItems = computed(
|
|
22
|
+
() => _options.value.some((item) => item.children?.length)
|
|
23
|
+
);
|
|
24
|
+
const proxyCache = /* @__PURE__ */ new WeakMap();
|
|
25
|
+
function createItemProxy(item) {
|
|
26
|
+
if (proxyCache.has(item)) {
|
|
27
|
+
return proxyCache.get(item);
|
|
28
|
+
}
|
|
29
|
+
const proxy = new Proxy(item, {
|
|
30
|
+
get(target, prop, receiver) {
|
|
31
|
+
return Reflect.get(target, prop, receiver);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
proxyCache.set(item, proxy);
|
|
35
|
+
return proxy;
|
|
36
|
+
}
|
|
37
|
+
function clickItem(item) {
|
|
38
|
+
if (item.disabled)
|
|
39
|
+
return;
|
|
40
|
+
const instance = props.dropdownInstance || window.LewContextMenu?.instance || null;
|
|
41
|
+
if (isFunction(item.onClick)) {
|
|
42
|
+
try {
|
|
43
|
+
const proxyItem = createItemProxy(item);
|
|
44
|
+
const proxyOptions = new Proxy(_options.value, {
|
|
45
|
+
get(target, prop, receiver) {
|
|
46
|
+
return Reflect.get(target, prop, receiver);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
item.onClick?.(proxyItem, proxyOptions, instance);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error("[LewContextMenu] Error in onClick handler:", error);
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
instance?.hide();
|
|
55
|
+
}
|
|
56
|
+
emit("change", item);
|
|
57
|
+
}
|
|
58
|
+
const TIPPY_CONFIG = {
|
|
59
|
+
theme: "light",
|
|
60
|
+
animation: "shift-away-subtle",
|
|
61
|
+
trigger: "mouseenter",
|
|
62
|
+
interactive: true,
|
|
63
|
+
placement: "right-start",
|
|
64
|
+
duration: [250, 250],
|
|
65
|
+
delay: [120, 120],
|
|
66
|
+
arrow: false,
|
|
67
|
+
offset: [0, 0],
|
|
68
|
+
allowHTML: true,
|
|
69
|
+
hideOnClick: false,
|
|
70
|
+
zIndex: 2001
|
|
71
|
+
};
|
|
72
|
+
const uniqueId = getUniqueId();
|
|
73
|
+
const subMenuInstances = /* @__PURE__ */ new Map();
|
|
74
|
+
const itemRefs = shallowRef([]);
|
|
75
|
+
function setItemRef(el, index) {
|
|
76
|
+
if (el && el instanceof HTMLElement) {
|
|
77
|
+
itemRefs.value[index] = el;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function createSubMenu(options) {
|
|
81
|
+
const menuDom = document.createElement("div");
|
|
82
|
+
const app = createApp({
|
|
83
|
+
render() {
|
|
84
|
+
return h(
|
|
85
|
+
defineAsyncComponent(() => Promise.resolve().then(() => LewContextMenu$1)),
|
|
86
|
+
{
|
|
87
|
+
options,
|
|
88
|
+
onChange: (item) => emit("change", item)
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
app.mount(menuDom);
|
|
94
|
+
return { element: menuDom, app };
|
|
95
|
+
}
|
|
96
|
+
function initTippy() {
|
|
97
|
+
itemRefs.value.forEach((el, index) => {
|
|
98
|
+
const option = _options.value[index];
|
|
99
|
+
if (!el || option?.disabled || !option?.children?.length) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
if (!window.LewContextMenu) {
|
|
104
|
+
initLewContextMenu();
|
|
105
|
+
}
|
|
106
|
+
const { element: menuDom, app } = createSubMenu(option.children);
|
|
107
|
+
const tippyInstances = tippy(el, {
|
|
108
|
+
...TIPPY_CONFIG,
|
|
109
|
+
content: menuDom
|
|
110
|
+
});
|
|
111
|
+
const tippyInstance = Array.isArray(tippyInstances) ? tippyInstances[0] : tippyInstances;
|
|
112
|
+
subMenuInstances.set(index, { app, tippy: tippyInstance });
|
|
113
|
+
window.LewContextMenu.menuInstance[`${uniqueId}-${index}`] = tippyInstance;
|
|
114
|
+
const popperElement = tippyInstance.popper?.children?.[0];
|
|
115
|
+
popperElement?.setAttribute("data-lew", "popover");
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.error("[LewContextMenu] Failed to initialize submenu:", error);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function cleanup() {
|
|
122
|
+
subMenuInstances.forEach(({ app, tippy: tippy2 }, index) => {
|
|
123
|
+
try {
|
|
124
|
+
app?.unmount?.();
|
|
125
|
+
tippy2?.destroy?.();
|
|
126
|
+
const key = `${uniqueId}-${index}`;
|
|
127
|
+
if (window.LewContextMenu?.menuInstance?.[key]) {
|
|
128
|
+
delete window.LewContextMenu.menuInstance[key];
|
|
129
|
+
}
|
|
130
|
+
} catch (error) {
|
|
131
|
+
console.warn("[LewContextMenu] Failed to cleanup submenu instance:", error);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
subMenuInstances.clear();
|
|
135
|
+
}
|
|
136
|
+
onMounted(() => {
|
|
137
|
+
nextTick(() => {
|
|
138
|
+
initTippy();
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
onBeforeUnmount(() => {
|
|
142
|
+
cleanup();
|
|
143
|
+
});
|
|
144
|
+
return (_ctx, _cache) => {
|
|
145
|
+
return openBlock(), createBlock(unref(LewFlex), {
|
|
146
|
+
direction: "y",
|
|
147
|
+
gap: "0",
|
|
148
|
+
class: "lew-context-menu"
|
|
149
|
+
}, {
|
|
150
|
+
default: withCtx(() => [
|
|
151
|
+
unref(_options).length > 0 ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(unref(_options), (item, index) => {
|
|
152
|
+
return openBlock(), createElementBlock("div", {
|
|
153
|
+
key: `menu-item-${index}`,
|
|
154
|
+
class: normalizeClass(["lew-context-menu-box", {
|
|
155
|
+
"lew-context-menu-box-disabled": item.disabled,
|
|
156
|
+
"lew-context-menu-box-divider-line": item.isDividerLine
|
|
157
|
+
}])
|
|
158
|
+
}, [
|
|
159
|
+
createElementVNode("div", {
|
|
160
|
+
ref_for: true,
|
|
161
|
+
ref: (el) => setItemRef(el, index),
|
|
162
|
+
class: normalizeClass(["lew-context-menu-item", {
|
|
163
|
+
"lew-context-menu-item-active": item.active,
|
|
164
|
+
"lew-context-menu-item-disabled": item.disabled
|
|
165
|
+
}]),
|
|
166
|
+
style: normalizeStyle({ "animation-delay": `${index * 10}ms` }),
|
|
167
|
+
onClick: ($event) => clickItem(item)
|
|
168
|
+
}, [
|
|
169
|
+
unref(hasCheckableItems) ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
170
|
+
item.checked ? (openBlock(), createBlock(CommonIcon, {
|
|
171
|
+
key: 0,
|
|
172
|
+
size: 12,
|
|
173
|
+
"stroke-width": 2.5,
|
|
174
|
+
type: "check"
|
|
175
|
+
})) : createCommentVNode("", true)
|
|
176
|
+
])) : createCommentVNode("", true),
|
|
177
|
+
createElementVNode("div", _hoisted_3, [
|
|
178
|
+
item.icon ? (openBlock(), createBlock(_sfc_main$1, {
|
|
179
|
+
key: 0,
|
|
180
|
+
"render-fn": item.icon
|
|
181
|
+
}, null, 8, ["render-fn"])) : createCommentVNode("", true),
|
|
182
|
+
createVNode(_sfc_main$1, {
|
|
183
|
+
class: "lew-context-menu-label-text",
|
|
184
|
+
"render-fn": item.label
|
|
185
|
+
}, null, 8, ["render-fn"])
|
|
186
|
+
]),
|
|
187
|
+
unref(hasChildrenItems) ? (openBlock(), createBlock(CommonIcon, {
|
|
188
|
+
key: 1,
|
|
189
|
+
class: "lew-context-menu-item-chevron",
|
|
190
|
+
size: 14,
|
|
191
|
+
style: normalizeStyle({
|
|
192
|
+
opacity: item.children?.length ? 1 : 0
|
|
193
|
+
}),
|
|
194
|
+
type: "chevron-right"
|
|
195
|
+
}, null, 8, ["style"])) : createCommentVNode("", true)
|
|
196
|
+
], 14, _hoisted_1)
|
|
197
|
+
], 2);
|
|
198
|
+
}), 128)) : (openBlock(), createBlock(unref(LewEmpty), {
|
|
199
|
+
key: 1,
|
|
200
|
+
width: "120px",
|
|
201
|
+
padding: "5px",
|
|
202
|
+
"font-size": "12px",
|
|
203
|
+
type: "search",
|
|
204
|
+
title: "暂无操作"
|
|
205
|
+
}))
|
|
206
|
+
]),
|
|
207
|
+
_: 1
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
const LewContextMenu = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-07a78cb9"]]);
|
|
213
|
+
const LewContextMenu$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
214
|
+
__proto__: null,
|
|
215
|
+
default: LewContextMenu
|
|
216
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
217
|
+
export {
|
|
218
|
+
LewContextMenu as default
|
|
219
|
+
};
|
|
@@ -17,6 +17,7 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
|
|
|
17
17
|
};
|
|
18
18
|
src: {
|
|
19
19
|
type: StringConstructor;
|
|
20
|
+
default: string;
|
|
20
21
|
validator: (value: any) => boolean;
|
|
21
22
|
};
|
|
22
23
|
alt: {
|
|
@@ -46,10 +47,7 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
|
|
|
46
47
|
default: string;
|
|
47
48
|
validator: (value: any) => boolean;
|
|
48
49
|
};
|
|
49
|
-
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
50
|
-
error: () => void;
|
|
51
|
-
load: () => void;
|
|
52
|
-
}, string, import('vue').PublicProps, Readonly<globalThis.ExtractPropTypes<{
|
|
50
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<globalThis.ExtractPropTypes<{
|
|
53
51
|
size: {
|
|
54
52
|
type: StringConstructor;
|
|
55
53
|
default: string;
|
|
@@ -68,6 +66,7 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
|
|
|
68
66
|
};
|
|
69
67
|
src: {
|
|
70
68
|
type: StringConstructor;
|
|
69
|
+
default: string;
|
|
71
70
|
validator: (value: any) => boolean;
|
|
72
71
|
};
|
|
73
72
|
alt: {
|
|
@@ -97,14 +96,12 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
|
|
|
97
96
|
default: string;
|
|
98
97
|
validator: (value: any) => boolean;
|
|
99
98
|
};
|
|
100
|
-
}>> & Readonly<{
|
|
101
|
-
onError?: (() => any) | undefined;
|
|
102
|
-
onLoad?: (() => any) | undefined;
|
|
103
|
-
}>, {
|
|
99
|
+
}>> & Readonly<{}>, {
|
|
104
100
|
loading: boolean;
|
|
105
101
|
size: string;
|
|
106
102
|
objectFit: import('../../../..').LewImageObjectFit;
|
|
107
103
|
objectPosition: import('../../../..').LewImageObjectPosition;
|
|
104
|
+
src: string;
|
|
108
105
|
shape: import('../../../..').LewAvatarShape;
|
|
109
106
|
statusPlacement: import('../../../..').LewAvatarPlacement;
|
|
110
107
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
|