@mk-drag-and-drop/react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +594 -0
- package/dist/drag-context.d.ts +6 -0
- package/dist/drag-context.js +2 -0
- package/dist/drag-overlay.d.ts +18 -0
- package/dist/drag-overlay.js +80 -0
- package/dist/drag-provider.d.ts +21 -0
- package/dist/drag-provider.js +293 -0
- package/dist/hooks/use-drag-handle.d.ts +5 -0
- package/dist/hooks/use-drag-handle.js +7 -0
- package/dist/hooks/use-draggable.d.ts +9 -0
- package/dist/hooks/use-draggable.js +36 -0
- package/dist/hooks/use-drop-container.d.ts +9 -0
- package/dist/hooks/use-drop-container.js +56 -0
- package/dist/hooks/use-droppable.d.ts +10 -0
- package/dist/hooks/use-droppable.js +23 -0
- package/dist/hooks/use-remeasure-drop-targets.d.ts +2 -0
- package/dist/hooks/use-remeasure-drop-targets.js +12 -0
- package/dist/hooks/use-sortable.d.ts +13 -0
- package/dist/hooks/use-sortable.js +49 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +10 -0
- package/dist/modifiers/restrict-to-container.d.ts +4 -0
- package/dist/modifiers/restrict-to-container.js +10 -0
- package/dist/utils/compose-refs.d.ts +2 -0
- package/dist/utils/compose-refs.js +15 -0
- package/package.json +70 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
import { type DragModifier, type DragRect, type RestrictToContainerResolver } from "@mk-drag-and-drop/dom";
|
|
3
|
+
export type ReactRestrictToContainerInput = RefObject<HTMLElement | null> | RestrictToContainerResolver;
|
|
4
|
+
export declare function restrictToContainer(input: ReactRestrictToContainerInput): DragModifier<DragRect | null>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { restrictToContainer as restrictDomToContainer, } from "@mk-drag-and-drop/dom";
|
|
2
|
+
export function restrictToContainer(input) {
|
|
3
|
+
if (isRefObject(input)) {
|
|
4
|
+
return restrictDomToContainer(() => input.current);
|
|
5
|
+
}
|
|
6
|
+
return restrictDomToContainer(input);
|
|
7
|
+
}
|
|
8
|
+
function isRefObject(input) {
|
|
9
|
+
return typeof input === "object" && input !== null && "current" in input;
|
|
10
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mk-drag-and-drop/react",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React hooks and provider for the mk drag-and-drop DOM runtime.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://mkramer.dev",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/mkramerdev/mk-drag-and-drop.git",
|
|
10
|
+
"directory": "packages/mk-drag-and-drop/react"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/mkramerdev/mk-drag-and-drop/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"drag-and-drop",
|
|
17
|
+
"dnd",
|
|
18
|
+
"sortable",
|
|
19
|
+
"react",
|
|
20
|
+
"hooks",
|
|
21
|
+
"headless",
|
|
22
|
+
"typescript"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@mk-drag-and-drop/dom": "0.1.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": "^19.0.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@testing-library/dom": "^10.4.1",
|
|
48
|
+
"@testing-library/jest-dom": "^6.6.4",
|
|
49
|
+
"@testing-library/react": "^16.3.0",
|
|
50
|
+
"@testing-library/user-event": "^14.6.1",
|
|
51
|
+
"@types/react": "^19.2.17",
|
|
52
|
+
"@types/react-dom": "^19.2.3",
|
|
53
|
+
"eslint": "^8.57.0",
|
|
54
|
+
"jsdom": "^24.1.3",
|
|
55
|
+
"react": "^19.2.7",
|
|
56
|
+
"react-dom": "^19.2.7",
|
|
57
|
+
"vitest": "^2.1.9",
|
|
58
|
+
"typescript": "5.5.4",
|
|
59
|
+
"@repo/eslint-config": "0.0.0",
|
|
60
|
+
"@repo/typescript-config": "0.0.0"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
64
|
+
"build": "pnpm run clean && tsc -p tsconfig.json",
|
|
65
|
+
"dev": "tsc -p tsconfig.json --watch --preserveWatchOutput",
|
|
66
|
+
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
|
67
|
+
"test": "vitest run",
|
|
68
|
+
"test:watch": "vitest"
|
|
69
|
+
}
|
|
70
|
+
}
|