jky-component-lib 0.0.18 → 0.0.20
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/es/button-nav/ButtonNav.vue.d.ts +6 -0
- package/dist/es/button-nav/ButtonNav.vue.js +29 -14
- package/dist/es/package.json.js +1 -1
- package/dist/es/page-header/PageHeader.vue.d.ts +1 -0
- package/dist/es/page-header/PageHeader.vue.js +27 -25
- package/dist/lib/button-nav/ButtonNav.vue.d.ts +6 -0
- package/dist/lib/button-nav/ButtonNav.vue.js +28 -13
- package/dist/lib/package.json.js +1 -1
- package/dist/lib/page-header/PageHeader.vue.d.ts +1 -0
- package/dist/lib/page-header/PageHeader.vue.js +27 -25
- package/dist/umd/index.js +56 -39
- package/package.json +2 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ButtonProps } from 'element-plus/es/components/button';
|
|
2
|
+
import { RouteLocationRaw } from 'vue-router';
|
|
2
3
|
type __VLS_Props = {
|
|
3
4
|
modelValue?: string | number;
|
|
4
5
|
items?: NavItem[];
|
|
@@ -7,17 +8,21 @@ type __VLS_Props = {
|
|
|
7
8
|
type?: ButtonProps['type'];
|
|
8
9
|
plain?: boolean;
|
|
9
10
|
buttonWidth?: string;
|
|
11
|
+
route?: boolean;
|
|
10
12
|
};
|
|
11
13
|
interface NavItem {
|
|
12
14
|
label: string;
|
|
13
15
|
value: string | number;
|
|
14
16
|
disabled?: boolean;
|
|
15
17
|
icon?: string;
|
|
18
|
+
to?: RouteLocationRaw;
|
|
16
19
|
}
|
|
17
20
|
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
21
|
+
click: (item: NavItem) => any;
|
|
18
22
|
change: (value: string | number) => any;
|
|
19
23
|
"update:modelValue": (value: string | number) => any;
|
|
20
24
|
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
25
|
+
onClick?: ((item: NavItem) => any) | undefined;
|
|
21
26
|
onChange?: ((value: string | number) => any) | undefined;
|
|
22
27
|
"onUpdate:modelValue"?: ((value: string | number) => any) | undefined;
|
|
23
28
|
}>, {
|
|
@@ -26,5 +31,6 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {
|
|
|
26
31
|
items: NavItem[];
|
|
27
32
|
limit: number;
|
|
28
33
|
plain: boolean;
|
|
34
|
+
route: boolean;
|
|
29
35
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
30
36
|
export default _default;
|
|
@@ -17,7 +17,7 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { defineComponent, computed, openBlock, createElementBlock, Fragment, renderList, createBlock, unref, normalizeClass, normalizeStyle, createSlots, withCtx, createTextVNode, toDisplayString, createElementVNode, createVNode, createCommentVNode } from "vue";
|
|
20
|
+
import { defineComponent, inject, computed, openBlock, createElementBlock, Fragment, renderList, createBlock, unref, normalizeClass, normalizeStyle, createSlots, withCtx, createTextVNode, toDisplayString, createElementVNode, createVNode, createCommentVNode } from "vue";
|
|
21
21
|
import { ElButton, ElDropdown, ElDropdownMenu, ElDropdownItem } from "element-plus";
|
|
22
22
|
const _hoisted_1 = { class: "jky-button-nav flex flex-wrap items-center gap-2" };
|
|
23
23
|
const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
|
|
@@ -31,33 +31,48 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
|
|
|
31
31
|
size: { default: "default" },
|
|
32
32
|
type: { default: "primary" },
|
|
33
33
|
plain: { type: Boolean, default: false },
|
|
34
|
-
buttonWidth: {}
|
|
34
|
+
buttonWidth: {},
|
|
35
|
+
route: { type: Boolean, default: false }
|
|
35
36
|
},
|
|
36
|
-
emits: ["update:modelValue", "change"],
|
|
37
|
+
emits: ["update:modelValue", "change", "click"],
|
|
37
38
|
setup(__props, { emit: __emit }) {
|
|
38
39
|
const props = __props;
|
|
39
40
|
const emit = __emit;
|
|
41
|
+
const router = inject("router", null);
|
|
42
|
+
const route = inject("route", null);
|
|
40
43
|
const visibleItems = computed(() => props.items.slice(0, props.limit));
|
|
41
44
|
const hiddenItems = computed(() => props.items.slice(props.limit));
|
|
42
45
|
const hasMore = computed(() => props.items.length > props.limit);
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
function isActiveItem(item) {
|
|
47
|
+
if (props.route && item.to && route) {
|
|
48
|
+
const targetPath = typeof item.to === "string" ? item.to : item.to.path;
|
|
49
|
+
return route.path === targetPath;
|
|
50
|
+
}
|
|
51
|
+
return props.modelValue === item.value;
|
|
52
|
+
}
|
|
53
|
+
function handleClick(item) {
|
|
54
|
+
if (props.route && item.to && router) {
|
|
55
|
+
router.push(item.to);
|
|
56
|
+
} else {
|
|
57
|
+
emit("update:modelValue", item.value);
|
|
58
|
+
emit("change", item.value);
|
|
59
|
+
emit("click", item);
|
|
60
|
+
}
|
|
46
61
|
}
|
|
47
62
|
return (_ctx, _cache) => {
|
|
48
63
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
49
64
|
(openBlock(true), createElementBlock(Fragment, null, renderList(visibleItems.value, (item) => {
|
|
50
65
|
return openBlock(), createBlock(unref(ElButton), {
|
|
51
66
|
key: item.value,
|
|
52
|
-
type:
|
|
67
|
+
type: isActiveItem(item) ? props.type : "default",
|
|
53
68
|
size: props.size,
|
|
54
69
|
disabled: item.disabled,
|
|
55
|
-
link: props.plain &&
|
|
70
|
+
link: props.plain && !isActiveItem(item),
|
|
56
71
|
style: normalizeStyle({ width: props.buttonWidth }),
|
|
57
72
|
class: normalizeClass({
|
|
58
|
-
"is-active":
|
|
73
|
+
"is-active": isActiveItem(item)
|
|
59
74
|
}),
|
|
60
|
-
onClick: ($event) => handleClick(item
|
|
75
|
+
onClick: ($event) => handleClick(item)
|
|
61
76
|
}, createSlots({
|
|
62
77
|
default: withCtx(() => [
|
|
63
78
|
createTextVNode(" " + toDisplayString(item.label), 1)
|
|
@@ -86,7 +101,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
|
|
|
86
101
|
return openBlock(), createBlock(unref(ElDropdownItem), {
|
|
87
102
|
key: item.value,
|
|
88
103
|
disabled: item.disabled,
|
|
89
|
-
onClick: ($event) => handleClick(item
|
|
104
|
+
onClick: ($event) => handleClick(item)
|
|
90
105
|
}, {
|
|
91
106
|
default: withCtx(() => [
|
|
92
107
|
item.icon ? (openBlock(), createElementBlock("span", {
|
|
@@ -104,12 +119,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
|
|
|
104
119
|
]),
|
|
105
120
|
default: withCtx(() => [
|
|
106
121
|
createVNode(unref(ElButton), {
|
|
107
|
-
type: hiddenItems.value.some((item) => item
|
|
122
|
+
type: hiddenItems.value.some((item) => isActiveItem(item)) ? props.type : "default",
|
|
108
123
|
size: props.size,
|
|
109
|
-
link: props.plain && !hiddenItems.value.some((item) => item
|
|
124
|
+
link: props.plain && !hiddenItems.value.some((item) => isActiveItem(item)),
|
|
110
125
|
style: normalizeStyle({ width: props.buttonWidth }),
|
|
111
126
|
class: normalizeClass({
|
|
112
|
-
"is-active": hiddenItems.value.some((item) => item
|
|
127
|
+
"is-active": hiddenItems.value.some((item) => isActiveItem(item))
|
|
113
128
|
})
|
|
114
129
|
}, {
|
|
115
130
|
default: withCtx(() => [..._cache[0] || (_cache[0] = [
|
package/dist/es/package.json.js
CHANGED
|
@@ -40,7 +40,7 @@ const _hoisted_9 = { class: "jky-page-header__time hidden md:block" };
|
|
|
40
40
|
const _hoisted_10 = { class: "jky-page-header__user" };
|
|
41
41
|
const _hoisted_11 = ["src", "alt"];
|
|
42
42
|
const _hoisted_12 = {
|
|
43
|
-
key:
|
|
43
|
+
key: 0,
|
|
44
44
|
class: "jky-page-header__username hidden md:block"
|
|
45
45
|
};
|
|
46
46
|
const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
|
|
@@ -224,33 +224,35 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
|
|
|
224
224
|
]),
|
|
225
225
|
default: withCtx(() => [
|
|
226
226
|
createElementVNode("div", _hoisted_10, [
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
227
|
+
renderSlot(_ctx.$slots, "userIcon", {}, () => [
|
|
228
|
+
__props.userAvatar ? (openBlock(), createBlock(unref(ElIcon), {
|
|
229
|
+
key: 0,
|
|
230
|
+
size: 24,
|
|
231
|
+
class: "jky-page-header__avatar"
|
|
232
|
+
}, {
|
|
233
|
+
default: withCtx(() => [
|
|
234
|
+
createElementVNode("img", {
|
|
235
|
+
src: __props.userAvatar,
|
|
236
|
+
alt: __props.userName,
|
|
237
|
+
class: "rounded-full"
|
|
238
|
+
}, null, 8, _hoisted_11)
|
|
239
|
+
]),
|
|
240
|
+
_: 1
|
|
241
|
+
})) : (openBlock(), createBlock(unref(ElIcon), {
|
|
242
|
+
key: 1,
|
|
243
|
+
size: 24,
|
|
244
|
+
class: "jky-page-header__avatar"
|
|
245
|
+
}, {
|
|
246
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [
|
|
247
|
+
createElementVNode("span", { class: "icon-[heroicons--user]" }, null, -1)
|
|
248
|
+
])]),
|
|
249
|
+
_: 1
|
|
250
|
+
}))
|
|
251
|
+
]),
|
|
250
252
|
__props.userName ? (openBlock(), createElementBlock("span", _hoisted_12, toDisplayString(__props.userName), 1)) : createCommentVNode("", true)
|
|
251
253
|
])
|
|
252
254
|
]),
|
|
253
|
-
_:
|
|
255
|
+
_: 3
|
|
254
256
|
})
|
|
255
257
|
])
|
|
256
258
|
])
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ButtonProps } from 'element-plus/es/components/button';
|
|
2
|
+
import { RouteLocationRaw } from 'vue-router';
|
|
2
3
|
type __VLS_Props = {
|
|
3
4
|
modelValue?: string | number;
|
|
4
5
|
items?: NavItem[];
|
|
@@ -7,17 +8,21 @@ type __VLS_Props = {
|
|
|
7
8
|
type?: ButtonProps['type'];
|
|
8
9
|
plain?: boolean;
|
|
9
10
|
buttonWidth?: string;
|
|
11
|
+
route?: boolean;
|
|
10
12
|
};
|
|
11
13
|
interface NavItem {
|
|
12
14
|
label: string;
|
|
13
15
|
value: string | number;
|
|
14
16
|
disabled?: boolean;
|
|
15
17
|
icon?: string;
|
|
18
|
+
to?: RouteLocationRaw;
|
|
16
19
|
}
|
|
17
20
|
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
21
|
+
click: (item: NavItem) => any;
|
|
18
22
|
change: (value: string | number) => any;
|
|
19
23
|
"update:modelValue": (value: string | number) => any;
|
|
20
24
|
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
25
|
+
onClick?: ((item: NavItem) => any) | undefined;
|
|
21
26
|
onChange?: ((value: string | number) => any) | undefined;
|
|
22
27
|
"onUpdate:modelValue"?: ((value: string | number) => any) | undefined;
|
|
23
28
|
}>, {
|
|
@@ -26,5 +31,6 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {
|
|
|
26
31
|
items: NavItem[];
|
|
27
32
|
limit: number;
|
|
28
33
|
plain: boolean;
|
|
34
|
+
route: boolean;
|
|
29
35
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
30
36
|
export default _default;
|
|
@@ -33,33 +33,48 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
|
|
|
33
33
|
size: { default: "default" },
|
|
34
34
|
type: { default: "primary" },
|
|
35
35
|
plain: { type: Boolean, default: false },
|
|
36
|
-
buttonWidth: {}
|
|
36
|
+
buttonWidth: {},
|
|
37
|
+
route: { type: Boolean, default: false }
|
|
37
38
|
},
|
|
38
|
-
emits: ["update:modelValue", "change"],
|
|
39
|
+
emits: ["update:modelValue", "change", "click"],
|
|
39
40
|
setup(__props, { emit: __emit }) {
|
|
40
41
|
const props = __props;
|
|
41
42
|
const emit = __emit;
|
|
43
|
+
const router = vue.inject("router", null);
|
|
44
|
+
const route = vue.inject("route", null);
|
|
42
45
|
const visibleItems = vue.computed(() => props.items.slice(0, props.limit));
|
|
43
46
|
const hiddenItems = vue.computed(() => props.items.slice(props.limit));
|
|
44
47
|
const hasMore = vue.computed(() => props.items.length > props.limit);
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
function isActiveItem(item) {
|
|
49
|
+
if (props.route && item.to && route) {
|
|
50
|
+
const targetPath = typeof item.to === "string" ? item.to : item.to.path;
|
|
51
|
+
return route.path === targetPath;
|
|
52
|
+
}
|
|
53
|
+
return props.modelValue === item.value;
|
|
54
|
+
}
|
|
55
|
+
function handleClick(item) {
|
|
56
|
+
if (props.route && item.to && router) {
|
|
57
|
+
router.push(item.to);
|
|
58
|
+
} else {
|
|
59
|
+
emit("update:modelValue", item.value);
|
|
60
|
+
emit("change", item.value);
|
|
61
|
+
emit("click", item);
|
|
62
|
+
}
|
|
48
63
|
}
|
|
49
64
|
return (_ctx, _cache) => {
|
|
50
65
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
|
|
51
66
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(visibleItems.value, (item) => {
|
|
52
67
|
return vue.openBlock(), vue.createBlock(vue.unref(ElementPlus.ElButton), {
|
|
53
68
|
key: item.value,
|
|
54
|
-
type:
|
|
69
|
+
type: isActiveItem(item) ? props.type : "default",
|
|
55
70
|
size: props.size,
|
|
56
71
|
disabled: item.disabled,
|
|
57
|
-
link: props.plain &&
|
|
72
|
+
link: props.plain && !isActiveItem(item),
|
|
58
73
|
style: vue.normalizeStyle({ width: props.buttonWidth }),
|
|
59
74
|
class: vue.normalizeClass({
|
|
60
|
-
"is-active":
|
|
75
|
+
"is-active": isActiveItem(item)
|
|
61
76
|
}),
|
|
62
|
-
onClick: ($event) => handleClick(item
|
|
77
|
+
onClick: ($event) => handleClick(item)
|
|
63
78
|
}, vue.createSlots({
|
|
64
79
|
default: vue.withCtx(() => [
|
|
65
80
|
vue.createTextVNode(" " + vue.toDisplayString(item.label), 1)
|
|
@@ -88,7 +103,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
|
|
|
88
103
|
return vue.openBlock(), vue.createBlock(vue.unref(ElementPlus.ElDropdownItem), {
|
|
89
104
|
key: item.value,
|
|
90
105
|
disabled: item.disabled,
|
|
91
|
-
onClick: ($event) => handleClick(item
|
|
106
|
+
onClick: ($event) => handleClick(item)
|
|
92
107
|
}, {
|
|
93
108
|
default: vue.withCtx(() => [
|
|
94
109
|
item.icon ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
@@ -106,12 +121,12 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
|
|
|
106
121
|
]),
|
|
107
122
|
default: vue.withCtx(() => [
|
|
108
123
|
vue.createVNode(vue.unref(ElementPlus.ElButton), {
|
|
109
|
-
type: hiddenItems.value.some((item) => item
|
|
124
|
+
type: hiddenItems.value.some((item) => isActiveItem(item)) ? props.type : "default",
|
|
110
125
|
size: props.size,
|
|
111
|
-
link: props.plain && !hiddenItems.value.some((item) => item
|
|
126
|
+
link: props.plain && !hiddenItems.value.some((item) => isActiveItem(item)),
|
|
112
127
|
style: vue.normalizeStyle({ width: props.buttonWidth }),
|
|
113
128
|
class: vue.normalizeClass({
|
|
114
|
-
"is-active": hiddenItems.value.some((item) => item
|
|
129
|
+
"is-active": hiddenItems.value.some((item) => isActiveItem(item))
|
|
115
130
|
})
|
|
116
131
|
}, {
|
|
117
132
|
default: vue.withCtx(() => [..._cache[0] || (_cache[0] = [
|
package/dist/lib/package.json.js
CHANGED
|
@@ -42,7 +42,7 @@ const _hoisted_9 = { class: "jky-page-header__time hidden md:block" };
|
|
|
42
42
|
const _hoisted_10 = { class: "jky-page-header__user" };
|
|
43
43
|
const _hoisted_11 = ["src", "alt"];
|
|
44
44
|
const _hoisted_12 = {
|
|
45
|
-
key:
|
|
45
|
+
key: 0,
|
|
46
46
|
class: "jky-page-header__username hidden md:block"
|
|
47
47
|
};
|
|
48
48
|
const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValues({}, {
|
|
@@ -226,33 +226,35 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValu
|
|
|
226
226
|
]),
|
|
227
227
|
default: vue.withCtx(() => [
|
|
228
228
|
vue.createElementVNode("div", _hoisted_10, [
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
vue.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
vue.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
229
|
+
vue.renderSlot(_ctx.$slots, "userIcon", {}, () => [
|
|
230
|
+
__props.userAvatar ? (vue.openBlock(), vue.createBlock(vue.unref(ElementPlus.ElIcon), {
|
|
231
|
+
key: 0,
|
|
232
|
+
size: 24,
|
|
233
|
+
class: "jky-page-header__avatar"
|
|
234
|
+
}, {
|
|
235
|
+
default: vue.withCtx(() => [
|
|
236
|
+
vue.createElementVNode("img", {
|
|
237
|
+
src: __props.userAvatar,
|
|
238
|
+
alt: __props.userName,
|
|
239
|
+
class: "rounded-full"
|
|
240
|
+
}, null, 8, _hoisted_11)
|
|
241
|
+
]),
|
|
242
|
+
_: 1
|
|
243
|
+
})) : (vue.openBlock(), vue.createBlock(vue.unref(ElementPlus.ElIcon), {
|
|
244
|
+
key: 1,
|
|
245
|
+
size: 24,
|
|
246
|
+
class: "jky-page-header__avatar"
|
|
247
|
+
}, {
|
|
248
|
+
default: vue.withCtx(() => [..._cache[1] || (_cache[1] = [
|
|
249
|
+
vue.createElementVNode("span", { class: "icon-[heroicons--user]" }, null, -1)
|
|
250
|
+
])]),
|
|
251
|
+
_: 1
|
|
252
|
+
}))
|
|
253
|
+
]),
|
|
252
254
|
__props.userName ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_12, vue.toDisplayString(__props.userName), 1)) : vue.createCommentVNode("", true)
|
|
253
255
|
])
|
|
254
256
|
]),
|
|
255
|
-
_:
|
|
257
|
+
_: 3
|
|
256
258
|
})
|
|
257
259
|
])
|
|
258
260
|
])
|
package/dist/umd/index.js
CHANGED
|
@@ -1398,7 +1398,7 @@ img {
|
|
|
1398
1398
|
}
|
|
1399
1399
|
/*$vite$:1*/`;
|
|
1400
1400
|
document.head.appendChild(__vite_style__);
|
|
1401
|
-
const version$1 = "0.0.
|
|
1401
|
+
const version$1 = "0.0.20";
|
|
1402
1402
|
const INSTALLED_KEY = Symbol("INSTALLED_KEY");
|
|
1403
1403
|
function createInstaller(components2 = []) {
|
|
1404
1404
|
const install2 = (app, options) => {
|
|
@@ -1532,33 +1532,48 @@ img {
|
|
|
1532
1532
|
size: { default: "default" },
|
|
1533
1533
|
type: { default: "primary" },
|
|
1534
1534
|
plain: { type: Boolean, default: false },
|
|
1535
|
-
buttonWidth: {}
|
|
1535
|
+
buttonWidth: {},
|
|
1536
|
+
route: { type: Boolean, default: false }
|
|
1536
1537
|
},
|
|
1537
|
-
emits: ["update:modelValue", "change"],
|
|
1538
|
+
emits: ["update:modelValue", "change", "click"],
|
|
1538
1539
|
setup(__props, { emit: __emit }) {
|
|
1539
1540
|
const props = __props;
|
|
1540
1541
|
const emit = __emit;
|
|
1542
|
+
const router = vue.inject("router", null);
|
|
1543
|
+
const route = vue.inject("route", null);
|
|
1541
1544
|
const visibleItems = vue.computed(() => props.items.slice(0, props.limit));
|
|
1542
1545
|
const hiddenItems = vue.computed(() => props.items.slice(props.limit));
|
|
1543
1546
|
const hasMore = vue.computed(() => props.items.length > props.limit);
|
|
1544
|
-
function
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
+
function isActiveItem(item) {
|
|
1548
|
+
if (props.route && item.to && route) {
|
|
1549
|
+
const targetPath = typeof item.to === "string" ? item.to : item.to.path;
|
|
1550
|
+
return route.path === targetPath;
|
|
1551
|
+
}
|
|
1552
|
+
return props.modelValue === item.value;
|
|
1553
|
+
}
|
|
1554
|
+
function handleClick(item) {
|
|
1555
|
+
if (props.route && item.to && router) {
|
|
1556
|
+
router.push(item.to);
|
|
1557
|
+
} else {
|
|
1558
|
+
emit("update:modelValue", item.value);
|
|
1559
|
+
emit("change", item.value);
|
|
1560
|
+
emit("click", item);
|
|
1561
|
+
}
|
|
1547
1562
|
}
|
|
1548
1563
|
return (_ctx, _cache) => {
|
|
1549
1564
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
|
|
1550
1565
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(visibleItems.value, (item) => {
|
|
1551
1566
|
return vue.openBlock(), vue.createBlock(vue.unref(ElementPlus.ElButton), {
|
|
1552
1567
|
key: item.value,
|
|
1553
|
-
type:
|
|
1568
|
+
type: isActiveItem(item) ? props.type : "default",
|
|
1554
1569
|
size: props.size,
|
|
1555
1570
|
disabled: item.disabled,
|
|
1556
|
-
link: props.plain &&
|
|
1571
|
+
link: props.plain && !isActiveItem(item),
|
|
1557
1572
|
style: vue.normalizeStyle({ width: props.buttonWidth }),
|
|
1558
1573
|
class: vue.normalizeClass({
|
|
1559
|
-
"is-active":
|
|
1574
|
+
"is-active": isActiveItem(item)
|
|
1560
1575
|
}),
|
|
1561
|
-
onClick: ($event) => handleClick(item
|
|
1576
|
+
onClick: ($event) => handleClick(item)
|
|
1562
1577
|
}, vue.createSlots({
|
|
1563
1578
|
default: vue.withCtx(() => [
|
|
1564
1579
|
vue.createTextVNode(" " + vue.toDisplayString(item.label), 1)
|
|
@@ -1587,7 +1602,7 @@ img {
|
|
|
1587
1602
|
return vue.openBlock(), vue.createBlock(vue.unref(ElementPlus.ElDropdownItem), {
|
|
1588
1603
|
key: item.value,
|
|
1589
1604
|
disabled: item.disabled,
|
|
1590
|
-
onClick: ($event) => handleClick(item
|
|
1605
|
+
onClick: ($event) => handleClick(item)
|
|
1591
1606
|
}, {
|
|
1592
1607
|
default: vue.withCtx(() => [
|
|
1593
1608
|
item.icon ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
@@ -1605,12 +1620,12 @@ img {
|
|
|
1605
1620
|
]),
|
|
1606
1621
|
default: vue.withCtx(() => [
|
|
1607
1622
|
vue.createVNode(vue.unref(ElementPlus.ElButton), {
|
|
1608
|
-
type: hiddenItems.value.some((item) => item
|
|
1623
|
+
type: hiddenItems.value.some((item) => isActiveItem(item)) ? props.type : "default",
|
|
1609
1624
|
size: props.size,
|
|
1610
|
-
link: props.plain && !hiddenItems.value.some((item) => item
|
|
1625
|
+
link: props.plain && !hiddenItems.value.some((item) => isActiveItem(item)),
|
|
1611
1626
|
style: vue.normalizeStyle({ width: props.buttonWidth }),
|
|
1612
1627
|
class: vue.normalizeClass({
|
|
1613
|
-
"is-active": hiddenItems.value.some((item) => item
|
|
1628
|
+
"is-active": hiddenItems.value.some((item) => isActiveItem(item))
|
|
1614
1629
|
})
|
|
1615
1630
|
}, {
|
|
1616
1631
|
default: vue.withCtx(() => [..._cache[0] || (_cache[0] = [
|
|
@@ -1735,7 +1750,7 @@ img {
|
|
|
1735
1750
|
const _hoisted_10 = { class: "jky-page-header__user" };
|
|
1736
1751
|
const _hoisted_11 = ["src", "alt"];
|
|
1737
1752
|
const _hoisted_12 = {
|
|
1738
|
-
key:
|
|
1753
|
+
key: 0,
|
|
1739
1754
|
class: "jky-page-header__username hidden md:block"
|
|
1740
1755
|
};
|
|
1741
1756
|
const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValues({}, {
|
|
@@ -1919,33 +1934,35 @@ img {
|
|
|
1919
1934
|
]),
|
|
1920
1935
|
default: vue.withCtx(() => [
|
|
1921
1936
|
vue.createElementVNode("div", _hoisted_10, [
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
vue.
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
vue.
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1937
|
+
vue.renderSlot(_ctx.$slots, "userIcon", {}, () => [
|
|
1938
|
+
__props.userAvatar ? (vue.openBlock(), vue.createBlock(vue.unref(ElementPlus.ElIcon), {
|
|
1939
|
+
key: 0,
|
|
1940
|
+
size: 24,
|
|
1941
|
+
class: "jky-page-header__avatar"
|
|
1942
|
+
}, {
|
|
1943
|
+
default: vue.withCtx(() => [
|
|
1944
|
+
vue.createElementVNode("img", {
|
|
1945
|
+
src: __props.userAvatar,
|
|
1946
|
+
alt: __props.userName,
|
|
1947
|
+
class: "rounded-full"
|
|
1948
|
+
}, null, 8, _hoisted_11)
|
|
1949
|
+
]),
|
|
1950
|
+
_: 1
|
|
1951
|
+
})) : (vue.openBlock(), vue.createBlock(vue.unref(ElementPlus.ElIcon), {
|
|
1952
|
+
key: 1,
|
|
1953
|
+
size: 24,
|
|
1954
|
+
class: "jky-page-header__avatar"
|
|
1955
|
+
}, {
|
|
1956
|
+
default: vue.withCtx(() => [..._cache[1] || (_cache[1] = [
|
|
1957
|
+
vue.createElementVNode("span", { class: "icon-[heroicons--user]" }, null, -1)
|
|
1958
|
+
])]),
|
|
1959
|
+
_: 1
|
|
1960
|
+
}))
|
|
1961
|
+
]),
|
|
1945
1962
|
__props.userName ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_12, vue.toDisplayString(__props.userName), 1)) : vue.createCommentVNode("", true)
|
|
1946
1963
|
])
|
|
1947
1964
|
]),
|
|
1948
|
-
_:
|
|
1965
|
+
_: 3
|
|
1949
1966
|
})
|
|
1950
1967
|
])
|
|
1951
1968
|
])
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jky-component-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.20",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -101,6 +101,7 @@
|
|
|
101
101
|
"vitepress": "^1.6.3",
|
|
102
102
|
"vitest": "^3.1.3",
|
|
103
103
|
"vue": "^3.5.13",
|
|
104
|
+
"vue-router": "^5.0.4",
|
|
104
105
|
"vue-tsc": "^2.2.10"
|
|
105
106
|
},
|
|
106
107
|
"simple-git-hooks": {
|