import * as React from 'react';
import { DefaultButton } from 'office-ui-fabric-react/lib/Button';
import { Panel } from 'office-ui-fabric-react/lib/Panel';
import { useConstCallback } from '@uifabric/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 = React.useState(false), isOpen = _a[0], setIsOpen = _a[1];
    var openPanel = useConstCallback(function () { return setIsOpen(true); });
    var dismissPanel = useConstCallback(function () { return setIsOpen(false); });
    var onDismiss = useConstCallback(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.');
        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();
    });
    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