gov-layout 1.2.1 → 1.2.3
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/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +30 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -47,9 +47,11 @@ interface StaffSidebarProps {
|
|
|
47
47
|
isOpen?: boolean;
|
|
48
48
|
/** callback เมื่อกดเปิด/ปิด */
|
|
49
49
|
onToggle?: () => void;
|
|
50
|
+
/** callback เมื่อกดเมนูที่มี children ขณะ sidebar ย่อ — ใช้สั่งกาง sidebar */
|
|
51
|
+
onExpandRequest?: () => void;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
declare function StaffSidebar({ orgLogo, orgName, orgSubtitle, menuItems, bottomMenuItems, user, roleLabel, onNavigate, onLogout, currentPath, width, className, collapsible, isOpen: controlledIsOpen, onToggle, }: StaffSidebarProps): react_jsx_runtime.JSX.Element;
|
|
54
|
+
declare function StaffSidebar({ orgLogo, orgName, orgSubtitle, menuItems, bottomMenuItems, user, roleLabel, onNavigate, onLogout, currentPath, width, className, collapsible, isOpen: controlledIsOpen, onToggle, onExpandRequest, }: StaffSidebarProps): react_jsx_runtime.JSX.Element;
|
|
53
55
|
|
|
54
56
|
interface SidebarHeaderProps {
|
|
55
57
|
orgLogo?: string;
|
|
@@ -64,8 +66,9 @@ interface SidebarMenuProps {
|
|
|
64
66
|
onItemClick: (path: string) => void;
|
|
65
67
|
currentPath?: string;
|
|
66
68
|
collapsed?: boolean;
|
|
69
|
+
onExpandRequest?: () => void;
|
|
67
70
|
}
|
|
68
|
-
declare function SidebarMenu({ menuItems, onItemClick, currentPath, collapsed }: SidebarMenuProps): react_jsx_runtime.JSX.Element;
|
|
71
|
+
declare function SidebarMenu({ menuItems, onItemClick, currentPath, collapsed, onExpandRequest }: SidebarMenuProps): react_jsx_runtime.JSX.Element;
|
|
69
72
|
|
|
70
73
|
interface SidebarUserProfileProps {
|
|
71
74
|
user: User | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -47,9 +47,11 @@ interface StaffSidebarProps {
|
|
|
47
47
|
isOpen?: boolean;
|
|
48
48
|
/** callback เมื่อกดเปิด/ปิด */
|
|
49
49
|
onToggle?: () => void;
|
|
50
|
+
/** callback เมื่อกดเมนูที่มี children ขณะ sidebar ย่อ — ใช้สั่งกาง sidebar */
|
|
51
|
+
onExpandRequest?: () => void;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
declare function StaffSidebar({ orgLogo, orgName, orgSubtitle, menuItems, bottomMenuItems, user, roleLabel, onNavigate, onLogout, currentPath, width, className, collapsible, isOpen: controlledIsOpen, onToggle, }: StaffSidebarProps): react_jsx_runtime.JSX.Element;
|
|
54
|
+
declare function StaffSidebar({ orgLogo, orgName, orgSubtitle, menuItems, bottomMenuItems, user, roleLabel, onNavigate, onLogout, currentPath, width, className, collapsible, isOpen: controlledIsOpen, onToggle, onExpandRequest, }: StaffSidebarProps): react_jsx_runtime.JSX.Element;
|
|
53
55
|
|
|
54
56
|
interface SidebarHeaderProps {
|
|
55
57
|
orgLogo?: string;
|
|
@@ -64,8 +66,9 @@ interface SidebarMenuProps {
|
|
|
64
66
|
onItemClick: (path: string) => void;
|
|
65
67
|
currentPath?: string;
|
|
66
68
|
collapsed?: boolean;
|
|
69
|
+
onExpandRequest?: () => void;
|
|
67
70
|
}
|
|
68
|
-
declare function SidebarMenu({ menuItems, onItemClick, currentPath, collapsed }: SidebarMenuProps): react_jsx_runtime.JSX.Element;
|
|
71
|
+
declare function SidebarMenu({ menuItems, onItemClick, currentPath, collapsed, onExpandRequest }: SidebarMenuProps): react_jsx_runtime.JSX.Element;
|
|
69
72
|
|
|
70
73
|
interface SidebarUserProfileProps {
|
|
71
74
|
user: User | null;
|
package/dist/index.js
CHANGED
|
@@ -417,7 +417,8 @@ function MenuItemComponent({
|
|
|
417
417
|
onItemClick,
|
|
418
418
|
currentPath,
|
|
419
419
|
depth = 0,
|
|
420
|
-
collapsed = false
|
|
420
|
+
collapsed = false,
|
|
421
|
+
onExpandRequest
|
|
421
422
|
}) {
|
|
422
423
|
const hasChildren = item.children && item.children.length > 0;
|
|
423
424
|
const isActive = item.path ? currentPath === item.path : false;
|
|
@@ -428,8 +429,14 @@ function MenuItemComponent({
|
|
|
428
429
|
const expanded = userToggled ? isOpen : isOpen || isChildActive;
|
|
429
430
|
const handleClick = () => {
|
|
430
431
|
if (hasChildren) {
|
|
431
|
-
|
|
432
|
-
|
|
432
|
+
if (collapsed) {
|
|
433
|
+
setUserToggled(true);
|
|
434
|
+
setIsOpen(true);
|
|
435
|
+
onExpandRequest?.();
|
|
436
|
+
} else {
|
|
437
|
+
setUserToggled(true);
|
|
438
|
+
setIsOpen(!expanded);
|
|
439
|
+
}
|
|
433
440
|
} else if (item.path) {
|
|
434
441
|
onItemClick(item.path);
|
|
435
442
|
}
|
|
@@ -538,7 +545,7 @@ function MenuItemComponent({
|
|
|
538
545
|
} }) })
|
|
539
546
|
] });
|
|
540
547
|
}
|
|
541
|
-
function SidebarMenu({ menuItems, onItemClick, currentPath, collapsed }) {
|
|
548
|
+
function SidebarMenu({ menuItems, onItemClick, currentPath, collapsed, onExpandRequest }) {
|
|
542
549
|
return /* @__PURE__ */ jsxRuntime.jsx("nav", { style: {
|
|
543
550
|
padding: collapsed ? "8px 8px" : "8px 12px",
|
|
544
551
|
overflowY: "auto"
|
|
@@ -555,7 +562,8 @@ function SidebarMenu({ menuItems, onItemClick, currentPath, collapsed }) {
|
|
|
555
562
|
item,
|
|
556
563
|
onItemClick,
|
|
557
564
|
currentPath,
|
|
558
|
-
collapsed
|
|
565
|
+
collapsed,
|
|
566
|
+
onExpandRequest
|
|
559
567
|
},
|
|
560
568
|
item.id
|
|
561
569
|
)) }) });
|
|
@@ -813,7 +821,8 @@ function StaffSidebar({
|
|
|
813
821
|
className,
|
|
814
822
|
collapsible = false,
|
|
815
823
|
isOpen: controlledIsOpen,
|
|
816
|
-
onToggle
|
|
824
|
+
onToggle,
|
|
825
|
+
onExpandRequest
|
|
817
826
|
}) {
|
|
818
827
|
const [internalOpen, setInternalOpen] = react.useState(true);
|
|
819
828
|
const sidebarOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalOpen;
|
|
@@ -828,6 +837,17 @@ function StaffSidebar({
|
|
|
828
837
|
setInternalOpen(!internalOpen);
|
|
829
838
|
}
|
|
830
839
|
};
|
|
840
|
+
const handleExpandRequest = () => {
|
|
841
|
+
if (onExpandRequest) {
|
|
842
|
+
onExpandRequest();
|
|
843
|
+
} else {
|
|
844
|
+
if (onToggle) {
|
|
845
|
+
onToggle();
|
|
846
|
+
} else {
|
|
847
|
+
setInternalOpen(true);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
};
|
|
831
851
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
832
852
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
833
853
|
"aside",
|
|
@@ -863,7 +883,8 @@ function StaffSidebar({
|
|
|
863
883
|
menuItems,
|
|
864
884
|
onItemClick: onNavigate,
|
|
865
885
|
currentPath,
|
|
866
|
-
collapsed
|
|
886
|
+
collapsed,
|
|
887
|
+
onExpandRequest: handleExpandRequest
|
|
867
888
|
}
|
|
868
889
|
) }),
|
|
869
890
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { flexShrink: 0 }, children: [
|
|
@@ -879,7 +900,8 @@ function StaffSidebar({
|
|
|
879
900
|
menuItems: resolvedBottomMenu,
|
|
880
901
|
onItemClick: onNavigate,
|
|
881
902
|
currentPath,
|
|
882
|
-
collapsed
|
|
903
|
+
collapsed,
|
|
904
|
+
onExpandRequest: handleExpandRequest
|
|
883
905
|
}
|
|
884
906
|
)
|
|
885
907
|
] }),
|