"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LinkV1Test = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const react_native_1 = require("react-native");
const react_native_2 = require("react-native");
const react_native_3 = require("@fluentui/react-native");
const e2e_testing_1 = require("@fluentui-react-native/e2e-testing");
const stack_1 = require("@fluentui-react-native/stack");
const E2ELinkV1Test_1 = require("./E2ELinkV1Test");
const InlineLinksTest_1 = require("./InlineLinksTest");
const styles_1 = require("../Common/styles");
const Test_1 = require("../Test");
const DefaultLinks = () => {
    const doPress = React.useCallback(() => react_native_1.Alert.alert('Alert.', 'You have been alerted.'), []);
    const doAllyTap = React.useCallback(() => react_native_1.Alert.alert('Alert.', 'You have invoked onAllyTap.'), []);
    return (React.createElement(stack_1.Stack, { style: styles_1.stackStyle },
        React.createElement(react_native_3.LinkV1, { tooltip: 'https://www.bing.com/', url: "https://www.bing.com/" }, "Click to navigate."),
        React.createElement(react_native_3.LinkV1, { onPress: doPress, onAccessibilityTap: doAllyTap }, "Click to alert."),
        React.createElement(react_native_3.LinkV1, { disabled: true }, "Disabled Link")));
};
const SubtleLinks = () => {
    const doPress = React.useCallback(() => react_native_1.Alert.alert('Alert.', 'You have been alerted.'), []);
    const doAllyTap = React.useCallback(() => react_native_1.Alert.alert('Alert.', 'You have invoked onAllyTap.'), []);
    const supportsInlineLink = react_native_2.Platform.OS !== 'win32';
    return (React.createElement(stack_1.Stack, { style: styles_1.stackStyle },
        React.createElement(react_native_3.LinkV1, { appearance: "subtle", url: "https://www.bing.com/" }, "Click to navigate."),
        supportsInlineLink && (React.createElement(react_native_1.Text, null,
            "This is inline Link.",
            ' ',
            React.createElement(react_native_3.LinkV1, { appearance: "subtle", inline: true, onPress: doPress, onAccessibilityTap: doAllyTap }, "Click to alert."))),
        React.createElement(react_native_3.LinkV1, { appearance: "subtle", onPress: doPress, disabled: true }, "Disabled Link")));
};
const styles = react_native_1.StyleSheet.create({
    tokensRow: {
        flexDirection: 'row',
        marginBottom: 10,
    },
    tokensColumn: {
        flexDirection: 'column',
        margin: 10,
    },
});
const BlueHeaderBold = react_native_3.LinkV1.customize({ variant: 'headerStandard', fontWeight: '700', color: '#0229c4', textAlign: 'right' });
const CustomLinks = () => {
    const [linkColor, setLinkColor] = React.useState('blue');
    const [linkFont, setLinkFont] = React.useState('Ariel');
    const [linkFontSize, setLinkFontSize] = React.useState(12);
    const [linkText, setLinkText] = React.useState('Click to Navigate');
    const [linkUrl, setLinkUrl] = React.useState('https://www.bing.com/');
    const CustomLink = React.useMemo(() => {
        const tokens = {
            color: linkColor,
            fontFamily: linkFont,
            fontSize: linkFontSize,
        };
        return react_native_3.LinkV1.customize(tokens);
    }, [linkColor, linkFont, linkFontSize]);
    return (React.createElement(react_native_1.View, { style: styles.tokensColumn },
        React.createElement(react_native_1.View, { style: styles.tokensRow },
            React.createElement(react_native_1.View, null,
                React.createElement(react_native_1.Text, null, "Text Tokens"),
                React.createElement(react_native_1.TextInput, { accessibilityLabel: "Link color", style: styles_1.commonTestStyles.textBox, placeholder: "Link color", blurOnSubmit: true, onSubmitEditing: (e) => {
                        setLinkColor(e.nativeEvent.text);
                    } }),
                React.createElement(react_native_1.TextInput, { accessibilityLabel: "Link font", style: styles_1.commonTestStyles.textBox, placeholder: "Link font", blurOnSubmit: true, onSubmitEditing: (e) => {
                        setLinkFont(e.nativeEvent.text);
                    } }),
                React.createElement(react_native_1.TextInput, { accessibilityLabel: "Link font size", style: styles_1.commonTestStyles.textBox, placeholder: "Link font size", blurOnSubmit: true, onSubmitEditing: (e) => {
                        setLinkFontSize(parseInt(e.nativeEvent.text));
                    } })),
            React.createElement(react_native_1.View, null,
                React.createElement(react_native_1.Text, null, "Content and URL customize"),
                React.createElement(react_native_1.TextInput, { accessibilityLabel: "Link text", style: styles_1.commonTestStyles.textBox, placeholder: "Link text", blurOnSubmit: true, onSubmitEditing: (e) => {
                        setLinkText(e.nativeEvent.text);
                    } }),
                React.createElement(react_native_1.TextInput, { accessibilityLabel: "Link Url", style: styles_1.commonTestStyles.textBox, placeholder: "Link URL", blurOnSubmit: true, onSubmitEditing: (e) => {
                        setLinkUrl(e.nativeEvent.text);
                    } }))),
        React.createElement(CustomLink, { align: "end", url: linkUrl }, linkText),
        React.createElement(BlueHeaderBold, null, "BlueHeaderBold")));
};
const linkSections = [
    {
        name: 'Default Links',
        testID: e2e_testing_1.LINKV1_TESTPAGE,
        component: DefaultLinks,
    },
    {
        name: 'Inline Links',
        component: InlineLinksTest_1.InlineLinks,
    },
    react_native_2.Platform.select({
        // As per design discussion, there is no use case for subtle link on Android, no tokens available for the same.
        android: null,
        default: {
            name: 'Subtle Links',
            component: SubtleLinks,
        },
    }),
    react_native_2.Platform.select({
        android: null,
        default: {
            name: 'Custom Link',
            component: CustomLinks,
        },
    }),
];
const e2eSections = [
    {
        name: 'Link E2E Test',
        component: E2ELinkV1Test_1.E2ELinkV1Test,
    },
];
const LinkV1Test = () => {
    const status = {
        win32Status: 'Production',
        uwpStatus: 'Backlog',
        iosStatus: 'Production',
        macosStatus: 'Production',
        androidStatus: 'Production',
    };
    const description = 'With a Link, users can navigate to another page, window, or Help topic; display a definition; initiate a command; or choose an option. A Link indicates that it can be clicked, typically by being displayed using the visited or unvisited link system colors. Traditionally, Links are underlined as well, but that approach is often unnecessary and falling out of favor to reduce visual clutter.\n\nA Link is the lightest weight clickable control, and is often used to reduce the visual complexity of a design.';
    return React.createElement(Test_1.Test, { name: "LinkV1 Test", description: description, sections: linkSections, status: status, e2eSections: e2eSections });
};
exports.LinkV1Test = LinkV1Test;
//# sourceMappingURL=LinkV1Test.js.map