@mirohq/design-system-utils
Advanced tools
Comparing version 0.14.0-use-press.1 to 0.14.0
@@ -35,11 +35,11 @@ 'use strict'; | ||
}; | ||
const removeEventProps = (props, exceptions) => Object.entries(props).reduce((result, [key, fn]) => { | ||
if (key.startsWith("on") && !exceptions.includes(key)) { | ||
return result; | ||
} | ||
return { | ||
...result, | ||
[key]: fn | ||
}; | ||
}, {}); | ||
const mergeRefs = (refs) => (value) => { | ||
refs.forEach((ref) => { | ||
if (typeof ref === "function") { | ||
ref(value); | ||
} else if (ref != null) { | ||
ref.current = value; | ||
} | ||
}); | ||
}; | ||
@@ -66,39 +66,8 @@ const mapKeysToVariants = (map, prop) => Object.keys(map).reduce((acc, key) => { | ||
const isOverTarget = (point, target) => { | ||
const rect = target.getBoundingClientRect(); | ||
const pointRect = getPointClientRect(point); | ||
return areRectanglesOverlapping(rect, pointRect); | ||
}; | ||
const getPointClientRect = (point) => { | ||
var _a, _b, _c, _d; | ||
const width = (_a = point.width) != null ? _a : 0; | ||
const height = (_b = point.height) != null ? _b : 0; | ||
const offsetX = (_c = width !== 0 ? width / 2 : point.radiusX) != null ? _c : 0; | ||
const offsetY = (_d = height !== 0 ? height / 2 : point.radiusY) != null ? _d : 0; | ||
return { | ||
top: point.clientY - offsetY, | ||
right: point.clientX + offsetX, | ||
bottom: point.clientY + offsetY, | ||
left: point.clientX - offsetX | ||
}; | ||
}; | ||
const areRectanglesOverlapping = (a, b) => { | ||
if (a.left > b.right || b.left > a.right) { | ||
return false; | ||
} | ||
if (a.top > b.bottom || b.top > a.bottom) { | ||
return false; | ||
} | ||
return true; | ||
}; | ||
exports.addPropsToChildren = addPropsToChildren; | ||
exports.areRectanglesOverlapping = areRectanglesOverlapping; | ||
exports.booleanify = booleanify; | ||
exports.createConstants = createConstants; | ||
exports.getPointClientRect = getPointClientRect; | ||
exports.isFragment = isFragment; | ||
exports.isOverTarget = isOverTarget; | ||
exports.mapKeysToVariants = mapKeysToVariants; | ||
exports.removeEventProps = removeEventProps; | ||
exports.mergeRefs = mergeRefs; | ||
//# sourceMappingURL=main.js.map |
@@ -31,11 +31,11 @@ import { Fragment, Children, cloneElement } from 'react'; | ||
}; | ||
const removeEventProps = (props, exceptions) => Object.entries(props).reduce((result, [key, fn]) => { | ||
if (key.startsWith("on") && !exceptions.includes(key)) { | ||
return result; | ||
} | ||
return { | ||
...result, | ||
[key]: fn | ||
}; | ||
}, {}); | ||
const mergeRefs = (refs) => (value) => { | ||
refs.forEach((ref) => { | ||
if (typeof ref === "function") { | ||
ref(value); | ||
} else if (ref != null) { | ||
ref.current = value; | ||
} | ||
}); | ||
}; | ||
@@ -62,31 +62,3 @@ const mapKeysToVariants = (map, prop) => Object.keys(map).reduce((acc, key) => { | ||
const isOverTarget = (point, target) => { | ||
const rect = target.getBoundingClientRect(); | ||
const pointRect = getPointClientRect(point); | ||
return areRectanglesOverlapping(rect, pointRect); | ||
}; | ||
const getPointClientRect = (point) => { | ||
var _a, _b, _c, _d; | ||
const width = (_a = point.width) != null ? _a : 0; | ||
const height = (_b = point.height) != null ? _b : 0; | ||
const offsetX = (_c = width !== 0 ? width / 2 : point.radiusX) != null ? _c : 0; | ||
const offsetY = (_d = height !== 0 ? height / 2 : point.radiusY) != null ? _d : 0; | ||
return { | ||
top: point.clientY - offsetY, | ||
right: point.clientX + offsetX, | ||
bottom: point.clientY + offsetY, | ||
left: point.clientX - offsetX | ||
}; | ||
}; | ||
const areRectanglesOverlapping = (a, b) => { | ||
if (a.left > b.right || b.left > a.right) { | ||
return false; | ||
} | ||
if (a.top > b.bottom || b.top > a.bottom) { | ||
return false; | ||
} | ||
return true; | ||
}; | ||
export { addPropsToChildren, areRectanglesOverlapping, booleanify, createConstants, getPointClientRect, isFragment, isOverTarget, mapKeysToVariants, removeEventProps }; | ||
export { addPropsToChildren, booleanify, createConstants, isFragment, mapKeysToVariants, mergeRefs }; | ||
//# sourceMappingURL=module.js.map |
@@ -0,1 +1,2 @@ | ||
import * as react from 'react'; | ||
import { ReactNode, ReactElement } from 'react'; | ||
@@ -18,8 +19,7 @@ import * as _stitches_react_types_css_util from '@stitches/react/types/css-util'; | ||
/** | ||
* Remove any `on` prop from an object | ||
* @param props object | ||
* @param exceptions array string starting with `on` | ||
* @returns props without keys starting by `on` | ||
* Set two refs inside the ref property in order to allow the use of the local ref and an external one | ||
* @param refs Array with both refs | ||
* @returns ref property | ||
*/ | ||
declare const removeEventProps: <T extends {}, Exceptions extends ("onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture")[] = []>(props: T, exceptions: Exceptions) => { [K in keyof T as K extends Exceptions ? never : K]: T[K]; }; | ||
declare const mergeRefs: <T = any>(refs: (react.MutableRefObject<T> | react.LegacyRef<T>)[]) => (instance: T | null) => void; | ||
@@ -47,20 +47,2 @@ declare type KeyVariants<KeyMap, Prop extends keyof CSSProperties> = { | ||
interface Rect { | ||
top: number; | ||
right: number; | ||
bottom: number; | ||
left: number; | ||
} | ||
interface EventPoint { | ||
clientX: number; | ||
clientY: number; | ||
width?: number; | ||
height?: number; | ||
radiusX?: number; | ||
radiusY?: number; | ||
} | ||
declare const isOverTarget: (point: EventPoint, target: Element) => boolean; | ||
declare const getPointClientRect: (point: EventPoint) => Rect; | ||
declare const areRectanglesOverlapping: (a: Rect, b: Rect) => boolean; | ||
export { addPropsToChildren, areRectanglesOverlapping, booleanify, createConstants, getPointClientRect, isFragment, isOverTarget, mapKeysToVariants, removeEventProps }; | ||
export { addPropsToChildren, booleanify, createConstants, isFragment, mapKeysToVariants, mergeRefs }; |
{ | ||
"name": "@mirohq/design-system-utils", | ||
"version": "0.14.0-use-press.1", | ||
"version": "0.14.0", | ||
"description": "", | ||
@@ -29,3 +29,3 @@ "author": "Miro", | ||
"dependencies": { | ||
"@mirohq/design-system-types": "^0.6.0-use-press.0" | ||
"@mirohq/design-system-types": "^0.5.0" | ||
}, | ||
@@ -32,0 +32,0 @@ "scripts": { |
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
17738
162
+ Added@mirohq/design-system-types@0.5.0(transitive)
- Removed@mirohq/design-system-types@0.6.2(transitive)