"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.E2EContextualMenuTest = void 0;
const React = __importStar(require("react"));
const react_native_1 = require("react-native");
const react_native_2 = require("@fluentui/react-native");
const e2e_testing_1 = require("@fluentui-react-native/e2e-testing");
const TestProps_1 = require("../Common/TestProps");
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(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, { onClick: toggleShowContextualMenu, componentRef: stdBtnRef, ...(0, TestProps_1.testProps)(e2e_testing_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, { text: "MenuItem 1", itemKey: "1", ...(0, TestProps_1.testProps)(e2e_testing_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