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

58
frontend/node_modules/dnd-core/src/utils/coords.ts generated vendored Normal file
View File

@@ -0,0 +1,58 @@
import type { XYCoord } from '../interfaces.js'
import type { State } from '../reducers/dragOffset.js'
/**
* Coordinate addition
* @param a The first coordinate
* @param b The second coordinate
*/
export function add(a: XYCoord, b: XYCoord): XYCoord {
return {
x: a.x + b.x,
y: a.y + b.y,
}
}
/**
* Coordinate subtraction
* @param a The first coordinate
* @param b The second coordinate
*/
export function subtract(a: XYCoord, b: XYCoord): XYCoord {
return {
x: a.x - b.x,
y: a.y - b.y,
}
}
/**
* Returns the cartesian distance of the drag source component's position, based on its position
* at the time when the current drag operation has started, and the movement difference.
*
* Returns null if no item is being dragged.
*
* @param state The offset state to compute from
*/
export function getSourceClientOffset(state: State): XYCoord | null {
const { clientOffset, initialClientOffset, initialSourceClientOffset } = state
if (!clientOffset || !initialClientOffset || !initialSourceClientOffset) {
return null
}
return subtract(
add(clientOffset, initialSourceClientOffset),
initialClientOffset,
)
}
/**
* Determines the x,y offset between the client offset and the initial client offset
*
* @param state The offset state to compute from
*/
export function getDifferenceFromInitialOffset(state: State): XYCoord | null {
const { clientOffset, initialClientOffset } = state
if (!clientOffset || !initialClientOffset) {
return null
}
return subtract(clientOffset, initialClientOffset)
}

29
frontend/node_modules/dnd-core/src/utils/dirtiness.ts generated vendored Normal file
View File

@@ -0,0 +1,29 @@
import { intersection } from './js_utils.js'
export const NONE: string[] = []
export const ALL: string[] = []
// Add these flags for debug
;(NONE as any).__IS_NONE__ = true
;(ALL as any).__IS_ALL__ = true
/**
* Determines if the given handler IDs are dirty or not.
*
* @param dirtyIds The set of dirty handler ids
* @param handlerIds The set of handler ids to check
*/
export function areDirty(
dirtyIds: string[],
handlerIds: string[] | undefined,
): boolean {
if (dirtyIds === NONE) {
return false
}
if (dirtyIds === ALL || typeof handlerIds === 'undefined') {
return true
}
const commonIds = intersection(handlerIds, dirtyIds)
return commonIds.length > 0
}

43
frontend/node_modules/dnd-core/src/utils/equality.ts generated vendored Normal file
View File

@@ -0,0 +1,43 @@
import type { XYCoord } from '../interfaces.js'
export type EqualityCheck<T> = (a: T, b: T) => boolean
export const strictEquality = <T>(a: T, b: T): boolean => a === b
/**
* Determine if two cartesian coordinate offsets are equal
* @param offsetA
* @param offsetB
*/
export function areCoordsEqual(
offsetA: XYCoord | null | undefined,
offsetB: XYCoord | null | undefined,
): boolean {
if (!offsetA && !offsetB) {
return true
} else if (!offsetA || !offsetB) {
return false
} else {
return offsetA.x === offsetB.x && offsetA.y === offsetB.y
}
}
/**
* Determines if two arrays of items are equal
* @param a The first array of items
* @param b The second array of items
*/
export function areArraysEqual<T>(
a: T[],
b: T[],
isEqual: EqualityCheck<T> = strictEquality,
): boolean {
if (a.length !== b.length) {
return false
}
for (let i = 0; i < a.length; ++i) {
if (!isEqual(a[i] as T, b[i] as T)) {
return false
}
}
return true
}

View File

@@ -0,0 +1,5 @@
let nextUniqueId = 0
export function getNextUniqueId(): number {
return nextUniqueId++
}

67
frontend/node_modules/dnd-core/src/utils/js_utils.ts generated vendored Normal file
View File

@@ -0,0 +1,67 @@
// cheap lodash replacements
/**
* drop-in replacement for _.get
* @param obj
* @param path
* @param defaultValue
*/
export function get<T>(obj: any, path: string, defaultValue: T): T {
return path
.split('.')
.reduce((a, c) => (a && a[c] ? a[c] : defaultValue || null), obj) as T
}
/**
* drop-in replacement for _.without
*/
export function without<T>(items: T[], item: T): T[] {
return items.filter((i) => i !== item)
}
/**
* drop-in replacement for _.isString
* @param input
*/
export function isString(input: any): boolean {
return typeof input === 'string'
}
/**
* drop-in replacement for _.isString
* @param input
*/
export function isObject(input: any): boolean {
return typeof input === 'object'
}
/**
* replacement for _.xor
* @param itemsA
* @param itemsB
*/
export function xor<T extends string | number>(itemsA: T[], itemsB: T[]): T[] {
const map = new Map<T, number>()
const insertItem = (item: T) => {
map.set(item, map.has(item) ? (map.get(item) as number) + 1 : 1)
}
itemsA.forEach(insertItem)
itemsB.forEach(insertItem)
const result: T[] = []
map.forEach((count, key) => {
if (count === 1) {
result.push(key)
}
})
return result
}
/**
* replacement for _.intersection
* @param itemsA
* @param itemsB
*/
export function intersection<T>(itemsA: T[], itemsB: T[]): T[] {
return itemsA.filter((t) => itemsB.indexOf(t) > -1)
}

View File

@@ -0,0 +1,13 @@
import type { Identifier } from '../interfaces.js'
export function matchesType(
targetType: Identifier | Identifier[] | null,
draggedItemType: Identifier | null,
): boolean {
if (draggedItemType === null) {
return targetType === null
}
return Array.isArray(targetType)
? (targetType as Identifier[]).some((t) => t === draggedItemType)
: targetType === draggedItemType
}