@gx-design-vue/pro-layout-components 0.1.0-alpha.4 → 0.1.0-alpha.6
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/RightContent/Search/Panel.js +5 -2
- package/dist/RightContent/Search/index.js +10 -6
- package/dist/RightContent/index.js +34 -33
- package/dist/RightContent/interface.d.ts +9 -16
- package/dist/RightContent/themeOptions.js +5 -3
- package/dist/pro-layout-components.esm.js +236 -709
- package/dist/pro-layout-components.js +1 -1
- package/package.json +10 -11
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { searchMenuItems, uniqueByField } from "../utils.js";
|
|
2
2
|
import { Fragment, createVNode, defineComponent, nextTick, onMounted, ref, unref, watch } from "vue";
|
|
3
|
-
import {
|
|
3
|
+
import { GIcon } from "@gx-design-vue/icon";
|
|
4
4
|
import { classNames, getPrefixCls, isString, isUrl } from "@gx-design-vue/pro-utils";
|
|
5
5
|
import { onKeyStroke, useLocalStorage, useThrottleFn } from "@vueuse/core";
|
|
6
6
|
import { Empty } from "antdv-next";
|
|
@@ -92,7 +92,10 @@ const GSearchPanel = /* @__PURE__ */ defineComponent((props) => {
|
|
|
92
92
|
"data-search-item": index,
|
|
93
93
|
"onClick": () => handleEnter(),
|
|
94
94
|
"onMouseenter": () => handleMouseenter(index)
|
|
95
|
-
}, [createVNode("div", { "class": getClassNames("panel-item-left") }, [item.meta?.title]), searchHistory.value.length > 0 && !props.keyword && createVNode(
|
|
95
|
+
}, [createVNode("div", { "class": getClassNames("panel-item-left") }, [item.meta?.title]), searchHistory.value.length > 0 && !props.keyword && createVNode(GIcon, {
|
|
96
|
+
"type": "CloseOutlined",
|
|
97
|
+
"onClick": (e) => removeItem(e, item)
|
|
98
|
+
}, null)]))])]) : renderEmpty.value?.() || createVNode(NoResult, {
|
|
96
99
|
"className": getClassNames("result"),
|
|
97
100
|
"value": props.keyword,
|
|
98
101
|
"locale": props.locale
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import GSearchPanel from "./Panel.js";
|
|
2
2
|
import style_default from "./style.js";
|
|
3
3
|
import { Fragment, computed, createTextVNode, createVNode, defineComponent, mergeProps, nextTick, ref } from "vue";
|
|
4
|
-
import {
|
|
4
|
+
import { GIcon } from "@gx-design-vue/icon";
|
|
5
5
|
import { useInjectLayoutContext } from "@gx-design-vue/pro-layout";
|
|
6
6
|
import { classNames, getLevelData, isWindowsOs } from "@gx-design-vue/pro-utils";
|
|
7
7
|
import { useMagicKeys, whenever } from "@vueuse/core";
|
|
@@ -10,9 +10,12 @@ import { useBaseConfig } from "antdv-next/config-provider/context";
|
|
|
10
10
|
import useCSSVarCls from "antdv-next/config-provider/hooks/useCSSVarCls";
|
|
11
11
|
import { GProModal } from "@gx-design-vue/pro-modal";
|
|
12
12
|
//#region src/RightContent/Search/index.tsx
|
|
13
|
-
const ModalFooter = ({ className, hashId, locale }) => createVNode("div", { "class": classNames(`${className}-footer`, hashId) }, [createVNode("div", { "class": classNames(`${className}-footer-icon`, hashId) }, [createVNode(
|
|
14
|
-
createVNode(
|
|
15
|
-
createVNode(
|
|
13
|
+
const ModalFooter = ({ className, hashId, locale }) => createVNode("div", { "class": classNames(`${className}-footer`, hashId) }, [createVNode("div", { "class": classNames(`${className}-footer-icon`, hashId) }, [createVNode(GIcon, { "type": "EnterOutlined" }, null), locale.selectLabel]), createVNode("div", { "class": classNames(`${className}-footer-icon`, hashId) }, [
|
|
14
|
+
createVNode(GIcon, { "type": "ArrowUpOutlined" }, null),
|
|
15
|
+
createVNode(GIcon, {
|
|
16
|
+
"type": "ArrowUpOutlined",
|
|
17
|
+
"rotate": 180
|
|
18
|
+
}, null),
|
|
16
19
|
locale.navigateLabel
|
|
17
20
|
])]);
|
|
18
21
|
const GSearchInput = /* @__PURE__ */ defineComponent((props) => {
|
|
@@ -55,7 +58,7 @@ const GSearchInput = /* @__PURE__ */ defineComponent((props) => {
|
|
|
55
58
|
open.value = true;
|
|
56
59
|
}
|
|
57
60
|
}, [
|
|
58
|
-
createVNode(
|
|
61
|
+
createVNode(GIcon, { "type": "SearchOutlined" }, null),
|
|
59
62
|
createVNode("span", { "class": classNames(`${prefixCls.value}-word`, hashId.value) }, [props.locale.searchLabel]),
|
|
60
63
|
createVNode("span", { "class": classNames(`${prefixCls.value}-word-icon`, hashId.value) }, [
|
|
61
64
|
createTextVNode("⌘"),
|
|
@@ -81,10 +84,11 @@ const GSearchInput = /* @__PURE__ */ defineComponent((props) => {
|
|
|
81
84
|
"size": "large",
|
|
82
85
|
"placeholder": props.locale.searchPlaceholder,
|
|
83
86
|
"value": keyword.value,
|
|
87
|
+
"prefix": createVNode(GIcon, { "type": "SearchOutlined" }, null),
|
|
84
88
|
"onUpdate:value": (val) => {
|
|
85
89
|
keyword.value = val;
|
|
86
90
|
}
|
|
87
|
-
},
|
|
91
|
+
}, null),
|
|
88
92
|
"open": open.value,
|
|
89
93
|
"footer": createVNode(ModalFooter, {
|
|
90
94
|
"className": modalClass,
|
|
@@ -3,11 +3,10 @@ import GSearchInput from "./Search/index.js";
|
|
|
3
3
|
import style_default from "./style.js";
|
|
4
4
|
import { defaultThemeOptions } from "./themeOptions.js";
|
|
5
5
|
import { Fragment, computed, createVNode, defineComponent, mergeProps, ref, watch } from "vue";
|
|
6
|
-
import { CompressOutlined, ExpandOutlined, LockOutlined, LogoutOutlined, SettingOutlined, UserOutlined } from "@antdv-next/icons";
|
|
7
6
|
import { useThemeContext } from "@gx-design-vue/context";
|
|
8
7
|
import { GIcon } from "@gx-design-vue/icon";
|
|
9
8
|
import { useInjectLayoutContext } from "@gx-design-vue/pro-layout";
|
|
10
|
-
import { classNames } from "@gx-design-vue/pro-utils";
|
|
9
|
+
import { classNames, isArray } from "@gx-design-vue/pro-utils";
|
|
11
10
|
import { useElementSize, useFullscreen } from "@vueuse/core";
|
|
12
11
|
import { Avatar, Dropdown } from "antdv-next";
|
|
13
12
|
import { useBaseConfig } from "antdv-next/config-provider/context";
|
|
@@ -36,10 +35,9 @@ const RightContent = /* @__PURE__ */ defineComponent((props, { emit, slots }) =>
|
|
|
36
35
|
const actions = computed(() => {
|
|
37
36
|
if (props.actions === false) return {};
|
|
38
37
|
return {
|
|
39
|
-
lock: true,
|
|
40
38
|
theme: true,
|
|
41
39
|
search: true,
|
|
42
|
-
themeEditor:
|
|
40
|
+
themeEditor: false,
|
|
43
41
|
fullScreen: true,
|
|
44
42
|
...props.actions
|
|
45
43
|
};
|
|
@@ -55,19 +53,23 @@ const RightContent = /* @__PURE__ */ defineComponent((props, { emit, slots }) =>
|
|
|
55
53
|
setTheme(value);
|
|
56
54
|
}
|
|
57
55
|
const userMenuItems = computed(() => {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
const menuSlots = slots?.dropdownMenu?.();
|
|
57
|
+
const items = props.dropdownProps?.menu?.items || [];
|
|
58
|
+
if (isArray(menuSlots)) menuSlots.forEach((item, index) => {
|
|
59
|
+
const key = item.props.key;
|
|
60
|
+
const icon = item.props.icon;
|
|
61
|
+
if (key === "menu-item") items.push({
|
|
62
|
+
key: `menu-${index}`,
|
|
63
|
+
label: item.children,
|
|
64
|
+
icon
|
|
64
65
|
});
|
|
65
|
-
items.push({ type: "divider" });
|
|
66
|
-
}
|
|
66
|
+
else if (key === "menu-divider") items.push({ type: "divider" });
|
|
67
|
+
});
|
|
67
68
|
items.push({
|
|
68
69
|
key: "logout",
|
|
69
|
-
icon: () => createVNode(
|
|
70
|
-
label: mergedLocale.value.logout
|
|
70
|
+
icon: () => createVNode(GIcon, { "type": "LogoutOutlined" }, null),
|
|
71
|
+
label: mergedLocale.value.logout,
|
|
72
|
+
onClick: handleUserMenuClick
|
|
71
73
|
});
|
|
72
74
|
return items;
|
|
73
75
|
});
|
|
@@ -78,12 +80,8 @@ const RightContent = /* @__PURE__ */ defineComponent((props, { emit, slots }) =>
|
|
|
78
80
|
function handleActionClick(type) {
|
|
79
81
|
emit("actionClick", type);
|
|
80
82
|
}
|
|
81
|
-
function handleLockOpenChange(val) {
|
|
82
|
-
lockOpen.value = val;
|
|
83
|
-
}
|
|
84
83
|
return () => {
|
|
85
84
|
const actionClassNames = [`${prefixCls.value}-header-actions-item`, hashId.value];
|
|
86
|
-
const FullScreenIcon = isFullscreen.value ? CompressOutlined : ExpandOutlined;
|
|
87
85
|
return createVNode("div", {
|
|
88
86
|
"ref": containerRef,
|
|
89
87
|
"class": classNames(prefixCls.value, hashId.value, cssVarCls.value, rootCls.value),
|
|
@@ -91,7 +89,7 @@ const RightContent = /* @__PURE__ */ defineComponent((props, { emit, slots }) =>
|
|
|
91
89
|
minWidth: minWidth.value,
|
|
92
90
|
height: "100%"
|
|
93
91
|
}
|
|
94
|
-
}, [createVNode("div", { "style": { height: "100%" } }, [createVNode("div", { "class": classNames(`${prefixCls.value}-header-actions
|
|
92
|
+
}, [createVNode("div", { "style": { height: "100%" } }, [createVNode("div", { "class": classNames(`${prefixCls.value}-header-actions`) }, [slots.default ? slots.default() : createVNode(Fragment, null, [
|
|
95
93
|
actions.value.search && !isMobile.value && createVNode(GSearchInput, {
|
|
96
94
|
"dataSource": props.searchConfig?.dataSource,
|
|
97
95
|
"disabledShortKey": props.searchConfig?.disabledShortKey,
|
|
@@ -111,22 +109,25 @@ const RightContent = /* @__PURE__ */ defineComponent((props, { emit, slots }) =>
|
|
|
111
109
|
selectedKeys: [theme.value]
|
|
112
110
|
}
|
|
113
111
|
}, { default: () => [createVNode(GIcon, {
|
|
114
|
-
"class": classNames(`${prefixCls.value}-header-actions-icon
|
|
115
|
-
"type": isDark.value ? "Moon" : "
|
|
112
|
+
"class": classNames(`${prefixCls.value}-header-actions-icon`),
|
|
113
|
+
"type": isDark.value ? "Moon" : "Sun"
|
|
116
114
|
}, null)] })]),
|
|
117
|
-
actions.value.themeEditor && !isMobile.value && createVNode("div", { "class": classNames(actionClassNames) }, [createVNode(
|
|
118
|
-
|
|
115
|
+
actions.value.themeEditor && !isMobile.value && createVNode("div", { "class": classNames(actionClassNames) }, [createVNode(GIcon, {
|
|
116
|
+
"type": "SettingOutlined",
|
|
117
|
+
"onClick": () => handleActionClick("themeEditor")
|
|
118
|
+
}, null)]),
|
|
119
|
+
actions.value.fullScreen && !isMobile.value && createVNode("div", { "class": classNames(actionClassNames) }, [createVNode(GIcon, {
|
|
120
|
+
"type": isFullscreen.value ? "CompressOutlined" : "ExpandOutlined",
|
|
121
|
+
"onClick": () => toggleFullscreen()
|
|
122
|
+
}, null)]),
|
|
119
123
|
slots.actionsRender?.(actionClassNames)
|
|
120
|
-
]), createVNode(Dropdown, mergeProps({ "placement": "bottomRight" }, props.dropdownProps, { "menu":
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
"
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
open: lockOpen.value,
|
|
128
|
-
onOpenChange: handleLockOpenChange
|
|
129
|
-
})]);
|
|
124
|
+
]), createVNode(Dropdown, mergeProps({ "placement": "bottomRight" }, props.dropdownProps, { "menu": { items: userMenuItems.value } }), {
|
|
125
|
+
default: () => [slots.dropdownTrigger ? slots.dropdownTrigger() : createVNode("div", { "class": classNames(`${prefixCls.value}-header-actions-avatar`) }, [createVNode(Avatar, {
|
|
126
|
+
"size": 28,
|
|
127
|
+
"icon": createVNode(GIcon, { "type": "UserOutlined" }, null)
|
|
128
|
+
}, null), props.name && createVNode("span", { "class": classNames(`${prefixCls.value}-header-actions-name`) }, [props.name])])],
|
|
129
|
+
popupRender: slots.popupRender
|
|
130
|
+
})])])]);
|
|
130
131
|
};
|
|
131
132
|
}, {
|
|
132
133
|
props: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { VNodeChild } from "vue";
|
|
2
1
|
import { ThemeValue } from "@gx-design-vue/context";
|
|
3
2
|
import { LayoutMenuRoute } from "@gx-design-vue/pro-layout";
|
|
3
|
+
import { CustomRender } from "@gx-design-vue/pro-utils";
|
|
4
|
+
import { DropdownProps, DropdownSlots } from "antdv-next";
|
|
4
5
|
|
|
5
6
|
//#region src/RightContent/interface.d.ts
|
|
6
7
|
interface RightContentEmits {
|
|
@@ -16,11 +17,10 @@ interface RightContentActionsConfig {
|
|
|
16
17
|
theme?: boolean;
|
|
17
18
|
themeEditor?: boolean;
|
|
18
19
|
fullScreen?: boolean;
|
|
19
|
-
lock?: boolean;
|
|
20
20
|
}
|
|
21
21
|
interface RightContentThemeOption {
|
|
22
22
|
value: ThemeValue;
|
|
23
|
-
label: () =>
|
|
23
|
+
label: () => CustomRender;
|
|
24
24
|
}
|
|
25
25
|
interface RightContentLocale {
|
|
26
26
|
searchPlaceholder?: string;
|
|
@@ -55,7 +55,7 @@ interface RightContentProps extends RightContentEmitsProps {
|
|
|
55
55
|
/** 用户头像 URL */
|
|
56
56
|
avatar?: string;
|
|
57
57
|
/** 透传给 antdv-next Dropdown 的额外 props */
|
|
58
|
-
dropdownProps?:
|
|
58
|
+
dropdownProps?: DropdownProps;
|
|
59
59
|
/** 自定义主题选项(覆盖默认的 亮色/深色/自动) */
|
|
60
60
|
themeOptions?: RightContentThemeOption[];
|
|
61
61
|
/** 搜索配置 */
|
|
@@ -65,20 +65,13 @@ interface RightContentProps extends RightContentEmitsProps {
|
|
|
65
65
|
}
|
|
66
66
|
interface RightContentSlots {
|
|
67
67
|
/** 替换整个 actions 区域 */
|
|
68
|
-
default?: () =>
|
|
68
|
+
default?: () => CustomRender;
|
|
69
69
|
/** 额外 action 项(在 avatar dropdown 前) */
|
|
70
|
-
actionsRender?: (classNames: string[]) =>
|
|
70
|
+
actionsRender?: (classNames: string[]) => CustomRender;
|
|
71
71
|
/** 替换 avatar 触发器 */
|
|
72
|
-
dropdownTrigger?: () =>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
/** dropdown 菜单顶部额外项 */
|
|
76
|
-
dropdownMenuExtra?: () => VNodeChild;
|
|
77
|
-
/** 锁屏内容(解耦 PageLock) */
|
|
78
|
-
lock?: (props: {
|
|
79
|
-
open: boolean;
|
|
80
|
-
onOpenChange: (val: boolean) => void;
|
|
81
|
-
}) => VNodeChild;
|
|
72
|
+
dropdownTrigger?: () => CustomRender;
|
|
73
|
+
dropdownMenu?: () => CustomRender;
|
|
74
|
+
popupRender?: DropdownSlots['popupRender'];
|
|
82
75
|
}
|
|
83
76
|
//#endregion
|
|
84
77
|
export { RightContentActionsConfig, RightContentEmits, RightContentEmitsProps, RightContentLocale, RightContentProps, RightContentSlots, RightContentThemeOption, SearchConfig };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createVNode, h } from "vue";
|
|
2
|
-
import { DesktopOutlined } from "@antdv-next/icons";
|
|
3
2
|
import { GIcon } from "@gx-design-vue/icon";
|
|
4
3
|
//#region src/RightContent/themeOptions.tsx
|
|
5
4
|
const iconStyle = { fontSize: "15px" };
|
|
@@ -21,13 +20,16 @@ const defaultThemeOptions = [
|
|
|
21
20
|
{
|
|
22
21
|
value: "dark",
|
|
23
22
|
label: labelWithIcon(h(GIcon, {
|
|
24
|
-
type: "
|
|
23
|
+
type: "Sun",
|
|
25
24
|
style: iconStyle
|
|
26
25
|
}), "深色")
|
|
27
26
|
},
|
|
28
27
|
{
|
|
29
28
|
value: "system",
|
|
30
|
-
label: labelWithIcon(h(
|
|
29
|
+
label: labelWithIcon(h(GIcon, {
|
|
30
|
+
type: "DesktopOutlined",
|
|
31
|
+
style: iconStyle
|
|
32
|
+
}), "自动")
|
|
31
33
|
}
|
|
32
34
|
];
|
|
33
35
|
//#endregion
|