import * as React from 'react';
import { View } from 'react-native';
import { ButtonV1 as Button } from '@fluentui-react-native/button';
import { MENUITEM_ACCESSIBILITY_LABEL, MENUITEM_NO_A11Y_LABEL_COMPONENT, MENUTRIGGER_TEST_COMPONENT, MENUITEM_TEST_LABEL, MENU_ON_CLOSE, MENU_ON_OPEN, MENUITEM_TEST_COMPONENT, MENUPOPOVER_TEST_COMPONENT, MENU_CALLBACK_RESET_BUTTON, MENUITEM_FOURTH_COMPONENT, MENUITEM_DISABLED_COMPONENT, MENUITEM_CALLBACK_LABEL, } from '@fluentui-react-native/e2e-testing';
import { Menu, MenuDivider, MenuGroup, MenuItem, MenuList, MenuPopover, MenuTrigger } from '@fluentui-react-native/menu';
import { Stack } from '@fluentui-react-native/stack';
import { TextV1 as Text } from '@fluentui-react-native/text';
import { stackStyle } from '../Common/styles';
import { testProps } from '../Common/TestProps';
export const E2EMenuTest = () => {
    const [menuOpened, setMenuOpened] = React.useState(false);
    const [numOnClickCalls, setNumOnClickCalls] = React.useState(0);
    const onOpenChange = React.useCallback((_e, isOpen) => {
        setMenuOpened(isOpen);
    }, [setMenuOpened]);
    const onItemClick = () => {
        setNumOnClickCalls((n) => n + 1);
    };
    const onResetClick = () => {
        setNumOnClickCalls(0);
    };
    return (React.createElement(Stack, { style: stackStyle },
        React.createElement(View, { style: { flexDirection: 'row' } },
            menuOpened ? (React.createElement(Text /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */, { ...testProps(MENU_ON_OPEN) }, "Menu opened")) : (React.createElement(Text /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */, { ...testProps(MENU_ON_CLOSE) }, "Menu closed")),
            React.createElement(Button, { onClick: onResetClick, ...testProps(MENU_CALLBACK_RESET_BUTTON) }, "Reset Item Callback"),
            React.createElement(Menu, { open: menuOpened, onOpenChange: onOpenChange },
                React.createElement(MenuTrigger, null,
                    React.createElement(Button
                    /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
                    , { ...testProps(MENUTRIGGER_TEST_COMPONENT) }, "Test")),
                React.createElement(MenuPopover
                /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
                , { ...testProps(MENUPOPOVER_TEST_COMPONENT) },
                    React.createElement(MenuList, null,
                        React.createElement(MenuGroup, null,
                            React.createElement(MenuItem, { onClick: onItemClick, accessibilityLabel: MENUITEM_ACCESSIBILITY_LABEL, persistOnClick: true, ...testProps(MENUITEM_TEST_COMPONENT) }, "A plain MenuItem"),
                            React.createElement(MenuItem, { onClick: onItemClick, ...testProps(MENUITEM_DISABLED_COMPONENT), disabled: true, persistOnClick: true }, "A second disabled plain MenuItem")),
                        React.createElement(MenuDivider, null),
                        React.createElement(MenuGroup, null,
                            React.createElement(MenuItem
                            /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
                            , { ...testProps(MENUITEM_NO_A11Y_LABEL_COMPONENT) }, MENUITEM_TEST_LABEL),
                            React.createElement(MenuItem
                            /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
                            , { ...testProps(MENUITEM_FOURTH_COMPONENT) }, "A fourth plain MenuItem")))))),
        React.createElement(Text, { style: { marginVertical: 4 }, ...testProps(MENUITEM_CALLBACK_LABEL) }, `onClick fired ${numOnClickCalls} times`)));
};
//# sourceMappingURL=E2EMenuTest.js.map