import { __spreadArray } from "tslib";
import React, { useState } from 'react';
import { TextInput, StyleSheet, View } from 'react-native';
import { ButtonV1 as Button } from '@fluentui/react-native';
import { Menu, MenuItem, MenuTrigger, MenuPopover, MenuList } from '@fluentui-react-native/menu';
import { Stack } from '@fluentui-react-native/stack';
import { stackStyle } from '../Common/styles';
import { commonTestStyles as commonStyles } from '../Common/styles';
var styles = StyleSheet.create({
    menuContainerRow: { flexDirection: 'row' },
    menuMargin: { marginRight: 20 },
});
export var MenuScrollView = function () {
    var _a = useState([
        React.createElement(MenuItem, { key: 1 }, "MenuItem 1"),
        React.createElement(MenuItem, { key: 2 }, "MenuItem 2"),
        React.createElement(MenuItem, { key: 3 }, "MenuItem 3"),
        React.createElement(MenuItem, { key: 4 }, "MenuItem 4"),
        React.createElement(MenuItem, { key: 5 }, "MenuItem 5"),
    ]), data = _a[0], setData = _a[1];
    var insertOnClick = React.useCallback(function () {
        data.push(React.createElement(MenuItem, { key: Math.random() }, "MenuItem"));
        var newList = __spreadArray([], data, true);
        setData(newList);
    }, [data]);
    var popOnClick = React.useCallback(function () {
        if (data.length > 0) {
            data.pop();
            var newList = __spreadArray([], data, true);
            setData(newList);
        }
    }, [data]);
    var _b = useState(800), maxHeight = _b[0], setMaxHeight = _b[1];
    var menuItems = [];
    for (var i = 0; i < 40; i++) {
        menuItems.push(React.createElement(MenuItem, { key: i },
            "MenuItem ",
            i));
    }
    return (React.createElement(Stack, { style: stackStyle },
        React.createElement(View, { style: styles.menuContainerRow },
            React.createElement(TextInput, { accessibilityLabel: "Max height for menu", style: [commonStyles.textBox, styles.menuMargin], placeholder: "Max height for menu", blurOnSubmit: true, onSubmitEditing: function (e) {
                    setMaxHeight(parseInt(e.nativeEvent.text));
                } }),
            React.createElement(Menu, null,
                React.createElement(MenuTrigger, null,
                    React.createElement(Button, null, "Custom height")),
                React.createElement(MenuPopover, { maxHeight: maxHeight },
                    React.createElement(MenuList, null, menuItems)))),
        React.createElement(View, { style: styles.menuContainerRow },
            React.createElement(Button, { appearance: "subtle", onClick: insertOnClick }, "Add new menu item"),
            React.createElement(Button, { appearance: "subtle", onClick: popOnClick }, "Remove last menu item"),
            React.createElement(Menu, null,
                React.createElement(MenuTrigger, null,
                    React.createElement(Button, null, "Mutable Menu: MaxHeight 250 ")),
                React.createElement(MenuPopover, { maxHeight: 250 },
                    React.createElement(MenuList, null, data)))),
        React.createElement(Menu, null,
            React.createElement(MenuTrigger, null,
                React.createElement(Button, null, "Height: 100 minWidth: 250")),
            React.createElement(MenuPopover, { maxHeight: 100, minWidth: 250 },
                React.createElement(MenuList, null,
                    React.createElement(MenuItem, null, "MenuItem 1"),
                    React.createElement(MenuItem, null, "MenuItem 2"),
                    React.createElement(MenuItem, null, "MenuItem 3"),
                    React.createElement(MenuItem, null, "MenuItem 4"),
                    React.createElement(MenuItem, null, "MenuItem 5"),
                    React.createElement(MenuItem, null, "MenuItem 6"))))));
};
//# sourceMappingURL=MenuScrollView.js.map