jky-component-lib 0.0.67 → 0.0.72

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.
Files changed (37) hide show
  1. package/dist/es/form/Form.vue.d.ts +8 -8
  2. package/dist/es/menu/Menu.vue.d.ts +5 -4
  3. package/dist/es/menu/Menu.vue.js +63 -70
  4. package/dist/es/menu/MenuItem.vue.d.ts +7 -0
  5. package/dist/es/menu/MenuItem.vue.js +67 -0
  6. package/dist/es/menu/MenuItem.vue2.js +4 -0
  7. package/dist/es/menu/style.css +3 -2
  8. package/dist/es/package.json.js +1 -1
  9. package/dist/es/page-layout/PageLayout.vue.d.ts +11 -31
  10. package/dist/es/page-layout/PageLayout.vue.js +274 -103
  11. package/dist/es/page-layout/style.css +59 -0
  12. package/dist/es/page-table/PageTable.vue.d.ts +28 -28
  13. package/dist/es/style.css +1017 -42
  14. package/dist/es/styles.css +1 -1
  15. package/dist/es/tabs/Tabs.vue.js +47 -11
  16. package/dist/lib/form/Form.vue.d.ts +8 -8
  17. package/dist/lib/menu/Menu.vue.d.ts +5 -4
  18. package/dist/lib/menu/Menu.vue.js +62 -69
  19. package/dist/lib/menu/MenuItem.vue.d.ts +7 -0
  20. package/dist/lib/menu/MenuItem.vue.js +67 -0
  21. package/dist/lib/menu/MenuItem.vue2.js +4 -0
  22. package/dist/lib/menu/style.css +3 -2
  23. package/dist/lib/package.json.js +1 -1
  24. package/dist/lib/page-layout/PageLayout.vue.d.ts +11 -31
  25. package/dist/lib/page-layout/PageLayout.vue.js +273 -102
  26. package/dist/lib/page-layout/style.css +59 -0
  27. package/dist/lib/page-table/PageTable.vue.d.ts +28 -28
  28. package/dist/lib/style.css +1017 -42
  29. package/dist/lib/styles.css +1 -1
  30. package/dist/lib/tabs/Tabs.vue.js +47 -11
  31. package/package.json +12 -3
  32. package/dist/es/menu/Aside.vue.d.ts +0 -17
  33. package/dist/es/menu/Aside.vue.js +0 -44
  34. package/dist/es/menu/Aside.vue2.js +0 -4
  35. package/dist/lib/menu/Aside.vue.d.ts +0 -17
  36. package/dist/lib/menu/Aside.vue.js +0 -44
  37. package/dist/lib/menu/Aside.vue2.js +0 -4
@@ -17,133 +17,304 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { defineComponent, resolveComponent, openBlock, createElementBlock, createVNode, unref, normalizeClass, createSlots, withCtx, createBlock, renderSlot, createCommentVNode, createElementVNode, resolveDynamicComponent } from "vue";
21
- import { ElCard, ElScrollbar } from "element-plus";
22
- const _hoisted_1 = {
23
- class: "jky-page-layout flex h-full w-full overflow-hidden",
24
- style: { "--el-menu-border-color": "transparent" }
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
25
31
  };
32
+ import { defineComponent, useAttrs, ref, computed, watch, openBlock, createElementBlock, normalizeClass, createBlock, unref, withCtx, createElementVNode, createVNode, createCommentVNode, normalizeStyle, resolveDynamicComponent, Transition, KeepAlive } from "vue";
33
+ import { ElCard, ElAside, ElScrollbar } from "element-plus";
34
+ import { cloneDeep } from "lodash-es";
35
+ import { useRouter, useRoute, RouterView } from "vue-router";
36
+ import _sfc_main$1 from "../menu/Menu.vue.js";
37
+ /* empty css */
38
+ import _sfc_main$2 from "../tabs/Tabs.vue.js";
39
+ /* empty css */
40
+ import { useTabsStore } from "../tabs/useTabsStore.js";
41
+ const _hoisted_1 = { class: "w-full flex justify-center" };
42
+ const _hoisted_2 = { class: "flex flex-1 min-h-0 overflow-hidden gap-3" };
26
43
  const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
27
44
  name: "JkyPageLayout"
28
45
  }), {
29
46
  __name: "PageLayout",
30
47
  props: {
48
+ showTopMenu: { type: Boolean, default: true },
49
+ showSideMenu: { type: Boolean, default: true },
50
+ asideWidth: { default: "200px" },
31
51
  asideClass: {},
32
52
  asideWithScrollbar: { type: Boolean, default: true },
33
53
  mainClass: {},
34
- mainWithCard: { type: Boolean },
54
+ mainWithCard: { type: Boolean, default: false },
35
55
  mainWithScrollbar: { type: Boolean, default: false },
36
56
  contentClass: {},
37
- navigationClass: {},
38
- navigationWithScrollbar: { type: Boolean, default: true },
39
- showNavigation: { type: Boolean, default: true },
40
- headerClass: {},
41
- tabsClass: {},
42
- showDashboard: { type: Boolean },
43
- dashboardWithScrollbar: { type: Boolean },
44
- dashboardClass: {},
45
- className: {}
57
+ cachable: { type: Boolean, default: true },
58
+ transitionName: { default: "fade" },
59
+ className: {},
60
+ tabsWithCard: { type: Boolean, default: true },
61
+ cardPadding: { default: "0px" },
62
+ topLevels: {},
63
+ sideLevels: {},
64
+ topMenuTrigger: { default: "click" },
65
+ topMenuSingleLevel: { type: Boolean, default: true }
46
66
  },
47
67
  setup(__props) {
48
68
  const props = __props;
69
+ const router = useRouter();
70
+ const route = useRoute();
71
+ const store = useTabsStore();
72
+ const attrs = useAttrs();
73
+ const activeTopMenu = ref("");
74
+ const activeSideMenu = ref("");
75
+ const routes = router.getRoutes();
76
+ const cacheInclude = computed(() => store.getCacheTabs());
77
+ watch(
78
+ cacheInclude,
79
+ (cacheTabs) => {
80
+ console.warn("CacheTabs changed:", cacheTabs);
81
+ },
82
+ { deep: true }
83
+ );
84
+ function buildMenuFromRoutes(routes2) {
85
+ const menuRoutes = routes2.filter((r) => {
86
+ var _a;
87
+ return (_a = r.meta) == null ? void 0 : _a.title;
88
+ });
89
+ const buildMenuItem = (route2, parentPath = "") => {
90
+ var _a, _b;
91
+ const fullPath = parentPath ? `${parentPath}/${route2.path}` : route2.path;
92
+ const normalizedPath = fullPath.startsWith("/") ? fullPath : `/${fullPath}`;
93
+ const item = {
94
+ index: normalizedPath,
95
+ title: ((_a = route2.meta) == null ? void 0 : _a.title) || "",
96
+ icon: ((_b = route2.meta) == null ? void 0 : _b.icon) || "",
97
+ route: normalizedPath,
98
+ path: normalizedPath,
99
+ customClass: activeTopMenu.value.startsWith(normalizedPath) ? "is-active jky-page-layout__active-top-menu" : ""
100
+ };
101
+ if (route2.children && route2.children.length > 0) {
102
+ item.children = route2.children.filter((child) => {
103
+ var _a2;
104
+ return (_a2 = child.meta) == null ? void 0 : _a2.title;
105
+ }).map((child) => buildMenuItem(child, normalizedPath));
106
+ }
107
+ return item;
108
+ };
109
+ return menuRoutes.filter((route2) => {
110
+ const pathSegments = route2.path.split("/").filter(Boolean);
111
+ return pathSegments.length === 1;
112
+ }).map((route2) => buildMenuItem(route2));
113
+ }
114
+ const menuData = computed(() => {
115
+ return buildMenuFromRoutes(routes);
116
+ });
117
+ const topMenuData = computed(() => {
118
+ console.warn("topMenuData:", menuData.value, props, attrs);
119
+ if (props.topMenuSingleLevel) {
120
+ return cloneDeep(menuData.value).map((item) => {
121
+ const _a = item, { children } = _a, rest = __objRest(_a, ["children"]);
122
+ return rest;
123
+ });
124
+ }
125
+ return menuData.value;
126
+ });
127
+ const displayedSideMenu = computed(() => {
128
+ if (menuData.value.length === 0) {
129
+ console.warn("displayedSideMenu: menuData is empty");
130
+ return [];
131
+ }
132
+ const topMenuItem = route.matched[0];
133
+ if (!topMenuItem) {
134
+ console.warn("displayedSideMenu: topMenuItem is empty");
135
+ return [];
136
+ }
137
+ const found = menuData.value.find((item) => item.path === topMenuItem.path);
138
+ if (!found) {
139
+ console.warn("displayedSideMenu: found not found", topMenuItem);
140
+ return [];
141
+ }
142
+ if ((found == null ? void 0 : found.children) && found.children.length > 0) {
143
+ return found.children;
144
+ }
145
+ return [];
146
+ });
147
+ const computedAsideWidth = computed(() => {
148
+ if (props.showSideMenu && displayedSideMenu.value.length > 0) {
149
+ return props.asideWidth;
150
+ }
151
+ return "0";
152
+ });
153
+ watch(
154
+ () => route.path,
155
+ () => {
156
+ const routePath = route.path;
157
+ const matchedMenus = route.matched.filter((r) => {
158
+ var _a;
159
+ return (_a = r.meta) == null ? void 0 : _a.title;
160
+ });
161
+ if (matchedMenus.length === 0) {
162
+ console.warn("No matching menu item found for route:", routePath);
163
+ return;
164
+ }
165
+ activeSideMenu.value = routePath;
166
+ if (matchedMenus.length >= 2) {
167
+ activeTopMenu.value = matchedMenus[matchedMenus.length - 2].path;
168
+ } else {
169
+ activeTopMenu.value = matchedMenus[0].path;
170
+ }
171
+ console.warn("Updated menu:", {
172
+ activeTopMenu: activeTopMenu.value,
173
+ activeSideMenu: activeSideMenu.value
174
+ });
175
+ },
176
+ { immediate: true }
177
+ );
178
+ function handleMenuOpen(index) {
179
+ console.warn("handleMenuOpen called with index:", index);
180
+ }
181
+ function handleMenuSelect(index) {
182
+ router.push(index);
183
+ }
49
184
  return (_ctx, _cache) => {
50
- const _component_ElAutoResizer = resolveComponent("ElAutoResizer");
51
- return openBlock(), createElementBlock("div", _hoisted_1, [
52
- createVNode(unref(ElCard), {
53
- class: normalizeClass(["jky-page-layout__aside shrink-0 overflow-hidden p-0", props.asideClass]),
54
- style: { "--el-card-padding": 0 }
55
- }, createSlots({
56
- default: withCtx(() => [
57
- props.asideWithScrollbar ? (openBlock(), createBlock(unref(ElScrollbar), { key: 0 }, {
58
- default: withCtx(() => [
59
- renderSlot(_ctx.$slots, "aside")
60
- ]),
61
- _: 3
62
- })) : renderSlot(_ctx.$slots, "aside", { key: 1 })
63
- ]),
64
- _: 2
65
- }, [
66
- _ctx.$slots.menuHeader ? {
67
- name: "header",
68
- fn: withCtx(() => [
69
- renderSlot(_ctx.$slots, "menuHeader")
70
- ]),
71
- key: "0"
72
- } : void 0
73
- ]), 1032, ["class"]),
74
- __props.showNavigation ? (openBlock(), createBlock(unref(ElCard), {
185
+ return openBlock(), createElementBlock("div", {
186
+ class: normalizeClass(["jky-page-layout flex h-full w-full flex-col overflow-hidden gap-3", props.className])
187
+ }, [
188
+ props.showTopMenu && menuData.value.length > 0 ? (openBlock(), createBlock(unref(ElCard), {
75
189
  key: 0,
76
- class: normalizeClass(["jky-page-layout__navigation shrink-0 overflow-hidden p-0", props.navigationClass]),
190
+ class: "jky-page-layout__top-menu shrink-0 overflow-hidden p-0",
77
191
  style: { "--el-card-padding": 0 }
78
- }, createSlots({
192
+ }, {
79
193
  default: withCtx(() => [
80
- props.navigationWithScrollbar ? (openBlock(), createBlock(unref(ElScrollbar), { key: 0 }, {
81
- default: withCtx(() => [
82
- renderSlot(_ctx.$slots, "navigation")
83
- ]),
84
- _: 3
85
- })) : renderSlot(_ctx.$slots, "navigation", { key: 1 })
194
+ createElementVNode("div", _hoisted_1, [
195
+ createVNode(_sfc_main$1, {
196
+ mode: "horizontal",
197
+ "default-active": activeTopMenu.value,
198
+ "menu-data": topMenuData.value,
199
+ "menu-trigger": props.topMenuTrigger,
200
+ router: false,
201
+ levels: props.topLevels,
202
+ onSelect: handleMenuSelect,
203
+ onOpen: handleMenuOpen
204
+ }, null, 8, ["default-active", "menu-data", "menu-trigger", "levels"])
205
+ ])
86
206
  ]),
87
- _: 2
88
- }, [
89
- _ctx.$slots.navigationHeader ? {
90
- name: "header",
91
- fn: withCtx(() => [
92
- renderSlot(_ctx.$slots, "navigationHeader")
93
- ]),
94
- key: "0"
95
- } : void 0
96
- ]), 1032, ["class"])) : createCommentVNode("", true),
97
- createElementVNode("div", {
98
- class: normalizeClass(["jky-page-layout__main flex-1 flex flex-col min-w-0 overflow-hidden p-0 gap-y-4", props.mainClass])
99
- }, [
100
- _ctx.$slots.header ? (openBlock(), createElementBlock("div", {
101
- key: 0,
102
- class: normalizeClass(["jky-page-layout__header shrink-0 flex items-center overflow-hidden px-4", props.headerClass])
103
- }, [
104
- renderSlot(_ctx.$slots, "header")
105
- ], 2)) : createCommentVNode("", true),
106
- _ctx.$slots.tabs ? (openBlock(), createElementBlock("div", {
107
- key: 1,
108
- class: normalizeClass(["jky-page-layout__tabs shrink-0 overflow-hidden", props.tabsClass])
109
- }, [
110
- renderSlot(_ctx.$slots, "tabs")
111
- ], 2)) : createCommentVNode("", true),
112
- _ctx.$slots.dashboard ? (openBlock(), createBlock(unref(ElCard), {
113
- key: 2,
114
- class: normalizeClass(["jky-page-layout__dashboard shrink-0 overflow-hidden", props.dashboardClass])
207
+ _: 1
208
+ })) : createCommentVNode("", true),
209
+ createElementVNode("div", _hoisted_2, [
210
+ createVNode(unref(ElAside), {
211
+ class: "shrink-0 overflow-hidden h-full",
212
+ style: normalizeStyle({ "--el-aside-width": computedAsideWidth.value })
115
213
  }, {
116
214
  default: withCtx(() => [
117
- props.dashboardWithScrollbar ? (openBlock(), createBlock(unref(ElScrollbar), { key: 0 }, {
215
+ props.showSideMenu && displayedSideMenu.value.length > 0 ? (openBlock(), createBlock(unref(ElCard), {
216
+ key: 0,
217
+ class: "h-full",
218
+ style: normalizeStyle({ "--el-card-padding": props.cardPadding })
219
+ }, {
118
220
  default: withCtx(() => [
119
- renderSlot(_ctx.$slots, "dashboard")
221
+ props.asideWithScrollbar ? (openBlock(), createBlock(unref(ElScrollbar), { key: 0 }, {
222
+ default: withCtx(() => [
223
+ createVNode(_sfc_main$1, {
224
+ mode: "vertical",
225
+ "default-active": activeSideMenu.value,
226
+ "menu-data": displayedSideMenu.value,
227
+ onSelect: handleMenuSelect
228
+ }, null, 8, ["default-active", "menu-data"])
229
+ ]),
230
+ _: 1
231
+ })) : createCommentVNode("", true),
232
+ createVNode(_sfc_main$1, {
233
+ mode: "vertical",
234
+ "default-active": activeSideMenu.value,
235
+ "menu-data": displayedSideMenu.value,
236
+ onSelect: handleMenuSelect
237
+ }, null, 8, ["default-active", "menu-data"])
120
238
  ]),
121
- _: 3
122
- })) : renderSlot(_ctx.$slots, "dashboard", { key: 1 })
239
+ _: 1
240
+ }, 8, ["style"])) : createCommentVNode("", true)
123
241
  ]),
124
- _: 3
125
- }, 8, ["class"])) : createCommentVNode("", true),
126
- (openBlock(), createBlock(resolveDynamicComponent(props.mainWithCard ? unref(ElCard) : "div"), {
127
- "body-class": props.mainWithScrollbar ? "" : "pb-0!",
128
- class: normalizeClass(["jky-page-layout__content flex-1 min-h-0 overflow-hidden", props.contentClass])
129
- }, {
130
- default: withCtx(() => [
131
- props.mainWithScrollbar ? (openBlock(), createBlock(unref(ElScrollbar), { key: 0 }, {
132
- default: withCtx(() => [
133
- renderSlot(_ctx.$slots, "default")
134
- ]),
135
- _: 3
136
- })) : (openBlock(), createBlock(_component_ElAutoResizer, { key: 1 }, {
137
- default: withCtx(({ height }) => [
138
- renderSlot(_ctx.$slots, "default", { height })
139
- ]),
140
- _: 3
141
- }))
142
- ]),
143
- _: 3
144
- }, 8, ["body-class", "class"]))
145
- ], 2)
146
- ]);
242
+ _: 1
243
+ }, 8, ["style"]),
244
+ createElementVNode("div", {
245
+ class: normalizeClass(["jky-page-layout__main flex-1 flex flex-col min-w-0 overflow-hidden", props.mainClass])
246
+ }, [
247
+ props.tabsWithCard ? (openBlock(), createBlock(unref(ElCard), {
248
+ key: 0,
249
+ class: "jky-page-layout__tabs shrink-0",
250
+ style: normalizeStyle({ "--el-card-padding": props.cardPadding })
251
+ }, {
252
+ default: withCtx(() => [
253
+ createVNode(_sfc_main$2, {
254
+ mode: "route",
255
+ cachable: props.cachable
256
+ }, null, 8, ["cachable"])
257
+ ]),
258
+ _: 1
259
+ }, 8, ["style"])) : (openBlock(), createBlock(_sfc_main$2, {
260
+ key: 1,
261
+ class: "jky-page-layout__tabs shrink-0",
262
+ mode: "route",
263
+ cachable: props.cachable
264
+ }, null, 8, ["cachable"])),
265
+ (openBlock(), createBlock(resolveDynamicComponent(props.mainWithCard ? unref(ElCard) : "div"), {
266
+ class: normalizeClass(["jky-page-layout__content flex-1 min-h-0 overflow-hidden", props.contentClass]),
267
+ "body-class": props.mainWithScrollbar ? "" : "pb-0!"
268
+ }, {
269
+ default: withCtx(() => [
270
+ props.mainWithScrollbar ? (openBlock(), createBlock(unref(ElScrollbar), { key: 0 }, {
271
+ default: withCtx(() => [
272
+ createVNode(unref(RouterView), null, {
273
+ default: withCtx(({ Component, route: currentRoute }) => [
274
+ createVNode(Transition, {
275
+ name: props.transitionName
276
+ }, {
277
+ default: withCtx(() => [
278
+ (openBlock(), createBlock(KeepAlive, {
279
+ include: props.cachable ? cacheInclude.value : []
280
+ }, [
281
+ (openBlock(), createBlock(resolveDynamicComponent(Component), {
282
+ key: currentRoute.name
283
+ }))
284
+ ], 1032, ["include"]))
285
+ ]),
286
+ _: 2
287
+ }, 1032, ["name"])
288
+ ]),
289
+ _: 1
290
+ })
291
+ ]),
292
+ _: 1
293
+ })) : (openBlock(), createBlock(unref(RouterView), { key: 1 }, {
294
+ default: withCtx(({ Component, route: currentRoute }) => [
295
+ createVNode(Transition, {
296
+ name: props.transitionName
297
+ }, {
298
+ default: withCtx(() => [
299
+ (openBlock(), createBlock(KeepAlive, {
300
+ include: props.cachable ? cacheInclude.value : []
301
+ }, [
302
+ (openBlock(), createBlock(resolveDynamicComponent(Component), {
303
+ key: currentRoute.name
304
+ }))
305
+ ], 1032, ["include"]))
306
+ ]),
307
+ _: 2
308
+ }, 1032, ["name"])
309
+ ]),
310
+ _: 1
311
+ }))
312
+ ]),
313
+ _: 1
314
+ }, 8, ["class", "body-class"]))
315
+ ], 2)
316
+ ])
317
+ ], 2);
147
318
  };
148
319
  }
149
320
  }));
@@ -7,4 +7,63 @@
7
7
  .el-menu {
8
8
  border-right: none;
9
9
  }
10
+
11
+ /* 顶部激活菜单项的自定义样式 */
12
+ .jky-page-layout__active-top-menu {
13
+ /* 这里可以添加自定义样式,例如: */
14
+ /* background-color: var(--el-color-primary-light-9); */
15
+ /* color: var(--el-color-primary); */
16
+ }
17
+ }
18
+
19
+ /* 淡入淡出动画 */
20
+ .fade-enter-active,
21
+ .fade-leave-active {
22
+ transition: opacity 0.3s ease;
23
+ }
24
+ .fade-enter-from,
25
+ .fade-leave-to {
26
+ opacity: 0;
27
+ }
28
+
29
+ /* 缩放动画 */
30
+ .zoom-enter-active,
31
+ .zoom-leave-active {
32
+ transition:
33
+ opacity 0.3s ease,
34
+ transform 0.3s ease;
35
+ }
36
+ .zoom-enter-from {
37
+ opacity: 0;
38
+ transform: scale(0.95);
39
+ }
40
+ .zoom-leave-to {
41
+ opacity: 0;
42
+ transform: scale(1.05);
43
+ }
44
+
45
+ /* 滑动动画 */
46
+ .slide-left-enter-active,
47
+ .slide-left-leave-active,
48
+ .slide-right-enter-active,
49
+ .slide-right-leave-active {
50
+ transition:
51
+ opacity 0.3s ease,
52
+ transform 0.3s ease;
53
+ }
54
+ .slide-left-enter-from {
55
+ opacity: 0;
56
+ transform: translateX(-30px);
57
+ }
58
+ .slide-left-leave-to {
59
+ opacity: 0;
60
+ transform: translateX(30px);
61
+ }
62
+ .slide-right-enter-from {
63
+ opacity: 0;
64
+ transform: translateX(30px);
65
+ }
66
+ .slide-right-leave-to {
67
+ opacity: 0;
68
+ transform: translateX(-30px);
10
69
  }