import * as React from 'react';
import { DefaultButton } from '@fluentui/react/lib/Button';
import { Panel } from '@fluentui/react/lib/Panel';
import { useBoolean } from '@fluentui/react-hooks';
var explanation = 'This example demonstrates detecting whether a panel was dismissed using the close button ' +
    'or using "light dismiss" (a click outside the panel area).';
export var PanelHandleDismissTargetExample = function () {
    var _a = useBoolean(false), isOpen = _a[0], _b = _a[1], openPanel = _b.setTrue, dismissPanel = _b.setFalse;
    var onDismiss = React.useCallback(function (ev) {
        if (!ev) {
            console.log('Panel dismissed.');
            return;
        }
        // Demonstrates how to do different things depending on how which element dismissed the panel
        console.log('Close button clicked or light dismissed.');
        // eslint-disable-next-line deprecation/deprecation
        var srcElement = ev.nativeEvent.srcElement;
        if (srcElement && srcElement.className.indexOf('ms-Button-icon') !== -1) {
            console.log('Close button clicked.');
        }
        if (srcElement && srcElement.className.indexOf('ms-Overlay') !== -1) {
            console.log('Light dismissed.');
        }
        dismissPanel();
    }, [dismissPanel]);
    return (React.createElement("div", null,
        explanation,
        React.createElement("br", null),
        React.createElement("br", null),
        React.createElement(DefaultButton, { text: "Open panel", onClick: openPanel }),
        React.createElement(Panel, { isOpen: isOpen, onDismiss: onDismiss, headerText: "Panel - Handle close button clicks or light dismissal", closeButtonAriaLabel: "Close", isLightDismiss: true },
            React.createElement("div", null,
                React.createElement("p", null, explanation),
                React.createElement("p", null, "(Check the debug console for results after dismissing the panel.)")))));
};
//# sourceMappingURL=Panel.HandleDismissTarget.Example.js.map