@ariakit/react
Version:
Toolkit for building accessible web apps with React
43 lines (29 loc) • 1.26 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});
var _LF4ENSO4cjs = require('./LF4ENSO4.cjs');
var _LZ6L3ECGcjs = require('./LZ6L3ECG.cjs');
// ../ariakit-react-components/dist/button/button.js
var _react = require('react');
var TagName = "button";
var useButton = _LZ6L3ECGcjs.createHook.call(void 0, function useButton2(props) {
const ref = _react.useRef.call(void 0, null);
const tagName = _LZ6L3ECGcjs.useTagName.call(void 0, ref, TagName);
const [isNativeButton, setIsNativeButton] = _react.useState.call(void 0, () => !!tagName && _LZ6L3ECGcjs.isButton.call(void 0, {
tagName,
type: props.type
}));
_react.useEffect.call(void 0, () => {
if (!ref.current) return;
setIsNativeButton(_LZ6L3ECGcjs.isButton.call(void 0, ref.current));
}, []);
props = {
role: !isNativeButton && tagName !== "a" ? "button" : void 0,
...props,
ref: _LZ6L3ECGcjs.useMergeRefs.call(void 0, ref, props.ref)
};
props = _LF4ENSO4cjs.useCommand.call(void 0, props);
return props;
});
var Button = _LZ6L3ECGcjs.forwardRef.call(void 0, function Button2(props) {
return _LZ6L3ECGcjs.createElement.call(void 0, TagName, useButton(props));
});
exports.useButton = useButton; exports.Button = Button;