@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniai-fe/uds-templates",
3
- "version": "0.3.9",
3
+ "version": "0.3.10",
4
4
  "description": "UNIAI Design System; UI Templates Package",
5
5
  "type": "module",
6
6
  "private": false,
@@ -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
- * - SNS 메시지 알림 설정
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: String(closestRoute?.routeKey) === String(item.routeKey),
80
+ selected:
81
+ isMatchRouteGroup &&
82
+ String(closestRoute?.routeKey) === String(item.routeKey),
58
83
  })),
59
- [closestRoute?.routeKey, menuItems],
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 target = menuItems.find(
69
- item => item.routeKey === payload.currentItem.id,
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],