@razorpay/blade
Version:
The Design System that powers Razorpay
43 lines (36 loc) • 1.3 kB
JavaScript
import React__default from 'react';
/**
* GenUI context value
*/
var GenUIContext = /*#__PURE__*/React__default.createContext(null);
/**
* Hook to access GenUI context
* @throws Error if used outside GenUIProvider
*/
var useGenUI = function useGenUI() {
var context = React__default.useContext(GenUIContext);
if (!context) {
throw new Error('useGenUI must be used within a GenUIProvider');
}
return context;
};
/**
* Hook to access action click handler (safe version that doesn't throw)
*/
var useGenUIAction = function useGenUIAction() {
var context = React__default.useContext(GenUIContext);
return context === null || context === void 0 ? void 0 : context.onActionClick;
};
/**
* Hook to access animation state
*/
var useGenUIAnimation = function useGenUIAnimation() {
var _context$isAnimating;
var context = React__default.useContext(GenUIContext);
return {
isAnimating: (_context$isAnimating = context === null || context === void 0 ? void 0 : context.isAnimating) !== null && _context$isAnimating !== void 0 ? _context$isAnimating : false,
animateOptions: context === null || context === void 0 ? void 0 : context.animateOptions
};
};
export { GenUIContext, useGenUI, useGenUIAction, useGenUIAnimation };
//# sourceMappingURL=GenUIContext.web.js.map