lew-ui 2.7.29 → 2.7.33

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 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-0Dikjcyf.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
+ };
@@ -321,10 +321,7 @@ declare function __VLS_template(): {
321
321
  type: PropType<() => Promise<void>>;
322
322
  validator: (value: any) => boolean;
323
323
  };
324
- }>> & Readonly<{}>, {
325
- focus: () => void;
326
- blur: () => void;
327
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {
324
+ }>> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {
328
325
  loading: boolean;
329
326
  type: import('../../../..').LewButtonType;
330
327
  color: LewColor;
@@ -418,10 +415,7 @@ declare function __VLS_template(): {
418
415
  type: PropType<() => Promise<void>>;
419
416
  validator: (value: any) => boolean;
420
417
  };
421
- }>> & Readonly<{}>, "blur" | "focus" | ("loading" | "type" | "color" | "size" | "round" | "disabled" | "singleIcon" | "dashed")> & import('vue').ShallowUnwrapRef<{
422
- focus: () => void;
423
- blur: () => void;
424
- }> & {} & import('vue').ComponentCustomProperties & {} & {
418
+ }>> & Readonly<{}>, "loading" | "type" | "color" | "size" | "round" | "disabled" | "singleIcon" | "dashed"> & import('vue').ShallowUnwrapRef<{}> & {} & import('vue').ComponentCustomProperties & {} & {
425
419
  $slots: {
426
420
  default?(_: {}): any;
427
421
  };
@@ -877,10 +871,7 @@ declare const __VLS_component: import('vue').DefineComponent<globalThis.ExtractP
877
871
  type: PropType<() => Promise<void>>;
878
872
  validator: (value: any) => boolean;
879
873
  };
880
- }>> & Readonly<{}>, {
881
- focus: () => void;
882
- blur: () => void;
883
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {
874
+ }>> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {
884
875
  loading: boolean;
885
876
  type: import('../../../..').LewButtonType;
886
877
  color: LewColor;
@@ -974,10 +965,7 @@ declare const __VLS_component: import('vue').DefineComponent<globalThis.ExtractP
974
965
  type: PropType<() => Promise<void>>;
975
966
  validator: (value: any) => boolean;
976
967
  };
977
- }>> & Readonly<{}>, "blur" | "focus" | ("loading" | "type" | "color" | "size" | "round" | "disabled" | "singleIcon" | "dashed")> & import('vue').ShallowUnwrapRef<{
978
- focus: () => void;
979
- blur: () => void;
980
- }> & {} & import('vue').ComponentCustomProperties & {} & {
968
+ }>> & Readonly<{}>, "loading" | "type" | "color" | "size" | "round" | "disabled" | "singleIcon" | "dashed"> & import('vue').ShallowUnwrapRef<{}> & {} & import('vue').ComponentCustomProperties & {} & {
981
969
  $slots: {
982
970
  default?(_: {}): any;
983
971
  };
@@ -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(): {