import { __assign } from "tslib";
/* eslint-disable @typescript-eslint/no-var-requires */
import * as React from 'react';
import { View } from 'react-native';
import { Text } from '@fluentui/react-native';
import { ButtonV1 as Button } from '@fluentui/react-native';
import { Stack } from '@fluentui-react-native/stack';
import { BUTTON_TEST_COMPONENT, BUTTON_ON_PRESS, BUTTON_NO_A11Y_LABEL_COMPONENT, BUTTON_ACCESSIBILITY_LABEL, BUTTON_TEST_COMPONENT_LABEL, BUTTON_ON_KEY, BUTTON_PRESS_TEST_COMPONENT, BUTTON_PRESS_TEST_COMPONENT_LABEL, BUTTON_FOCUSABLE_TEST_COMPONENT, BUTTON_FOCUSABLE_TEST_COMPONENT_LABEL, } from '../../../../E2E/src/ButtonLegacy/consts';
import { stackStyle } from '../Common/styles';
import { testProps } from '../Common/TestProps';
export 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(View, null,
        React.createElement(Stack, { style: stackStyle },
            React.createElement(Button, __assign({ onClick: onClick, accessibilityLabel: BUTTON_ACCESSIBILITY_LABEL }, testProps(BUTTON_TEST_COMPONENT)), "This is a button for E2E testing"),
            React.createElement(Button, __assign({ onClick: onClick, accessibilityRole: "menuitem" }, testProps(BUTTON_NO_A11Y_LABEL_COMPONENT)), BUTTON_TEST_COMPONENT_LABEL),
            React.createElement(Button, __assign({ onClick: onClick, accessibilityLabel: BUTTON_PRESS_TEST_COMPONENT_LABEL }, keyPressProps, testProps(BUTTON_PRESS_TEST_COMPONENT)), "Press \"a\" or \"b\" after focusing this button"),
            React.createElement(Button, __assign({ onClick: onClick, accessibilityLabel: BUTTON_FOCUSABLE_TEST_COMPONENT_LABEL, focusable: false }, testProps(BUTTON_FOCUSABLE_TEST_COMPONENT)), "This button isn't focusable (but isn't disabled or indeterminate either)"),
            buttonPressed ? (React.createElement(Text
            /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
            , __assign({}, testProps(BUTTON_ON_PRESS)), "Button Pressed")) : null,
            keyDetected ? (React.createElement(Text /* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */, __assign({}, testProps(BUTTON_ON_KEY)),
                "Button Key Press detected: ",
                keyDetected)) : null)));
};
//# sourceMappingURL=E2EButtonTest.js.map