UNPKG

tdesign-react

Version:
38 lines (34 loc) 1.26 kB
/** * tdesign v1.16.2 * (c) 2025 tdesign * @license MIT */ import { _ as _toConsumableArray } from '../_chunks/dep-a3a3e527.js'; import { useEffect } from 'react'; import '../_chunks/dep-74a10cfb.js'; var dialogSet = /* @__PURE__ */new Set(); var useDialogEsc = function useDialogEsc(visible, dialog) { useEffect(function () { if (visible) { if (dialog !== null && dialog !== void 0 && dialog.current) { var _dialog$current; dialogSet.add(dialog); dialog === null || dialog === void 0 || (_dialog$current = dialog.current) === null || _dialog$current === void 0 || _dialog$current.focus(); } } else if (dialogSet.has(dialog)) { var _dialogList; dialogSet["delete"](dialog); var dialogList = _toConsumableArray(dialogSet); (_dialogList = dialogList[dialogList.length - 1]) === null || _dialogList === void 0 || (_dialogList = _dialogList.current) === null || _dialogList === void 0 || _dialogList.focus(); } return function () { dialogSet.forEach(function (item) { if (item.current === null) { dialogSet["delete"](item); } }); }; }, [visible, dialog]); }; export { useDialogEsc as default }; //# sourceMappingURL=useDialogEsc.js.map