Socket
Socket
Sign inDemoInstall

@interop-ui/utils

Package Overview
Dependencies
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@interop-ui/utils - npm Package Compare versions

Comparing version 0.0.1-5 to 0.0.1-6

27

dist/index.d.ts

@@ -8,2 +8,3 @@ export function arrayRemove<T>(array: T[], item: T): T[];

export function wrapArray<T>(array: T[], startIndex: number): T[];
export function namespaced(componentPart: string): string;
export function getPartDataAttr(componentPart: string): string;

@@ -15,2 +16,15 @@ export function getPartDataAttrObj(componentPart: string): {

export function makeId(...args: (string | number | null | undefined)[]): string;
export function isMainClick(event: MouseEvent | PointerEvent): boolean;
export function getResizeObserverEntryBorderBoxSize(entry: ResizeObserverEntry): ResizeObserverSize;
interface ResizeObserverSize {
readonly inlineSize: number;
readonly blockSize: number;
}
interface ResizeObserverEntry {
readonly target: Element;
readonly contentRect: DOMRectReadOnly;
readonly borderBoxSize: ResizeObserverSize[] | ResizeObserverSize;
readonly contentBoxSize: ResizeObserverSize[] | ResizeObserverSize;
readonly devicePixelContentBoxSize: ResizeObserverSize[];
}
export const SIDE_OPTIONS: readonly ["top", "right", "bottom", "left"];

@@ -45,3 +59,2 @@ export const ALIGN_OPTIONS: readonly ["start", "center", "end"];

}): boolean;
export type Collisions = Record<Side, boolean>;
/**

@@ -54,3 +67,8 @@ * Gets collisions for each side of a rect (top, right, bottom, left)

/** An optional tolerance if you want the collisions to trigger a bit before/after */
tolerance?: number): Collisions;
tolerance?: number): {
top: boolean;
right: boolean;
bottom: boolean;
left: boolean;
};
export function warning(cond: boolean, message: string): void;

@@ -60,2 +78,5 @@ export function warningOnce(key: string, cond: boolean, message: string): void;

export function wrap(index: number, max: number): number;
export type MeasurableElement = {
getBoundingClientRect(): ClientRect;
};
/**

@@ -68,3 +89,3 @@ * Observes an element's rectangle on screen (getBoundingClientRect)

/** The element whose rect to observe */
elementToObserve: HTMLElement | SVGElement,
elementToObserve: MeasurableElement,
/** The callback which will be called when the rect changes */

@@ -71,0 +92,0 @@ callback: CallbackFn): () => void;

2

dist/index.js

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

function t(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(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.arrayRemove=function(r,e){var n=t(r),o=n.indexOf(e);return-1!==o&&n.splice(o,1),n},exports.arrayInsert=function(r,e,n){return[].concat(t(r.slice(0,n)),[e],t(r.slice(n)))},exports.wrapArray=function(t,r){return t.map((function(e,n){return t[(r+n)%t.length]}))};function e(t){return"data-".concat(function(t){var r=t.replace(".","").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return"".concat("interop-ui","-").concat(r)}(t))}exports.getPartDataAttr=e,exports.getPartDataAttrObj=function(t){return r={},n=e(t),o="",n in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,r;var r,n,o},exports.canUseDOM=function(){return!("undefined"==typeof window||!window.document||!window.document.createElement)},exports.makeId=function(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];return r.filter((function(t){return null!=t})).join("-")};exports.SIDE_OPTIONS=["top","right","bottom","left"];function n(t,r){return t.width===r.width&&t.height===r.height&&t.top===r.top&&t.right===r.right&&t.bottom===r.bottom&&t.left===r.left}exports.ALIGN_OPTIONS=["start","center","end"],exports.makeRect=function(t,r){var e=t.width,n=t.height,o=r.x,i=r.y;return{width:e,height:n,top:i,bottom:i+n,left:o,right:o+e}},exports.getOppositeSide=function(t){return{top:"bottom",right:"left",bottom:"top",left:"right"}[t]},exports.rectEquals=n,exports.isInsideRect=function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=e.inclusive,o=void 0===n||n;return o?r.x>=t.left&&r.x<=t.right&&r.y>=t.top&&r.y<=t.bottom:r.x>t.left&&r.x<t.right&&r.y>t.top&&r.y<t.bottom},exports.getCollisions=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{top:t.top<r,right:t.right>window.innerWidth-r,bottom:t.bottom>window.innerHeight-r,left:t.left<r}};var o,i={};function a(t,r){if(!t){0;try{throw new Error(r)}catch(t){}}}function c(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,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(n=(a=c.next()).done)&&(e.push(a.value),!r||e.length!==r);n=!0);}catch(t){o=!0,i=t}finally{try{n||null==c.return||c.return()}finally{if(o)throw i}}return e}(t,r)||function(t,r){if(!t)return;if("string"==typeof t)return u(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 u(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 u(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.warning=a,exports.warningOnce=function(t,r,e){r||i[t]||(i[t]=!0,a(!1,e))},exports.clamp=function(t,r){var e=c(r,2),n=e[0],o=e[1];return Math.min(o,Math.max(n,t))},exports.wrap=function(t,r){return(r+t)%r},exports.observeElementRect=function(t,r){var e=f.get(t);return void 0===e?(f.set(t,{rect:{},callbacks:[r]}),1===f.size&&(o=requestAnimationFrame(l))):e.callbacks.push(r),function(){var e=f.get(t);if(void 0!==e){var n=e.callbacks.indexOf(r);n>-1&&e.callbacks.splice(n,1),0===e.callbacks.length&&(f.delete(t),0===f.size&&cancelAnimationFrame(o))}}};var f=new Map;function l(){var t=[];f.forEach((function(r,e){var o=e.getBoundingClientRect();n(r.rect,o)||(r.rect=o,t.push(r))})),t.forEach((function(t){t.callbacks.forEach((function(r){return r(t.rect)}))})),o=requestAnimationFrame(l)}exports.isFunction=function(t){return!(!t||"[object Function]"!=={}.toString.call(t))},exports.isUndefined=function(t){return void 0===t};
function t(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(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.arrayRemove=function(r,e){var n=t(r),o=n.indexOf(e);return-1!==o&&n.splice(o,1),n},exports.arrayInsert=function(r,e,n){return[].concat(t(r.slice(0,n)),[e],t(r.slice(n)))},exports.wrapArray=function(t,r){return t.map((function(e,n){return t[(r+n)%t.length]}))};function e(t){var r=t.replace(".","").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return"".concat("radix","-").concat(r)}function n(t){return"data-".concat(e(t))}exports.namespaced=e,exports.getPartDataAttr=n,exports.getPartDataAttrObj=function(t){return r={},e=n(t),o="",e in r?Object.defineProperty(r,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[e]=o,r;var r,e,o},exports.canUseDOM=function(){return!("undefined"==typeof window||!window.document||!window.document.createElement)},exports.makeId=function(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];return r.filter((function(t){return null!=t})).join("-")},exports.isMainClick=function(t){return 0===t.button},exports.getResizeObserverEntryBorderBoxSize=function(t){if("borderBoxSize"in t)return Array.isArray(t.borderBoxSize)?t.borderBoxSize[0]:t.borderBoxSize;var r=t.target.getBoundingClientRect();return{inlineSize:r.width,blockSize:r.height}};exports.SIDE_OPTIONS=["top","right","bottom","left"];function o(t,r){return t.width===r.width&&t.height===r.height&&t.top===r.top&&t.right===r.right&&t.bottom===r.bottom&&t.left===r.left}exports.ALIGN_OPTIONS=["start","center","end"],exports.makeRect=function(t,r){var e=t.width,n=t.height,o=r.x,i=r.y;return DOMRect.fromRect({width:e,height:n,x:o,y:i})},exports.getOppositeSide=function(t){return{top:"bottom",right:"left",bottom:"top",left:"right"}[t]},exports.rectEquals=o,exports.isInsideRect=function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=e.inclusive,o=void 0===n||n;return o?r.x>=t.left&&r.x<=t.right&&r.y>=t.top&&r.y<=t.bottom:r.x>t.left&&r.x<t.right&&r.y>t.top&&r.y<t.bottom},exports.getCollisions=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{top:t.top<r,right:t.right>window.innerWidth-r,bottom:t.bottom>window.innerHeight-r,left:t.left<r}};var i,a={};function c(t,r){if(!t){0;try{throw new Error(r)}catch(t){}}}function u(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,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(n=(a=c.next()).done)&&(e.push(a.value),!r||e.length!==r);n=!0);}catch(t){o=!0,i=t}finally{try{n||null==c.return||c.return()}finally{if(o)throw i}}return e}(t,r)||function(t,r){if(!t)return;if("string"==typeof t)return f(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 f(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 f(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.warning=c,exports.warningOnce=function(t,r,e){r||a[t]||(a[t]=!0,c(!1,e))},exports.clamp=function(t,r){var e=u(r,2),n=e[0],o=e[1];return Math.min(o,Math.max(n,t))},exports.wrap=function(t,r){return(r+t)%r},exports.observeElementRect=function(t,r){var e=l.get(t);return void 0===e?(l.set(t,{rect:{},callbacks:[r]}),1===l.size&&(i=requestAnimationFrame(s))):e.callbacks.push(r),function(){var e=l.get(t);if(void 0!==e){var n=e.callbacks.indexOf(r);n>-1&&e.callbacks.splice(n,1),0===e.callbacks.length&&(l.delete(t),0===l.size&&cancelAnimationFrame(i))}}};var l=new Map;function s(){var t=[];l.forEach((function(r,e){var n=e.getBoundingClientRect();o(r.rect,n)||(r.rect=n,t.push(r))})),t.forEach((function(t){t.callbacks.forEach((function(r){return r(t.rect)}))})),i=requestAnimationFrame(s)}exports.isFunction=function(t){return!(!t||"[object Function]"!=={}.toString.call(t))},exports.isUndefined=function(t){return void 0===t};
//# sourceMappingURL=index.js.map

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

export function arrayRemove(t,e){const n=[...t],o=n.indexOf(e);return-1!==o&&n.splice(o,1),n}export function arrayInsert(t,e,n){return[...t.slice(0,n),e,...t.slice(n)]}export function wrapArray(t,e){return t.map(((n,o)=>t[(e+o)%t.length]))}export function getPartDataAttr(t){return"data-".concat(function(t){const e=t.replace(".","").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return"".concat("interop-ui","-").concat(e)}(t))}export function getPartDataAttrObj(t){return{[getPartDataAttr(t)]:""}}export function canUseDOM(){return!("undefined"==typeof window||!window.document||!window.document.createElement)}export function makeId(...t){return t.filter((t=>null!=t)).join("-")}export const SIDE_OPTIONS=["top","right","bottom","left"];export const ALIGN_OPTIONS=["start","center","end"];export function makeRect({width:t,height:e},{x:n,y:o}){return{width:t,height:e,top:o,bottom:o+e,left:n,right:n+t}}export function getOppositeSide(t){return{top:"bottom",right:"left",bottom:"top",left:"right"}[t]}export function rectEquals(t,e){return t.width===e.width&&t.height===e.height&&t.top===e.top&&t.right===e.right&&t.bottom===e.bottom&&t.left===e.left}export function isInsideRect(t,e,{inclusive:n=!0}={}){return n?e.x>=t.left&&e.x<=t.right&&e.y>=t.top&&e.y<=t.bottom:e.x>t.left&&e.x<t.right&&e.y>t.top&&e.y<t.bottom}export function getCollisions(t,e=0){return{top:t.top<e,right:t.right>window.innerWidth-e,bottom:t.bottom>window.innerHeight-e,left:t.left<e}}const t={};export function warning(t,e){if(!t){0;try{throw new Error(e)}catch(t){}}}export function warningOnce(e,n,o){n||t[e]||(t[e]=!0,warning(!1,o))}export function clamp(t,[e,n]){return Math.min(n,Math.max(e,t))}export function wrap(t,e){return(e+t)%e}export function observeElementRect(t,r){const i=n.get(t);return void 0===i?(n.set(t,{rect:{},callbacks:[r]}),1===n.size&&(e=requestAnimationFrame(o))):i.callbacks.push(r),()=>{const o=n.get(t);if(void 0===o)return;const i=o.callbacks.indexOf(r);i>-1&&o.callbacks.splice(i,1),0===o.callbacks.length&&(n.delete(t),0===n.size&&cancelAnimationFrame(e))}}let e;const n=new Map;function o(){const t=[];n.forEach(((e,n)=>{const o=n.getBoundingClientRect();rectEquals(e.rect,o)||(e.rect=o,t.push(e))})),t.forEach((t=>{t.callbacks.forEach((e=>e(t.rect)))})),e=requestAnimationFrame(o)}export function isFunction(t){return!(!t||"[object Function]"!=={}.toString.call(t))}export function isUndefined(t){return void 0===t}
export function arrayRemove(t,e){const n=[...t],r=n.indexOf(e);return-1!==r&&n.splice(r,1),n}export function arrayInsert(t,e,n){return[...t.slice(0,n),e,...t.slice(n)]}export function wrapArray(t,e){return t.map(((n,r)=>t[(e+r)%t.length]))}export function namespaced(t){const e=t.replace(".","").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return"".concat("radix","-").concat(e)}export function getPartDataAttr(t){return"data-".concat(namespaced(t))}export function getPartDataAttrObj(t){return{[getPartDataAttr(t)]:""}}export function canUseDOM(){return!("undefined"==typeof window||!window.document||!window.document.createElement)}export function makeId(...t){return t.filter((t=>null!=t)).join("-")}export function isMainClick(t){return 0===t.button}export function getResizeObserverEntryBorderBoxSize(t){if("borderBoxSize"in t)return Array.isArray(t.borderBoxSize)?t.borderBoxSize[0]:t.borderBoxSize;const e=t.target.getBoundingClientRect();return{inlineSize:e.width,blockSize:e.height}}export const SIDE_OPTIONS=["top","right","bottom","left"];export const ALIGN_OPTIONS=["start","center","end"];export function makeRect({width:t,height:e},{x:n,y:r}){return DOMRect.fromRect({width:t,height:e,x:n,y:r})}export function getOppositeSide(t){return{top:"bottom",right:"left",bottom:"top",left:"right"}[t]}export function rectEquals(t,e){return t.width===e.width&&t.height===e.height&&t.top===e.top&&t.right===e.right&&t.bottom===e.bottom&&t.left===e.left}export function isInsideRect(t,e,{inclusive:n=!0}={}){return n?e.x>=t.left&&e.x<=t.right&&e.y>=t.top&&e.y<=t.bottom:e.x>t.left&&e.x<t.right&&e.y>t.top&&e.y<t.bottom}export function getCollisions(t,e=0){return{top:t.top<e,right:t.right>window.innerWidth-e,bottom:t.bottom>window.innerHeight-e,left:t.left<e}}const t={};export function warning(t,e){if(!t){0;try{throw new Error(e)}catch(t){}}}export function warningOnce(e,n,r){n||t[e]||(t[e]=!0,warning(!1,r))}export function clamp(t,[e,n]){return Math.min(n,Math.max(e,t))}export function wrap(t,e){return(e+t)%e}export function observeElementRect(t,o){const i=n.get(t);return void 0===i?(n.set(t,{rect:{},callbacks:[o]}),1===n.size&&(e=requestAnimationFrame(r))):i.callbacks.push(o),()=>{const r=n.get(t);if(void 0===r)return;const i=r.callbacks.indexOf(o);i>-1&&r.callbacks.splice(i,1),0===r.callbacks.length&&(n.delete(t),0===n.size&&cancelAnimationFrame(e))}}let e;const n=new Map;function r(){const t=[];n.forEach(((e,n)=>{const r=n.getBoundingClientRect();rectEquals(e.rect,r)||(e.rect=r,t.push(e))})),t.forEach((t=>{t.callbacks.forEach((e=>e(t.rect)))})),e=requestAnimationFrame(r)}export function isFunction(t){return!(!t||"[object Function]"!=={}.toString.call(t))}export function isUndefined(t){return void 0===t}
//# sourceMappingURL=index.module.js.map
{
"name": "@interop-ui/utils",
"version": "0.0.1-5",
"version": "0.0.1-6",
"license": "MIT",

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

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