Update Fix
This commit is contained in:
36
node_modules/react-dnd-html5-backend/src/NativeDragSources/index.ts
generated
vendored
Normal file
36
node_modules/react-dnd-html5-backend/src/NativeDragSources/index.ts
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import { NativeDragSource } from './NativeDragSource.js'
|
||||
import { nativeTypesConfig } from './nativeTypesConfig.js'
|
||||
|
||||
export function createNativeDragSource(
|
||||
type: string,
|
||||
dataTransfer?: DataTransfer,
|
||||
): NativeDragSource {
|
||||
const config = nativeTypesConfig[type]
|
||||
if (!config) {
|
||||
throw new Error(`native type ${type} has no configuration`)
|
||||
}
|
||||
const result = new NativeDragSource(config)
|
||||
result.loadDataTransfer(dataTransfer)
|
||||
return result
|
||||
}
|
||||
|
||||
export function matchNativeItemType(
|
||||
dataTransfer: DataTransfer | null,
|
||||
): string | null {
|
||||
if (!dataTransfer) {
|
||||
return null
|
||||
}
|
||||
|
||||
const dataTransferTypes = Array.prototype.slice.call(dataTransfer.types || [])
|
||||
return (
|
||||
Object.keys(nativeTypesConfig).filter((nativeItemType) => {
|
||||
const typeConfig = nativeTypesConfig[nativeItemType]
|
||||
if (!typeConfig?.matchesTypes) {
|
||||
return false
|
||||
}
|
||||
return typeConfig.matchesTypes.some(
|
||||
(t) => dataTransferTypes.indexOf(t) > -1,
|
||||
)
|
||||
})[0] || null
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user