@uniai-fe/uds-templates 0.3.9 → 0.3.10
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/package.json
CHANGED
|
@@ -25,12 +25,11 @@ import { PAGE_FRAME_DESKTOP_SETTING_ITEMS } from "../../../../data/setting";
|
|
|
25
25
|
* @property {string} [props.className] 사용자 정의 className
|
|
26
26
|
* @property {PageFrameDesktopSettingItem[]} [props.items] dropdown 항목 배열
|
|
27
27
|
* @description
|
|
28
|
-
* -
|
|
29
|
-
* -
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* - 비밀번호 재설정
|
|
28
|
+
* - 내 정보 관리
|
|
29
|
+
* - 내 농장 관리
|
|
30
|
+
* - 기본 정보
|
|
31
|
+
* - 인증 정보
|
|
32
|
+
* - 시설 정보
|
|
34
33
|
*/
|
|
35
34
|
export default function PageHeaderSettingButton({
|
|
36
35
|
className,
|
|
@@ -46,17 +45,43 @@ export default function PageHeaderSettingButton({
|
|
|
46
45
|
() => getClosestRoute(menuItems, resolvedPath),
|
|
47
46
|
[menuItems, resolvedPath],
|
|
48
47
|
);
|
|
48
|
+
const commonRoute = useMemo(() => {
|
|
49
|
+
const routes = menuItems.map(({ path }) => path.split("/").filter(Boolean));
|
|
50
|
+
|
|
51
|
+
// route 각 index 아이템이 가장 많이 겹치는 route 추출
|
|
52
|
+
const maxLength = Math.max(...routes.map(route => route.length));
|
|
53
|
+
const res = Array(maxLength)
|
|
54
|
+
.fill("")
|
|
55
|
+
.map((_, index) => {
|
|
56
|
+
const current = routes[0][index] ?? "";
|
|
57
|
+
if (routes.every(route => route[index] === current)) {
|
|
58
|
+
return current;
|
|
59
|
+
}
|
|
60
|
+
return "";
|
|
61
|
+
})
|
|
62
|
+
.filter(Boolean);
|
|
63
|
+
return `/${res.join("/")}`;
|
|
64
|
+
}, [menuItems]);
|
|
65
|
+
|
|
66
|
+
const isMatchRouteGroup = useMemo(
|
|
67
|
+
() => pathname.startsWith(commonRoute),
|
|
68
|
+
[pathname, commonRoute],
|
|
69
|
+
);
|
|
49
70
|
|
|
50
71
|
const dropdownItems: DropdownTemplateItem[] = useMemo(
|
|
51
72
|
() =>
|
|
52
73
|
menuItems.map(item => ({
|
|
53
74
|
id: item.routeKey,
|
|
75
|
+
// 변경: Dropdown.Template value-first 계약에 맞춰 routeKey를 value로도 전달한다.
|
|
76
|
+
value: item.routeKey,
|
|
54
77
|
label: item.name,
|
|
55
78
|
left: item.icon,
|
|
56
79
|
// 변경: Dropdown.Template 선택 계약은 items[].selected를 source로 사용한다.
|
|
57
|
-
selected:
|
|
80
|
+
selected:
|
|
81
|
+
isMatchRouteGroup &&
|
|
82
|
+
String(closestRoute?.routeKey) === String(item.routeKey),
|
|
58
83
|
})),
|
|
59
|
-
[closestRoute?.routeKey
|
|
84
|
+
[menuItems, isMatchRouteGroup, closestRoute?.routeKey],
|
|
60
85
|
);
|
|
61
86
|
|
|
62
87
|
/**
|
|
@@ -65,9 +90,8 @@ export default function PageHeaderSettingButton({
|
|
|
65
90
|
*/
|
|
66
91
|
const handleSelect = useCallback(
|
|
67
92
|
(payload: DropdownTemplateChangePayload) => {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
);
|
|
93
|
+
const currentRouteKey = String(payload.currentValue);
|
|
94
|
+
const target = menuItems.find(item => item.routeKey === currentRouteKey);
|
|
71
95
|
target?.onSelect?.();
|
|
72
96
|
},
|
|
73
97
|
[menuItems],
|