Socket
Socket
Sign inDemoInstall

@interop-ui/react-utils

Package Overview
Dependencies
Maintainers
4
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@interop-ui/react-utils - npm Package Compare versions

Comparing version 0.0.1-13 to 0.0.1-14

14

dist/index.d.ts
import * as React from "react";
import { ForwardRefExoticComponentWithAs } from "@interop-ui/react-polymorphic";
import { MeasurableElement } from "@interop-ui/utils";
export function composeEventHandlers<E extends React.SyntheticEvent | Event>(originalEventHandler?: (event: E) => void, ourEventHandler?: (event: E) => void, { checkForDefaultPrevented }?: {

@@ -6,2 +8,3 @@ checkForDefaultPrevented?: boolean | undefined;

export function createContext<ContextValueType>(displayName: string, rootComponentName: string): readonly [React.Context<ContextValueType>, (componentName: string) => ContextValueType];
export function extendComponent<As extends ForwardRefExoticComponentWithAs<any, any>>(Comp: As extends ForwardRefExoticComponentWithAs<infer I, infer P> ? ForwardRefExoticComponentWithAs<I, P> : As, displayName: string): ForwardRefExoticComponentWithAs<import("@interop-ui/react-polymorphic").IntrinsicElement<As extends ForwardRefExoticComponentWithAs<infer I, infer P> ? ForwardRefExoticComponentWithAs<I, P> : As>, import("@interop-ui/react-polymorphic").ExtendedProps<As extends ForwardRefExoticComponentWithAs<infer I, infer P> ? ForwardRefExoticComponentWithAs<I, P> : As, {}>>;
/**

@@ -51,3 +54,12 @@ * A custom hook that converts a callback to a ref

export function useDocumentRef<T extends Element>(forwardedRef: React.RefObject<T | null>): React.MutableRefObject<Document>;
export function getOwnerDocument(nodeRef: React.RefObject<Element | null | undefined>): Document;
export function getOwnerWindow(nodeRef: React.RefObject<Element | null | undefined>): Window & typeof globalThis;
export function getOwnerGlobals(nodeRef: React.RefObject<Element | null | undefined>): {
ownerDocument: Document;
ownerWindow: Window & typeof globalThis;
};
export const useId: () => number;
export function usePrefersReducedMotion(nodeRef: React.RefObject<Element>): boolean;
export function prefersReducedMotion(globalWindow?: Window & typeof globalThis): boolean;
export function onPrefersReducedMotionChange(callback: (prefers: boolean) => any, globalWindow?: Window & typeof globalThis): () => void;
export function usePrevious<T>(value: T): T | undefined;

@@ -60,4 +72,4 @@ /**

/** A reference to the element whose rect to observe */
refToObserve: React.RefObject<HTMLElement | SVGElement>): ClientRect | undefined;
refToObserve: React.RefObject<MeasurableElement>): ClientRect | undefined;
//# sourceMappingURL=index.d.ts.map

2

dist/index.js

@@ -1,2 +0,2 @@

var t,r,e=require("@interop-ui/utils"),n=e.canUseDOM,o=e.observeElementRect,u=(t={},r=require("react"),Object.keys(r).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})})),t);function i(t){var r=u.useRef(t);return u.useEffect((function(){r.current=t})),u.useCallback((function(){for(var t,e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];null===(t=r.current)||void 0===t||t.call.apply(t,[r].concat(n))}),[])}function a(t,r){"function"==typeof t?t(r):null!=t&&(t.current=r)}function c(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];return function(t){return r.forEach((function(r){return a(r,t)}))}}function f(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var e=[],n=!0,o=!1,u=void 0;try{for(var i,a=t[Symbol.iterator]();!(n=(i=a.next()).done)&&(e.push(i.value),!r||e.length!==r);n=!0);}catch(t){o=!0,u=t}finally{try{n||null==a.return||a.return()}finally{if(o)throw u}}return e}(t,r)||function(t,r){if(!t)return;if("string"==typeof t)return l(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);"Object"===e&&t.constructor&&(e=t.constructor.name);if("Map"===e||"Set"===e)return Array.from(t);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return l(t,r)}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}exports.composeEventHandlers=function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=e.checkForDefaultPrevented,o=void 0===n||n;return function(e){if(null==t||t(e),!1===o||!e.defaultPrevented)return null==r?void 0:r(e)}},exports.createContext=function(t,r){var e=u.createContext(null);return e.displayName=t,[e,function(t){var n=u.useContext(e);if(null===n)throw new Error("`".concat(t,"` must be used within `").concat(r,"`"));return n}]},exports.useCallbackRef=i,exports.composeRefs=c,exports.useComposedRefs=function(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];return u.useCallback(c.apply(void 0,r),r)},exports.useConstant=function(t){var r=u.useRef();return r.current||(r.current={v:t()}),r.current.v},exports.useControlledState=function(t){var r=t.prop,e=t.defaultProp,n=t.onChange,o=void 0===n?function(){}:n,a=function(t){var r=t.defaultProp,e=t.onChange,n=u.useState(r),o=f(n,1)[0],a=u.useRef(o),c=i(e);return u.useEffect((function(){a.current!==o&&(c(o),a.current=o)}),[o,a,c]),n}({defaultProp:e,onChange:o}),c=f(a,2),l=c[0],s=c[1],y=void 0!==r,d=y?r:l,v=i(o);return[d,u.useCallback((function(t){if(y){var e="function"==typeof t?t(r):t;e!==r&&v(e)}else s(t)}),[y,r,s,v])]};var s=n()?u.useLayoutEffect:function(){};exports.useLayoutEffect=s;var y,d=0;function v(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var e=[],n=!0,o=!1,u=void 0;try{for(var i,a=t[Symbol.iterator]();!(n=(i=a.next()).done)&&(e.push(i.value),!r||e.length!==r);n=!0);}catch(t){o=!0,u=t}finally{try{n||null==a.return||a.return()}finally{if(o)throw u}}return e}(t,r)||function(t,r){if(!t)return;if("string"==typeof t)return p(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);"Object"===e&&t.constructor&&(e=t.constructor.name);if("Map"===e||"Set"===e)return Array.from(t);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return p(t,r)}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}exports.useDisableBodyPointerEvents=function(t){var r=t.disabled;s((function(){if(r)return 0===d&&(y=document.body.style.pointerEvents),document.body.style.pointerEvents="none",d++,function(){0===--d&&(document.body.style.pointerEvents=y)}}),[r])},exports.useDocumentRef=function(t){var r=u.useRef("undefined"!=typeof document?document:void 0);return s((function(){t.current instanceof Element&&(r.current=t.current.ownerDocument||document)})),r};var m=0;function b(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var e=[],n=!0,o=!1,u=void 0;try{for(var i,a=t[Symbol.iterator]();!(n=(i=a.next()).done)&&(e.push(i.value),!r||e.length!==r);n=!0);}catch(t){o=!0,u=t}finally{try{n||null==a.return||a.return()}finally{if(o)throw u}}return e}(t,r)||function(t,r){if(!t)return;if("string"==typeof t)return h(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);"Object"===e&&t.constructor&&(e=t.constructor.name);if("Map"===e||"Set"===e)return Array.from(t);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return h(t,r)}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}exports.useId=function(){return v(u.useState((function(){return m+=1})),1)[0]},exports.usePrevious=function(t){var r=u.useRef();return u.useEffect((function(){r.current=t}),[t]),r.current},exports.useRect=function(t){var r=b(u.useState(),2),e=r[0],n=r[1];return s((function(){if(t.current){var r=o(t.current,n);return function(){n(void 0),r()}}}),[t]),e};
var r,t,e=require("@interop-ui/utils"),n=e.getPartDataAttrObj,o=e.canUseDOM,u=e.observeElementRect,i=require("@interop-ui/react-polymorphic").forwardRefWithAs,a=(r={},t=require("react"),Object.keys(t).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})})),r);function c(){return(c=Object.assign||function(r){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r}).apply(this,arguments)}function f(r){var t=a.useRef(r);return a.useEffect((function(){t.current=r})),a.useCallback((function(){for(var r,e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];null===(r=t.current)||void 0===r||r.call.apply(r,[t].concat(n))}),[])}function l(r,t){"function"==typeof r?r(t):null!=r&&(r.current=t)}function s(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];return function(r){return t.forEach((function(t){return l(t,r)}))}}function d(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(r)))return;var e=[],n=!0,o=!1,u=void 0;try{for(var i,a=r[Symbol.iterator]();!(n=(i=a.next()).done)&&(e.push(i.value),!t||e.length!==t);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==a.return||a.return()}finally{if(o)throw u}}return e}(r,t)||function(r,t){if(!r)return;if("string"==typeof r)return y(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);"Object"===e&&r.constructor&&(e=r.constructor.name);if("Map"===e||"Set"===e)return Array.from(r);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return y(r,t)}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}exports.composeEventHandlers=function(r,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=e.checkForDefaultPrevented,o=void 0===n||n;return function(e){if(null==r||r(e),!1===o||!e.defaultPrevented)return null==t?void 0:t(e)}},exports.createContext=function(r,t){var e=a.createContext(null);return e.displayName=r,[e,function(r){var n=a.useContext(e);if(null===n)throw new Error("`".concat(r,"` must be used within `").concat(t,"`"));return n}]},exports.extendComponent=function(r,t){var e=i((function(e,o){var u=r;return a.createElement(u,c({},n(t),e,{ref:o}))}));return e.displayName=t,e},exports.useCallbackRef=f,exports.composeRefs=s,exports.useComposedRefs=function(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];return a.useCallback(s.apply(void 0,t),t)},exports.useConstant=function(r){var t=a.useRef();return t.current||(t.current={v:r()}),t.current.v},exports.useControlledState=function(r){var t=r.prop,e=r.defaultProp,n=r.onChange,o=void 0===n?function(){}:n,u=function(r){var t=r.defaultProp,e=r.onChange,n=a.useState(t),o=d(n,1)[0],u=a.useRef(o),i=f(e);return a.useEffect((function(){u.current!==o&&(i(o),u.current=o)}),[o,u,i]),n}({defaultProp:e,onChange:o}),i=d(u,2),c=i[0],l=i[1],s=void 0!==t,y=s?t:c,p=f(o);return[y,a.useCallback((function(r){if(s){var e="function"==typeof r?r(t):r;e!==t&&p(e)}else l(r)}),[s,t,l,p])]};var p=o()?a.useLayoutEffect:function(){};exports.useLayoutEffect=p;var v,m=0;function h(r){return r.current instanceof Element&&r.current.ownerDocument||document}function b(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(r)))return;var e=[],n=!0,o=!1,u=void 0;try{for(var i,a=r[Symbol.iterator]();!(n=(i=a.next()).done)&&(e.push(i.value),!t||e.length!==t);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==a.return||a.return()}finally{if(o)throw u}}return e}(r,t)||function(r,t){if(!r)return;if("string"==typeof r)return w(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);"Object"===e&&r.constructor&&(e=r.constructor.name);if("Map"===e||"Set"===e)return Array.from(r);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return w(r,t)}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}exports.useDisableBodyPointerEvents=function(r){var t=r.disabled;p((function(){if(t)return 0===m&&(v=document.body.style.pointerEvents),document.body.style.pointerEvents="none",m++,function(){0===--m&&(document.body.style.pointerEvents=v)}}),[t])},exports.useDocumentRef=function(r){var t=a.useRef("undefined"!=typeof document?document:void 0);return p((function(){t.current=h(r)})),t},exports.getOwnerDocument=h,exports.getOwnerWindow=function(r){return r.current instanceof Element&&h(r).defaultView||window},exports.getOwnerGlobals=function(r){var t=h(r);return{ownerDocument:t,ownerWindow:t.defaultView||window}};var g=0;function A(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(r)))return;var e=[],n=!0,o=!1,u=void 0;try{for(var i,a=r[Symbol.iterator]();!(n=(i=a.next()).done)&&(e.push(i.value),!t||e.length!==t);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==a.return||a.return()}finally{if(o)throw u}}return e}(r,t)||function(r,t){if(!r)return;if("string"==typeof r)return S(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);"Object"===e&&r.constructor&&(e=r.constructor.name);if("Map"===e||"Set"===e)return Array.from(r);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return S(r,t)}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}exports.useId=function(){return b(a.useState((function(){return g+=1})),1)[0]};function x(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window;try{var e=t.matchMedia("(prefers-reduced-motion: no-preference)");return e.addEventListener("change",n),function(){e.removeEventListener("change",n)}}catch(r){}return function(){};function n(t){r(!t.matches)}}function E(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(r)))return;var e=[],n=!0,o=!1,u=void 0;try{for(var i,a=r[Symbol.iterator]();!(n=(i=a.next()).done)&&(e.push(i.value),!t||e.length!==t);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==a.return||a.return()}finally{if(o)throw u}}return e}(r,t)||function(r,t){if(!r)return;if("string"==typeof r)return O(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);"Object"===e&&r.constructor&&(e=r.constructor.name);if("Map"===e||"Set"===e)return Array.from(r);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return O(r,t)}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}exports.usePrefersReducedMotion=function(r){var t=A(a.useState(!1),2),e=t[0],n=t[1];return a.useEffect((function(){var t;return x(n,(null===(t=r.current)||void 0===t?void 0:t.ownerDocument.defaultView)||window)}),[r]),e},exports.prefersReducedMotion=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window;try{return!r.matchMedia("(prefers-reduced-motion: no-preference)").matches}catch(r){return!1}},exports.onPrefersReducedMotionChange=x,exports.usePrevious=function(r){var t=a.useRef();return a.useEffect((function(){t.current=r}),[r]),t.current},exports.useRect=function(r){var t=E(a.useState(),2),e=t[0],n=t[1];return p((function(){if(r.current){var t=u(r.current,n);return function(){n(void 0),t()}}}),[r]),e};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import{canUseDOM as e,observeElementRect as t}from"@interop-ui/utils";import*as n from"react";export function composeEventHandlers(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(null==e||e(o),!1===n||!o.defaultPrevented)return null==t?void 0:t(o)}}export function createContext(e,t){const o=n.createContext(null);return o.displayName=e,[o,function(e){const u=n.useContext(o);if(null===u)throw new Error("`".concat(e,"` must be used within `").concat(t,"`"));return u}]}export function useCallbackRef(e){const t=n.useRef(e);return n.useEffect((()=>{t.current=e})),n.useCallback(((...e)=>{var n;null===(n=t.current)||void 0===n||n.call(t,...e)}),[])}export function composeRefs(...e){return t=>e.forEach((e=>function(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}(e,t)))}export function useComposedRefs(...e){return n.useCallback(composeRefs(...e),e)}export function useConstant(e){const t=n.useRef();return t.current||(t.current={v:e()}),t.current.v}export function useControlledState({prop:e,defaultProp:t,onChange:o=(()=>{})}){const[u,r]=function({defaultProp:e,onChange:t}){const o=n.useState(e),[u]=o,r=n.useRef(u),c=useCallbackRef(t);return n.useEffect((()=>{r.current!==u&&(c(u),r.current=u)}),[u,r,c]),o}({defaultProp:t,onChange:o}),c=void 0!==e,s=c?e:u,f=useCallbackRef(o);return[s,n.useCallback((t=>{if(c){const n=t,o="function"==typeof t?n(e):t;o!==e&&f(o)}else r(t)}),[c,e,r,f])]}export const useLayoutEffect=e()?n.useLayoutEffect:()=>{};let o,u=0;export function useDisableBodyPointerEvents({disabled:e}){useLayoutEffect((()=>{if(e)return 0===u&&(o=document.body.style.pointerEvents),document.body.style.pointerEvents="none",u++,()=>{u--,0===u&&(document.body.style.pointerEvents=o)}}),[e])}export function useDocumentRef(e){const t=n.useRef("undefined"!=typeof document?document:void 0);return useLayoutEffect((()=>{e.current instanceof Element&&(t.current=e.current.ownerDocument||document)})),t}let r=0;export const useId=()=>{const[e]=n.useState((()=>(r+=1,r)));return e};export function usePrevious(e){const t=n.useRef();return n.useEffect((()=>{t.current=e}),[e]),t.current}export function useRect(e){const[o,u]=n.useState();return useLayoutEffect((()=>{if(e.current){const n=t(e.current,u);return()=>{u(void 0),n()}}}),[e]),o}
import{getPartDataAttrObj as e,canUseDOM as t,observeElementRect as n}from"@interop-ui/utils";import{forwardRefWithAs as r}from"@interop-ui/react-polymorphic";import*as o from"react";export function composeEventHandlers(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(null==e||e(r),!1===n||!r.defaultPrevented)return null==t?void 0:t(r)}}export function createContext(e,t){const n=o.createContext(null);return n.displayName=e,[n,function(e){const r=o.useContext(n);if(null===r)throw new Error("`".concat(e,"` must be used within `").concat(t,"`"));return r}]}function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}export function extendComponent(t,n){const c=r(((r,c)=>{const s=t;return o.createElement(s,u({},e(n),r,{ref:c}))}));return c.displayName=n,c}export function useCallbackRef(e){const t=o.useRef(e);return o.useEffect((()=>{t.current=e})),o.useCallback(((...e)=>{var n;null===(n=t.current)||void 0===n||n.call(t,...e)}),[])}export function composeRefs(...e){return t=>e.forEach((e=>function(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}(e,t)))}export function useComposedRefs(...e){return o.useCallback(composeRefs(...e),e)}export function useConstant(e){const t=o.useRef();return t.current||(t.current={v:e()}),t.current.v}export function useControlledState({prop:e,defaultProp:t,onChange:n=(()=>{})}){const[r,u]=function({defaultProp:e,onChange:t}){const n=o.useState(e),[r]=n,u=o.useRef(r),c=useCallbackRef(t);return o.useEffect((()=>{u.current!==r&&(c(r),u.current=r)}),[r,u,c]),n}({defaultProp:t,onChange:n}),c=void 0!==e,s=c?e:r,f=useCallbackRef(n);return[s,o.useCallback((t=>{if(c){const n=t,r="function"==typeof t?n(e):t;r!==e&&f(r)}else u(t)}),[c,e,u,f])]}export const useLayoutEffect=t()?o.useLayoutEffect:()=>{};let c,s=0;export function useDisableBodyPointerEvents({disabled:e}){useLayoutEffect((()=>{if(e)return 0===s&&(c=document.body.style.pointerEvents),document.body.style.pointerEvents="none",s++,()=>{s--,0===s&&(document.body.style.pointerEvents=c)}}),[e])}export function useDocumentRef(e){const t=o.useRef("undefined"!=typeof document?document:void 0);return useLayoutEffect((()=>{t.current=getOwnerDocument(e)})),t}export function getOwnerDocument(e){return e.current instanceof Element&&e.current.ownerDocument||document}export function getOwnerWindow(e){return e.current instanceof Element&&getOwnerDocument(e).defaultView||window}export function getOwnerGlobals(e){const t=getOwnerDocument(e);return{ownerDocument:t,ownerWindow:t.defaultView||window}}let f=0;export const useId=()=>{const[e]=o.useState((()=>(f+=1,f)));return e};export function usePrefersReducedMotion(e){const[t,n]=o.useState(!1);return o.useEffect((()=>{var t;return onPrefersReducedMotionChange(n,(null===(t=e.current)||void 0===t?void 0:t.ownerDocument.defaultView)||window)}),[e]),t}export function prefersReducedMotion(e=window){try{return!e.matchMedia("(prefers-reduced-motion: no-preference)").matches}catch(e){return!1}}export function onPrefersReducedMotionChange(e,t=window){try{const e=t.matchMedia("(prefers-reduced-motion: no-preference)");return e.addEventListener("change",n),function(){e.removeEventListener("change",n)}}catch(e){}return function(){};function n(t){e(!t.matches)}}export function usePrevious(e){const t=o.useRef();return o.useEffect((()=>{t.current=e}),[e]),t.current}export function useRect(e){const[t,r]=o.useState();return useLayoutEffect((()=>{if(e.current){const t=n(e.current,r);return()=>{r(void 0),t()}}}),[e]),t}
//# sourceMappingURL=index.module.js.map
{
"name": "@interop-ui/react-utils",
"version": "0.0.1-13",
"version": "0.0.1-14",
"license": "MIT",

@@ -20,5 +20,6 @@ "source": "src/index.ts",

"dependencies": {
"@interop-ui/utils": "0.0.1-5"
"@interop-ui/utils": "0.0.1-6"
},
"devDependencies": {
"@testing-library/react": "^10.4.8",
"parcel": "^2.0.0-beta.1"

@@ -25,0 +26,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc