@lobehub/ui
Version:
Lobe UI is an open-source UI component library for building AIGC web apps
1 lines • 1.33 kB
Source Map (JSON)
{"version":3,"file":"utils.mjs","names":["Icon"],"sources":["../../src/Menu/utils.tsx"],"sourcesContent":["import type { ItemType as AntdItemType } from 'antd/es/menu/interface';\nimport { isValidElement } from 'react';\n\nimport Icon from '@/Icon';\n\nimport type { ItemType } from './type';\n\nexport const mapItems = (item: ItemType): AntdItemType => {\n switch (item?.type) {\n case 'divider': {\n return item;\n }\n case 'group': {\n const { children, ...rest } = item;\n return {\n children: children ? children?.map((i) => mapItems(i)) : undefined,\n ...rest,\n };\n }\n default: {\n const { children, icon, ...rest } = item as any;\n return {\n children: children ? children?.map((i: any) => mapItems(i)) : undefined,\n icon: icon ? isValidElement(icon) ? icon : <Icon icon={icon} size={'small'} /> : undefined,\n ...rest,\n };\n }\n }\n};\n"],"mappings":";;;;;AAOA,MAAa,YAAY,SAAiC;AACxD,SAAQ,MAAM,MAAd;EACE,KAAK,UACH,QAAO;EAET,KAAK,SAAS;GACZ,MAAM,EAAE,UAAU,GAAG,SAAS;AAC9B,UAAO;IACL,UAAU,WAAW,UAAU,KAAK,MAAM,SAAS,EAAE,CAAC,GAAG;IACzD,GAAG;IACJ;;EAEH,SAAS;GACP,MAAM,EAAE,UAAU,MAAM,GAAG,SAAS;AACpC,UAAO;IACL,UAAU,WAAW,UAAU,KAAK,MAAW,SAAS,EAAE,CAAC,GAAG;IAC9D,MAAM,OAAO,eAAe,KAAK,GAAG,OAAO,oBAACA;KAAW;KAAM,MAAM;MAAW,GAAG;IACjF,GAAG;IACJ"}