import * as React from 'react';
import { Text, View, Switch } from 'react-native';
import { ButtonV1 as Button, ContextualMenu, ContextualMenuItem, Separator } from '@fluentui/react-native';
import { CONTEXTUALMENUITEM_TEST_COMPONENT, CONTEXTUALMENU_TEST_COMPONENT } from '@fluentui-react-native/e2e-testing';
import { testProps } from '../Common/TestProps';
export const E2EContextualMenuTest = () => {
    const stdBtnRef = React.useRef(null);
    const [showContextualMenu, setShowContextualMenu] = React.useState(false);
    const [isContextualMenuVisible, setIsContextualMenuVisible] = React.useState(false);
    const [lastMenuItemClicked, setLastMenuItemClicked] = React.useState(null);
    const [isBeakVisible, setIsBeakVisible] = React.useState(false);
    const onIsBeakVisibleChange = React.useCallback((value) => setIsBeakVisible(value), []);
    const [focusOnMount, setShouldFocusOnMount] = React.useState(true);
    const toggleFocusOnMount = React.useCallback((value) => setShouldFocusOnMount(value), [setShouldFocusOnMount]);
    const [focusOnContainer, setShouldFocusOnContainer] = React.useState(false);
    const toggleFocusOnContainer = React.useCallback((value) => setShouldFocusOnContainer(value), [setShouldFocusOnContainer]);
    const toggleShowContextualMenu = React.useCallback(() => {
        setShowContextualMenu(!showContextualMenu);
        setIsContextualMenuVisible(false);
    }, [showContextualMenu, setShowContextualMenu, setIsContextualMenuVisible]);
    const onShowContextualMenu = React.useCallback(() => {
        setIsContextualMenuVisible(true);
    }, [setIsContextualMenuVisible]);
    const onDismissContextualMenu = React.useCallback(() => {
        setShowContextualMenu(false);
        setIsContextualMenuVisible(false);
    }, [setShowContextualMenu]);
    const onItemClick = React.useCallback((key) => {
        setLastMenuItemClicked(key);
    }, [setLastMenuItemClicked]);
    return (React.createElement(View, null,
        React.createElement(View, { style: { flexDirection: 'row', paddingVertical: 5 } },
            React.createElement(View, { style: { flexDirection: 'column', paddingHorizontal: 5 } },
                React.createElement(View, { style: { flexDirection: 'row' } },
                    React.createElement(Text, null, "Should Focus on Mount"),
                    React.createElement(Switch, { value: focusOnMount, onValueChange: toggleFocusOnMount })),
                React.createElement(View, { style: { flexDirection: 'row' } },
                    React.createElement(Text, null, "Should Focus on Container"),
                    React.createElement(Switch, { value: focusOnContainer, onValueChange: toggleFocusOnContainer })),
                React.createElement(View, { style: { flexDirection: 'row' } },
                    React.createElement(Text, null, "Beak Visible"),
                    React.createElement(Switch, { value: isBeakVisible, onValueChange: onIsBeakVisibleChange }))),
            React.createElement(Separator, { vertical: true }),
            React.createElement(View, { style: { flexDirection: 'column', paddingHorizontal: 5 } },
                React.createElement(Text, null,
                    React.createElement(Text, null, "Menu Visibility: "),
                    isContextualMenuVisible ? React.createElement(Text, { style: { color: 'green' } }, "Visible") : React.createElement(Text, { style: { color: 'red' } }, "Not Visible")),
                React.createElement(Text, null,
                    React.createElement(Text, null, "Last Menu Item Clicked: "),
                    lastMenuItemClicked > 0 ? (React.createElement(Text, { style: { color: 'blue' } }, lastMenuItemClicked)) : (React.createElement(Text, { style: { color: 'blue' } }, "none"))),
                React.createElement(Button, { onClick: toggleShowContextualMenu, componentRef: stdBtnRef, ...testProps(CONTEXTUALMENU_TEST_COMPONENT) }, "Press for ContextualMenu"))),
        showContextualMenu && (React.createElement(ContextualMenu, { target: stdBtnRef, onDismiss: onDismissContextualMenu, onShow: onShowContextualMenu, onItemClick: onItemClick, setShowMenu: toggleShowContextualMenu, shouldFocusOnMount: focusOnMount, shouldFocusOnContainer: focusOnContainer, isBeakVisible: isBeakVisible },
            React.createElement(ContextualMenuItem, { text: "MenuItem 1", itemKey: "1", ...testProps(CONTEXTUALMENUITEM_TEST_COMPONENT) }),
            React.createElement(ContextualMenuItem, { text: "MenuItem 2", itemKey: "2" }),
            React.createElement(ContextualMenuItem, { text: "Disabled Menu Item", itemKey: "3", disabled: true }),
            React.createElement(ContextualMenuItem, { text: "MenuItem 4", itemKey: "4" }),
            React.createElement(ContextualMenuItem, { text: "MenuItem 5", itemKey: "5" })))));
};
//# sourceMappingURL=E2EContextualMenuTest.js.map