Files
NapCatQQ/.pnpm-store/v3/files/dc/d2fa0468d5c9fa72647cf9da4ef46cd16b2820dd32cb1cd2b9687b85bfb6150ec8706674f3d395caa72a39379ac50890957faef25f67b55f82d646d48c4351
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

39 lines
1.4 KiB
Plaintext

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = useFocusWithin;
var _tslib = require("tslib");
var _react = require("react");
var _useEventListener = _interopRequireDefault(require("../useEventListener"));
function useFocusWithin(target, options) {
var _a = (0, _tslib.__read)((0, _react.useState)(false), 2),
isFocusWithin = _a[0],
setIsFocusWithin = _a[1];
var _b = options || {},
onFocus = _b.onFocus,
onBlur = _b.onBlur,
onChange = _b.onChange;
(0, _useEventListener["default"])('focusin', function (e) {
if (!isFocusWithin) {
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
onChange === null || onChange === void 0 ? void 0 : onChange(true);
setIsFocusWithin(true);
}
}, {
target: target
});
(0, _useEventListener["default"])('focusout', function (e) {
var _a, _b;
if (isFocusWithin && !((_b = (_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.contains) === null || _b === void 0 ? void 0 : _b.call(_a, e.relatedTarget))) {
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
onChange === null || onChange === void 0 ? void 0 : onChange(false);
setIsFocusWithin(false);
}
}, {
target: target
});
return isFocusWithin;
}