UNPKG

@yandex/ui

Version:

Yandex UI components

25 lines (24 loc) 1.32 kB
import { __assign, __read, __rest } from "tslib"; import React, { useState } from 'react'; import { withOutsideClick } from '@yandex-lego/components/withOutsideClick'; import { Button } from '@yandex-lego/components/Button/Button.bundle/desktop'; var ComponentWithOutsideClick = withOutsideClick(function (_a) { var visible = _a.visible, targetRef = _a.targetRef, props = __rest(_a, ["visible", "targetRef"]); return (React.createElement(React.Fragment, null, visible && (React.createElement("div", __assign({ style: { backgroundColor: 'lightgray', borderRadius: '4px', lineHeight: '70px', width: '70px', textAlign: 'center', }, ref: targetRef }, props), "Press Esc")))); }); export var Esc = function () { var _a = __read(useState(false), 2), visible = _a[0], setVisible = _a[1]; return (React.createElement(React.Fragment, null, React.createElement(Button, { view: "action", size: "m", onClick: function () { return setVisible(function (prev) { return !prev; }); } }, "Click"), " ", React.createElement("br", null), " ", React.createElement("br", null), React.createElement(ComponentWithOutsideClick, { visible: visible, onEscapeKeyDown: function () { return setVisible(false); } }))); };