@darkroom.engineering/hamo
Advanced tools
Comparing version 0.6.43 to 0.6.44
@@ -1,2 +0,2 @@ | ||
var e=require("react"),t=require("@darkroom.engineering/tempus"),n=require("just-debounce-it"),r=require("nanoevents");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=/*#__PURE__*/u(t),i=/*#__PURE__*/u(n);function c(){var t=e.useState(!1),n=t[0],r=t[1];return e.useEffect(function(){r(!0)},[]),n}function a(){return a=Object.assign?Object.assign.bind():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},a.apply(this,arguments)}function s(e){"sticky"===getComputedStyle(e).position&&(e.style.setProperty("position","relative"),e.dataset.sticky="true"),e.offsetParent&&s(e.offsetParent)}function f(e){var t;"true"===(null==e||null==(t=e.dataset)?void 0:t.sticky)&&(e.style.removeProperty("position"),delete e.dataset.sticky),e.parentNode&&f(e.parentNode)}function d(e,t){void 0===t&&(t=0);var n=t+e.offsetTop;return e.offsetParent?d(e.offsetParent,n):n}function v(e,t){void 0===t&&(t=0);var n=t+e.offsetLeft;return e.offsetParent?v(e.offsetParent,n):n}function l(e,t){void 0===t&&(t=0);var n=t+e.scrollTop;return e.parentNode?l(e.parentNode,n):n+window.scrollY}function h(e,t){void 0===t&&(t=0);var n=t+e.scrollLeft;return e.parentNode?h(e.parentNode,n):n+window.scrollX}var p=r.createNanoEvents();function m(t){var n=void 0===t?{}:t,r=n.ignoreTransform,u=void 0!==r&&r,o=n.ignoreSticky,c=void 0===o||o,m=n.debounce,b=void 0===m?500:m,g=n.lazy,w=void 0!==g&&g,E=n.callback,y=e.useState(),S=y[0],x=y[1],z=e.useRef({}),k=e.useState({}),C=k[0],R=k[1],L=e.useCallback(function(e){var t,n,r,u,o,i=e.top,c=e.left,s=e.width,f=e.height,d=e.element;i=null!=(t=i)?t:z.current.top,c=null!=(n=c)?n:z.current.left,s=null!=(r=s)?r:z.current.width,f=null!=(u=f)?u:z.current.height,d=null!=(o=d)?o:z.current.element,i===z.current.top&&c===z.current.left&&s===z.current.width&&f===z.current.height&&d===z.current.element||(z.current.top=i,z.current.y=i,z.current.width=s,z.current.height=f,z.current.left=c,z.current.x=c,z.current.bottom=i+f,z.current.right=c+s,z.current.element=d,null==E||E(z.current),w||R(a({},z.current)))},[w]);e.useEffect(function(){if(S){var e=S.getBoundingClientRect();L({width:e.width,height:e.height});var t=i.default(function(e){var t=e[0];L({width:t.borderBoxSize[0].inlineSize,height:t.borderBoxSize[0].blockSize})},b),n=new ResizeObserver(t);return n.observe(S),function(){n.disconnect(),t.cancel()}}},[S,b,L]);var M=e.useState(),O=M[0],P=M[1],N=e.useCallback(function(){if(S){var e,t;if(c&&s(S),u)e=d(S),t=v(S);else{var n=S.getBoundingClientRect();e=n.top+l(S),t=n.left+h(S)}c&&f(S),L({top:e,left:t,element:S})}},[u,c,S,L]);e.useEffect(function(){N();var e=i.default(N,b),t=new ResizeObserver(e);return t.observe(null!=O?O:document.body),function(){t.disconnect(),e.cancel()}},[O,b,N]);var I=e.useCallback(function(){if(S){var e=S.getBoundingClientRect();L({width:e.width,height:e.height}),N()}},[S,N,L]);e.useEffect(function(){return z.current.resize=I,w||R(a({},z.current)),p.on("resize",I)},[I,w]);var T=e.useCallback(function(){return z.current},[]);return[x,w?T:C,P]}m.resize=function(){p.emit("resize")},exports.useDebug=function(){var t=c();return e.useMemo(function(){if(t){var e=window.location,n=e.href,r=new URLSearchParams(e.search),u=n.includes("#debug")||n.includes("/_debug")||r.has("debug")||"development"===process.env.NODE_ENV,o=n.includes("#production")||r.has("production");return u&&!o}},[t])},exports.useDocumentReadyState=function(){var t=e.useState(),n=t[0],r=t[1];return e.useEffect(function(){function e(){r(document.readyState)}return document.addEventListener("readystatechange",e,!1),e(),function(){return document.removeEventListener("readystatechange",e,!1)}},[]),n},exports.useFrame=function(t,n){void 0===n&&(n=0),e.useEffect(function(){if(t)return o.default.add(t,n),function(){return o.default.remove(t)}},[t,n])},exports.useIntersectionObserver=function(t,n){var r=void 0===t?{}:t,u=r.root,o=void 0===u?null:u,i=r.rootMargin,c=void 0===i?"0px":i,a=r.threshold,s=void 0===a?0:a,f=r.once,d=void 0!==f&&f,v=r.lazy,l=void 0!==v&&v,h=r.callback,p=void 0===h?function(){}:h;void 0===n&&(n=[]);var m=e.useRef({}),b=e.useState({}),g=b[0],w=b[1],E=e.useState(),y=E[0],S=E[1];e.useEffect(function(){if(y){var e=new IntersectionObserver(function(t){var n=t[0];l?m.current=n:w(n),p(n),d&&n.isIntersecting&&e.disconnect()},{root:o,rootMargin:c,threshold:s});return e.observe(y),function(){e.disconnect()}}},[y,o,c,s,l,d].concat(n));var x=e.useCallback(function(){return m.current},[]);return[S,l?x:g]},exports.useInterval=function(t,n,r){void 0===n&&(n=1e3),void 0===r&&(r=[]),e.useEffect(function(){var e=setInterval(t,n);return function(){return clearInterval(e)}},[n].concat(r))},exports.useIsClient=c,exports.useIsTouchDevice=function(){var t=e.useState(),n=t[0],r=t[1];return e.useEffect(function(){function e(){r("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0)}return window.addEventListener("resize",e,!1),e(),function(){window.removeEventListener("resize",e,!1)}},[]),n},exports.useMediaQuery=function(t){var n=e.useState(),r=n[0],u=n[1];return e.useEffect(function(){var e=window.matchMedia(t);function n(){u(e.matches)}return e.addEventListener("change",n,!1),n(),function(){return e.removeEventListener("change",n,!1)}},[t]),r},exports.useOutsideClickEvent=function(t,n){var r=e.useCallback(function(e){t.current&&!t.current.contains(e.target)&&n()},[t,n]);e.useEffect(function(){if(t.current)return document.addEventListener("mousedown",r),function(){document.removeEventListener("mousedown",r)}},[r,t])},exports.useRect=m,exports.useResizeObserver=function(t){var n=void 0===t?{}:t,r=n.lazy,u=void 0!==r&&r,o=n.debounce,c=void 0===o?500:o,a=n.box,s=void 0===a?"border-box":a,f=n.callback,d=void 0===f?function(){}:f,v=e.useRef({}),l=e.useState({}),h=l[0],p=l[1],m=e.useState(),b=m[0],g=m[1],w=e.useRef(!1),E=e.useMemo(function(){return i.default(p,c)},[c]),y=e.useCallback(function(e){var t=e[0];v.current=t,d(t),u||(w.current?p(t):E(t)),w.current=!1},[u,E]);e.useEffect(function(){if(b){w.current=!0;var e=new ResizeObserver(y);return e.observe(b,{box:s}),function(){e.disconnect(),E.cancel()}}},[b,c,s,y,E]);var S=e.useCallback(function(){return v.current},[]);return[g,u?S:h]},exports.useSlots=function(t,n){void 0===t&&(t=[]),void 0===n&&(n=[]);var r=e.useMemo(function(){return n&&[n].flat()},[n]),u=e.useMemo(function(){return t&&[t].flat()},[t]);return e.useMemo(function(){if(r&&u){var e=u.map(function(e){var t;return null==(t=r.find(function(t){return t.type===e}))?void 0:t.props.children});return t[0]?e:e[0]}},[r,u])},exports.useWindowSize=function(t){void 0===t&&(t=500);var n=e.useState(),r=n[0],u=n[1],o=e.useState(),c=o[0],a=o[1];return e.useEffect(function(){var e=i.default(function(){u(Math.min(window.innerWidth,document.documentElement.clientWidth)),a(Math.min(window.innerHeight,document.documentElement.clientHeight))},t);return window.addEventListener("resize",e,!1),e(),function(){return window.removeEventListener("resize",e,!1)}},[t]),{width:r,height:c}}; | ||
var e=require("react"),t=require("@darkroom.engineering/tempus"),n=require("just-debounce-it"),r=require("nanoevents");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=/*#__PURE__*/u(t),i=/*#__PURE__*/u(n);function c(){var t=e.useState(!1),n=t[0],r=t[1];return e.useEffect(function(){r(!0)},[]),n}function a(){return a=Object.assign?Object.assign.bind():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},a.apply(this,arguments)}function s(e){"sticky"===getComputedStyle(e).position&&(e.style.setProperty("position","relative"),e.dataset.sticky="true"),e.offsetParent&&s(e.offsetParent)}function f(e){var t;"true"===(null==e||null==(t=e.dataset)?void 0:t.sticky)&&(e.style.removeProperty("position"),delete e.dataset.sticky),e.parentNode&&f(e.parentNode)}function d(e,t){void 0===t&&(t=0);var n=t+e.offsetTop;return e.offsetParent?d(e.offsetParent,n):n}function l(e,t){void 0===t&&(t=0);var n=t+e.offsetLeft;return e.offsetParent?l(e.offsetParent,n):n}function v(e,t){void 0===t&&(t=0);var n=t+(null==e?void 0:e.scrollTop)||0;return e.parentNode?v(e.parentNode,n):n+window.scrollY}function h(e,t){void 0===t&&(t=0);var n=t+(null==e?void 0:e.scrollLeft)||0;return e.parentNode?h(e.parentNode,n):n+window.scrollX}var p=r.createNanoEvents();function m(t){var n=void 0===t?{}:t,r=n.ignoreTransform,u=void 0!==r&&r,o=n.ignoreSticky,c=void 0===o||o,m=n.debounce,b=void 0===m?500:m,g=n.lazy,w=void 0!==g&&g,E=n.callback,y=e.useState(),S=y[0],x=y[1],z=e.useRef({}),k=e.useState({}),C=k[0],R=k[1],L=e.useCallback(function(e){var t,n,r,u,o,i=e.top,c=e.left,s=e.width,f=e.height,d=e.element;i=null!=(t=i)?t:z.current.top,c=null!=(n=c)?n:z.current.left,s=null!=(r=s)?r:z.current.width,f=null!=(u=f)?u:z.current.height,d=null!=(o=d)?o:z.current.element,i===z.current.top&&c===z.current.left&&s===z.current.width&&f===z.current.height&&d===z.current.element||(z.current.top=i,z.current.y=i,z.current.width=s,z.current.height=f,z.current.left=c,z.current.x=c,z.current.bottom=i+f,z.current.right=c+s,z.current.element=d,null==E||E(z.current),w||R(a({},z.current)))},[w]);e.useEffect(function(){if(S){var e=S.getBoundingClientRect();L({width:e.width,height:e.height});var t=i.default(function(e){var t=e[0];L({width:t.borderBoxSize[0].inlineSize,height:t.borderBoxSize[0].blockSize})},b),n=new ResizeObserver(t);return n.observe(S),function(){n.disconnect(),t.cancel()}}},[S,b,L]);var M=e.useState(),O=M[0],P=M[1],N=e.useCallback(function(){if(S){var e,t;if(c&&s(S),u)e=d(S),t=l(S);else{var n=S.getBoundingClientRect();e=n.top+v(S),t=n.left+h(S)}c&&f(S),L({top:e,left:t,element:S})}},[u,c,S,L]);e.useEffect(function(){N();var e=i.default(N,b),t=new ResizeObserver(e);return t.observe(null!=O?O:document.body),function(){t.disconnect(),e.cancel()}},[O,b,N]);var I=e.useCallback(function(){if(S){var e=S.getBoundingClientRect();L({width:e.width,height:e.height}),N()}},[S,N,L]);e.useEffect(function(){return z.current.resize=I,w||R(a({},z.current)),p.on("resize",I)},[I,w]);var T=e.useCallback(function(){return z.current},[]);return[x,w?T:C,P]}m.resize=function(){p.emit("resize")},exports.useDebug=function(){var t=c();return e.useMemo(function(){if(t){var e=window.location,n=e.href,r=new URLSearchParams(e.search),u=n.includes("#debug")||n.includes("/_debug")||r.has("debug")||"development"===process.env.NODE_ENV,o=n.includes("#production")||r.has("production");return u&&!o}},[t])},exports.useDocumentReadyState=function(){var t=e.useState(),n=t[0],r=t[1];return e.useEffect(function(){function e(){r(document.readyState)}return document.addEventListener("readystatechange",e,!1),e(),function(){return document.removeEventListener("readystatechange",e,!1)}},[]),n},exports.useFrame=function(t,n){void 0===n&&(n=0),e.useEffect(function(){if(t)return o.default.add(t,n),function(){return o.default.remove(t)}},[t,n])},exports.useIntersectionObserver=function(t,n){var r=void 0===t?{}:t,u=r.root,o=void 0===u?null:u,i=r.rootMargin,c=void 0===i?"0px":i,a=r.threshold,s=void 0===a?0:a,f=r.once,d=void 0!==f&&f,l=r.lazy,v=void 0!==l&&l,h=r.callback,p=void 0===h?function(){}:h;void 0===n&&(n=[]);var m=e.useRef({}),b=e.useState({}),g=b[0],w=b[1],E=e.useState(),y=E[0],S=E[1];e.useEffect(function(){if(y){var e=new IntersectionObserver(function(t){var n=t[0];v?m.current=n:w(n),p(n),d&&n.isIntersecting&&e.disconnect()},{root:o,rootMargin:c,threshold:s});return e.observe(y),function(){e.disconnect()}}},[y,o,c,s,v,d].concat(n));var x=e.useCallback(function(){return m.current},[]);return[S,v?x:g]},exports.useInterval=function(t,n,r){void 0===n&&(n=1e3),void 0===r&&(r=[]),e.useEffect(function(){var e=setInterval(t,n);return function(){return clearInterval(e)}},[n].concat(r))},exports.useIsClient=c,exports.useIsTouchDevice=function(){var t=e.useState(),n=t[0],r=t[1];return e.useEffect(function(){function e(){r("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0)}return window.addEventListener("resize",e,!1),e(),function(){window.removeEventListener("resize",e,!1)}},[]),n},exports.useMediaQuery=function(t){var n=e.useState(),r=n[0],u=n[1];return e.useEffect(function(){var e=window.matchMedia(t);function n(){u(e.matches)}return e.addEventListener("change",n,!1),n(),function(){return e.removeEventListener("change",n,!1)}},[t]),r},exports.useOutsideClickEvent=function(t,n){var r=e.useCallback(function(e){t.current&&!t.current.contains(e.target)&&n()},[t,n]);e.useEffect(function(){if(t.current)return document.addEventListener("mousedown",r),function(){document.removeEventListener("mousedown",r)}},[r,t])},exports.useRect=m,exports.useResizeObserver=function(t){var n=void 0===t?{}:t,r=n.lazy,u=void 0!==r&&r,o=n.debounce,c=void 0===o?500:o,a=n.box,s=void 0===a?"border-box":a,f=n.callback,d=void 0===f?function(){}:f,l=e.useRef({}),v=e.useState({}),h=v[0],p=v[1],m=e.useState(),b=m[0],g=m[1],w=e.useRef(!1),E=e.useMemo(function(){return i.default(p,c)},[c]),y=e.useCallback(function(e){var t=e[0];l.current=t,d(t),u||(w.current?p(t):E(t)),w.current=!1},[u,E]);e.useEffect(function(){if(b){w.current=!0;var e=new ResizeObserver(y);return e.observe(b,{box:s}),function(){e.disconnect(),E.cancel()}}},[b,c,s,y,E]);var S=e.useCallback(function(){return l.current},[]);return[g,u?S:h]},exports.useSlots=function(t,n){void 0===t&&(t=[]),void 0===n&&(n=[]);var r=e.useMemo(function(){return n&&[n].flat()},[n]),u=e.useMemo(function(){return t&&[t].flat()},[t]);return e.useMemo(function(){if(r&&u){var e=u.map(function(e){var t;return null==(t=r.find(function(t){return t.type===e}))?void 0:t.props.children});return t[0]?e:e[0]}},[r,u])},exports.useWindowSize=function(t){void 0===t&&(t=500);var n=e.useState(),r=n[0],u=n[1],o=e.useState(),c=o[0],a=o[1];return e.useEffect(function(){var e=i.default(function(){u(Math.min(window.innerWidth,document.documentElement.clientWidth)),a(Math.min(window.innerHeight,document.documentElement.clientHeight))},t);return window.addEventListener("resize",e,!1),e(),function(){return window.removeEventListener("resize",e,!1)}},[t]),{width:r,height:c}}; | ||
//# sourceMappingURL=hamo.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@darkroom.engineering/tempus"),require("just-debounce-it"),require("nanoevents")):"function"==typeof define&&define.amd?define(["exports","react","@darkroom.engineering/tempus","just-debounce-it","nanoevents"],t):t((e||self).hamo={},e.react,e.Tempus,e.justDebounceIt,e.nanoevents)}(this,function(e,t,n,r,u){function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/o(n),c=/*#__PURE__*/o(r);function a(){var e=t.useState(!1),n=e[0],r=e[1];return t.useEffect(function(){r(!0)},[]),n}function s(){return s=Object.assign?Object.assign.bind():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},s.apply(this,arguments)}function f(e){"sticky"===getComputedStyle(e).position&&(e.style.setProperty("position","relative"),e.dataset.sticky="true"),e.offsetParent&&f(e.offsetParent)}function d(e){var t;"true"===(null==e||null==(t=e.dataset)?void 0:t.sticky)&&(e.style.removeProperty("position"),delete e.dataset.sticky),e.parentNode&&d(e.parentNode)}function l(e,t){void 0===t&&(t=0);var n=t+e.offsetTop;return e.offsetParent?l(e.offsetParent,n):n}function v(e,t){void 0===t&&(t=0);var n=t+e.offsetLeft;return e.offsetParent?v(e.offsetParent,n):n}function h(e,t){void 0===t&&(t=0);var n=t+e.scrollTop;return e.parentNode?h(e.parentNode,n):n+window.scrollY}function m(e,t){void 0===t&&(t=0);var n=t+e.scrollLeft;return e.parentNode?m(e.parentNode,n):n+window.scrollX}var b=u.createNanoEvents();function g(e){var n=void 0===e?{}:e,r=n.ignoreTransform,u=void 0!==r&&r,o=n.ignoreSticky,i=void 0===o||o,a=n.debounce,g=void 0===a?500:a,p=n.lazy,w=void 0!==p&&p,y=n.callback,E=t.useState(),S=E[0],k=E[1],z=t.useRef({}),C=t.useState({}),R=C[0],L=C[1],x=t.useCallback(function(e){var t,n,r,u,o,i=e.top,c=e.left,a=e.width,f=e.height,d=e.element;i=null!=(t=i)?t:z.current.top,c=null!=(n=c)?n:z.current.left,a=null!=(r=a)?r:z.current.width,f=null!=(u=f)?u:z.current.height,d=null!=(o=d)?o:z.current.element,i===z.current.top&&c===z.current.left&&a===z.current.width&&f===z.current.height&&d===z.current.element||(z.current.top=i,z.current.y=i,z.current.width=a,z.current.height=f,z.current.left=c,z.current.x=c,z.current.bottom=i+f,z.current.right=c+a,z.current.element=d,null==y||y(z.current),w||L(s({},z.current)))},[w]);t.useEffect(function(){if(S){var e=S.getBoundingClientRect();x({width:e.width,height:e.height});var t=c.default(function(e){var t=e[0];x({width:t.borderBoxSize[0].inlineSize,height:t.borderBoxSize[0].blockSize})},g),n=new ResizeObserver(t);return n.observe(S),function(){n.disconnect(),t.cancel()}}},[S,g,x]);var M=t.useState(),O=M[0],P=M[1],I=t.useCallback(function(){if(S){var e,t;if(i&&f(S),u)e=l(S),t=v(S);else{var n=S.getBoundingClientRect();e=n.top+h(S),t=n.left+m(S)}i&&d(S),x({top:e,left:t,element:S})}},[u,i,S,x]);t.useEffect(function(){I();var e=c.default(I,g),t=new ResizeObserver(e);return t.observe(null!=O?O:document.body),function(){t.disconnect(),e.cancel()}},[O,g,I]);var N=t.useCallback(function(){if(S){var e=S.getBoundingClientRect();x({width:e.width,height:e.height}),I()}},[S,I,x]);t.useEffect(function(){return z.current.resize=N,w||L(s({},z.current)),b.on("resize",N)},[N,w]);var T=t.useCallback(function(){return z.current},[]);return[k,w?T:R,P]}g.resize=function(){b.emit("resize")},e.useDebug=function(){var e=a();return t.useMemo(function(){if(e){var t=window.location,n=t.href,r=new URLSearchParams(t.search),u=n.includes("#debug")||n.includes("/_debug")||r.has("debug")||"development"===process.env.NODE_ENV,o=n.includes("#production")||r.has("production");return u&&!o}},[e])},e.useDocumentReadyState=function(){var e=t.useState(),n=e[0],r=e[1];return t.useEffect(function(){function e(){r(document.readyState)}return document.addEventListener("readystatechange",e,!1),e(),function(){return document.removeEventListener("readystatechange",e,!1)}},[]),n},e.useFrame=function(e,n){void 0===n&&(n=0),t.useEffect(function(){if(e)return i.default.add(e,n),function(){return i.default.remove(e)}},[e,n])},e.useIntersectionObserver=function(e,n){var r=void 0===e?{}:e,u=r.root,o=void 0===u?null:u,i=r.rootMargin,c=void 0===i?"0px":i,a=r.threshold,s=void 0===a?0:a,f=r.once,d=void 0!==f&&f,l=r.lazy,v=void 0!==l&&l,h=r.callback,m=void 0===h?function(){}:h;void 0===n&&(n=[]);var b=t.useRef({}),g=t.useState({}),p=g[0],w=g[1],y=t.useState(),E=y[0],S=y[1];t.useEffect(function(){if(E){var e=new IntersectionObserver(function(t){var n=t[0];v?b.current=n:w(n),m(n),d&&n.isIntersecting&&e.disconnect()},{root:o,rootMargin:c,threshold:s});return e.observe(E),function(){e.disconnect()}}},[E,o,c,s,v,d].concat(n));var k=t.useCallback(function(){return b.current},[]);return[S,v?k:p]},e.useInterval=function(e,n,r){void 0===n&&(n=1e3),void 0===r&&(r=[]),t.useEffect(function(){var t=setInterval(e,n);return function(){return clearInterval(t)}},[n].concat(r))},e.useIsClient=a,e.useIsTouchDevice=function(){var e=t.useState(),n=e[0],r=e[1];return t.useEffect(function(){function e(){r("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0)}return window.addEventListener("resize",e,!1),e(),function(){window.removeEventListener("resize",e,!1)}},[]),n},e.useMediaQuery=function(e){var n=t.useState(),r=n[0],u=n[1];return t.useEffect(function(){var t=window.matchMedia(e);function n(){u(t.matches)}return t.addEventListener("change",n,!1),n(),function(){return t.removeEventListener("change",n,!1)}},[e]),r},e.useOutsideClickEvent=function(e,n){var r=t.useCallback(function(t){e.current&&!e.current.contains(t.target)&&n()},[e,n]);t.useEffect(function(){if(e.current)return document.addEventListener("mousedown",r),function(){document.removeEventListener("mousedown",r)}},[r,e])},e.useRect=g,e.useResizeObserver=function(e){var n=void 0===e?{}:e,r=n.lazy,u=void 0!==r&&r,o=n.debounce,i=void 0===o?500:o,a=n.box,s=void 0===a?"border-box":a,f=n.callback,d=void 0===f?function(){}:f,l=t.useRef({}),v=t.useState({}),h=v[0],m=v[1],b=t.useState(),g=b[0],p=b[1],w=t.useRef(!1),y=t.useMemo(function(){return c.default(m,i)},[i]),E=t.useCallback(function(e){var t=e[0];l.current=t,d(t),u||(w.current?m(t):y(t)),w.current=!1},[u,y]);t.useEffect(function(){if(g){w.current=!0;var e=new ResizeObserver(E);return e.observe(g,{box:s}),function(){e.disconnect(),y.cancel()}}},[g,i,s,E,y]);var S=t.useCallback(function(){return l.current},[]);return[p,u?S:h]},e.useSlots=function(e,n){void 0===e&&(e=[]),void 0===n&&(n=[]);var r=t.useMemo(function(){return n&&[n].flat()},[n]),u=t.useMemo(function(){return e&&[e].flat()},[e]);return t.useMemo(function(){if(r&&u){var t=u.map(function(e){var t;return null==(t=r.find(function(t){return t.type===e}))?void 0:t.props.children});return e[0]?t:t[0]}},[r,u])},e.useWindowSize=function(e){void 0===e&&(e=500);var n=t.useState(),r=n[0],u=n[1],o=t.useState(),i=o[0],a=o[1];return t.useEffect(function(){var t=c.default(function(){u(Math.min(window.innerWidth,document.documentElement.clientWidth)),a(Math.min(window.innerHeight,document.documentElement.clientHeight))},e);return window.addEventListener("resize",t,!1),t(),function(){return window.removeEventListener("resize",t,!1)}},[e]),{width:r,height:i}}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@darkroom.engineering/tempus"),require("just-debounce-it"),require("nanoevents")):"function"==typeof define&&define.amd?define(["exports","react","@darkroom.engineering/tempus","just-debounce-it","nanoevents"],t):t((e||self).hamo={},e.react,e.Tempus,e.justDebounceIt,e.nanoevents)}(this,function(e,t,n,r,u){function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/o(n),c=/*#__PURE__*/o(r);function a(){var e=t.useState(!1),n=e[0],r=e[1];return t.useEffect(function(){r(!0)},[]),n}function s(){return s=Object.assign?Object.assign.bind():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},s.apply(this,arguments)}function f(e){"sticky"===getComputedStyle(e).position&&(e.style.setProperty("position","relative"),e.dataset.sticky="true"),e.offsetParent&&f(e.offsetParent)}function d(e){var t;"true"===(null==e||null==(t=e.dataset)?void 0:t.sticky)&&(e.style.removeProperty("position"),delete e.dataset.sticky),e.parentNode&&d(e.parentNode)}function l(e,t){void 0===t&&(t=0);var n=t+e.offsetTop;return e.offsetParent?l(e.offsetParent,n):n}function v(e,t){void 0===t&&(t=0);var n=t+e.offsetLeft;return e.offsetParent?v(e.offsetParent,n):n}function h(e,t){void 0===t&&(t=0);var n=t+(null==e?void 0:e.scrollTop)||0;return e.parentNode?h(e.parentNode,n):n+window.scrollY}function m(e,t){void 0===t&&(t=0);var n=t+(null==e?void 0:e.scrollLeft)||0;return e.parentNode?m(e.parentNode,n):n+window.scrollX}var b=u.createNanoEvents();function g(e){var n=void 0===e?{}:e,r=n.ignoreTransform,u=void 0!==r&&r,o=n.ignoreSticky,i=void 0===o||o,a=n.debounce,g=void 0===a?500:a,p=n.lazy,w=void 0!==p&&p,y=n.callback,E=t.useState(),S=E[0],k=E[1],z=t.useRef({}),C=t.useState({}),R=C[0],L=C[1],x=t.useCallback(function(e){var t,n,r,u,o,i=e.top,c=e.left,a=e.width,f=e.height,d=e.element;i=null!=(t=i)?t:z.current.top,c=null!=(n=c)?n:z.current.left,a=null!=(r=a)?r:z.current.width,f=null!=(u=f)?u:z.current.height,d=null!=(o=d)?o:z.current.element,i===z.current.top&&c===z.current.left&&a===z.current.width&&f===z.current.height&&d===z.current.element||(z.current.top=i,z.current.y=i,z.current.width=a,z.current.height=f,z.current.left=c,z.current.x=c,z.current.bottom=i+f,z.current.right=c+a,z.current.element=d,null==y||y(z.current),w||L(s({},z.current)))},[w]);t.useEffect(function(){if(S){var e=S.getBoundingClientRect();x({width:e.width,height:e.height});var t=c.default(function(e){var t=e[0];x({width:t.borderBoxSize[0].inlineSize,height:t.borderBoxSize[0].blockSize})},g),n=new ResizeObserver(t);return n.observe(S),function(){n.disconnect(),t.cancel()}}},[S,g,x]);var M=t.useState(),O=M[0],P=M[1],I=t.useCallback(function(){if(S){var e,t;if(i&&f(S),u)e=l(S),t=v(S);else{var n=S.getBoundingClientRect();e=n.top+h(S),t=n.left+m(S)}i&&d(S),x({top:e,left:t,element:S})}},[u,i,S,x]);t.useEffect(function(){I();var e=c.default(I,g),t=new ResizeObserver(e);return t.observe(null!=O?O:document.body),function(){t.disconnect(),e.cancel()}},[O,g,I]);var N=t.useCallback(function(){if(S){var e=S.getBoundingClientRect();x({width:e.width,height:e.height}),I()}},[S,I,x]);t.useEffect(function(){return z.current.resize=N,w||L(s({},z.current)),b.on("resize",N)},[N,w]);var T=t.useCallback(function(){return z.current},[]);return[k,w?T:R,P]}g.resize=function(){b.emit("resize")},e.useDebug=function(){var e=a();return t.useMemo(function(){if(e){var t=window.location,n=t.href,r=new URLSearchParams(t.search),u=n.includes("#debug")||n.includes("/_debug")||r.has("debug")||"development"===process.env.NODE_ENV,o=n.includes("#production")||r.has("production");return u&&!o}},[e])},e.useDocumentReadyState=function(){var e=t.useState(),n=e[0],r=e[1];return t.useEffect(function(){function e(){r(document.readyState)}return document.addEventListener("readystatechange",e,!1),e(),function(){return document.removeEventListener("readystatechange",e,!1)}},[]),n},e.useFrame=function(e,n){void 0===n&&(n=0),t.useEffect(function(){if(e)return i.default.add(e,n),function(){return i.default.remove(e)}},[e,n])},e.useIntersectionObserver=function(e,n){var r=void 0===e?{}:e,u=r.root,o=void 0===u?null:u,i=r.rootMargin,c=void 0===i?"0px":i,a=r.threshold,s=void 0===a?0:a,f=r.once,d=void 0!==f&&f,l=r.lazy,v=void 0!==l&&l,h=r.callback,m=void 0===h?function(){}:h;void 0===n&&(n=[]);var b=t.useRef({}),g=t.useState({}),p=g[0],w=g[1],y=t.useState(),E=y[0],S=y[1];t.useEffect(function(){if(E){var e=new IntersectionObserver(function(t){var n=t[0];v?b.current=n:w(n),m(n),d&&n.isIntersecting&&e.disconnect()},{root:o,rootMargin:c,threshold:s});return e.observe(E),function(){e.disconnect()}}},[E,o,c,s,v,d].concat(n));var k=t.useCallback(function(){return b.current},[]);return[S,v?k:p]},e.useInterval=function(e,n,r){void 0===n&&(n=1e3),void 0===r&&(r=[]),t.useEffect(function(){var t=setInterval(e,n);return function(){return clearInterval(t)}},[n].concat(r))},e.useIsClient=a,e.useIsTouchDevice=function(){var e=t.useState(),n=e[0],r=e[1];return t.useEffect(function(){function e(){r("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0)}return window.addEventListener("resize",e,!1),e(),function(){window.removeEventListener("resize",e,!1)}},[]),n},e.useMediaQuery=function(e){var n=t.useState(),r=n[0],u=n[1];return t.useEffect(function(){var t=window.matchMedia(e);function n(){u(t.matches)}return t.addEventListener("change",n,!1),n(),function(){return t.removeEventListener("change",n,!1)}},[e]),r},e.useOutsideClickEvent=function(e,n){var r=t.useCallback(function(t){e.current&&!e.current.contains(t.target)&&n()},[e,n]);t.useEffect(function(){if(e.current)return document.addEventListener("mousedown",r),function(){document.removeEventListener("mousedown",r)}},[r,e])},e.useRect=g,e.useResizeObserver=function(e){var n=void 0===e?{}:e,r=n.lazy,u=void 0!==r&&r,o=n.debounce,i=void 0===o?500:o,a=n.box,s=void 0===a?"border-box":a,f=n.callback,d=void 0===f?function(){}:f,l=t.useRef({}),v=t.useState({}),h=v[0],m=v[1],b=t.useState(),g=b[0],p=b[1],w=t.useRef(!1),y=t.useMemo(function(){return c.default(m,i)},[i]),E=t.useCallback(function(e){var t=e[0];l.current=t,d(t),u||(w.current?m(t):y(t)),w.current=!1},[u,y]);t.useEffect(function(){if(g){w.current=!0;var e=new ResizeObserver(E);return e.observe(g,{box:s}),function(){e.disconnect(),y.cancel()}}},[g,i,s,E,y]);var S=t.useCallback(function(){return l.current},[]);return[p,u?S:h]},e.useSlots=function(e,n){void 0===e&&(e=[]),void 0===n&&(n=[]);var r=t.useMemo(function(){return n&&[n].flat()},[n]),u=t.useMemo(function(){return e&&[e].flat()},[e]);return t.useMemo(function(){if(r&&u){var t=u.map(function(e){var t;return null==(t=r.find(function(t){return t.type===e}))?void 0:t.props.children});return e[0]?t:t[0]}},[r,u])},e.useWindowSize=function(e){void 0===e&&(e=500);var n=t.useState(),r=n[0],u=n[1],o=t.useState(),i=o[0],a=o[1];return t.useEffect(function(){var t=c.default(function(){u(Math.min(window.innerWidth,document.documentElement.clientWidth)),a(Math.min(window.innerHeight,document.documentElement.clientHeight))},e);return window.addEventListener("resize",t,!1),t(),function(){return window.removeEventListener("resize",t,!1)}},[e]),{width:r,height:i}}}); | ||
//# sourceMappingURL=hamo.umd.js.map |
{ | ||
"name": "@darkroom.engineering/hamo", | ||
"version": "0.6.43", | ||
"version": "0.6.44", | ||
"description": "hamo means hook, do the math.", | ||
@@ -5,0 +5,0 @@ "files": [ |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
147015
151