Files
NapCatQQ/.pnpm-store/v3/files/12/46206835f0219514e4b1dcffd803c1bd98aaef9977ce76a0233ce8dd624550cf23a54783212ab61c79f8e560c88594d6f86b9d7171aa2f5c4e4a4948fb60ab
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

117 lines
3.7 KiB
Plaintext

"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
useAriaButton: () => useAriaButton
});
module.exports = __toCommonJS(src_exports);
var import_shared_utils = require("@heroui/shared-utils");
var import_utils = require("@react-aria/utils");
var import_focus = require("@react-aria/focus");
var import_interactions = require("@react-aria/interactions");
function useAriaButton(props, ref) {
let {
elementType = "button",
isDisabled,
onPress,
onPressStart,
onPressEnd,
onPressChange,
preventFocusOnPress,
allowFocusWhenDisabled,
onClick: deprecatedOnClick,
href,
target,
rel,
type = "button",
allowTextSelectionOnPress
} = props;
let additionalProps;
if (elementType === "button") {
additionalProps = {
type,
disabled: isDisabled
};
} else {
additionalProps = {
role: "button",
tabIndex: isDisabled ? void 0 : 0,
href: elementType === "a" && !isDisabled ? href : void 0,
target: elementType === "a" ? target : void 0,
type: elementType === "input" ? type : void 0,
disabled: elementType === "input" ? isDisabled : void 0,
"aria-disabled": !isDisabled || elementType === "input" ? void 0 : isDisabled,
rel: elementType === "a" ? rel : void 0
};
}
let isMobile = (0, import_utils.isIOS)() || (0, import_utils.isAndroid)();
if (deprecatedOnClick && typeof deprecatedOnClick === "function") {
(0, import_shared_utils.warn)(
"onClick is deprecated, please use onPress instead. See: https://github.com/heroui-inc/heroui/issues/4292",
"useButton"
);
}
const handlePress = (e) => {
if (isMobile) {
deprecatedOnClick == null ? void 0 : deprecatedOnClick(e);
}
onPress == null ? void 0 : onPress(e);
};
let { pressProps, isPressed } = (0, import_interactions.usePress)({
onPressStart,
onPressEnd,
onPressChange,
onPress: handlePress,
isDisabled,
preventFocusOnPress,
allowTextSelectionOnPress,
ref
});
let { focusableProps } = (0, import_focus.useFocusable)(props, ref);
if (allowFocusWhenDisabled) {
focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
}
let buttonProps = (0, import_utils.mergeProps)(
focusableProps,
pressProps,
(0, import_utils.filterDOMProps)(props, { labelable: true })
);
return {
isPressed,
buttonProps: (0, import_utils.mergeProps)(additionalProps, buttonProps, {
"aria-haspopup": props["aria-haspopup"],
"aria-expanded": props["aria-expanded"],
"aria-controls": props["aria-controls"],
"aria-pressed": props["aria-pressed"],
onClick: (e) => {
if (type === "button" && isMobile) {
return;
}
deprecatedOnClick == null ? void 0 : deprecatedOnClick(e);
}
})
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
useAriaButton
});