init 3
This commit is contained in:
38
node_modules/dnd-core/dist/actions/registry.js
generated
vendored
Normal file
38
node_modules/dnd-core/dist/actions/registry.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
export const ADD_SOURCE = 'dnd-core/ADD_SOURCE';
|
||||
export const ADD_TARGET = 'dnd-core/ADD_TARGET';
|
||||
export const REMOVE_SOURCE = 'dnd-core/REMOVE_SOURCE';
|
||||
export const REMOVE_TARGET = 'dnd-core/REMOVE_TARGET';
|
||||
export function addSource(sourceId) {
|
||||
return {
|
||||
type: ADD_SOURCE,
|
||||
payload: {
|
||||
sourceId
|
||||
}
|
||||
};
|
||||
}
|
||||
export function addTarget(targetId) {
|
||||
return {
|
||||
type: ADD_TARGET,
|
||||
payload: {
|
||||
targetId
|
||||
}
|
||||
};
|
||||
}
|
||||
export function removeSource(sourceId) {
|
||||
return {
|
||||
type: REMOVE_SOURCE,
|
||||
payload: {
|
||||
sourceId
|
||||
}
|
||||
};
|
||||
}
|
||||
export function removeTarget(targetId) {
|
||||
return {
|
||||
type: REMOVE_TARGET,
|
||||
payload: {
|
||||
targetId
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=registry.js.map
|
||||
129
node_modules/dnd-core/dist/classes/HandlerRegistryImpl.js
generated
vendored
Normal file
129
node_modules/dnd-core/dist/classes/HandlerRegistryImpl.js
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
import { asap } from '@react-dnd/asap';
|
||||
import { invariant } from '@react-dnd/invariant';
|
||||
import { addSource, addTarget, removeSource, removeTarget } from '../actions/registry.js';
|
||||
import { validateSourceContract, validateTargetContract, validateType } from '../contracts.js';
|
||||
import { HandlerRole } from '../interfaces.js';
|
||||
import { getNextUniqueId } from '../utils/getNextUniqueId.js';
|
||||
function getNextHandlerId(role) {
|
||||
const id = getNextUniqueId().toString();
|
||||
switch(role){
|
||||
case HandlerRole.SOURCE:
|
||||
return `S${id}`;
|
||||
case HandlerRole.TARGET:
|
||||
return `T${id}`;
|
||||
default:
|
||||
throw new Error(`Unknown Handler Role: ${role}`);
|
||||
}
|
||||
}
|
||||
function parseRoleFromHandlerId(handlerId) {
|
||||
switch(handlerId[0]){
|
||||
case 'S':
|
||||
return HandlerRole.SOURCE;
|
||||
case 'T':
|
||||
return HandlerRole.TARGET;
|
||||
default:
|
||||
throw new Error(`Cannot parse handler ID: ${handlerId}`);
|
||||
}
|
||||
}
|
||||
function mapContainsValue(map, searchValue) {
|
||||
const entries = map.entries();
|
||||
let isDone = false;
|
||||
do {
|
||||
const { done , value: [, value] , } = entries.next();
|
||||
if (value === searchValue) {
|
||||
return true;
|
||||
}
|
||||
isDone = !!done;
|
||||
}while (!isDone)
|
||||
return false;
|
||||
}
|
||||
export class HandlerRegistryImpl {
|
||||
addSource(type, source) {
|
||||
validateType(type);
|
||||
validateSourceContract(source);
|
||||
const sourceId = this.addHandler(HandlerRole.SOURCE, type, source);
|
||||
this.store.dispatch(addSource(sourceId));
|
||||
return sourceId;
|
||||
}
|
||||
addTarget(type, target) {
|
||||
validateType(type, true);
|
||||
validateTargetContract(target);
|
||||
const targetId = this.addHandler(HandlerRole.TARGET, type, target);
|
||||
this.store.dispatch(addTarget(targetId));
|
||||
return targetId;
|
||||
}
|
||||
containsHandler(handler) {
|
||||
return mapContainsValue(this.dragSources, handler) || mapContainsValue(this.dropTargets, handler);
|
||||
}
|
||||
getSource(sourceId, includePinned = false) {
|
||||
invariant(this.isSourceId(sourceId), 'Expected a valid source ID.');
|
||||
const isPinned = includePinned && sourceId === this.pinnedSourceId;
|
||||
const source = isPinned ? this.pinnedSource : this.dragSources.get(sourceId);
|
||||
return source;
|
||||
}
|
||||
getTarget(targetId) {
|
||||
invariant(this.isTargetId(targetId), 'Expected a valid target ID.');
|
||||
return this.dropTargets.get(targetId);
|
||||
}
|
||||
getSourceType(sourceId) {
|
||||
invariant(this.isSourceId(sourceId), 'Expected a valid source ID.');
|
||||
return this.types.get(sourceId);
|
||||
}
|
||||
getTargetType(targetId) {
|
||||
invariant(this.isTargetId(targetId), 'Expected a valid target ID.');
|
||||
return this.types.get(targetId);
|
||||
}
|
||||
isSourceId(handlerId) {
|
||||
const role = parseRoleFromHandlerId(handlerId);
|
||||
return role === HandlerRole.SOURCE;
|
||||
}
|
||||
isTargetId(handlerId) {
|
||||
const role = parseRoleFromHandlerId(handlerId);
|
||||
return role === HandlerRole.TARGET;
|
||||
}
|
||||
removeSource(sourceId) {
|
||||
invariant(this.getSource(sourceId), 'Expected an existing source.');
|
||||
this.store.dispatch(removeSource(sourceId));
|
||||
asap(()=>{
|
||||
this.dragSources.delete(sourceId);
|
||||
this.types.delete(sourceId);
|
||||
});
|
||||
}
|
||||
removeTarget(targetId) {
|
||||
invariant(this.getTarget(targetId), 'Expected an existing target.');
|
||||
this.store.dispatch(removeTarget(targetId));
|
||||
this.dropTargets.delete(targetId);
|
||||
this.types.delete(targetId);
|
||||
}
|
||||
pinSource(sourceId) {
|
||||
const source = this.getSource(sourceId);
|
||||
invariant(source, 'Expected an existing source.');
|
||||
this.pinnedSourceId = sourceId;
|
||||
this.pinnedSource = source;
|
||||
}
|
||||
unpinSource() {
|
||||
invariant(this.pinnedSource, 'No source is pinned at the time.');
|
||||
this.pinnedSourceId = null;
|
||||
this.pinnedSource = null;
|
||||
}
|
||||
addHandler(role, type, handler) {
|
||||
const id = getNextHandlerId(role);
|
||||
this.types.set(id, type);
|
||||
if (role === HandlerRole.SOURCE) {
|
||||
this.dragSources.set(id, handler);
|
||||
} else if (role === HandlerRole.TARGET) {
|
||||
this.dropTargets.set(id, handler);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
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
node_modules/dnd-core/dist/index.js.map
generated
vendored
Normal file
1
node_modules/dnd-core/dist/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './createDragDropManager.js'\nexport * from './interfaces.js'\n"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iBAAiB,CAAA"}
|
||||
15
node_modules/dnd-core/dist/reducers/refCount.js
generated
vendored
Normal file
15
node_modules/dnd-core/dist/reducers/refCount.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { ADD_SOURCE, ADD_TARGET, REMOVE_SOURCE, REMOVE_TARGET } from '../actions/registry.js';
|
||||
export function reduce(state = 0, action) {
|
||||
switch(action.type){
|
||||
case ADD_SOURCE:
|
||||
case ADD_TARGET:
|
||||
return state + 1;
|
||||
case REMOVE_SOURCE:
|
||||
case REMOVE_TARGET:
|
||||
return state - 1;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=refCount.js.map
|
||||
1
node_modules/dnd-core/dist/utils/dirtiness.js.map
generated
vendored
Normal file
1
node_modules/dnd-core/dist/utils/dirtiness.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/utils/dirtiness.ts"],"sourcesContent":["import { intersection } from './js_utils.js'\n\nexport const NONE: string[] = []\nexport const ALL: string[] = []\n// Add these flags for debug\n;(NONE as any).__IS_NONE__ = true\n;(ALL as any).__IS_ALL__ = true\n\n/**\n * Determines if the given handler IDs are dirty or not.\n *\n * @param dirtyIds The set of dirty handler ids\n * @param handlerIds The set of handler ids to check\n */\nexport function areDirty(\n\tdirtyIds: string[],\n\thandlerIds: string[] | undefined,\n): boolean {\n\tif (dirtyIds === NONE) {\n\t\treturn false\n\t}\n\n\tif (dirtyIds === ALL || typeof handlerIds === 'undefined') {\n\t\treturn true\n\t}\n\n\tconst commonIds = intersection(handlerIds, dirtyIds)\n\treturn commonIds.length > 0\n}\n"],"names":["intersection","NONE","ALL","__IS_NONE__","__IS_ALL__","areDirty","dirtyIds","handlerIds","commonIds","length"],"mappings":"AAAA,SAASA,YAAY,QAAQ,eAAe,CAAA;AAE5C,OAAO,MAAMC,IAAI,GAAa,EAAE,CAAA;AAChC,OAAO,MAAMC,GAAG,GAAa,EAAE,CAE9B;AAAA,AAACD,IAAI,CAASE,WAAW,GAAG,IAAI,CAChC;AAAA,AAACD,GAAG,CAASE,UAAU,GAAG,IAAI;AAE/B;;;;;GAKG,CACH,OAAO,SAASC,QAAQ,CACvBC,QAAkB,EAClBC,UAAgC,EACtB;IACV,IAAID,QAAQ,KAAKL,IAAI,EAAE;QACtB,OAAO,KAAK,CAAA;KACZ;IAED,IAAIK,QAAQ,KAAKJ,GAAG,IAAI,OAAOK,UAAU,KAAK,WAAW,EAAE;QAC1D,OAAO,IAAI,CAAA;KACX;IAED,MAAMC,SAAS,GAAGR,YAAY,CAACO,UAAU,EAAED,QAAQ,CAAC;IACpD,OAAOE,SAAS,CAACC,MAAM,GAAG,CAAC,CAAA;CAC3B"}
|
||||
1
node_modules/dnd-core/dist/utils/getNextUniqueId.js.map
generated
vendored
Normal file
1
node_modules/dnd-core/dist/utils/getNextUniqueId.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/utils/getNextUniqueId.ts"],"sourcesContent":["let nextUniqueId = 0\n\nexport function getNextUniqueId(): number {\n\treturn nextUniqueId++\n}\n"],"names":["nextUniqueId","getNextUniqueId"],"mappings":"AAAA,IAAIA,YAAY,GAAG,CAAC;AAEpB,OAAO,SAASC,eAAe,GAAW;IACzC,OAAOD,YAAY,EAAE,CAAA;CACrB"}
|
||||
5
node_modules/dnd-core/src/utils/getNextUniqueId.ts
generated
vendored
Normal file
5
node_modules/dnd-core/src/utils/getNextUniqueId.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
let nextUniqueId = 0
|
||||
|
||||
export function getNextUniqueId(): number {
|
||||
return nextUniqueId++
|
||||
}
|
||||
Reference in New Issue
Block a user