element.js 923 B

1234567891011121314151617181920212223242526
  1. import { View } from 'app/design/view'
  2. import { components } from 'app/components/registry';
  3. import { useMemo } from "react";
  4. export default function MenuItemElement(oProps) {
  5. const type = oProps?.data?.type;
  6. const bShowVertical = oProps?.params?.showVertical === true;
  7. const Element = useMemo(() => type ? components['molecule'][String(type)] : null, [type]);
  8. if (!type) return;
  9. if (!Element) return;
  10. oProps.data.params = {
  11. ...oProps.data.params,
  12. ...(oProps.params || {})
  13. };
  14. const sClassName = `menu-item ${(oProps?.params?.classNameItem || 'flex')} ${bShowVertical ? 'flex-col w-full' : 'flex-auto flex-row'}`;
  15. return <Element mode={oProps.mode} key={oProps.id || oProps.name} {...oProps.data} />
  16. return (
  17. <View className={sClassName}>
  18. <Element mode={oProps.mode} key={oProps.id || oProps.name} {...oProps.data} />
  19. </View>
  20. );
  21. }