@fc-components/menu
Advanced tools
+1
-1
| { | ||
| "name": "@fc-components/menu", | ||
| "version": "1.1.21", | ||
| "version": "1.1.22", | ||
| "description": "The Menu component used for flashcat.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.tsx", |
@@ -58,10 +58,23 @@ import React, { useState, useEffect, useRef } from 'react'; | ||
| const [starActiveIndex, setStarActiveIndex] = useState(-1); | ||
| const displayMenus = menus.filter( | ||
| (menu) => | ||
| const displayMenus = menus.filter((menu) => { | ||
| const label = | ||
| typeof menu.label === 'string' | ||
| ? menu.label | ||
| : typeof (menu.label as React.ReactElement).props?.text === 'string' | ||
| ? (menu.label as React.ReactElement).props?.text | ||
| : ''; | ||
| const primaryLabel = | ||
| typeof menu.primaryLabel === 'string' | ||
| ? menu.primaryLabel | ||
| : typeof (menu.primaryLabel as React.ReactElement).props?.text === 'string' | ||
| ? (menu.primaryLabel as React.ReactElement).props?.text | ||
| : ''; | ||
| return ( | ||
| !search || | ||
| match(menu.label, search) || | ||
| match(menu.primaryLabel, search) || | ||
| menu.label.includes(search) || | ||
| menu.primaryLabel.includes(search), | ||
| ); | ||
| match(label, search) || | ||
| match(primaryLabel, search) || | ||
| label.includes(search) || | ||
| primaryLabel.includes(search) | ||
| ); | ||
| }); | ||
| const staredMenus = menus.filter((item) => item.stared); | ||
@@ -68,0 +81,0 @@ const handleMenuStar = (key, v, e) => { |
47609
1.02%927
1.42%