import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDecorator"; import Spottable from "@enact/spotlight/Spottable"; import Spotlight from "@enact/spotlight"; import Alert from "@enact/sandstone/Alert"; import { $L } from "../../utils/helperMethods"; import React, { useCallback, useEffect } from "react"; import TButton from "../TButton/TButton"; import css from "../TPopUp/TPopUp.module.less"; import classNames from "classnames"; const Container = SpotlightContainerDecorator( { enterTo: "default-element", preserveId: true }, Spottable("div") ); const SpottableComponent = Spottable("li"); const KINDS = ["textPopup", "termsPopup", "introTermsPopup", "optionPopup"]; export default function TPopUp({ kind, children, onExit, onClose, hasButton, hasText, className, button1Text, button2Text, open, title, text, options, useOptionImg, selectedOptionIdx, setSelectedOptionIdx, ...rest }) { useEffect(() => { if (KINDS.indexOf(kind) < 0) { console.error("TPopUp kind error"); } }, [kind]); useEffect(() => { Spotlight.focus("tPopupBtn1"); Spotlight.focus("tPopupBtn2"); // TODO // if (options) Spotlight.focus(`option_${selectedOptionIdx}`) }, []); const _onClose = useCallback( (e) => { if (onClose) { onClose(e); } }, [onClose] ); const handleOptionClick = useCallback((index) => { setSelectedOptionIdx(index); _onClose(); }, []); return ( {hasText && (
{title &&
{title}
} {text &&
{text}
}
)} {options && ( )} {children} {hasButton && (
{button1Text && ( {button1Text} )} {button2Text && ( {button2Text} )}
)}
); }