primereact
Version:
PrimeReact is an open source UI library for React featuring a rich set of 90+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with Prime
2 lines (1 loc) • 2.35 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/api"),r=require("primereact/hooks"),n=require("primereact/utils");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function c(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var o=c(e),a=u(t),i=o.memo(o.forwardRef((function(){var e=o.useRef(null),t=o.useRef(null),u=function(){return e.current&&e.current.parentElement},c=function(){t.current&&(t.current.addEventListener("mousedown",l),n.DomHandler.isTouchDevice()&&t.current.addEventListener("touchstart",i))},i=function(r){var u=n.DomHandler.getOffset(t.current),c=r.targetTouches[0].pageX-u.left+document.body.scrollTop-n.DomHandler.getWidth(e.current)/2,o=r.targetTouches[0].pageY-u.top+document.body.scrollLeft-n.DomHandler.getHeight(e.current)/2;d(c,o)},l=function(r){if(!n.DomHandler.isTouchDevice()){var u=n.DomHandler.getOffset(t.current),c=r.pageX-u.left+document.body.scrollTop-n.DomHandler.getWidth(e.current)/2,o=r.pageY-u.top+document.body.scrollLeft-n.DomHandler.getHeight(e.current)/2;d(c,o)}},d=function(r,u){if(e.current&&"none"!==getComputedStyle(e.current,null).display){if(n.DomHandler.removeClass(e.current,"p-ink-active"),!n.DomHandler.getHeight(e.current)&&!n.DomHandler.getWidth(e.current)){var c=Math.max(n.DomHandler.getOuterWidth(t.current),n.DomHandler.getOuterHeight(t.current));e.current.style.height=c+"px",e.current.style.width=c+"px"}e.current.style.top=u+"px",e.current.style.left=r+"px",n.DomHandler.addClass(e.current,"p-ink-active")}};return r.useMountEffect((function(){e.current&&(t.current=u(),c())})),r.useUpdateEffect((function(){e.current&&!t.current&&(t.current=u(),c())})),r.useUnmountEffect((function(){e.current&&(t.current=null,t.current&&(t.current.removeEventListener("mousedown",l),n.DomHandler.isTouchDevice()&&t.current.removeEventListener("touchstart",i)))})),a.default.ripple?o.createElement("span",{role:"presentation",ref:e,className:"p-ink",onAnimationEnd:function(e){n.DomHandler.removeClass(e.currentTarget,"p-ink-active")}}):null})));i.displayName="Ripple",exports.Ripple=i;