"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.E2EContextualMenuTest = void 0;
var tslib_1 = require("tslib");
/* eslint-disable @typescript-eslint/no-var-requires */
var React = tslib_1.__importStar(require("react"));
var react_native_1 = require("react-native");
var react_native_2 = require("@fluentui/react-native");
var consts_1 = require("../../../../E2E/src/ContextualMenu/consts");
var TestProps_1 = require("../Common/TestProps");
var E2EContextualMenuTest = function () {
    var stdBtnRef = React.useRef(null);
    var _a = React.useState(false), showContextualMenu = _a[0], setShowContextualMenu = _a[1];
    var _b = React.useState(false), isContextualMenuVisible = _b[0], setIsContextualMenuVisible = _b[1];
    var _c = React.useState(null), lastMenuItemClicked = _c[0], setLastMenuItemClicked = _c[1];
    var _d = React.useState(false), isBeakVisible = _d[0], setIsBeakVisible = _d[1];
    var onIsBeakVisibleChange = React.useCallback(function (value) { return setIsBeakVisible(value); }, []);
    var _e = React.useState(true), focusOnMount = _e[0], setShouldFocusOnMount = _e[1];
    var toggleFocusOnMount = React.useCallback(function (value) { return setShouldFocusOnMount(value); }, [setShouldFocusOnMount]);
    var _f = React.useState(false), focusOnContainer = _f[0], setShouldFocusOnContainer = _f[1];
    var toggleFocusOnContainer = React.useCallback(function (value) { return setShouldFocusOnContainer(value); }, [setShouldFocusOnContainer]);
    var toggleShowContextualMenu = React.useCallback(function () {
        setShowContextualMenu(!showContextualMenu);
        setIsContextualMenuVisible(false);
    }, [showContextualMenu, setShowContextualMenu, setIsContextualMenuVisible]);
    var onShowContextualMenu = React.useCallback(function () {
        setIsContextualMenuVisible(true);
    }, [setIsContextualMenuVisible]);
    var onDismissContextualMenu = React.useCallback(function () {
        setShowContextualMenu(false);
        setIsContextualMenuVisible(false);
    }, [setShowContextualMenu]);
    var onItemClick = React.useCallback(function (key) {
        setLastMenuItemClicked(key);
    }, [setLastMenuItemClicked]);
    return (React.createElement(react_native_1.View, null,
        React.createElement(react_native_1.View, { style: { flexDirection: 'row', paddingVertical: 5 } },
            React.createElement(react_native_1.View, { style: { flexDirection: 'column', paddingHorizontal: 5 } },
                React.createElement(react_native_1.View, { style: { flexDirection: 'row' } },
                    React.createElement(react_native_1.Text, null, "Should Focus on Mount"),
                    React.createElement(react_native_1.Switch, { value: focusOnMount, onValueChange: toggleFocusOnMount })),
                React.createElement(react_native_1.View, { style: { flexDirection: 'row' } },
                    React.createElement(react_native_1.Text, null, "Should Focus on Container"),
                    React.createElement(react_native_1.Switch, { value: focusOnContainer, onValueChange: toggleFocusOnContainer })),
                React.createElement(react_native_1.View, { style: { flexDirection: 'row' } },
                    React.createElement(react_native_1.Text, null, "Beak Visible"),
                    React.createElement(react_native_1.Switch, { value: isBeakVisible, onValueChange: onIsBeakVisibleChange }))),
            React.createElement(react_native_2.Separator, { vertical: true }),
            React.createElement(react_native_1.View, { style: { flexDirection: 'column', paddingHorizontal: 5 } },
                React.createElement(react_native_1.Text, null,
                    React.createElement(react_native_1.Text, null, "Menu Visibility: "),
                    isContextualMenuVisible ? React.createElement(react_native_1.Text, { style: { color: 'green' } }, "Visible") : React.createElement(react_native_1.Text, { style: { color: 'red' } }, "Not Visible")),
                React.createElement(react_native_1.Text, null,
                    React.createElement(react_native_1.Text, null, "Last Menu Item Clicked: "),
                    lastMenuItemClicked > 0 ? (React.createElement(react_native_1.Text, { style: { color: 'blue' } }, lastMenuItemClicked)) : (React.createElement(react_native_1.Text, { style: { color: 'blue' } }, "none"))),
                React.createElement(react_native_2.ButtonV1, tslib_1.__assign({ onClick: toggleShowContextualMenu, componentRef: stdBtnRef }, (0, TestProps_1.testProps)(consts_1.CONTEXTUALMENU_TEST_COMPONENT)), "Press for ContextualMenu"))),
        showContextualMenu && (React.createElement(react_native_2.ContextualMenu, { target: stdBtnRef, onDismiss: onDismissContextualMenu, onShow: onShowContextualMenu, onItemClick: onItemClick, setShowMenu: toggleShowContextualMenu, shouldFocusOnMount: focusOnMount, shouldFocusOnContainer: focusOnContainer, isBeakVisible: isBeakVisible },
            React.createElement(react_native_2.ContextualMenuItem, tslib_1.__assign({ text: "MenuItem 1", itemKey: "1" }, (0, TestProps_1.testProps)(consts_1.CONTEXTUALMENUITEM_TEST_COMPONENT))),
            React.createElement(react_native_2.ContextualMenuItem, { text: "MenuItem 2", itemKey: "2" }),
            React.createElement(react_native_2.ContextualMenuItem, { text: "Disabled Menu Item", itemKey: "3", disabled: true }),
            React.createElement(react_native_2.ContextualMenuItem, { text: "MenuItem 4", itemKey: "4" }),
            React.createElement(react_native_2.ContextualMenuItem, { text: "MenuItem 5", itemKey: "5" })))));
};
exports.E2EContextualMenuTest = E2EContextualMenuTest;
//# sourceMappingURL=E2EContextualMenuTest.js.map