refactor(utils): rename function
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { memo } from 'react';
|
||||
import cx from 'classnames';
|
||||
|
||||
import { isInputNode } from '../../utils';
|
||||
import { inInputDOMNode } from '../../utils';
|
||||
import store from '../../store';
|
||||
|
||||
export default EdgeComponent => {
|
||||
@@ -12,7 +12,7 @@ export default EdgeComponent => {
|
||||
} = props;
|
||||
const edgeClasses = cx('react-flow__edge', { selected, animated });
|
||||
const onEdgeClick = (evt) => {
|
||||
if (isInputNode(evt)) {
|
||||
if (inInputDOMNode(evt)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState, memo } from 'react';
|
||||
import ReactDraggable from 'react-draggable';
|
||||
import cx from 'classnames';
|
||||
|
||||
import { getDimensions, isInputNode } from '../../utils';
|
||||
import { getDimensions, inInputDOMNode } from '../../utils';
|
||||
import { Provider } from '../../contexts/NodeIdContext';
|
||||
import store from '../../store';
|
||||
|
||||
@@ -45,7 +45,7 @@ const getHandleBounds = (sel, nodeElement, parentBounds, k) => {
|
||||
};
|
||||
|
||||
const onStart = (evt, { setOffset, onClick, id, type, data, position, transform }) => {
|
||||
if (isInputNode(evt) || isHandle(evt)) {
|
||||
if (inInputDOMNode(evt) || isHandle(evt)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
import { isInputNode } from '../utils';
|
||||
import { inInputDOMNode } from '../utils';
|
||||
|
||||
export default function useKeyPress(keyCode) {
|
||||
const [keyPressed, setKeyPressed] = useState(false);
|
||||
|
||||
function downHandler(evt) {
|
||||
if (evt.keyCode === keyCode && !isInputNode(evt.target)) {
|
||||
if (evt.keyCode === keyCode && !inInputDOMNode(evt.target)) {
|
||||
setKeyPressed(true);
|
||||
}
|
||||
}
|
||||
|
||||
const upHandler = (evt) => {
|
||||
if (evt.keyCode === keyCode && !isInputNode(evt.target)) {
|
||||
if (evt.keyCode === keyCode && !inInputDOMNode(evt.target)) {
|
||||
setKeyPressed(false);
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
export const isFunction = obj => !!(obj && obj.constructor && obj.call && obj.apply);
|
||||
|
||||
export const isInputNode = e => e && e.target && ['INPUT', 'SELECT', 'TEXTAREA'].includes(e.target.nodeName);
|
||||
export const inInputDOMNode = e => e && e.target && ['INPUT', 'SELECT', 'TEXTAREA'].includes(e.target.nodeName);
|
||||
|
||||
export const getDimensions = (node = {}) => ({
|
||||
width: node.offsetWidth,
|
||||
|
||||
Reference in New Issue
Block a user