lew-ui 2.7.29 → 2.7.32

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.
@@ -0,0 +1,218 @@
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-Cue9CPcJ.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) return;
39
+ const instance = props.dropdownInstance || window.LewContextMenu?.instance || null;
40
+ if (isFunction(item.onClick)) {
41
+ try {
42
+ const proxyItem = createItemProxy(item);
43
+ const proxyOptions = new Proxy(_options.value, {
44
+ get(target, prop, receiver) {
45
+ return Reflect.get(target, prop, receiver);
46
+ }
47
+ });
48
+ item.onClick?.(proxyItem, proxyOptions, instance);
49
+ } catch (error) {
50
+ console.error("[LewContextMenu] Error in onClick handler:", error);
51
+ }
52
+ } else {
53
+ instance?.hide();
54
+ }
55
+ emit("change", item);
56
+ }
57
+ const TIPPY_CONFIG = {
58
+ theme: "light",
59
+ animation: "shift-away-subtle",
60
+ trigger: "mouseenter",
61
+ interactive: true,
62
+ placement: "right-start",
63
+ duration: [250, 250],
64
+ delay: [120, 120],
65
+ arrow: false,
66
+ offset: [0, 0],
67
+ allowHTML: true,
68
+ hideOnClick: false,
69
+ zIndex: 2001
70
+ };
71
+ const uniqueId = getUniqueId();
72
+ const subMenuInstances = /* @__PURE__ */ new Map();
73
+ const itemRefs = shallowRef([]);
74
+ function setItemRef(el, index) {
75
+ if (el && el instanceof HTMLElement) {
76
+ itemRefs.value[index] = el;
77
+ }
78
+ }
79
+ function createSubMenu(options) {
80
+ const menuDom = document.createElement("div");
81
+ const app = createApp({
82
+ render() {
83
+ return h(
84
+ defineAsyncComponent(() => Promise.resolve().then(() => LewContextMenu$1)),
85
+ {
86
+ options,
87
+ onChange: (item) => emit("change", item)
88
+ }
89
+ );
90
+ }
91
+ });
92
+ app.mount(menuDom);
93
+ return { element: menuDom, app };
94
+ }
95
+ function initTippy() {
96
+ itemRefs.value.forEach((el, index) => {
97
+ const option = _options.value[index];
98
+ if (!el || option?.disabled || !option?.children?.length) {
99
+ return;
100
+ }
101
+ try {
102
+ if (!window.LewContextMenu) {
103
+ initLewContextMenu();
104
+ }
105
+ const { element: menuDom, app } = createSubMenu(option.children);
106
+ const tippyInstances = tippy(el, {
107
+ ...TIPPY_CONFIG,
108
+ content: menuDom
109
+ });
110
+ const tippyInstance = Array.isArray(tippyInstances) ? tippyInstances[0] : tippyInstances;
111
+ subMenuInstances.set(index, { app, tippy: tippyInstance });
112
+ window.LewContextMenu.menuInstance[`${uniqueId}-${index}`] = tippyInstance;
113
+ const popperElement = tippyInstance.popper?.children?.[0];
114
+ popperElement?.setAttribute("data-lew", "popover");
115
+ } catch (error) {
116
+ console.error("[LewContextMenu] Failed to initialize submenu:", error);
117
+ }
118
+ });
119
+ }
120
+ function cleanup() {
121
+ subMenuInstances.forEach(({ app, tippy: tippy2 }, index) => {
122
+ try {
123
+ app?.unmount?.();
124
+ tippy2?.destroy?.();
125
+ const key = `${uniqueId}-${index}`;
126
+ if (window.LewContextMenu?.menuInstance?.[key]) {
127
+ delete window.LewContextMenu.menuInstance[key];
128
+ }
129
+ } catch (error) {
130
+ console.warn("[LewContextMenu] Failed to cleanup submenu instance:", error);
131
+ }
132
+ });
133
+ subMenuInstances.clear();
134
+ }
135
+ onMounted(() => {
136
+ nextTick(() => {
137
+ initTippy();
138
+ });
139
+ });
140
+ onBeforeUnmount(() => {
141
+ cleanup();
142
+ });
143
+ return (_ctx, _cache) => {
144
+ return openBlock(), createBlock(unref(LewFlex), {
145
+ direction: "y",
146
+ gap: "0",
147
+ class: "lew-context-menu"
148
+ }, {
149
+ default: withCtx(() => [
150
+ unref(_options).length > 0 ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(unref(_options), (item, index) => {
151
+ return openBlock(), createElementBlock("div", {
152
+ key: `menu-item-${index}`,
153
+ class: normalizeClass(["lew-context-menu-box", {
154
+ "lew-context-menu-box-disabled": item.disabled,
155
+ "lew-context-menu-box-divider-line": item.isDividerLine
156
+ }])
157
+ }, [
158
+ createElementVNode("div", {
159
+ ref_for: true,
160
+ ref: (el) => setItemRef(el, index),
161
+ class: normalizeClass(["lew-context-menu-item", {
162
+ "lew-context-menu-item-active": item.active,
163
+ "lew-context-menu-item-disabled": item.disabled
164
+ }]),
165
+ style: normalizeStyle({ "animation-delay": `${index * 10}ms` }),
166
+ onClick: ($event) => clickItem(item)
167
+ }, [
168
+ unref(hasCheckableItems) ? (openBlock(), createElementBlock("div", _hoisted_2, [
169
+ item.checked ? (openBlock(), createBlock(CommonIcon, {
170
+ key: 0,
171
+ size: 12,
172
+ "stroke-width": 2.5,
173
+ type: "check"
174
+ })) : createCommentVNode("", true)
175
+ ])) : createCommentVNode("", true),
176
+ createElementVNode("div", _hoisted_3, [
177
+ item.icon ? (openBlock(), createBlock(_sfc_main$1, {
178
+ key: 0,
179
+ "render-fn": item.icon
180
+ }, null, 8, ["render-fn"])) : createCommentVNode("", true),
181
+ createVNode(_sfc_main$1, {
182
+ class: "lew-context-menu-label-text",
183
+ "render-fn": item.label
184
+ }, null, 8, ["render-fn"])
185
+ ]),
186
+ unref(hasChildrenItems) ? (openBlock(), createBlock(CommonIcon, {
187
+ key: 1,
188
+ class: "lew-context-menu-item-chevron",
189
+ size: 14,
190
+ style: normalizeStyle({
191
+ opacity: item.children?.length ? 1 : 0
192
+ }),
193
+ type: "chevron-right"
194
+ }, null, 8, ["style"])) : createCommentVNode("", true)
195
+ ], 14, _hoisted_1)
196
+ ], 2);
197
+ }), 128)) : (openBlock(), createBlock(unref(LewEmpty), {
198
+ key: 1,
199
+ width: "120px",
200
+ padding: "5px",
201
+ "font-size": "12px",
202
+ type: "search",
203
+ title: "暂无操作"
204
+ }))
205
+ ]),
206
+ _: 1
207
+ });
208
+ };
209
+ }
210
+ });
211
+ const LewContextMenu = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-8caf1ded"]]);
212
+ const LewContextMenu$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
213
+ __proto__: null,
214
+ default: LewContextMenu
215
+ }, Symbol.toStringTag, { value: "Module" }));
216
+ export {
217
+ LewContextMenu as default
218
+ };
@@ -337,6 +337,10 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
337
337
  type: PropType<"year" | "quarter" | "month" | "date" | "date-time" | "time">;
338
338
  default: string;
339
339
  };
340
+ valueFormat: {
341
+ type: StringConstructor;
342
+ default: string;
343
+ };
340
344
  }>> & Readonly<{
341
345
  onCancel?: ((...args: any[]) => any) | undefined;
342
346
  onChange?: ((...args: any[]) => any) | undefined;
@@ -347,6 +351,7 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
347
351
  change: (...args: any[]) => void;
348
352
  }, import('vue').PublicProps, {
349
353
  type: "time" | "date" | "month" | "year" | "quarter" | "date-time";
354
+ valueFormat: string;
350
355
  }, true, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
351
356
  currentComponentRef: unknown;
352
357
  }, HTMLDivElement, import('vue').ComponentProvideOptions, {
@@ -361,6 +366,10 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
361
366
  type: PropType<"year" | "quarter" | "month" | "date" | "date-time" | "time">;
362
367
  default: string;
363
368
  };
369
+ valueFormat: {
370
+ type: StringConstructor;
371
+ default: string;
372
+ };
364
373
  }>> & Readonly<{
365
374
  onCancel?: ((...args: any[]) => any) | undefined;
366
375
  onChange?: ((...args: any[]) => any) | undefined;
@@ -368,6 +377,7 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
368
377
  init: (date?: string | undefined) => void;
369
378
  }, {}, {}, {}, {
370
379
  type: "time" | "date" | "month" | "year" | "quarter" | "date-time";
380
+ valueFormat: string;
371
381
  }> | null;
372
382
  }, HTMLDivElement>;
373
383
  export default _default;
@@ -4,6 +4,10 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
4
4
  type: PropType<"year" | "quarter" | "month" | "date" | "date-time" | "time">;
5
5
  default: string;
6
6
  };
7
+ valueFormat: {
8
+ type: StringConstructor;
9
+ default: string;
10
+ };
7
11
  }>, {
8
12
  init: typeof init;
9
13
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
@@ -14,11 +18,16 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
14
18
  type: PropType<"year" | "quarter" | "month" | "date" | "date-time" | "time">;
15
19
  default: string;
16
20
  };
21
+ valueFormat: {
22
+ type: StringConstructor;
23
+ default: string;
24
+ };
17
25
  }>> & Readonly<{
18
26
  onCancel?: ((...args: any[]) => any) | undefined;
19
27
  onChange?: ((...args: any[]) => any) | undefined;
20
28
  }>, {
21
29
  type: "time" | "date" | "month" | "year" | "quarter" | "date-time";
30
+ valueFormat: string;
22
31
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
23
32
  currentComponentRef: unknown;
24
33
  }, HTMLDivElement>;
@@ -1,7 +1,7 @@
1
1
  import { LewInputTableColumn } from '../../../../types';
2
- declare module "vue" {
2
+ declare module 'vue' {
3
3
  interface ComponentCustomEvents {
4
- "drag-sort": [data: any[]];
4
+ 'drag-sort': [data: any[]];
5
5
  }
6
6
  }
7
7
  declare function __VLS_template(): {