import { __spreadArray } from "tslib";
import * as React from 'react';
import { Text, View, Switch } from 'react-native';
import { Separator, MenuButton } from '@fluentui/react-native';
import { viewWrapperStyle, columnStyle, rowStyle, textColor } from './MenuButtonLegacyTestStyles';
import { menuItems, iconProps } from './testData';
import { testImage } from '../Common/iconExamples';
export var NestedMenuButton = function () {
    var _a = React.useState(null), lastMenuItemClicked = _a[0], setLastMenuItemClicked = _a[1];
    var _b = React.useState(true), focusOnMount = _b[0], setShouldFocusOnMount = _b[1];
    var toggleFocusOnMount = React.useCallback(function (value) { return setShouldFocusOnMount(value); }, [setShouldFocusOnMount]);
    var _c = React.useState(false), focusOnContainer = _c[0], setShouldFocusOnContainer = _c[1];
    var toggleFocusOnContainer = React.useCallback(function (value) { return setShouldFocusOnContainer(value); }, [setShouldFocusOnContainer]);
    var onItemClick = React.useCallback(function (key) {
        setLastMenuItemClicked(key);
    }, [setLastMenuItemClicked]);
    var _d = React.useState(false), showSubmenu = _d[0], setShowSubmenu = _d[1];
    var _e = React.useState(false), isSubmenuVisible = _e[0], setIsSubmenuVisible = _e[1];
    var _f = React.useState(null), lastSubmenuItemClicked = _f[0], setSubmenuLastItemClicked = _f[1];
    var toggleShowSubmenu = React.useCallback(function () {
        setShowSubmenu(!showSubmenu);
        setIsSubmenuVisible(!isSubmenuVisible);
    }, [showSubmenu, isSubmenuVisible, setShowSubmenu, setIsSubmenuVisible]);
    var onShowSubmenu = React.useCallback(function () {
        setIsSubmenuVisible(true);
    }, [setIsSubmenuVisible]);
    var onDismissSubmenu = React.useCallback(function () {
        setShowSubmenu(false);
    }, [setShowSubmenu]);
    var onSubmenuItemClick = React.useCallback(function (key) {
        setSubmenuLastItemClicked(key);
    }, [setSubmenuLastItemClicked]);
    var nestedMenuItems = __spreadArray(__spreadArray([], menuItems, true), [
        {
            hasSubmenu: true,
            itemKey: '4',
            text: 'SubmenuItem svg icon',
            componentRef: React.useRef(null),
            icon: iconProps,
            onHoverIn: toggleShowSubmenu,
            showSubmenu: showSubmenu,
            submenuProps: {
                onShow: onShowSubmenu,
                setShowMenu: toggleShowSubmenu,
                onDismiss: onDismissSubmenu,
                onItemClick: onSubmenuItemClick,
            },
            submenuItems: [
                {
                    icon: iconProps,
                    text: 'SubmenuItem svg icon',
                    itemKey: '1',
                },
                {
                    itemKey: '2',
                    text: 'SubmenuItem 2',
                    disabled: true,
                },
                {
                    itemKey: '3',
                    text: 'SubmenuItem 3',
                },
            ],
        },
        {
            itemKey: '5',
            text: 'Menu Item',
        },
        {
            hasSubmenu: true,
            itemKey: '6',
            text: 'SubmenuItem',
            componentRef: React.useRef(null),
            submenuProps: {
                onItemClick: onSubmenuItemClick,
            },
            submenuItems: [
                {
                    text: 'SubmenuItem 1',
                    itemKey: '1',
                },
                {
                    itemKey: '2',
                    text: 'SubmenuItem 2',
                },
                {
                    itemKey: '3',
                    text: 'SubmenuItem 3',
                },
            ],
        },
    ], false);
    var rasterImageProps = {
        rasterImageSource: {
            src: testImage,
        },
        width: 12,
        height: 12,
    };
    return (React.createElement(View, null,
        React.createElement(View, { style: viewWrapperStyle },
            React.createElement(View, { style: columnStyle },
                React.createElement(View, { style: rowStyle },
                    React.createElement(Text, null, "Should Focus on Mount"),
                    React.createElement(Switch, { value: focusOnMount, onValueChange: toggleFocusOnMount })),
                React.createElement(View, { style: rowStyle },
                    React.createElement(Text, null, "Should Focus on Container"),
                    React.createElement(Switch, { value: focusOnContainer, onValueChange: toggleFocusOnContainer }))),
            React.createElement(Separator, { vertical: true }),
            React.createElement(View, { style: columnStyle },
                React.createElement(Text, null,
                    React.createElement(Text, null, "Last Menu Item Clicked: "),
                    lastMenuItemClicked > 0 ? React.createElement(Text, { style: textColor }, lastMenuItemClicked) : React.createElement(Text, { style: textColor }, "none")),
                React.createElement(Text, null,
                    React.createElement(Text, null, "Last Submenu Item Clicked: "),
                    lastSubmenuItemClicked > 0 ? React.createElement(Text, { style: textColor }, lastSubmenuItemClicked) : React.createElement(Text, { style: textColor }, "none")),
                React.createElement(MenuButton, { startIcon: rasterImageProps, content: "Press for Nested MenuButton", menuItems: nestedMenuItems, onItemClick: onItemClick })))));
};
//# sourceMappingURL=NestedMenuButtonTest.js.map