"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.E2EMenuTest = void 0;
var tslib_1 = require("tslib");
var React = tslib_1.__importStar(require("react"));
var react_native_1 = require("react-native");
var button_1 = require("@fluentui-react-native/button");
var menu_1 = require("@fluentui-react-native/menu");
var stack_1 = require("@fluentui-react-native/stack");
var text_1 = require("@fluentui-react-native/text");
var consts_1 = require("../../../../E2E/src/Menu/consts");
var styles_1 = require("../Common/styles");
var TestProps_1 = require("../Common/TestProps");
var E2EMenuTest = function () {
    var _a = React.useState(false), menuOpened = _a[0], setMenuOpened = _a[1];
    var _b = React.useState(0), numOnClickCalls = _b[0], setNumOnClickCalls = _b[1];
    var onOpenChange = React.useCallback(function (_e, isOpen) {
        setMenuOpened(isOpen);
    }, [setMenuOpened]);
    var onItemClick = function () {
        setNumOnClickCalls(function (n) { return n + 1; });
    };
    var onResetClick = function () {
        setNumOnClickCalls(0);
    };
    return (React.createElement(stack_1.Stack, { style: styles_1.stackStyle },
        React.createElement(react_native_1.View, { style: { flexDirection: 'row' } },
            menuOpened ? (React.createElement(text_1.TextV1 /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */, tslib_1.__assign({}, (0, TestProps_1.testProps)(consts_1.MENU_ON_OPEN)), "Menu opened")) : (React.createElement(text_1.TextV1 /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */, tslib_1.__assign({}, (0, TestProps_1.testProps)(consts_1.MENU_ON_CLOSE)), "Menu closed")),
            React.createElement(button_1.ButtonV1, tslib_1.__assign({ onClick: onResetClick }, (0, TestProps_1.testProps)(consts_1.MENU_CALLBACK_RESET_BUTTON)), "Reset Item Callback"),
            React.createElement(menu_1.Menu, { open: menuOpened, onOpenChange: onOpenChange },
                React.createElement(menu_1.MenuTrigger, null,
                    React.createElement(button_1.ButtonV1
                    /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
                    , tslib_1.__assign({}, (0, TestProps_1.testProps)(consts_1.MENUTRIGGER_TEST_COMPONENT)), "Test")),
                React.createElement(menu_1.MenuPopover
                /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
                , tslib_1.__assign({}, (0, TestProps_1.testProps)(consts_1.MENUPOPOVER_TEST_COMPONENT)),
                    React.createElement(menu_1.MenuList, null,
                        React.createElement(menu_1.MenuGroup, null,
                            React.createElement(menu_1.MenuItem, tslib_1.__assign({ onClick: onItemClick, accessibilityLabel: consts_1.MENUITEM_ACCESSIBILITY_LABEL, persistOnClick: true }, (0, TestProps_1.testProps)(consts_1.MENUITEM_TEST_COMPONENT)), "A plain MenuItem"),
                            React.createElement(menu_1.MenuItem, tslib_1.__assign({ onClick: onItemClick }, (0, TestProps_1.testProps)(consts_1.MENUITEM_DISABLED_COMPONENT), { disabled: true, persistOnClick: true }), "A second disabled plain MenuItem")),
                        React.createElement(menu_1.MenuDivider, null),
                        React.createElement(menu_1.MenuGroup, null,
                            React.createElement(menu_1.MenuItem
                            /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
                            , tslib_1.__assign({}, (0, TestProps_1.testProps)(consts_1.MENUITEM_NO_A11Y_LABEL_COMPONENT)), consts_1.MENUITEM_TEST_LABEL),
                            React.createElement(menu_1.MenuItem
                            /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
                            , tslib_1.__assign({}, (0, TestProps_1.testProps)(consts_1.MENUITEM_FOURTH_COMPONENT)), "A fourth plain MenuItem")))))),
        React.createElement(text_1.TextV1, tslib_1.__assign({ style: { marginVertical: 4 } }, (0, TestProps_1.testProps)(consts_1.MENUITEM_CALLBACK_LABEL)), "onClick fired ".concat(numOnClickCalls, " times"))));
};
exports.E2EMenuTest = E2EMenuTest;
//# sourceMappingURL=E2EMenuTest.js.map