@razorpay/blade
Version:
The Design System that powers Razorpay
33 lines (30 loc) • 1.03 kB
JavaScript
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { useState } from 'react';
var useInteraction = function useInteraction() {
var _useState = useState('default'),
_useState2 = _slicedToArray(_useState, 2),
currentInteraction = _useState2[0],
setCurrentInteraction = _useState2[1];
var onMouseEnter = function onMouseEnter() {
if (currentInteraction !== 'focus') setCurrentInteraction('hover');
};
var onMouseLeave = function onMouseLeave() {
if (currentInteraction !== 'focus') setCurrentInteraction('default');
};
var onFocus = function onFocus() {
setCurrentInteraction('focus');
};
var onBlur = function onBlur() {
setCurrentInteraction('default');
};
return {
onMouseEnter: onMouseEnter,
onMouseLeave: onMouseLeave,
onFocus: onFocus,
onBlur: onBlur,
currentInteraction: currentInteraction,
setCurrentInteraction: setCurrentInteraction
};
};
export { useInteraction as default };
//# sourceMappingURL=useInteraction.js.map