New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dnd-core

Package Overview
Dependencies
Maintainers
5
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dnd-core - npm Package Compare versions

Comparing version 14.0.1 to 15.0.0

lib/actions/dragDrop/beginDrag.js.map

2

lib/actions/dragDrop/beginDrag.d.ts

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

import { Action, DragDropManager, BeginDragPayload, BeginDragOptions, Identifier } from '../../interfaces';
import type { Action, DragDropManager, BeginDragPayload, BeginDragOptions, Identifier } from '../../interfaces';
export declare function createBeginDrag(manager: DragDropManager): (sourceIds?: Identifier[], options?: BeginDragOptions) => Action<BeginDragPayload> | undefined;

@@ -9,10 +9,10 @@ import { invariant } from '@react-dnd/invariant';

clientOffset: null,
sourceClientOffset: null,
},
sourceClientOffset: null
}
};
export function createBeginDrag(manager) {
return function beginDrag(sourceIds = [], options = {
publishSource: true,
publishSource: true
}) {
const { publishSource = true, clientOffset, getSourceClientOffset, } = options;
const { publishSource =true , clientOffset , getSourceClientOffset , } = options;
const monitor = manager.getMonitor();

@@ -57,4 +57,4 @@ const registry = manager.getRegistry();

sourceClientOffset: sourceClientOffset || null,
isSourcePublic: !!publishSource,
},
isSourcePublic: !!publishSource
}
};

@@ -65,3 +65,3 @@ };

invariant(!monitor.isDragging(), 'Cannot call beginDrag while dragging.');
sourceIds.forEach(function (sourceId) {
sourceIds.forEach(function(sourceId) {
invariant(registry.getSource(sourceId), 'Expected sourceIds to be registered.');

@@ -78,3 +78,3 @@ });

let sourceId = null;
for (let i = sourceIds.length - 1; i >= 0; i--) {
for(let i = sourceIds.length - 1; i >= 0; i--){
if (monitor.canDragSource(sourceIds[i])) {

@@ -87,1 +87,3 @@ sourceId = sourceIds[i];

}
//# sourceMappingURL=beginDrag.js.map

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

import { DragDropManager } from '../../interfaces';
import type { DragDropManager } from '../../interfaces';
export declare function createDrop(manager: DragDropManager): (options?: {}) => void;
import { invariant } from '@react-dnd/invariant';
import { DROP } from './types';
import { isObject } from '../../utils/js_utils';
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === "function") {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function(key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
export function createDrop(manager) {

@@ -11,3 +39,3 @@ return function drop(options = {}) {

// Multiple actions are dispatched here, which is why this doesn't return an action
targetIds.forEach((targetId, index) => {
targetIds.forEach((targetId, index)=>{
const dropResult = determineDropResult(targetId, index, registry, monitor);

@@ -17,7 +45,4 @@ const action = {

payload: {
dropResult: {
...options,
...dropResult,
},
},
dropResult: _objectSpread({}, options, dropResult)
}
};

@@ -45,7 +70,7 @@ manager.dispatch(action);

function getDroppableTargets(monitor) {
const targetIds = monitor
.getTargetIds()
.filter(monitor.canDropOnTarget, monitor);
const targetIds = monitor.getTargetIds().filter(monitor.canDropOnTarget, monitor);
targetIds.reverse();
return targetIds;
}
//# sourceMappingURL=drop.js.map

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

import { DragDropManager, SentinelAction } from '../../interfaces';
import type { DragDropManager, SentinelAction } from '../../interfaces';
export declare function createEndDrag(manager: DragDropManager): () => SentinelAction;

@@ -14,3 +14,5 @@ import { invariant } from '@react-dnd/invariant';

}
return { type: END_DRAG };
return {
type: END_DRAG
};
};

@@ -21,1 +23,3 @@ }

}
//# sourceMappingURL=endDrag.js.map

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

import { Action, DragDropManager, HoverPayload, HoverOptions } from '../../interfaces';
import type { Action, DragDropManager, HoverPayload, HoverOptions } from '../../interfaces';
export declare function createHover(manager: DragDropManager): (targetIdsArg: string[], { clientOffset }?: HoverOptions) => Action<HoverPayload>;

@@ -5,3 +5,3 @@ import { invariant } from '@react-dnd/invariant';

export function createHover(manager) {
return function hover(targetIdsArg, { clientOffset } = {}) {
return function hover(targetIdsArg, { clientOffset } = {}) {
verifyTargetIdsIsArray(targetIdsArg);

@@ -19,4 +19,4 @@ const targetIds = targetIdsArg.slice(0);

targetIds,
clientOffset: clientOffset || null,
},
clientOffset: clientOffset || null
}
};

@@ -31,3 +31,3 @@ };

invariant(!monitor.didDrop(), 'Cannot call hover after drop.');
for (let i = 0; i < targetIds.length; i++) {
for(let i = 0; i < targetIds.length; i++){
const targetId = targetIds[i];

@@ -43,3 +43,3 @@ invariant(targetIds.lastIndexOf(targetId) === i, 'Expected targetIds to be unique in the passed array.');

// non-matching targets.
for (let i = targetIds.length - 1; i >= 0; i--) {
for(let i = targetIds.length - 1; i >= 0; i--){
const targetId = targetIds[i];

@@ -54,3 +54,3 @@ const targetType = registry.getTargetType(targetId);

// Finally call hover on all matching targets.
targetIds.forEach(function (targetId) {
targetIds.forEach(function(targetId) {
const target = registry.getTarget(targetId);

@@ -60,1 +60,3 @@ target.hover(monitor, targetId);

}
//# sourceMappingURL=hover.js.map

@@ -1,3 +0,3 @@

import { DragDropManager, DragDropActions } from '../../interfaces';
import type { DragDropManager, DragDropActions } from '../../interfaces';
export * from './types';
export declare function createDragDropActions(manager: DragDropManager): DragDropActions;

@@ -13,4 +13,6 @@ import { createBeginDrag } from './beginDrag';

drop: createDrop(manager),
endDrag: createEndDrag(manager),
endDrag: createEndDrag(manager)
};
}
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

import { XYCoord } from '../../../interfaces';
import { AnyAction } from 'redux';
import type { XYCoord } from '../../../interfaces';
import type { AnyAction } from 'redux';
export declare function setClientOffset(clientOffset: XYCoord | null | undefined, sourceClientOffset?: XYCoord | null | undefined): AnyAction;

@@ -7,5 +7,7 @@ import { INIT_COORDS } from '../types';

sourceClientOffset: sourceClientOffset || null,
clientOffset: clientOffset || null,
},
clientOffset: clientOffset || null
}
};
}
//# sourceMappingURL=setClientOffset.js.map

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

import { DragDropManager, SentinelAction } from '../../interfaces';
import type { DragDropManager, SentinelAction } from '../../interfaces';
export declare function createPublishDragSource(manager: DragDropManager): () => SentinelAction | undefined;

@@ -6,5 +6,9 @@ import { PUBLISH_DRAG_SOURCE } from './types';

if (monitor.isDragging()) {
return { type: PUBLISH_DRAG_SOURCE };
return {
type: PUBLISH_DRAG_SOURCE
};
}
};
}
//# sourceMappingURL=publishDragSource.js.map

@@ -7,1 +7,3 @@ export const INIT_COORDS = 'dnd-core/INIT_COORDS';

export const END_DRAG = 'dnd-core/END_DRAG';
//# sourceMappingURL=types.js.map

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

import { Action, SourceIdPayload, TargetIdPayload } from '../interfaces';
import type { Action, SourceIdPayload, TargetIdPayload } from '../interfaces';
export declare const ADD_SOURCE = "dnd-core/ADD_SOURCE";

@@ -3,0 +3,0 @@ export declare const ADD_TARGET = "dnd-core/ADD_TARGET";

@@ -9,4 +9,4 @@ export const ADD_SOURCE = 'dnd-core/ADD_SOURCE';

payload: {
sourceId,
},
sourceId
}
};

@@ -18,4 +18,4 @@ }

payload: {
targetId,
},
targetId
}
};

@@ -27,4 +27,4 @@ }

payload: {
sourceId,
},
sourceId
}
};

@@ -36,5 +36,7 @@ }

payload: {
targetId,
},
targetId
}
};
}
//# sourceMappingURL=registry.js.map

@@ -1,4 +0,4 @@

import { Store, Action } from 'redux';
import { Backend, DragDropActions, DragDropMonitor, DragDropManager, HandlerRegistry } from '../interfaces';
import { State } from '../reducers';
import type { Store, Action } from 'redux';
import type { State } from '../reducers';
import type { Backend, DragDropActions, DragDropMonitor, DragDropManager, HandlerRegistry } from '../interfaces';
export declare class DragDropManagerImpl implements DragDropManager {

@@ -5,0 +5,0 @@ private store;

import { createDragDropActions } from '../actions/dragDrop';
export class DragDropManagerImpl {
store;
monitor;
backend;
isSetUp = false;
constructor(store, monitor) {
this.store = store;
this.monitor = monitor;
store.subscribe(this.handleRefCountChange);
}
receiveBackend(backend) {

@@ -25,7 +16,6 @@ this.backend = backend;

getActions() {
/* eslint-disable-next-line @typescript-eslint/no-this-alias */
const manager = this;
const { dispatch } = this.store;
/* eslint-disable-next-line @typescript-eslint/no-this-alias */ const manager = this;
const { dispatch } = this.store;
function bindActionCreator(actionCreator) {
return (...args) => {
return (...args)=>{
const action = actionCreator.apply(manager, args);

@@ -38,3 +28,3 @@ if (typeof action !== 'undefined') {

const actions = createDragDropActions(this);
return Object.keys(actions).reduce((boundActions, key) => {
return Object.keys(actions).reduce((boundActions, key)=>{
const action = actions[key];

@@ -48,15 +38,22 @@ boundActions[key] = bindActionCreator(action);

}
handleRefCountChange = () => {
const shouldSetUp = this.store.getState().refCount > 0;
if (this.backend) {
if (shouldSetUp && !this.isSetUp) {
this.backend.setup();
this.isSetUp = true;
constructor(store, monitor){
this.isSetUp = false;
this.handleRefCountChange = ()=>{
const shouldSetUp = this.store.getState().refCount > 0;
if (this.backend) {
if (shouldSetUp && !this.isSetUp) {
this.backend.setup();
this.isSetUp = true;
} else if (!shouldSetUp && this.isSetUp) {
this.backend.teardown();
this.isSetUp = false;
}
}
else if (!shouldSetUp && this.isSetUp) {
this.backend.teardown();
this.isSetUp = false;
}
}
};
};
this.store = store;
this.monitor = monitor;
store.subscribe(this.handleRefCountChange);
}
}
//# sourceMappingURL=DragDropManagerImpl.js.map

@@ -1,4 +0,4 @@

import { Store } from 'redux';
import type { Store } from 'redux';
import { State } from '../reducers';
import { DragDropMonitor, Listener, Unsubscribe, XYCoord, HandlerRegistry, Identifier } from '../interfaces';
import type { DragDropMonitor, Listener, Unsubscribe, XYCoord, HandlerRegistry, Identifier } from '../interfaces';
export declare class DragDropMonitorImpl implements DragDropMonitor {

@@ -5,0 +5,0 @@ private store;

import { invariant } from '@react-dnd/invariant';
import { matchesType } from '../utils/matchesType';
import { getSourceClientOffset, getDifferenceFromInitialOffset, } from '../utils/coords';
import { getSourceClientOffset, getDifferenceFromInitialOffset } from '../utils/coords';
import { areDirty } from '../utils/dirtiness';
export class DragDropMonitorImpl {
store;
registry;
constructor(store, registry) {
this.store = store;
this.registry = registry;
}
subscribeToStateChange(listener, options = { handlerIds: undefined }) {
const { handlerIds } = options;
subscribeToStateChange(listener, options = {
handlerIds: undefined
}) {
const { handlerIds } = options;
invariant(typeof listener === 'function', 'listener must be a function.');
invariant(typeof handlerIds === 'undefined' || Array.isArray(handlerIds), 'handlerIds, when specified, must be an array of strings.');
let prevStateId = this.store.getState().stateId;
const handleChange = () => {
const handleChange = ()=>{
const state = this.store.getState();
const currentStateId = state.stateId;
try {
const canSkipListener = currentStateId === prevStateId ||
(currentStateId === prevStateId + 1 &&
!areDirty(state.dirtyHandlerIds, handlerIds));
const canSkipListener = currentStateId === prevStateId || currentStateId === prevStateId + 1 && !areDirty(state.dirtyHandlerIds, handlerIds);
if (!canSkipListener) {
listener();
}
}
finally {
} finally{
prevStateId = currentStateId;

@@ -37,3 +30,3 @@ }

let previousState = this.store.getState().dragOffset;
const handleChange = () => {
const handleChange = ()=>{
const nextState = this.store.getState().dragOffset;

@@ -71,3 +64,3 @@ if (nextState === previousState) {

const draggedItemType = this.getItemType();
return (matchesType(targetType, draggedItemType) && target.canDrop(this, targetId));
return matchesType(targetType, draggedItemType) && target.canDrop(this, targetId);
}

@@ -94,3 +87,5 @@ isDragging() {

}
isOverTarget(targetId, options = { shallow: false }) {
isOverTarget(targetId, options = {
shallow: false
}) {
// undefined on initial render

@@ -100,3 +95,3 @@ if (!targetId) {

}
const { shallow } = options;
const { shallow } = options;
if (!this.isDragging()) {

@@ -117,4 +112,3 @@ return false;

return index === targetIds.length - 1;
}
else {
} else {
return index > -1;

@@ -159,2 +153,8 @@ }

}
constructor(store, registry){
this.store = store;
this.registry = registry;
}
}
//# sourceMappingURL=DragDropMonitorImpl.js.map

@@ -1,3 +0,3 @@

import { Store } from 'redux';
import { State } from '../reducers';
import type { Store } from 'redux';
import type { State } from '../reducers';
import { DragSource, DropTarget, SourceType, TargetType, Identifier, HandlerRegistry } from '../interfaces';

@@ -4,0 +4,0 @@ export declare class HandlerRegistryImpl implements HandlerRegistry {

import { invariant } from '@react-dnd/invariant';
import { addSource, addTarget, removeSource, removeTarget, } from '../actions/registry';
import { addSource, addTarget, removeSource, removeTarget } from '../actions/registry';
import { getNextUniqueId } from '../utils/getNextUniqueId';
import { HandlerRole, } from '../interfaces';
import { validateSourceContract, validateTargetContract, validateType, } from '../contracts';
import { HandlerRole } from '../interfaces';
import { validateSourceContract, validateTargetContract, validateType } from '../contracts';
import { asap } from '@react-dnd/asap';
function getNextHandlerId(role) {
const id = getNextUniqueId().toString();
switch (role) {
switch(role){
case HandlerRole.SOURCE:

@@ -19,3 +19,3 @@ return `S${id}`;

function parseRoleFromHandlerId(handlerId) {
switch (handlerId[0]) {
switch(handlerId[0]){
case 'S':

@@ -33,3 +33,3 @@ return HandlerRole.SOURCE;

do {
const { done, value: [, value], } = entries.next();
const { done , value: [, value] , } = entries.next();
if (value === searchValue) {

@@ -39,15 +39,6 @@ return true;

isDone = !!done;
} while (!isDone);
}while (!isDone)
return false;
}
export class HandlerRegistryImpl {
types = new Map();
dragSources = new Map();
dropTargets = new Map();
pinnedSourceId = null;
pinnedSource = null;
store;
constructor(store) {
this.store = store;
}
addSource(type, source) {

@@ -68,4 +59,3 @@ validateType(type);

containsHandler(handler) {
return (mapContainsValue(this.dragSources, handler) ||
mapContainsValue(this.dropTargets, handler));
return mapContainsValue(this.dragSources, handler) || mapContainsValue(this.dropTargets, handler);
}

@@ -101,3 +91,3 @@ getSource(sourceId, includePinned = false) {

this.store.dispatch(removeSource(sourceId));
asap(() => {
asap(()=>{
this.dragSources.delete(sourceId);

@@ -129,4 +119,3 @@ this.types.delete(sourceId);

this.dragSources.set(id, handler);
}
else if (role === HandlerRole.TARGET) {
} else if (role === HandlerRole.TARGET) {
this.dropTargets.set(id, handler);

@@ -136,2 +125,12 @@ }

}
constructor(store){
this.types = new Map();
this.dragSources = new Map();
this.dropTargets = new Map();
this.pinnedSourceId = null;
this.pinnedSource = null;
this.store = store;
}
}
//# sourceMappingURL=HandlerRegistryImpl.js.map

@@ -1,4 +0,4 @@

import { DragSource, DropTarget, Identifier } from './interfaces';
import type { DragSource, DropTarget, Identifier } from './interfaces';
export declare function validateSourceContract(source: DragSource): void;
export declare function validateTargetContract(target: DropTarget): void;
export declare function validateType(type: Identifier | Identifier[], allowArray?: boolean): void;

@@ -14,8 +14,9 @@ import { invariant } from '@react-dnd/invariant';

if (allowArray && Array.isArray(type)) {
type.forEach((t) => validateType(t, false));
type.forEach((t)=>validateType(t, false)
);
return;
}
invariant(typeof type === 'string' || typeof type === 'symbol', allowArray
? 'Type can only be a string, a symbol, or an array of either.'
: 'Type can only be a string or a symbol.');
invariant(typeof type === 'string' || typeof type === 'symbol', allowArray ? 'Type can only be a string, a symbol, or an array of either.' : 'Type can only be a string or a symbol.');
}
//# sourceMappingURL=contracts.js.map

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

import { DragDropManager, BackendFactory } from './interfaces';
import type { DragDropManager, BackendFactory } from './interfaces';
export declare function createDragDropManager(backendFactory: BackendFactory, globalContext?: unknown, backendOptions?: unknown, debugMode?: boolean): DragDropManager;

@@ -17,10 +17,9 @@ import { DragDropManagerImpl } from './classes/DragDropManagerImpl';

// we'll need to consider how to pull off dev-tooling
const reduxDevTools = typeof window !== 'undefined' &&
window.__REDUX_DEVTOOLS_EXTENSION__;
return createStore(reduce, debugMode &&
reduxDevTools &&
reduxDevTools({
name: 'dnd-core',
instanceId: 'dnd-core',
}));
const reduxDevTools = typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__;
return createStore(reduce, debugMode && reduxDevTools && reduxDevTools({
name: 'dnd-core',
instanceId: 'dnd-core'
}));
}
//# sourceMappingURL=createDragDropManager.js.map
export * from './interfaces';
export * from './createDragDropManager';
//# sourceMappingURL=index.js.map
export var HandlerRole;
(function (HandlerRole) {
(function(HandlerRole) {
HandlerRole["SOURCE"] = "SOURCE";
HandlerRole["TARGET"] = "TARGET";
})(HandlerRole || (HandlerRole = {}));
//# sourceMappingURL=interfaces.js.map

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

import { Action } from '../interfaces';
import type { Action } from '../interfaces';
export declare type State = string[];

@@ -3,0 +3,0 @@ export interface DirtyHandlerIdPayload {

@@ -1,10 +0,9 @@

import { BEGIN_DRAG, PUBLISH_DRAG_SOURCE, HOVER, END_DRAG, DROP, } from '../actions/dragDrop';
import { ADD_SOURCE, ADD_TARGET, REMOVE_SOURCE, REMOVE_TARGET, } from '../actions/registry';
import { BEGIN_DRAG, PUBLISH_DRAG_SOURCE, HOVER, END_DRAG, DROP } from '../actions/dragDrop';
import { ADD_SOURCE, ADD_TARGET, REMOVE_SOURCE, REMOVE_TARGET } from '../actions/registry';
import { areArraysEqual } from '../utils/equality';
import { NONE, ALL } from '../utils/dirtiness';
import { xor } from '../utils/js_utils';
export function reduce(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function reduce(// eslint-disable-next-line @typescript-eslint/no-unused-vars
_state = NONE, action) {
switch (action.type) {
switch(action.type){
case HOVER:

@@ -24,3 +23,3 @@ break;

}
const { targetIds = [], prevTargetIds = [] } = action.payload;
const { targetIds =[] , prevTargetIds =[] } = action.payload;
const result = xor(targetIds, prevTargetIds);

@@ -45,1 +44,3 @@ const didChange = result.length > 0 || !areArraysEqual(targetIds, prevTargetIds);

}
//# sourceMappingURL=dirtyHandlerIds.js.map

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

import { XYCoord, Action } from '../interfaces';
import type { XYCoord, Action } from '../interfaces';
export interface State {

@@ -3,0 +3,0 @@ initialSourceClientOffset: XYCoord | null;

@@ -1,11 +0,39 @@

import { INIT_COORDS, BEGIN_DRAG, HOVER, END_DRAG, DROP, } from '../actions/dragDrop';
import { INIT_COORDS, BEGIN_DRAG, HOVER, END_DRAG, DROP } from '../actions/dragDrop';
import { areCoordsEqual } from '../utils/equality';
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === "function") {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function(key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
const initialState = {
initialSourceClientOffset: null,
initialClientOffset: null,
clientOffset: null,
clientOffset: null
};
export function reduce(state = initialState, action) {
const { payload } = action;
switch (action.type) {
const { payload } = action;
switch(action.type){
case INIT_COORDS:

@@ -16,3 +44,3 @@ case BEGIN_DRAG:

initialClientOffset: payload.clientOffset,
clientOffset: payload.clientOffset,
clientOffset: payload.clientOffset
};

@@ -23,6 +51,5 @@ case HOVER:

}
return {
...state,
clientOffset: payload.clientOffset,
};
return _objectSpread({}, state, {
clientOffset: payload.clientOffset
});
case END_DRAG:

@@ -35,1 +62,3 @@ case DROP:

}
//# sourceMappingURL=dragOffset.js.map

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

import { Identifier, Action } from '../interfaces';
import type { Identifier, Action } from '../interfaces';
export interface State {

@@ -3,0 +3,0 @@ itemType: Identifier | Identifier[] | null;

@@ -1,4 +0,32 @@

import { BEGIN_DRAG, PUBLISH_DRAG_SOURCE, HOVER, END_DRAG, DROP, } from '../actions/dragDrop';
import { BEGIN_DRAG, PUBLISH_DRAG_SOURCE, HOVER, END_DRAG, DROP } from '../actions/dragDrop';
import { REMOVE_TARGET } from '../actions/registry';
import { without } from '../utils/js_utils';
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === "function") {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function(key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
const initialState = {

@@ -11,10 +39,9 @@ itemType: null,

didDrop: false,
isSourcePublic: null,
isSourcePublic: null
};
export function reduce(state = initialState, action) {
const { payload } = action;
switch (action.type) {
const { payload } = action;
switch(action.type){
case BEGIN_DRAG:
return {
...state,
return _objectSpread({}, state, {
itemType: payload.itemType,

@@ -25,14 +52,12 @@ item: payload.item,

dropResult: null,
didDrop: false,
};
didDrop: false
});
case PUBLISH_DRAG_SOURCE:
return {
...state,
isSourcePublic: true,
};
return _objectSpread({}, state, {
isSourcePublic: true
});
case HOVER:
return {
...state,
targetIds: payload.targetIds,
};
return _objectSpread({}, state, {
targetIds: payload.targetIds
});
case REMOVE_TARGET:

@@ -42,16 +67,13 @@ if (state.targetIds.indexOf(payload.targetId) === -1) {

}
return {
...state,
targetIds: without(state.targetIds, payload.targetId),
};
return _objectSpread({}, state, {
targetIds: without(state.targetIds, payload.targetId)
});
case DROP:
return {
...state,
return _objectSpread({}, state, {
dropResult: payload.dropResult,
didDrop: true,
targetIds: [],
};
targetIds: []
});
case END_DRAG:
return {
...state,
return _objectSpread({}, state, {
itemType: null,

@@ -63,4 +85,4 @@ item: null,

isSourcePublic: null,
targetIds: [],
};
targetIds: []
});
default:

@@ -70,1 +92,3 @@ return state;

}
//# sourceMappingURL=dragOperation.js.map

@@ -6,3 +6,3 @@ import { State as DragOffsetState } from './dragOffset';

import { State as StateIdState } from './stateId';
import { Action } from '../interfaces';
import type { Action } from '../interfaces';
export interface State {

@@ -9,0 +9,0 @@ dirtyHandlerIds: DirtyHandlerIdsState;

import { reduce as dragOffset } from './dragOffset';
import { reduce as dragOperation, } from './dragOperation';
import { reduce as dragOperation } from './dragOperation';
import { reduce as refCount } from './refCount';
import { reduce as dirtyHandlerIds, } from './dirtyHandlerIds';
import { reduce as dirtyHandlerIds } from './dirtyHandlerIds';
import { reduce as stateId } from './stateId';
import { get } from '../utils/js_utils';
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === "function") {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function(key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
export function reduce(state = {}, action) {

@@ -11,6 +39,5 @@ return {

type: action.type,
payload: {
...action.payload,
prevTargetIds: get(state, 'dragOperation.targetIds', []),
},
payload: _objectSpread({}, action.payload, {
prevTargetIds: get(state, 'dragOperation.targetIds', [])
})
}),

@@ -20,4 +47,6 @@ dragOffset: dragOffset(state.dragOffset, action),

dragOperation: dragOperation(state.dragOperation, action),
stateId: stateId(state.stateId),
stateId: stateId(state.stateId)
};
}
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

import { Action } from '../interfaces';
import type { Action } from '../interfaces';
export declare type State = number;
export declare function reduce(state: number | undefined, action: Action<any>): State;

@@ -1,4 +0,4 @@

import { ADD_SOURCE, ADD_TARGET, REMOVE_SOURCE, REMOVE_TARGET, } from '../actions/registry';
import { ADD_SOURCE, ADD_TARGET, REMOVE_SOURCE, REMOVE_TARGET } from '../actions/registry';
export function reduce(state = 0, action) {
switch (action.type) {
switch(action.type){
case ADD_SOURCE:

@@ -14,1 +14,3 @@ case ADD_TARGET:

}
//# sourceMappingURL=refCount.js.map
export function reduce(state = 0) {
return state + 1;
}
//# sourceMappingURL=stateId.js.map

@@ -1,3 +0,3 @@

import { State } from '../reducers/dragOffset';
import { XYCoord } from '..';
import type { State } from '../reducers/dragOffset';
import type { XYCoord } from '..';
/**

@@ -4,0 +4,0 @@ * Coordinate addition

@@ -5,7 +5,6 @@ /**

* @param b The second coordinate
*/
export function add(a, b) {
*/ export function add(a, b) {
return {
x: a.x + b.x,
y: a.y + b.y,
y: a.y + b.y
};

@@ -17,7 +16,6 @@ }

* @param b The second coordinate
*/
export function subtract(a, b) {
*/ export function subtract(a, b) {
return {
x: a.x - b.x,
y: a.y - b.y,
y: a.y - b.y
};

@@ -32,5 +30,4 @@ }

* @param state The offset state to compute from
*/
export function getSourceClientOffset(state) {
const { clientOffset, initialClientOffset, initialSourceClientOffset } = state;
*/ export function getSourceClientOffset(state) {
const { clientOffset , initialClientOffset , initialSourceClientOffset } = state;
if (!clientOffset || !initialClientOffset || !initialSourceClientOffset) {

@@ -45,5 +42,4 @@ return null;

* @param state The offset state to compute from
*/
export function getDifferenceFromInitialOffset(state) {
const { clientOffset, initialClientOffset } = state;
*/ export function getDifferenceFromInitialOffset(state) {
const { clientOffset , initialClientOffset } = state;
if (!clientOffset || !initialClientOffset) {

@@ -54,1 +50,3 @@ return null;

}
//# sourceMappingURL=coords.js.map

@@ -11,4 +11,3 @@ import { intersection } from './js_utils';

* @param handlerIds The set of handler ids to check
*/
export function areDirty(dirtyIds, handlerIds) {
*/ export function areDirty(dirtyIds, handlerIds) {
if (dirtyIds === NONE) {

@@ -23,1 +22,3 @@ return false;

}
//# sourceMappingURL=dirtiness.js.map

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

import { XYCoord } from '../interfaces';
import type { XYCoord } from '../interfaces';
export declare type EqualityCheck<T> = (a: T, b: T) => boolean;

@@ -3,0 +3,0 @@ export declare const strictEquality: <T>(a: T, b: T) => boolean;

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

export const strictEquality = (a, b) => a === b;
export const strictEquality = (a, b)=>a === b
;
/**

@@ -6,11 +7,8 @@ * Determine if two cartesian coordinate offsets are equal

* @param offsetB
*/
export function areCoordsEqual(offsetA, offsetB) {
*/ export function areCoordsEqual(offsetA, offsetB) {
if (!offsetA && !offsetB) {
return true;
}
else if (!offsetA || !offsetB) {
} else if (!offsetA || !offsetB) {
return false;
}
else {
} else {
return offsetA.x === offsetB.x && offsetA.y === offsetB.y;

@@ -23,8 +21,7 @@ }

* @param b The second array of items
*/
export function areArraysEqual(a, b, isEqual = strictEquality) {
*/ export function areArraysEqual(a, b, isEqual = strictEquality) {
if (a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; ++i) {
for(let i = 0; i < a.length; ++i){
if (!isEqual(a[i], b[i])) {

@@ -36,1 +33,3 @@ return false;

}
//# sourceMappingURL=equality.js.map

@@ -5,1 +5,3 @@ let nextUniqueId = 0;

}
//# sourceMappingURL=getNextUniqueId.js.map

@@ -23,3 +23,3 @@ /**

/**
* repalcement for _.xor
* replacement for _.xor
* @param itemsA

@@ -26,0 +26,0 @@ * @param itemsB

@@ -7,13 +7,11 @@ // cheap lodash replacements

* @param defaultValue
*/
export function get(obj, path, defaultValue) {
return path
.split('.')
.reduce((a, c) => (a && a[c] ? a[c] : defaultValue || null), obj);
*/ export function get(obj, path, defaultValue) {
return path.split('.').reduce((a, c)=>a && a[c] ? a[c] : defaultValue || null
, obj);
}
/**
* drop-in replacement for _.without
*/
export function without(items, item) {
return items.filter((i) => i !== item);
*/ export function without(items, item) {
return items.filter((i)=>i !== item
);
}

@@ -23,4 +21,3 @@ /**

* @param input
*/
export function isString(input) {
*/ export function isString(input) {
return typeof input === 'string';

@@ -31,14 +28,12 @@ }

* @param input
*/
export function isObject(input) {
*/ export function isObject(input) {
return typeof input === 'object';
}
/**
* repalcement for _.xor
* replacement for _.xor
* @param itemsA
* @param itemsB
*/
export function xor(itemsA, itemsB) {
*/ export function xor(itemsA, itemsB) {
const map = new Map();
const insertItem = (item) => {
const insertItem = (item)=>{
map.set(item, map.has(item) ? map.get(item) + 1 : 1);

@@ -49,3 +44,3 @@ };

const result = [];
map.forEach((count, key) => {
map.forEach((count, key)=>{
if (count === 1) {

@@ -61,5 +56,7 @@ result.push(key);

* @param itemsB
*/
export function intersection(itemsA, itemsB) {
return itemsA.filter((t) => itemsB.indexOf(t) > -1);
*/ export function intersection(itemsA, itemsB) {
return itemsA.filter((t)=>itemsB.indexOf(t) > -1
);
}
//# sourceMappingURL=js_utils.js.map

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

import { Identifier } from '../interfaces';
import type { Identifier } from '../interfaces';
export declare function matchesType(targetType: Identifier | Identifier[] | null, draggedItemType: Identifier | null): boolean;

@@ -5,5 +5,6 @@ export function matchesType(targetType, draggedItemType) {

}
return Array.isArray(targetType)
? targetType.some((t) => t === draggedItemType)
: targetType === draggedItemType;
return Array.isArray(targetType) ? targetType.some((t)=>t === draggedItemType
) : targetType === draggedItemType;
}
//# sourceMappingURL=matchesType.js.map
{
"name": "dnd-core",
"version": "14.0.1",
"version": "15.0.0",
"description": "Drag and drop sans the GUI",
"license": "MIT",
"main": "dist/cjs/index.js",
"publishConfig": {
"main:bundle": "dist/esm/index.js",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts"
},
"type": "module",
"exports": "./lib/index.js",
"types": "./lib/index.d.ts",
"sideEffects": false,
"scripts": {
"build": "gulp build",
"clean": "gulp clean",
"watch": "gulp watch"
"build": "tsc -b . && swc src -d lib",
"clean": "shx rm -rf dist/ lib/"
},

@@ -29,10 +24,10 @@ "repository": {

"devDependencies": {
"@react-dnd/build": "12.0.0",
"@swc/cli": "^0.1.55",
"@swc/core": "^1.2.135",
"@types/setimmediate": "^1.0.2",
"gulp": "^4.0.2",
"react-dnd-test-backend": "portal:../backend-test",
"setimmediate": "^1.0.5"
},
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts"
"setimmediate": "^1.0.5",
"shx": "^0.3.4",
"typescript": "^4.5.5"
}
}

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