@sikka/hawa 0.1.23 → 0.1.25
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/es/index.es.js +1 -1
- package/es/layout/Sidebar.d.ts +2 -0
- package/lib/index.js +1 -1
- package/lib/layout/Sidebar.d.ts +2 -0
- package/package.json +1 -1
- package/src/layout/AppLayout.tsx +42 -42
- package/src/layout/Sidebar.tsx +19 -2
package/lib/layout/Sidebar.d.ts
CHANGED
|
@@ -21,11 +21,13 @@ interface SidebarGroupProps {
|
|
|
21
21
|
isOpen?: boolean;
|
|
22
22
|
onItemClick?: (value: string[]) => void;
|
|
23
23
|
onSubItemClick?: (values: string[]) => void;
|
|
24
|
+
direction?: "rtl" | "ltr";
|
|
24
25
|
}
|
|
25
26
|
declare const SidebarGroup: React.FC<SidebarGroupProps>;
|
|
26
27
|
declare const SidebarItem: React.FC<{
|
|
27
28
|
item: Item;
|
|
28
29
|
isSelected: any;
|
|
30
|
+
direction?: "rtl" | "ltr";
|
|
29
31
|
onItemClick?: (value: string[]) => void;
|
|
30
32
|
onSubItemClick?: (values: string[]) => void;
|
|
31
33
|
isOpen?: boolean;
|
package/package.json
CHANGED
package/src/layout/AppLayout.tsx
CHANGED
|
@@ -64,23 +64,41 @@ export const AppLayout: React.FunctionComponent<AppLayoutTypes> = ({
|
|
|
64
64
|
clickedItem,
|
|
65
65
|
...props
|
|
66
66
|
}) => {
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
let closeDrawerWidth = 56
|
|
68
|
+
let openDrawerWidth = 200
|
|
69
|
+
let drawerSizeStyle = {
|
|
70
|
+
opened: {
|
|
71
|
+
sm: "100",
|
|
72
|
+
md: openDrawerWidth,
|
|
73
|
+
lg: "250",
|
|
74
|
+
},
|
|
75
|
+
closed: {
|
|
76
|
+
sm: closeDrawerWidth,
|
|
77
|
+
md: closeDrawerWidth,
|
|
78
|
+
lg: closeDrawerWidth,
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const ref = useRef(null)
|
|
83
|
+
const isRTL = direction === "rtl"
|
|
84
|
+
|
|
69
85
|
const [openedSidebarItem, setOpenedSidebarItem] = useState("")
|
|
70
|
-
const { isOpen, onClose, onOpen } = useDiscloser(false)
|
|
71
86
|
const [selectedItem, setSelectedItem] = useState(
|
|
72
87
|
currentPage ? currentPage : []
|
|
73
88
|
)
|
|
74
89
|
|
|
75
|
-
const [keepOpen, setKeepOpen] = useState(false)
|
|
76
|
-
const ref = useRef(null)
|
|
77
|
-
const isRTL = direction === "rtl"
|
|
78
90
|
let size
|
|
79
91
|
if (typeof window !== "undefined") {
|
|
80
92
|
size = useBreakpoint()
|
|
81
93
|
} else {
|
|
82
94
|
size = 1200
|
|
83
95
|
}
|
|
96
|
+
const [keepOpen, setKeepOpen] = useState(size > 600 ? true : false)
|
|
97
|
+
const [openSideMenu, setOpenSideMenu] = useState(size > 600 ? true : false)
|
|
98
|
+
|
|
99
|
+
let drawerSizeCondition =
|
|
100
|
+
size > 600 ? drawerSizeStyle[keepOpen ? "opened" : "closed"][drawerSize] : 0
|
|
101
|
+
|
|
84
102
|
useEffect(() => {
|
|
85
103
|
const handleClickOutside = (event) => {
|
|
86
104
|
if (ref.current && !ref.current.contains(event.target) && !keepOpen) {
|
|
@@ -93,29 +111,13 @@ export const AppLayout: React.FunctionComponent<AppLayoutTypes> = ({
|
|
|
93
111
|
}
|
|
94
112
|
}, [keepOpen])
|
|
95
113
|
|
|
96
|
-
let drawerDefaultStyle =
|
|
97
|
-
"fixed top-0 z-40 flex h-full flex-col justify-between overflow-x-clip bg-card transition-all"
|
|
98
|
-
//The width of the drawer when closed
|
|
99
|
-
let closeDrawerWidth = 56
|
|
100
|
-
//The width of the drawer when opened
|
|
101
|
-
let openDrawerWidth = 200
|
|
102
|
-
let drawerSizeStyle = {
|
|
103
|
-
opened: {
|
|
104
|
-
sm: "100",
|
|
105
|
-
md: openDrawerWidth,
|
|
106
|
-
lg: "250",
|
|
107
|
-
},
|
|
108
|
-
closed: {
|
|
109
|
-
sm: "56",
|
|
110
|
-
md: "56",
|
|
111
|
-
lg: "56",
|
|
112
|
-
},
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
let drawerSizeCondition =
|
|
116
|
-
size > 600 ? drawerSizeStyle[keepOpen ? "opened" : "closed"][drawerSize] : 0
|
|
117
114
|
return (
|
|
118
115
|
<div className="fixed left-0">
|
|
116
|
+
{/*
|
|
117
|
+
* ----------------------------------------------------------------------------------------------------
|
|
118
|
+
* Top Bar
|
|
119
|
+
* ----------------------------------------------------------------------------------------------------
|
|
120
|
+
*/}
|
|
119
121
|
{props.topBar && (
|
|
120
122
|
<div
|
|
121
123
|
className={clsx(
|
|
@@ -212,7 +214,18 @@ export const AppLayout: React.FunctionComponent<AppLayoutTypes> = ({
|
|
|
212
214
|
direction={isRTL ? "rtl" : "ltr"}
|
|
213
215
|
trigger={
|
|
214
216
|
<div className="relative h-8 w-8 cursor-pointer overflow-clip rounded ring-1 ring-primary/30 dark:bg-gray-600">
|
|
215
|
-
<
|
|
217
|
+
<svg
|
|
218
|
+
aria-aria-label="Avatar Icon"
|
|
219
|
+
className="absolute -left-1 h-10 w-10 text-gray-400"
|
|
220
|
+
fill="currentColor"
|
|
221
|
+
viewBox="0 0 20 20"
|
|
222
|
+
>
|
|
223
|
+
<path
|
|
224
|
+
fillRule="evenodd"
|
|
225
|
+
d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z"
|
|
226
|
+
clipRule="evenodd"
|
|
227
|
+
></path>
|
|
228
|
+
</svg>
|
|
216
229
|
</div>
|
|
217
230
|
}
|
|
218
231
|
items={props.profileMenuItems}
|
|
@@ -327,6 +340,7 @@ export const AppLayout: React.FunctionComponent<AppLayoutTypes> = ({
|
|
|
327
340
|
*/}
|
|
328
341
|
|
|
329
342
|
<SidebarGroup
|
|
343
|
+
direction={direction}
|
|
330
344
|
onItemClick={(values) => {
|
|
331
345
|
setSelectedItem(values)
|
|
332
346
|
clickedItem(values)
|
|
@@ -432,17 +446,3 @@ export const AppLayout: React.FunctionComponent<AppLayoutTypes> = ({
|
|
|
432
446
|
</div>
|
|
433
447
|
)
|
|
434
448
|
}
|
|
435
|
-
|
|
436
|
-
const AvatarIcon = () => (
|
|
437
|
-
<svg
|
|
438
|
-
className="absolute -left-1 h-10 w-10 text-gray-400"
|
|
439
|
-
fill="currentColor"
|
|
440
|
-
viewBox="0 0 20 20"
|
|
441
|
-
>
|
|
442
|
-
<path
|
|
443
|
-
fillRule="evenodd"
|
|
444
|
-
d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z"
|
|
445
|
-
clipRule="evenodd"
|
|
446
|
-
></path>
|
|
447
|
-
</svg>
|
|
448
|
-
)
|
package/src/layout/Sidebar.tsx
CHANGED
|
@@ -94,6 +94,7 @@ interface SidebarGroupProps {
|
|
|
94
94
|
isOpen?: boolean
|
|
95
95
|
onItemClick?: (value: string[]) => void
|
|
96
96
|
onSubItemClick?: (values: string[]) => void
|
|
97
|
+
direction?: "rtl" | "ltr"
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
const SidebarGroup: React.FC<SidebarGroupProps> = ({
|
|
@@ -104,6 +105,7 @@ const SidebarGroup: React.FC<SidebarGroupProps> = ({
|
|
|
104
105
|
setOpenedItem,
|
|
105
106
|
onItemClick,
|
|
106
107
|
onSubItemClick,
|
|
108
|
+
direction,
|
|
107
109
|
isOpen,
|
|
108
110
|
}) => {
|
|
109
111
|
return (
|
|
@@ -124,6 +126,7 @@ const SidebarGroup: React.FC<SidebarGroupProps> = ({
|
|
|
124
126
|
isOpen={isOpen}
|
|
125
127
|
isSelected={selectedItem}
|
|
126
128
|
key={idx}
|
|
129
|
+
direction={direction}
|
|
127
130
|
item={item}
|
|
128
131
|
onItemClick={onItemClick}
|
|
129
132
|
onSubItemClick={onSubItemClick}
|
|
@@ -137,10 +140,19 @@ const SidebarGroup: React.FC<SidebarGroupProps> = ({
|
|
|
137
140
|
const SidebarItem: React.FC<{
|
|
138
141
|
item: Item
|
|
139
142
|
isSelected: any
|
|
143
|
+
direction?: "rtl" | "ltr"
|
|
144
|
+
|
|
140
145
|
onItemClick?: (value: string[]) => void
|
|
141
146
|
onSubItemClick?: (values: string[]) => void
|
|
142
147
|
isOpen?: boolean
|
|
143
|
-
}> = ({
|
|
148
|
+
}> = ({
|
|
149
|
+
item,
|
|
150
|
+
isSelected,
|
|
151
|
+
onItemClick,
|
|
152
|
+
onSubItemClick,
|
|
153
|
+
direction,
|
|
154
|
+
isOpen = true,
|
|
155
|
+
}) => {
|
|
144
156
|
const getSelectedStyle = (value: string, index: number) => {
|
|
145
157
|
return isSelected && isSelected[index] === value
|
|
146
158
|
? "bg-primary text-primary-foreground cursor-default"
|
|
@@ -148,7 +160,11 @@ const SidebarItem: React.FC<{
|
|
|
148
160
|
}
|
|
149
161
|
if (item.subitems) {
|
|
150
162
|
return (
|
|
151
|
-
<AccordionItem
|
|
163
|
+
<AccordionItem
|
|
164
|
+
value={item.value}
|
|
165
|
+
className="overflow-x-clip"
|
|
166
|
+
dir={direction}
|
|
167
|
+
>
|
|
152
168
|
<AccordionTrigger
|
|
153
169
|
className={cn(getSelectedStyle(item.value, 0))}
|
|
154
170
|
showArrow={isOpen}
|
|
@@ -203,6 +219,7 @@ const SidebarItem: React.FC<{
|
|
|
203
219
|
} else {
|
|
204
220
|
return (
|
|
205
221
|
<div
|
|
222
|
+
dir={direction}
|
|
206
223
|
onClick={() => {
|
|
207
224
|
if (onItemClick) {
|
|
208
225
|
onItemClick([item.value])
|