@sikka/hawa 0.2.1 → 0.2.2

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": "@sikka/hawa",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Modern UI Kit made with Tailwind & Radix Primitives",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -2,3 +2,12 @@ export * from "./useDiscloser"
2
2
  export * from "./useHover"
3
3
  export * from "./useToast"
4
4
  export * from "./useCarousel"
5
+ export * from "./useClipboard"
6
+ export * from "./useBreakpoint"
7
+ export * from "./useFocusWithin"
8
+ export * from "./useMediaQuery"
9
+ export * from "./useScrollPosition"
10
+ export * from "./useTable"
11
+ export * from "./useTabs"
12
+ export * from "./useWindowEvent"
13
+ export * from "./useWindowScroll"
@@ -0,0 +1,37 @@
1
+ import { useEffect, useState } from "react"
2
+
3
+ function useTabs(initialTab = "") {
4
+ const [activeTab, setActiveTab] = useState(initialTab)
5
+
6
+ // Listen to hash changes in the URL
7
+ useEffect(() => {
8
+ const handleHashChange = () => {
9
+ const hash = window.location.hash.substring(1)
10
+ setActiveTab(hash || initialTab)
11
+ }
12
+
13
+ window.addEventListener("hashchange", handleHashChange)
14
+
15
+ // Initialize the tab based on the initial hash
16
+ handleHashChange()
17
+
18
+ return () => {
19
+ // Remove the event listener when the component unmounts
20
+ window.removeEventListener("hashchange", handleHashChange)
21
+ }
22
+ }, [initialTab])
23
+
24
+ const handleTabChange = (index) => {
25
+ setActiveTab(index)
26
+
27
+ // Update the URL hash when the tab changes
28
+ window.location.hash = index
29
+ }
30
+
31
+ return {
32
+ activeTab,
33
+ handleTabChange,
34
+ }
35
+ }
36
+
37
+ export { useTabs }
@@ -1,6 +1,5 @@
1
1
  import React, { useEffect, useRef, useState } from "react"
2
2
  import clsx from "clsx"
3
- import useDiscloser from "../hooks/useDiscloser"
4
3
  import useBreakpoint from "../hooks/useBreakpoint"
5
4
  import { Button, DropdownMenu, MenuItemType, Tooltip } from "../elements"
6
5
  import { SidebarGroup } from "./Sidebar"
@@ -27,6 +26,7 @@ type AppLayoutTypes = {
27
26
  profileMenuWidth: "default" | "sm" | "lg" | "parent"
28
27
  onSettingsClick?: () => void
29
28
  onDrawerExpand?: (e) => void
29
+ keepDrawerOpen?: boolean
30
30
  DrawerFooterActions?: any
31
31
  clickedItem?: any
32
32
  texts?: {
@@ -85,7 +85,15 @@ export const AppLayout: React.FunctionComponent<AppLayoutTypes> = ({
85
85
  } else {
86
86
  size = 1200
87
87
  }
88
- const [keepOpen, setKeepOpen] = useState(size > 600 ? true : false)
88
+ const [keepOpen, setKeepOpen] = useState(() => {
89
+ if (size > 600) {
90
+ // If size is larger than 600, use prop.isDrawerOpen if it exists, or default to true.
91
+ return props.keepDrawerOpen !== undefined ? props.keepDrawerOpen : true
92
+ } else {
93
+ // If size is less than or equal to 600, set keepOpen to false.
94
+ return false
95
+ }
96
+ })
89
97
  const [openSideMenu, setOpenSideMenu] = useState(size > 600 ? true : false)
90
98
 
91
99
  let drawerSizeCondition =