uikit-react-public 0.25.2 → 0.25.4
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/components/Dropdown/Dropdown.context.d.ts +2 -0
- package/dist/components/Dropdown/DropdownContent.d.ts +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +7 -2
- package/dist/components/MenuNew/Menu.d.ts +3 -1
- package/dist/components/MenuNew/MenuHead.d.ts +9 -0
- package/dist/components/MenuNew/index.d.ts +1 -1
- package/dist/index.js +4036 -3839
- package/lib/components/Dropdown/Dropdown.context.tsx +9 -1
- package/lib/components/Dropdown/Dropdown.tsx +10 -2
- package/lib/components/Dropdown/DropdownContent.tsx +178 -18
- package/lib/components/Dropdown/DropdownTrigger.tsx +3 -2
- package/lib/components/Dropdown/__tests__/Dropdown.test.tsx +1 -1
- package/lib/components/DropdownMenu/DropdownMenu.tsx +41 -3
- package/lib/components/DropdownMenu/__tests__/DropdownMenu.test.tsx +49 -0
- package/lib/components/MenuNew/Menu.tsx +8 -2
- package/lib/components/MenuNew/MenuAccordion/MenuAccordion.tsx +1 -0
- package/lib/components/MenuNew/MenuHead.tsx +76 -0
- package/lib/components/MenuNew/MenuHeading.tsx +1 -0
- package/lib/components/MenuNew/PrimaryMenuItem.tsx +1 -0
- package/lib/components/MenuNew/SecondaryMenuItem.tsx +5 -1
- package/lib/components/MenuNew/__tests__/Menu.test.tsx +25 -0
- package/lib/components/MenuNew/index.ts +1 -0
- package/lib/hooks/useMediaQuery.ts +13 -1
- package/package.json +1 -1
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
2
|
|
|
3
|
+
const getInitialMatch = (query: string): boolean => {
|
|
4
|
+
if (typeof window === 'undefined') return false;
|
|
5
|
+
if (typeof window.matchMedia !== 'function') return false;
|
|
6
|
+
return window.matchMedia(query).matches;
|
|
7
|
+
};
|
|
8
|
+
|
|
3
9
|
const useMediaQuery = (query: string): boolean => {
|
|
4
|
-
const [isQueryMatch, setIsQueryMatch] = useState<boolean>(
|
|
10
|
+
const [isQueryMatch, setIsQueryMatch] = useState<boolean>(() =>
|
|
11
|
+
getInitialMatch(query)
|
|
12
|
+
);
|
|
5
13
|
|
|
6
14
|
useEffect(() => {
|
|
15
|
+
if (typeof window === 'undefined') return;
|
|
16
|
+
if (typeof window.matchMedia !== 'function') return;
|
|
17
|
+
|
|
7
18
|
const mediaQueryList = window.matchMedia(query);
|
|
8
19
|
|
|
20
|
+
// Keep state in sync if query changes
|
|
9
21
|
setIsQueryMatch(mediaQueryList.matches);
|
|
10
22
|
|
|
11
23
|
const handleChange = (event: MediaQueryListEvent) => {
|