Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mirohq/design-system-use-press

Package Overview
Dependencies
Maintainers
0
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mirohq/design-system-use-press - npm Package Compare versions

Comparing version 0.3.5 to 0.4.0

85

dist/main.js

@@ -625,2 +625,10 @@ 'use strict';

const patchStopPropagation = (event) => {
const originalMethod = event.stopPropagation;
event.stopPropagation = () => {
originalMethod.call(event);
event.isPropagationStopped = () => true;
};
};
const usePress = (props) => {

@@ -666,4 +674,4 @@ const {

const state = ref.current;
const triggerPressStart = (originalEvent, pointerType) => {
printLog("triggerPressStart", { originalEvent, pointerType });
const triggerPressStart = (event, pointerType) => {
printLog("triggerPressStart", { event, pointerType });
const { onPressStart: onPressStart2, onPressChange: onPressChange2, disabled: disabled2 } = propsRef.current;

@@ -676,8 +684,8 @@ if (disabled2 === true || state.didFirePressStart) {

pointerType,
target: originalEvent.currentTarget,
shiftKey: originalEvent.shiftKey,
metaKey: originalEvent.metaKey,
ctrlKey: originalEvent.ctrlKey,
altKey: originalEvent.altKey,
originalEvent: "event" in originalEvent ? originalEvent.event : originalEvent
target: event.currentTarget,
shiftKey: event.shiftKey,
metaKey: event.metaKey,
ctrlKey: event.ctrlKey,
altKey: event.altKey,
originalEvent: "event" in event ? event.event : event
});

@@ -688,4 +696,4 @@ onPressChange2 == null ? void 0 : onPressChange2(true);

};
const triggerPressUp = (originalEvent, pointerType) => {
printLog("triggerPressUp", { originalEvent, pointerType });
const triggerPressUp = (event, pointerType) => {
printLog("triggerPressUp", { event, pointerType });
const { onPressUp: onPressUp2, disabled: disabled2 } = propsRef.current;

@@ -698,12 +706,12 @@ if (disabled2 === true) {

pointerType,
target: originalEvent.currentTarget,
shiftKey: originalEvent.shiftKey,
metaKey: originalEvent.metaKey,
ctrlKey: originalEvent.ctrlKey,
altKey: originalEvent.altKey,
originalEvent: "event" in originalEvent ? originalEvent.event : originalEvent
target: event.currentTarget,
shiftKey: event.shiftKey,
metaKey: event.metaKey,
ctrlKey: event.ctrlKey,
altKey: event.altKey,
originalEvent: "event" in event ? event.event : event
});
};
const triggerPressEnd = (originalEvent, pointerType, wasPressed) => {
printLog("triggerPressEnd", { originalEvent, pointerType });
const triggerPressEnd = (event, pointerType, wasPressed) => {
printLog("triggerPressEnd", { event, pointerType });
const { onPressEnd: onPressEnd2, onPressChange: onPressChange2, onPress: onPress2, disabled: disabled2 } = propsRef.current;

@@ -713,25 +721,30 @@ if (!state.didFirePressStart) {

}
const originalEvent = "event" in event ? event.event : event;
state.didFirePressStart = false;
onPressEnd2 == null ? void 0 : onPressEnd2({
type: "pressend",
pointerType,
target: originalEvent.currentTarget,
shiftKey: originalEvent.shiftKey,
metaKey: originalEvent.metaKey,
ctrlKey: originalEvent.ctrlKey,
altKey: originalEvent.altKey,
originalEvent: "event" in originalEvent ? originalEvent.event : originalEvent
});
const isPropagationStopped = "isPropagationStopped" in originalEvent && originalEvent.isPropagationStopped();
patchStopPropagation(originalEvent);
if (!isPropagationStopped) {
onPressEnd2 == null ? void 0 : onPressEnd2({
type: "pressend",
pointerType,
target: event.currentTarget,
shiftKey: event.shiftKey,
metaKey: event.metaKey,
ctrlKey: event.ctrlKey,
altKey: event.altKey,
originalEvent
});
}
onPressChange2 == null ? void 0 : onPressChange2(false);
setIsPressed(false);
if (wasPressed && disabled2 !== true) {
if (wasPressed && disabled2 !== true && !isPropagationStopped) {
onPress2 == null ? void 0 : onPress2({
type: "press",
pointerType,
target: originalEvent.currentTarget,
shiftKey: originalEvent.shiftKey,
metaKey: originalEvent.metaKey,
ctrlKey: originalEvent.ctrlKey,
altKey: originalEvent.altKey,
originalEvent: "event" in originalEvent ? originalEvent.event : originalEvent
target: event.currentTarget,
shiftKey: event.shiftKey,
metaKey: event.metaKey,
ctrlKey: event.ctrlKey,
altKey: event.altKey,
originalEvent
});

@@ -746,3 +759,3 @@ }

altKey: e.altKey,
event: e
event: "event" in e ? e.event : e
});

@@ -749,0 +762,0 @@ const cancel = (e, state2) => {

@@ -621,2 +621,10 @@ import { useRef, useState, useEffect } from 'react';

const patchStopPropagation = (event) => {
const originalMethod = event.stopPropagation;
event.stopPropagation = () => {
originalMethod.call(event);
event.isPropagationStopped = () => true;
};
};
const usePress = (props) => {

@@ -662,4 +670,4 @@ const {

const state = ref.current;
const triggerPressStart = (originalEvent, pointerType) => {
printLog("triggerPressStart", { originalEvent, pointerType });
const triggerPressStart = (event, pointerType) => {
printLog("triggerPressStart", { event, pointerType });
const { onPressStart: onPressStart2, onPressChange: onPressChange2, disabled: disabled2 } = propsRef.current;

@@ -672,8 +680,8 @@ if (disabled2 === true || state.didFirePressStart) {

pointerType,
target: originalEvent.currentTarget,
shiftKey: originalEvent.shiftKey,
metaKey: originalEvent.metaKey,
ctrlKey: originalEvent.ctrlKey,
altKey: originalEvent.altKey,
originalEvent: "event" in originalEvent ? originalEvent.event : originalEvent
target: event.currentTarget,
shiftKey: event.shiftKey,
metaKey: event.metaKey,
ctrlKey: event.ctrlKey,
altKey: event.altKey,
originalEvent: "event" in event ? event.event : event
});

@@ -684,4 +692,4 @@ onPressChange2 == null ? void 0 : onPressChange2(true);

};
const triggerPressUp = (originalEvent, pointerType) => {
printLog("triggerPressUp", { originalEvent, pointerType });
const triggerPressUp = (event, pointerType) => {
printLog("triggerPressUp", { event, pointerType });
const { onPressUp: onPressUp2, disabled: disabled2 } = propsRef.current;

@@ -694,12 +702,12 @@ if (disabled2 === true) {

pointerType,
target: originalEvent.currentTarget,
shiftKey: originalEvent.shiftKey,
metaKey: originalEvent.metaKey,
ctrlKey: originalEvent.ctrlKey,
altKey: originalEvent.altKey,
originalEvent: "event" in originalEvent ? originalEvent.event : originalEvent
target: event.currentTarget,
shiftKey: event.shiftKey,
metaKey: event.metaKey,
ctrlKey: event.ctrlKey,
altKey: event.altKey,
originalEvent: "event" in event ? event.event : event
});
};
const triggerPressEnd = (originalEvent, pointerType, wasPressed) => {
printLog("triggerPressEnd", { originalEvent, pointerType });
const triggerPressEnd = (event, pointerType, wasPressed) => {
printLog("triggerPressEnd", { event, pointerType });
const { onPressEnd: onPressEnd2, onPressChange: onPressChange2, onPress: onPress2, disabled: disabled2 } = propsRef.current;

@@ -709,25 +717,30 @@ if (!state.didFirePressStart) {

}
const originalEvent = "event" in event ? event.event : event;
state.didFirePressStart = false;
onPressEnd2 == null ? void 0 : onPressEnd2({
type: "pressend",
pointerType,
target: originalEvent.currentTarget,
shiftKey: originalEvent.shiftKey,
metaKey: originalEvent.metaKey,
ctrlKey: originalEvent.ctrlKey,
altKey: originalEvent.altKey,
originalEvent: "event" in originalEvent ? originalEvent.event : originalEvent
});
const isPropagationStopped = "isPropagationStopped" in originalEvent && originalEvent.isPropagationStopped();
patchStopPropagation(originalEvent);
if (!isPropagationStopped) {
onPressEnd2 == null ? void 0 : onPressEnd2({
type: "pressend",
pointerType,
target: event.currentTarget,
shiftKey: event.shiftKey,
metaKey: event.metaKey,
ctrlKey: event.ctrlKey,
altKey: event.altKey,
originalEvent
});
}
onPressChange2 == null ? void 0 : onPressChange2(false);
setIsPressed(false);
if (wasPressed && disabled2 !== true) {
if (wasPressed && disabled2 !== true && !isPropagationStopped) {
onPress2 == null ? void 0 : onPress2({
type: "press",
pointerType,
target: originalEvent.currentTarget,
shiftKey: originalEvent.shiftKey,
metaKey: originalEvent.metaKey,
ctrlKey: originalEvent.ctrlKey,
altKey: originalEvent.altKey,
originalEvent: "event" in originalEvent ? originalEvent.event : originalEvent
target: event.currentTarget,
shiftKey: event.shiftKey,
metaKey: event.metaKey,
ctrlKey: event.ctrlKey,
altKey: event.altKey,
originalEvent
});

@@ -742,3 +755,3 @@ }

altKey: e.altKey,
event: e
event: "event" in e ? e.event : e
});

@@ -745,0 +758,0 @@ const cancel = (e, state2) => {

@@ -32,3 +32,3 @@ import { AriaAttributes, DOMAttributes as DOMAttributes$1, AriaRole, CSSProperties } from 'react';

/** The original event being fired. */
originalEvent: AllEvents | Event;
originalEvent: OriginalEvent;
}

@@ -76,15 +76,4 @@ interface PressEvents {

}
interface ScrollEvent extends Omit<EventBase, 'event'> {
event: Event;
}
declare type AllEvents = MouseEvent | KeyboardEvent | PointerEvent | EventBase | ScrollEvent | FocusableEvent;
declare type FocusableEvent = React.KeyboardEvent<FocusableElement> | React.MouseEvent<FocusableElement> | React.TouchEvent<FocusableElement> | React.DragEvent<FocusableElement> | React.PointerEvent<HTMLElement>;
interface EventBase {
currentTarget: EventTarget;
shiftKey: boolean;
ctrlKey: boolean;
metaKey: boolean;
altKey: boolean;
event: AllEvents;
}
declare type OriginalEvent = MouseEvent | KeyboardEvent | PointerEvent | FocusableEvent | Event;
interface PressResult {

@@ -91,0 +80,0 @@ /** Whether the target is currently pressed. */

{
"name": "@mirohq/design-system-use-press",
"version": "0.3.5",
"version": "0.4.0",
"description": "",

@@ -30,4 +30,4 @@ "author": "Miro",

"@mirohq/design-system-use-listeners": "^0.1.1",
"@mirohq/design-system-utils": "^0.15.4",
"@mirohq/design-system-use-logger": "^0.1.11"
"@mirohq/design-system-use-logger": "^0.1.11",
"@mirohq/design-system-utils": "^0.15.4"
},

@@ -34,0 +34,0 @@ "scripts": {

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