import React, { useCallback, useMemo, } from 'react'; import classNames from 'classnames'; import { Marquee } from '@enact/sandstone/Marquee'; import SpotlightContainerDecorator from '@enact/spotlight/SpotlightContainerDecorator'; import Spottable from '@enact/spotlight/Spottable'; import defaultLogoImg from '../../../../assets/images/ic-tab-partners-default@3x.png'; import { $L } from '../../../utils/helperMethods'; import css from './THeaderCustom.module.less'; const Container = SpotlightContainerDecorator( { enterTo: "last-focused" }, "div" ); const SpottableComponent = Spottable("button"); export default function THeaderCustom({ prdtId, title, type, themeTitle, selectedIndex, className, onBackButton, onSpotlightUp, onSpotlightLeft, onBackButtonFocus, marqueeDisabled = true, onClick, ariaLabel, children, kind, logoImg, patnrId, themeData, ...rest }) { const convertedTitle = useMemo(() => { if (title && typeof title === "string") { const cleanedTitle = title.replace(/(\r\n|\n)/g, ""); return $L(marqueeDisabled ? title : cleanedTitle); } else if(type === "theme") { return themeData?.productInfos[selectedIndex].prdtNm; } return ""; }, [marqueeDisabled, title, selectedIndex, themeData, type]); const _onClick = useCallback( (e) => { if (onClick) { onClick(e); } }, [onClick] ); const _onSpotlightUp = (e) => { if (onSpotlightUp) { onSpotlightUp(e); } }; const _onSpotlightLeft = (e) => { if (onSpotlightLeft) { onSpotlightLeft(e); } }; const _onBackButtonFocus = useCallback(() => { if(onBackButtonFocus){ onBackButtonFocus(); } },[onBackButtonFocus]) return ( {onBackButton && ( )} {kind ? ( "" ) : (
)} {type === "theme" && themeTitle && ( )} {(prdtId && patnrId !== "21") && ID : {prdtId}} {convertedTitle && ( )} {children} ); }