Initial commit: igny8 project

This commit is contained in:
igny8
2025-11-09 10:27:02 +00:00
commit 60b8188111
27265 changed files with 4360521 additions and 0 deletions

16
frontend/node_modules/react-dnd/src/core/DndContext.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
import type { DragDropManager } from 'dnd-core'
import { createContext } from 'react'
/**
* The React context type
*/
export interface DndContextType {
dragDropManager: DragDropManager | undefined
}
/**
* Create the React Context
*/
export const DndContext = createContext<DndContextType>({
dragDropManager: undefined,
})

View File

@@ -0,0 +1,93 @@
import type { BackendFactory, DragDropManager } from 'dnd-core'
import { createDragDropManager } from 'dnd-core'
import type { FC, ReactNode } from 'react'
import { memo, useEffect } from 'react'
import { DndContext } from './DndContext.js'
export type DndProviderProps<BackendContext, BackendOptions> =
| {
children?: ReactNode
manager: DragDropManager
}
| {
backend: BackendFactory
children?: ReactNode
context?: BackendContext
options?: BackendOptions
debugMode?: boolean
}
let refCount = 0
const INSTANCE_SYM = Symbol.for('__REACT_DND_CONTEXT_INSTANCE__')
/**
* A React component that provides the React-DnD context
*/
export const DndProvider: FC<DndProviderProps<unknown, unknown>> = memo(
function DndProvider({ children, ...props }) {
const [manager, isGlobalInstance] = getDndContextValue(props) // memoized from props
/**
* If the global context was used to store the DND context
* then where theres no more references to it we should
* clean it up to avoid memory leaks
*/
useEffect(() => {
if (isGlobalInstance) {
const context = getGlobalContext()
++refCount
return () => {
if (--refCount === 0) {
context[INSTANCE_SYM] = null
}
}
}
return
}, [])
return <DndContext.Provider value={manager}>{children}</DndContext.Provider>
},
)
function getDndContextValue(props: DndProviderProps<unknown, unknown>) {
if ('manager' in props) {
const manager = { dragDropManager: props.manager }
return [manager, false]
}
const manager = createSingletonDndContext(
props.backend,
props.context,
props.options,
props.debugMode,
)
const isGlobalInstance = !props.context
return [manager, isGlobalInstance]
}
function createSingletonDndContext<BackendContext, BackendOptions>(
backend: BackendFactory,
context: BackendContext = getGlobalContext(),
options: BackendOptions,
debugMode?: boolean,
) {
const ctx = context as any
if (!ctx[INSTANCE_SYM]) {
ctx[INSTANCE_SYM] = {
dragDropManager: createDragDropManager(
backend,
context,
options,
debugMode,
),
}
}
return ctx[INSTANCE_SYM]
}
declare const global: any
function getGlobalContext() {
return typeof global !== 'undefined' ? global : (window as any)
}

View File

@@ -0,0 +1,34 @@
import type { FC } from 'react'
import { memo, useEffect } from 'react'
import type { ConnectDragPreview } from '../types/index.js'
export interface DragPreviewImageProps {
connect: ConnectDragPreview
src: string
}
/**
* A utility for rendering a drag preview image
*/
export const DragPreviewImage: FC<DragPreviewImageProps> = memo(
function DragPreviewImage({ connect, src }) {
useEffect(() => {
if (typeof Image === 'undefined') return
let connected = false
const img = new Image()
img.src = src
img.onload = () => {
connect(img)
connected = true
}
return () => {
if (connected) {
connect(null)
}
}
})
return null
},
)

3
frontend/node_modules/react-dnd/src/core/index.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export * from './DndContext.js'
export * from './DndProvider.js'
export * from './DragPreviewImage.js'