"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.E2EButtonTest = 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 react_native_3 = require("@fluentui/react-native");
var stack_1 = require("@fluentui-react-native/stack");
var consts_1 = require("../../../../E2E/src/ButtonLegacy/consts");
var styles_1 = require("../Common/styles");
var TestProps_1 = require("../Common/TestProps");
var E2EButtonTest = function () {
    var _a = React.useState(false), buttonPressed = _a[0], setButtonPressed = _a[1];
    var _b = React.useState(''), keyDetected = _b[0], setKeyDetected = _b[1];
    var onClick = React.useCallback(function () {
        setButtonPressed(!buttonPressed);
        setKeyDetected('');
    }, [buttonPressed]);
    var keyPressProps = {
        keyDownEvents: [{ key: 'a' }],
        onKeyDown: function (args) {
            if (args.nativeEvent.key === 'a') {
                setKeyDetected('a (down)');
                args.stopPropagation();
            }
        },
        keyUpEvents: [{ key: 'b' }],
        onKeyUp: function (args) {
            if (args.nativeEvent.key === 'b') {
                setKeyDetected('b (up)');
                args.stopPropagation();
            }
        },
    };
    return (React.createElement(react_native_1.View, null,
        React.createElement(stack_1.Stack, { style: styles_1.stackStyle },
            React.createElement(react_native_3.ButtonV1, tslib_1.__assign({ onClick: onClick, accessibilityLabel: consts_1.BUTTON_ACCESSIBILITY_LABEL }, (0, TestProps_1.testProps)(consts_1.BUTTON_TEST_COMPONENT)), "This is a button for E2E testing"),
            React.createElement(react_native_3.ButtonV1, tslib_1.__assign({ onClick: onClick, accessibilityRole: "menuitem" }, (0, TestProps_1.testProps)(consts_1.BUTTON_NO_A11Y_LABEL_COMPONENT)), consts_1.BUTTON_TEST_COMPONENT_LABEL),
            React.createElement(react_native_3.ButtonV1, tslib_1.__assign({ onClick: onClick, accessibilityLabel: consts_1.BUTTON_PRESS_TEST_COMPONENT_LABEL }, keyPressProps, (0, TestProps_1.testProps)(consts_1.BUTTON_PRESS_TEST_COMPONENT)), "Press \"a\" or \"b\" after focusing this button"),
            React.createElement(react_native_3.ButtonV1, tslib_1.__assign({ onClick: onClick, accessibilityLabel: consts_1.BUTTON_FOCUSABLE_TEST_COMPONENT_LABEL, focusable: false }, (0, TestProps_1.testProps)(consts_1.BUTTON_FOCUSABLE_TEST_COMPONENT)), "This button isn't focusable (but isn't disabled or indeterminate either)"),
            buttonPressed ? (React.createElement(react_native_2.Text
            /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
            , tslib_1.__assign({}, (0, TestProps_1.testProps)(consts_1.BUTTON_ON_PRESS)), "Button Pressed")) : null,
            keyDetected ? (React.createElement(react_native_2.Text /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */, tslib_1.__assign({}, (0, TestProps_1.testProps)(consts_1.BUTTON_ON_KEY)),
                "Button Key Press detected: ",
                keyDetected)) : null)));
};
exports.E2EButtonTest = E2EButtonTest;
//# sourceMappingURL=E2EButtonTest.js.map