@pyreon/dnd 0.14.0 → 0.16.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/lib/analysis/index.js.html +1 -1
- package/lib/index.js +3 -1
- package/lib/types/index.d.ts +13 -4
- package/package.json +9 -7
- package/src/tests/dnd.test.ts +26 -0
- package/src/types.ts +13 -4
- package/src/use-file-drop.browser.test.tsx +148 -0
- package/src/use-sortable.ts +12 -6
- package/lib/index.js.map +0 -1
- package/lib/types/index.d.ts.map +0 -1
|
@@ -5386,7 +5386,7 @@ var drawChart = (function (exports) {
|
|
|
5386
5386
|
</script>
|
|
5387
5387
|
<script>
|
|
5388
5388
|
/*<!--*/
|
|
5389
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"
|
|
5389
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"0889448f-1","name":"use-drag-monitor.ts"},{"uid":"0889448f-3","name":"use-draggable.ts"},{"uid":"0889448f-5","name":"use-droppable.ts"},{"uid":"0889448f-7","name":"use-file-drop.ts"},{"uid":"0889448f-9","name":"use-sortable.ts"},{"uid":"0889448f-11","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"0889448f-1":{"renderedLength":1307,"gzipLength":625,"brotliLength":0,"metaUid":"0889448f-0"},"0889448f-3":{"renderedLength":1312,"gzipLength":600,"brotliLength":0,"metaUid":"0889448f-2"},"0889448f-5":{"renderedLength":1361,"gzipLength":597,"brotliLength":0,"metaUid":"0889448f-4"},"0889448f-7":{"renderedLength":2300,"gzipLength":939,"brotliLength":0,"metaUid":"0889448f-6"},"0889448f-9":{"renderedLength":5920,"gzipLength":2016,"brotliLength":0,"metaUid":"0889448f-8"},"0889448f-11":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"0889448f-10"}},"nodeMetas":{"0889448f-0":{"id":"/src/use-drag-monitor.ts","moduleParts":{"index.js":"0889448f-1"},"imported":[{"uid":"0889448f-12"},{"uid":"0889448f-13"}],"importedBy":[{"uid":"0889448f-10"}]},"0889448f-2":{"id":"/src/use-draggable.ts","moduleParts":{"index.js":"0889448f-3"},"imported":[{"uid":"0889448f-12"},{"uid":"0889448f-13"}],"importedBy":[{"uid":"0889448f-10"}]},"0889448f-4":{"id":"/src/use-droppable.ts","moduleParts":{"index.js":"0889448f-5"},"imported":[{"uid":"0889448f-12"},{"uid":"0889448f-13"}],"importedBy":[{"uid":"0889448f-10"}]},"0889448f-6":{"id":"/src/use-file-drop.ts","moduleParts":{"index.js":"0889448f-7"},"imported":[{"uid":"0889448f-14"},{"uid":"0889448f-15"},{"uid":"0889448f-13"}],"importedBy":[{"uid":"0889448f-10"}]},"0889448f-8":{"id":"/src/use-sortable.ts","moduleParts":{"index.js":"0889448f-9"},"imported":[{"uid":"0889448f-16"},{"uid":"0889448f-12"},{"uid":"0889448f-17"},{"uid":"0889448f-18"},{"uid":"0889448f-13"}],"importedBy":[{"uid":"0889448f-10"}]},"0889448f-10":{"id":"/src/index.ts","moduleParts":{"index.js":"0889448f-11"},"imported":[{"uid":"0889448f-0"},{"uid":"0889448f-2"},{"uid":"0889448f-4"},{"uid":"0889448f-6"},{"uid":"0889448f-8"}],"importedBy":[],"isEntry":true},"0889448f-12":{"id":"@atlaskit/pragmatic-drag-and-drop/element/adapter","moduleParts":{},"imported":[],"importedBy":[{"uid":"0889448f-0"},{"uid":"0889448f-2"},{"uid":"0889448f-4"},{"uid":"0889448f-8"}]},"0889448f-13":{"id":"@pyreon/reactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"0889448f-0"},{"uid":"0889448f-2"},{"uid":"0889448f-4"},{"uid":"0889448f-6"},{"uid":"0889448f-8"}]},"0889448f-14":{"id":"@atlaskit/pragmatic-drag-and-drop/external/adapter","moduleParts":{},"imported":[],"importedBy":[{"uid":"0889448f-6"}]},"0889448f-15":{"id":"@atlaskit/pragmatic-drag-and-drop/external/file","moduleParts":{},"imported":[],"importedBy":[{"uid":"0889448f-6"}]},"0889448f-16":{"id":"@atlaskit/pragmatic-drag-and-drop/combine","moduleParts":{},"imported":[],"importedBy":[{"uid":"0889448f-8"}]},"0889448f-17":{"id":"@atlaskit/pragmatic-drag-and-drop-auto-scroll/element","moduleParts":{},"imported":[],"importedBy":[{"uid":"0889448f-8"}]},"0889448f-18":{"id":"@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge","moduleParts":{},"imported":[],"importedBy":[{"uid":"0889448f-8"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
5390
5390
|
|
|
5391
5391
|
const run = () => {
|
|
5392
5392
|
const width = window.innerWidth;
|
package/lib/index.js
CHANGED
|
@@ -296,7 +296,7 @@ let _sortableCounter = 0;
|
|
|
296
296
|
*/
|
|
297
297
|
function useSortable(options) {
|
|
298
298
|
if (typeof document === "undefined") {
|
|
299
|
-
const noop = () => {};
|
|
299
|
+
const noop = (_el) => {};
|
|
300
300
|
return {
|
|
301
301
|
containerRef: noop,
|
|
302
302
|
itemRef: () => noop,
|
|
@@ -330,6 +330,7 @@ function useSortable(options) {
|
|
|
330
330
|
options.onReorder(reordered);
|
|
331
331
|
}
|
|
332
332
|
function containerRef(el) {
|
|
333
|
+
if (!el) return;
|
|
333
334
|
cleanups.push(autoScrollForElements({
|
|
334
335
|
element: el,
|
|
335
336
|
canScroll: ({ source }) => source.data[SORT_ID] === sortableId
|
|
@@ -378,6 +379,7 @@ function useSortable(options) {
|
|
|
378
379
|
}
|
|
379
380
|
function itemRef(key) {
|
|
380
381
|
return (el) => {
|
|
382
|
+
if (!el) return;
|
|
381
383
|
el.dataset.pyreonSortKey = String(key);
|
|
382
384
|
if (!el.hasAttribute("tabindex")) el.setAttribute("tabindex", "0");
|
|
383
385
|
el.setAttribute("role", "listitem");
|
package/lib/types/index.d.ts
CHANGED
|
@@ -57,10 +57,19 @@ interface UseSortableOptions<T> {
|
|
|
57
57
|
axis?: 'vertical' | 'horizontal';
|
|
58
58
|
}
|
|
59
59
|
interface UseSortableResult {
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Attach to the scroll container. Pyreon's runtime invokes refs with
|
|
62
|
+
* `T | null` (called with `null` on unmount), so the parameter widens
|
|
63
|
+
* accordingly. The hook ignores `null` calls — they're a no-op
|
|
64
|
+
* because the underlying pdnd cleanup is registered via `onCleanup`.
|
|
65
|
+
*/
|
|
66
|
+
containerRef: (el: HTMLElement | null) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Attach to each sortable item. Call with the item's key — the
|
|
69
|
+
* returned callback accepts `T | null` for the same Pyreon `RefProp`
|
|
70
|
+
* compatibility reason as `containerRef` above.
|
|
71
|
+
*/
|
|
72
|
+
itemRef: (key: string | number) => (el: HTMLElement | null) => void;
|
|
64
73
|
/** The key of the currently dragging item. */
|
|
65
74
|
activeId: () => string | number | null;
|
|
66
75
|
/** The key of the item being hovered over. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/dnd",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Signal-driven drag and drop for Pyreon — wraps @atlaskit/pragmatic-drag-and-drop",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/pyreon/pyreon/issues"
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"lib",
|
|
16
|
+
"!lib/**/*.map",
|
|
16
17
|
"src",
|
|
17
18
|
"README.md",
|
|
18
19
|
"LICENSE"
|
|
@@ -33,19 +34,20 @@
|
|
|
33
34
|
"build": "vl_rolldown_build",
|
|
34
35
|
"dev": "vl_rolldown_build-watch",
|
|
35
36
|
"test": "vitest run",
|
|
37
|
+
"test:browser": "vitest run --config ./vitest.browser.config.ts",
|
|
36
38
|
"typecheck": "tsc --noEmit",
|
|
37
39
|
"lint": "oxlint ."
|
|
38
40
|
},
|
|
39
41
|
"dependencies": {
|
|
40
42
|
"@atlaskit/pragmatic-drag-and-drop": "^1.7.10",
|
|
41
43
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.0.0",
|
|
42
|
-
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0"
|
|
44
|
+
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
|
|
45
|
+
"@pyreon/core": "^0.16.0",
|
|
46
|
+
"@pyreon/reactivity": "^0.16.0"
|
|
43
47
|
},
|
|
44
48
|
"devDependencies": {
|
|
45
|
-
"@pyreon/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"@pyreon/core": "^0.14.0",
|
|
49
|
-
"@pyreon/reactivity": "^0.14.0"
|
|
49
|
+
"@pyreon/test-utils": "^0.13.3",
|
|
50
|
+
"@pyreon/typescript": "^0.16.0",
|
|
51
|
+
"@vitest/browser-playwright": "^4.1.4"
|
|
50
52
|
}
|
|
51
53
|
}
|
package/src/tests/dnd.test.ts
CHANGED
|
@@ -158,6 +158,32 @@ describe('useSortable', () => {
|
|
|
158
158
|
expect(el.dataset.pyreonSortKey).toBe('1')
|
|
159
159
|
})
|
|
160
160
|
|
|
161
|
+
it('containerRef and itemRef accept null without throwing (Pyreon RefProp contract)', async () => {
|
|
162
|
+
// Regression: Pyreon's runtime invokes ref callbacks with `el | null`
|
|
163
|
+
// — `null` on unmount. Previously the exported types were
|
|
164
|
+
// `(el: HTMLElement) => void` (non-null), forcing every consumer to
|
|
165
|
+
// wrap with adapter callbacks. The hook now accepts `null` and
|
|
166
|
+
// no-ops — pdnd's per-element cleanups are registered via
|
|
167
|
+
// `onCleanup`, so the unmount path is already covered.
|
|
168
|
+
const { useSortable } = await import('../use-sortable')
|
|
169
|
+
const items = signal([{ id: '1' }, { id: '2' }])
|
|
170
|
+
|
|
171
|
+
const { containerRef, itemRef } = useSortable({
|
|
172
|
+
items,
|
|
173
|
+
by: (item) => item.id,
|
|
174
|
+
onReorder: () => {},
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
expect(() => containerRef(null)).not.toThrow()
|
|
178
|
+
expect(() => itemRef('1')(null)).not.toThrow()
|
|
179
|
+
|
|
180
|
+
// Sanity: a real element still wires up the ARIA attributes after a
|
|
181
|
+
// prior null call (idempotent — the null path didn't poison state).
|
|
182
|
+
const el = document.createElement('div')
|
|
183
|
+
itemRef('1')(el)
|
|
184
|
+
expect(el.getAttribute('role')).toBe('listitem')
|
|
185
|
+
})
|
|
186
|
+
|
|
161
187
|
it('does not override existing tabindex', async () => {
|
|
162
188
|
const { useSortable } = await import('../use-sortable')
|
|
163
189
|
const items = signal([{ id: '1' }])
|
package/src/types.ts
CHANGED
|
@@ -70,10 +70,19 @@ export interface UseSortableOptions<T> {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
export interface UseSortableResult {
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Attach to the scroll container. Pyreon's runtime invokes refs with
|
|
75
|
+
* `T | null` (called with `null` on unmount), so the parameter widens
|
|
76
|
+
* accordingly. The hook ignores `null` calls — they're a no-op
|
|
77
|
+
* because the underlying pdnd cleanup is registered via `onCleanup`.
|
|
78
|
+
*/
|
|
79
|
+
containerRef: (el: HTMLElement | null) => void
|
|
80
|
+
/**
|
|
81
|
+
* Attach to each sortable item. Call with the item's key — the
|
|
82
|
+
* returned callback accepts `T | null` for the same Pyreon `RefProp`
|
|
83
|
+
* compatibility reason as `containerRef` above.
|
|
84
|
+
*/
|
|
85
|
+
itemRef: (key: string | number) => (el: HTMLElement | null) => void
|
|
77
86
|
/** The key of the currently dragging item. */
|
|
78
87
|
activeId: () => string | number | null
|
|
79
88
|
/** The key of the item being hovered over. */
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { useFileDrop } from './use-file-drop'
|
|
3
|
+
|
|
4
|
+
// Real-Chromium browser test for `useFileDrop`'s drop pathway. The
|
|
5
|
+
// happy-dom unit suite (`src/tests/dnd.test.ts`) covers the signal
|
|
6
|
+
// surface — `isOver`, `isDraggingFiles`, accept-filter wiring — but
|
|
7
|
+
// can't drive pragmatic-drag-and-drop's external/file adapter end-to-
|
|
8
|
+
// end because happy-dom's `DataTransfer` polyfill is incomplete enough
|
|
9
|
+
// that the adapter's window-level dragenter activation rejects the
|
|
10
|
+
// synthetic event.
|
|
11
|
+
//
|
|
12
|
+
// This test uses pdnd's official Playwright pattern (window-level
|
|
13
|
+
// `dragenter` + element-level `dragover` + `drop`, all sharing one
|
|
14
|
+
// DataTransfer) — same shape as the app-showcase `/dnd` e2e file-drop
|
|
15
|
+
// spec — but at the package level so a regression in `useFileDrop`'s
|
|
16
|
+
// `onDrop` wiring surfaces in `bun run test:browser` against
|
|
17
|
+
// @pyreon/dnd directly, before any consumer-app e2e runs.
|
|
18
|
+
//
|
|
19
|
+
// Why both this AND the e2e spec: the e2e exercises the FULL stack
|
|
20
|
+
// (Pyreon JSX → ref-callback → element resolution → pdnd → onDrop →
|
|
21
|
+
// signal write → DOM update). This unit-level test isolates the
|
|
22
|
+
// PDND-bridge layer — if pdnd updates and breaks `getFiles({source})`
|
|
23
|
+
// or the `onDrop` callback signature, this test fails BEFORE the e2e
|
|
24
|
+
// (which depends on a 100+ ms dev-server boot).
|
|
25
|
+
|
|
26
|
+
describe('useFileDrop — real-Chromium drop flow', () => {
|
|
27
|
+
it('fires onDrop with the dropped File when the full pdnd sequence runs', async () => {
|
|
28
|
+
const dropZone = document.createElement('div')
|
|
29
|
+
dropZone.style.cssText = 'width: 200px; height: 200px'
|
|
30
|
+
document.body.appendChild(dropZone)
|
|
31
|
+
|
|
32
|
+
let received: File[] | null = null
|
|
33
|
+
const result = useFileDrop({
|
|
34
|
+
element: () => dropZone,
|
|
35
|
+
onDrop: (files) => {
|
|
36
|
+
received = files
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// pdnd registers its drop target asynchronously via `queueMicrotask`
|
|
41
|
+
// (see `use-file-drop.ts` setup function). Yield a microtask so the
|
|
42
|
+
// adapter is wired before we dispatch.
|
|
43
|
+
await Promise.resolve()
|
|
44
|
+
await new Promise<void>((r) => setTimeout(r, 0))
|
|
45
|
+
|
|
46
|
+
const file = new File(['<bytes>'], 'avatar.png', { type: 'image/png' })
|
|
47
|
+
const dataTransfer = new DataTransfer()
|
|
48
|
+
dataTransfer.items.add(file)
|
|
49
|
+
|
|
50
|
+
// 1. `dragenter` on `window` activates pdnd's external adapter.
|
|
51
|
+
// Bubbling a zone-targeted dragenter is platform-fragile (works
|
|
52
|
+
// on macOS Chromium, fails on Linux Chromium under headless);
|
|
53
|
+
// dispatching directly on window is the deterministic path
|
|
54
|
+
// documented in pdnd's own Playwright suite.
|
|
55
|
+
window.dispatchEvent(new DragEvent('dragenter', { dataTransfer }))
|
|
56
|
+
|
|
57
|
+
// 2. `dragover` + `drop` on the zone with the same DataTransfer
|
|
58
|
+
// instance — pdnd reads the file list from the event's transfer
|
|
59
|
+
// at drop time.
|
|
60
|
+
dropZone.dispatchEvent(new DragEvent('dragover', { dataTransfer }))
|
|
61
|
+
dropZone.dispatchEvent(new DragEvent('drop', { dataTransfer }))
|
|
62
|
+
|
|
63
|
+
// pdnd's onDrop fires synchronously off the drop event, but the
|
|
64
|
+
// signal write is wrapped in our cleanup-aware effect — yield once
|
|
65
|
+
// more to let any pending microtasks flush.
|
|
66
|
+
await Promise.resolve()
|
|
67
|
+
|
|
68
|
+
expect(received).not.toBeNull()
|
|
69
|
+
expect(received).toHaveLength(1)
|
|
70
|
+
expect(received![0]!.name).toBe('avatar.png')
|
|
71
|
+
expect(received![0]!.type).toBe('image/png')
|
|
72
|
+
expect(result.isOver()).toBe(false)
|
|
73
|
+
|
|
74
|
+
dropZone.remove()
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('filters out files that fail the `accept` pattern', async () => {
|
|
78
|
+
const dropZone = document.createElement('div')
|
|
79
|
+
dropZone.style.cssText = 'width: 200px; height: 200px'
|
|
80
|
+
document.body.appendChild(dropZone)
|
|
81
|
+
|
|
82
|
+
let received: File[] | null = null
|
|
83
|
+
useFileDrop({
|
|
84
|
+
element: () => dropZone,
|
|
85
|
+
// PDF-only accept — image file should be rejected.
|
|
86
|
+
accept: ['application/pdf'],
|
|
87
|
+
onDrop: (files) => {
|
|
88
|
+
received = files
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
await Promise.resolve()
|
|
93
|
+
await new Promise<void>((r) => setTimeout(r, 0))
|
|
94
|
+
|
|
95
|
+
const file = new File(['<bytes>'], 'avatar.png', { type: 'image/png' })
|
|
96
|
+
const dataTransfer = new DataTransfer()
|
|
97
|
+
dataTransfer.items.add(file)
|
|
98
|
+
|
|
99
|
+
window.dispatchEvent(new DragEvent('dragenter', { dataTransfer }))
|
|
100
|
+
dropZone.dispatchEvent(new DragEvent('dragover', { dataTransfer }))
|
|
101
|
+
dropZone.dispatchEvent(new DragEvent('drop', { dataTransfer }))
|
|
102
|
+
|
|
103
|
+
await Promise.resolve()
|
|
104
|
+
|
|
105
|
+
// The hook filters BEFORE invoking `onDrop` — when zero files
|
|
106
|
+
// survive the filter, `onDrop` is never called.
|
|
107
|
+
expect(received).toBeNull()
|
|
108
|
+
|
|
109
|
+
dropZone.remove()
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('respects maxFiles by truncating the dropped list', async () => {
|
|
113
|
+
const dropZone = document.createElement('div')
|
|
114
|
+
dropZone.style.cssText = 'width: 200px; height: 200px'
|
|
115
|
+
document.body.appendChild(dropZone)
|
|
116
|
+
|
|
117
|
+
let received: File[] | null = null
|
|
118
|
+
useFileDrop({
|
|
119
|
+
element: () => dropZone,
|
|
120
|
+
accept: ['image/*'],
|
|
121
|
+
maxFiles: 2,
|
|
122
|
+
onDrop: (files) => {
|
|
123
|
+
received = files
|
|
124
|
+
},
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
await Promise.resolve()
|
|
128
|
+
await new Promise<void>((r) => setTimeout(r, 0))
|
|
129
|
+
|
|
130
|
+
const dataTransfer = new DataTransfer()
|
|
131
|
+
dataTransfer.items.add(new File(['a'], 'a.png', { type: 'image/png' }))
|
|
132
|
+
dataTransfer.items.add(new File(['b'], 'b.png', { type: 'image/png' }))
|
|
133
|
+
dataTransfer.items.add(new File(['c'], 'c.png', { type: 'image/png' }))
|
|
134
|
+
|
|
135
|
+
window.dispatchEvent(new DragEvent('dragenter', { dataTransfer }))
|
|
136
|
+
dropZone.dispatchEvent(new DragEvent('dragover', { dataTransfer }))
|
|
137
|
+
dropZone.dispatchEvent(new DragEvent('drop', { dataTransfer }))
|
|
138
|
+
|
|
139
|
+
await Promise.resolve()
|
|
140
|
+
|
|
141
|
+
expect(received).not.toBeNull()
|
|
142
|
+
expect(received).toHaveLength(2) // truncated from 3
|
|
143
|
+
expect(received![0]!.name).toBe('a.png')
|
|
144
|
+
expect(received![1]!.name).toBe('b.png')
|
|
145
|
+
|
|
146
|
+
dropZone.remove()
|
|
147
|
+
})
|
|
148
|
+
})
|
package/src/use-sortable.ts
CHANGED
|
@@ -55,10 +55,10 @@ let _sortableCounter = 0
|
|
|
55
55
|
*/
|
|
56
56
|
export function useSortable<T>(options: UseSortableOptions<T>): UseSortableResult {
|
|
57
57
|
if (typeof document === 'undefined') {
|
|
58
|
-
const noop = () => {}
|
|
58
|
+
const noop = (_el: HTMLElement | null) => {}
|
|
59
59
|
return {
|
|
60
|
-
containerRef: noop
|
|
61
|
-
itemRef: () => noop
|
|
60
|
+
containerRef: noop,
|
|
61
|
+
itemRef: () => noop,
|
|
62
62
|
activeId: () => null,
|
|
63
63
|
overId: () => null,
|
|
64
64
|
overEdge: () => null,
|
|
@@ -104,7 +104,11 @@ export function useSortable<T>(options: UseSortableOptions<T>): UseSortableResul
|
|
|
104
104
|
options.onReorder(reordered)
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
function containerRef(el: HTMLElement) {
|
|
107
|
+
function containerRef(el: HTMLElement | null) {
|
|
108
|
+
// Pyreon's runtime calls refs with `null` on unmount; the per-element
|
|
109
|
+
// pdnd cleanups are already registered via `onCleanup` below, so we
|
|
110
|
+
// can no-op the unmount-time call.
|
|
111
|
+
if (!el) return
|
|
108
112
|
// Auto-scroll when dragging near container edges
|
|
109
113
|
cleanups.push(
|
|
110
114
|
autoScrollForElements({
|
|
@@ -173,8 +177,10 @@ export function useSortable<T>(options: UseSortableOptions<T>): UseSortableResul
|
|
|
173
177
|
cleanups.push(() => el.removeEventListener('keydown', keyHandler))
|
|
174
178
|
}
|
|
175
179
|
|
|
176
|
-
function itemRef(key: string | number): (el: HTMLElement) => void {
|
|
177
|
-
return (el: HTMLElement) => {
|
|
180
|
+
function itemRef(key: string | number): (el: HTMLElement | null) => void {
|
|
181
|
+
return (el: HTMLElement | null) => {
|
|
182
|
+
// Pyreon ref-on-unmount: see containerRef comment.
|
|
183
|
+
if (!el) return
|
|
178
184
|
el.dataset.pyreonSortKey = String(key)
|
|
179
185
|
if (!el.hasAttribute('tabindex')) el.setAttribute('tabindex', '0')
|
|
180
186
|
el.setAttribute('role', 'listitem')
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/use-drag-monitor.ts","../src/use-draggable.ts","../src/use-droppable.ts","../src/use-file-drop.ts","../src/use-sortable.ts"],"sourcesContent":["import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'\nimport { onCleanup, signal } from '@pyreon/reactivity'\nimport type { DragData } from './types'\n\nexport interface UseDragMonitorOptions {\n /** Called on any drag start in the page. */\n onDragStart?: (data: DragData) => void\n /** Called on any drop in the page. */\n onDrop?: (sourceData: DragData, targetData: DragData) => void\n /** Filter which drags to monitor. */\n canMonitor?: (data: DragData) => boolean\n}\n\nexport interface UseDragMonitorResult {\n /** Whether any element is currently being dragged. */\n isDragging: () => boolean\n /** Data of the currently dragging element (null if not dragging). */\n dragData: () => DragData | null\n}\n\n/**\n * Monitor all drag operations on the page.\n * Useful for global drag indicators, analytics, or coordination between\n * multiple drag-and-drop areas.\n *\n * @example\n * ```tsx\n * const { isDragging, dragData } = useDragMonitor({\n * canMonitor: (data) => data.type === \"card\",\n * onDrop: (source, target) => logDrop(source, target),\n * })\n *\n * <Show when={isDragging()}>\n * <div class=\"global-drag-overlay\">\n * Dragging: {() => dragData()?.name}\n * </div>\n * </Show>\n * ```\n */\nexport function useDragMonitor(options?: UseDragMonitorOptions): UseDragMonitorResult {\n if (typeof document === 'undefined') return { isDragging: () => false, dragData: () => null }\n\n const isDragging = signal(false)\n const dragData = signal<DragData | null>(null)\n\n const canMonitorFn = options?.canMonitor\n ? ({ source }: { source: { data: Record<string, unknown> } }) =>\n options.canMonitor?.(source.data as DragData) ?? true\n : null\n\n const cleanup = monitorForElements({\n ...(canMonitorFn ? { canMonitor: canMonitorFn } : {}),\n onDragStart: ({ source }) => {\n isDragging.set(true)\n dragData.set(source.data as DragData)\n options?.onDragStart?.(source.data as DragData)\n },\n onDrop: ({ source, location }) => {\n isDragging.set(false)\n dragData.set(null)\n const targetData = location.current.dropTargets[0]?.data ?? {}\n options?.onDrop?.(source.data as DragData, targetData as DragData)\n },\n })\n\n onCleanup(cleanup)\n\n return { isDragging, dragData }\n}\n","import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'\nimport { onCleanup, signal } from '@pyreon/reactivity'\nimport type { DragData, UseDraggableOptions, UseDraggableResult } from './types'\n\n/**\n * Make an element draggable with signal-driven state.\n *\n * @example\n * ```tsx\n * let cardEl: HTMLElement | null = null\n *\n * const { isDragging } = useDraggable({\n * element: () => cardEl,\n * data: { id: card.id, type: \"card\" },\n * })\n *\n * <div ref={(el) => cardEl = el} class={isDragging() ? \"opacity-50\" : \"\"}>\n * {card.title}\n * </div>\n * ```\n */\nexport function useDraggable<T extends DragData = DragData>(\n options: UseDraggableOptions<T>,\n): UseDraggableResult {\n if (typeof document === 'undefined') return { isDragging: () => false }\n\n const isDragging = signal(false)\n let cleanup: (() => void) | undefined\n\n function setup() {\n if (cleanup) cleanup()\n\n const el = options.element()\n if (!el) return\n\n const resolveData = () =>\n typeof options.data === 'function' ? (options.data as () => T)() : options.data\n\n const handle = options.handle?.()\n cleanup = draggable({\n element: el,\n ...(handle ? { dragHandle: handle } : {}),\n getInitialData: resolveData,\n canDrag: () => {\n const disabled = options.disabled\n if (typeof disabled === 'function') return !disabled()\n return !disabled\n },\n onDragStart: () => {\n isDragging.set(true)\n options.onDragStart?.()\n },\n onDrop: () => {\n isDragging.set(false)\n options.onDragEnd?.()\n },\n })\n }\n\n // Defer setup to next microtask so refs are populated\n queueMicrotask(setup)\n\n onCleanup(() => {\n if (cleanup) cleanup()\n })\n\n return { isDragging }\n}\n","import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'\nimport { onCleanup, signal } from '@pyreon/reactivity'\nimport type { DragData, UseDroppableOptions, UseDroppableResult } from './types'\n\n/**\n * Make an element a drop target with signal-driven state.\n *\n * @example\n * ```tsx\n * let zoneEl: HTMLElement | null = null\n *\n * const { isOver } = useDroppable({\n * element: () => zoneEl,\n * onDrop: (data) => handleDrop(data),\n * canDrop: (data) => data.type === \"card\",\n * })\n *\n * <div ref={(el) => zoneEl = el} class={isOver() ? \"bg-blue-50\" : \"\"}>\n * Drop here\n * </div>\n * ```\n */\nexport function useDroppable<T extends DragData = DragData>(\n options: UseDroppableOptions<T>,\n): UseDroppableResult {\n if (typeof document === 'undefined') return { isOver: () => false }\n\n const isOver = signal(false)\n let cleanup: (() => void) | undefined\n\n function setup() {\n if (cleanup) cleanup()\n\n const el = options.element()\n if (!el) return\n\n cleanup = dropTargetForElements({\n element: el,\n getData: () => {\n if (!options.data) return {}\n return typeof options.data === 'function' ? (options.data as () => T)() : options.data\n },\n canDrop: ({ source }) => {\n if (!options.canDrop) return true\n return options.canDrop(source.data as DragData)\n },\n onDragEnter: ({ source }) => {\n isOver.set(true)\n options.onDragEnter?.(source.data as DragData)\n },\n onDragLeave: () => {\n isOver.set(false)\n options.onDragLeave?.()\n },\n onDrop: ({ source }) => {\n isOver.set(false)\n options.onDrop?.(source.data as DragData)\n },\n })\n }\n\n queueMicrotask(setup)\n\n onCleanup(() => {\n if (cleanup) cleanup()\n })\n\n return { isOver }\n}\n","import {\n dropTargetForExternal,\n monitorForExternal,\n} from '@atlaskit/pragmatic-drag-and-drop/external/adapter'\nimport { containsFiles, getFiles } from '@atlaskit/pragmatic-drag-and-drop/external/file'\nimport { onCleanup, signal } from '@pyreon/reactivity'\n\nexport interface UseFileDropOptions {\n /** Element getter for the drop zone. */\n element: () => HTMLElement | null\n /** Called when files are dropped. */\n onDrop: (files: File[]) => void\n /** Filter accepted file types (e.g. [\"image/*\", \".pdf\"]). */\n accept?: string[]\n /** Maximum number of files. */\n maxFiles?: number\n /** Whether drop is disabled. */\n disabled?: boolean | (() => boolean)\n}\n\nexport interface UseFileDropResult {\n /** Whether files are being dragged over the drop zone. */\n isOver: () => boolean\n /** Whether files are being dragged anywhere on the page. */\n isDraggingFiles: () => boolean\n}\n\n/**\n * File drop zone with signal-driven state.\n * Uses the native file drag events via pragmatic-drag-and-drop.\n *\n * @example\n * ```tsx\n * let dropZone: HTMLElement | null = null\n *\n * const { isOver, isDraggingFiles } = useFileDrop({\n * element: () => dropZone,\n * accept: [\"image/*\", \".pdf\"],\n * maxFiles: 5,\n * onDrop: (files) => upload(files),\n * })\n *\n * <div\n * ref={(el) => dropZone = el}\n * class={isOver() ? \"drop-active\" : isDraggingFiles() ? \"drop-ready\" : \"\"}\n * >\n * Drop files here\n * </div>\n * ```\n */\nexport function useFileDrop(options: UseFileDropOptions): UseFileDropResult {\n if (typeof document === 'undefined') return { isOver: () => false, isDraggingFiles: () => false }\n\n const isOver = signal(false)\n const isDraggingFiles = signal(false)\n let cleanup: (() => void) | undefined\n\n function matchesAccept(file: File, accept: string[]): boolean {\n return accept.some((pattern) => {\n if (pattern.startsWith('.')) {\n return file.name.toLowerCase().endsWith(pattern.toLowerCase())\n }\n if (pattern.endsWith('/*')) {\n return file.type.startsWith(pattern.slice(0, -1))\n }\n return file.type === pattern\n })\n }\n\n function setup() {\n if (cleanup) cleanup()\n\n const el = options.element()\n if (!el) return\n\n const cleanups: (() => void)[] = []\n\n // Monitor for file drags anywhere on the page\n cleanups.push(\n monitorForExternal({\n canMonitor: ({ source }) => containsFiles({ source }),\n onDragStart: () => isDraggingFiles.set(true),\n onDrop: () => isDraggingFiles.set(false),\n }),\n )\n\n // Drop target on the specific element\n cleanups.push(\n dropTargetForExternal({\n element: el,\n canDrop: ({ source }) => {\n const disabled = options.disabled\n if (typeof disabled === 'function' ? disabled() : disabled) return false\n return containsFiles({ source })\n },\n onDragEnter: () => isOver.set(true),\n onDragLeave: () => isOver.set(false),\n onDrop: ({ source }) => {\n isOver.set(false)\n isDraggingFiles.set(false)\n\n let files = getFiles({ source })\n\n // Filter by accept\n if (options.accept && options.accept.length > 0) {\n files = files.filter((f) => matchesAccept(f, options.accept as string[]))\n }\n\n // Limit count\n if (options.maxFiles && files.length > options.maxFiles) {\n files = files.slice(0, options.maxFiles)\n }\n\n if (files.length > 0) {\n options.onDrop(files)\n }\n },\n }),\n )\n\n cleanup = () => {\n for (const fn of cleanups) fn()\n }\n }\n\n queueMicrotask(setup)\n\n onCleanup(() => {\n if (cleanup) cleanup()\n })\n\n return { isOver, isDraggingFiles }\n}\n","import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine'\nimport { draggable, dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'\nimport { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element'\nimport {\n attachClosestEdge,\n type Edge,\n extractClosestEdge,\n} from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge'\nimport { onCleanup, signal } from '@pyreon/reactivity'\nimport type { DropEdge, UseSortableOptions, UseSortableResult } from './types'\n\nconst SORT_KEY = '__pyreon_sortable_key'\nconst SORT_ID = '__pyreon_sortable_id'\n\nlet _sortableCounter = 0\n\n/**\n * Sortable list with signal-driven state, auto-scroll, and edge detection.\n *\n * Features:\n * - Keyed drag items matching `<For by={...}>` pattern\n * - Auto-scroll when dragging near container edges\n * - Closest-edge detection (drop above/below or left/right)\n * - Axis constraint (vertical/horizontal)\n * - Keyboard reordering (Alt+Arrow keys)\n *\n * @example\n * ```tsx\n * const items = signal([\n * { id: \"1\", name: \"Alice\" },\n * { id: \"2\", name: \"Bob\" },\n * { id: \"3\", name: \"Charlie\" },\n * ])\n *\n * const { containerRef, itemRef, activeId, overId, overEdge } = useSortable({\n * items,\n * by: (item) => item.id,\n * onReorder: (newItems) => items.set(newItems),\n * })\n *\n * <ul ref={containerRef}>\n * <For each={items()} by={item => item.id}>\n * {(item) => (\n * <li\n * ref={itemRef(item.id)}\n * class={activeId() === item.id ? \"dragging\" : \"\"}\n * style={overId() === item.id ? `border-${overEdge()}: 2px solid blue` : \"\"}\n * >\n * {item.name}\n * </li>\n * )}\n * </For>\n * </ul>\n * ```\n */\nexport function useSortable<T>(options: UseSortableOptions<T>): UseSortableResult {\n if (typeof document === 'undefined') {\n const noop = () => {}\n return {\n containerRef: noop as (el: HTMLElement) => void,\n itemRef: () => noop as (el: HTMLElement) => void,\n activeId: () => null,\n overId: () => null,\n overEdge: () => null,\n }\n }\n\n const sortableId = `sortable-${++_sortableCounter}`\n const activeId = signal<string | number | null>(null)\n const overId = signal<string | number | null>(null)\n const overEdge = signal<DropEdge | null>(null)\n const axis = options.axis ?? 'vertical'\n\n const cleanups: (() => void)[] = []\n\n /** Perform the reorder based on current active/over/edge state. */\n function performReorder() {\n const dragId = activeId.peek()\n const dropId = overId.peek()\n const edge = overEdge.peek()\n if (dragId == null || dropId == null || dragId === dropId) return\n\n const currentItems = options.items()\n const dragIndex = currentItems.findIndex((item) => options.by(item) === dragId)\n const dropIndex = currentItems.findIndex((item) => options.by(item) === dropId)\n if (dragIndex === -1 || dropIndex === -1) return\n\n const reordered = [...currentItems]\n const [moved] = reordered.splice(dragIndex, 1)\n if (!moved) return\n\n // Determine insert position based on closest edge\n const rawInsert =\n edge === 'bottom' || edge === 'right'\n ? dropIndex >= dragIndex\n ? dropIndex\n : dropIndex + 1\n : dropIndex <= dragIndex\n ? dropIndex\n : dropIndex - 1\n const insertAt = Math.max(0, Math.min(rawInsert, reordered.length))\n\n reordered.splice(insertAt, 0, moved)\n options.onReorder(reordered)\n }\n\n function containerRef(el: HTMLElement) {\n // Auto-scroll when dragging near container edges\n cleanups.push(\n autoScrollForElements({\n element: el,\n canScroll: ({ source }) => source.data[SORT_ID] === sortableId,\n }),\n )\n\n // Container is a drop target for reorder finalization\n cleanups.push(\n dropTargetForElements({\n element: el,\n getData: () => ({ [SORT_ID]: sortableId }),\n canDrop: ({ source }) => source.data[SORT_ID] === sortableId,\n onDrop: () => {\n performReorder()\n activeId.set(null)\n overId.set(null)\n overEdge.set(null)\n },\n }),\n )\n\n // Keyboard reordering: Alt+Arrow keys\n const keyHandler = (e: KeyboardEvent) => {\n if (!e.altKey) return\n\n const isUp = axis === 'vertical' ? e.key === 'ArrowUp' : e.key === 'ArrowLeft'\n const isDown = axis === 'vertical' ? e.key === 'ArrowDown' : e.key === 'ArrowRight'\n if (!isUp && !isDown) return\n\n const focused = document.activeElement as HTMLElement | null\n if (!focused || !el.contains(focused)) return\n\n const focusedKey = focused.dataset.pyreonSortKey\n if (!focusedKey) return\n\n e.preventDefault()\n\n const currentItems = options.items()\n const currentIndex = currentItems.findIndex((item) => String(options.by(item)) === focusedKey)\n if (currentIndex === -1) return\n\n const targetIndex = isUp ? currentIndex - 1 : currentIndex + 1\n if (targetIndex < 0 || targetIndex >= currentItems.length) return\n\n const reordered = [...currentItems]\n const temp = reordered[currentIndex]\n reordered[currentIndex] = reordered[targetIndex] as T\n reordered[targetIndex] = temp as T\n options.onReorder(reordered)\n\n // Restore focus after DOM update\n requestAnimationFrame(() => {\n const items = el.querySelectorAll('[data-pyreon-sort-key]')\n for (const item of items) {\n if ((item as HTMLElement).dataset.pyreonSortKey === focusedKey) {\n ;(item as HTMLElement).focus()\n break\n }\n }\n })\n }\n\n el.addEventListener('keydown', keyHandler)\n cleanups.push(() => el.removeEventListener('keydown', keyHandler))\n }\n\n function itemRef(key: string | number): (el: HTMLElement) => void {\n return (el: HTMLElement) => {\n el.dataset.pyreonSortKey = String(key)\n if (!el.hasAttribute('tabindex')) el.setAttribute('tabindex', '0')\n el.setAttribute('role', 'listitem')\n el.setAttribute('aria-roledescription', 'sortable item')\n\n const allowedEdges: Edge[] = axis === 'vertical' ? ['top', 'bottom'] : ['left', 'right']\n\n const cleanup = combine(\n draggable({\n element: el,\n getInitialData: () => ({\n [SORT_KEY]: key,\n [SORT_ID]: sortableId,\n }),\n onDragStart: () => activeId.set(key),\n onDrop: () => {\n queueMicrotask(() => {\n activeId.set(null)\n overId.set(null)\n overEdge.set(null)\n })\n },\n }),\n dropTargetForElements({\n element: el,\n getData: ({ input, element }) =>\n attachClosestEdge(\n { [SORT_KEY]: key, [SORT_ID]: sortableId },\n { input, element, allowedEdges },\n ),\n canDrop: ({ source }) => source.data[SORT_ID] === sortableId,\n onDragEnter: ({ self }) => {\n overId.set(key)\n overEdge.set(extractClosestEdge(self.data) as DropEdge | null)\n },\n onDrag: ({ self }) => {\n overEdge.set(extractClosestEdge(self.data) as DropEdge | null)\n },\n onDragLeave: () => {\n if (overId.peek() === key) {\n overId.set(null)\n overEdge.set(null)\n }\n },\n }),\n )\n\n cleanups.push(cleanup)\n }\n }\n\n onCleanup(() => {\n for (const cleanup of cleanups) cleanup()\n cleanups.length = 0\n activeId.set(null)\n overId.set(null)\n overEdge.set(null)\n })\n\n return { containerRef, itemRef, activeId, overId, overEdge }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAg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S,SAAS;AAClB,WAAS,IAAI,KAAK;AAClB,SAAO,IAAI,KAAK;AAChB,WAAS,IAAI,KAAK;GAClB;AAEF,QAAO;EAAE;EAAc;EAAS;EAAU;EAAQ;EAAU"}
|
package/lib/types/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index2.d.ts","names":[],"sources":["../../../src/types.ts","../../../src/use-drag-monitor.ts","../../../src/use-draggable.ts","../../../src/use-droppable.ts","../../../src/use-file-drop.ts","../../../src/use-sortable.ts"],"mappings":";;KACY,QAAA,GAAW,MAAA;;KAGX,QAAA;;UAGK,YAAA;EAHL;EAKV,IAAA,EAAM,QAAA;;EAEN,IAAA,EAAM,QAAA;AAAA;AAAA,UAKS,mBAAA,WAA8B,QAAA,GAAW,QAAA;EAT7B;EAW3B,OAAA,QAAe,WAAA;EAPD;EASd,IAAA,EAAM,CAAA,UAAW,CAAA;EAXX;EAaN,MAAA,SAAe,WAAA;EAXT;EAaN,QAAA;EAbc;EAed,WAAA;EAVkC;EAYlC,SAAA;AAAA;AAAA,UAGe,kBAAA;EAbA;EAef,UAAA;AAAA;AAAA,UAKe,mBAAA,WAA8B,QAAA,GAAW,QAAA;EAhB9B;EAkB1B,OAAA,QAAe,WAAA;EAxBoB;EA0BnC,IAAA,GAAO,CAAA,UAAW,CAAA;EA1BsC;EA4BxD,OAAA,IAAW,UAAA,EAAY,QAAA;EA1BR;EA4Bf,WAAA,IAAe,UAAA,EAAY,QAAA;EA1BrB;EA4BN,WAAA;EA1BA;EA4BA,MAAA,IAAU,UAAA,EAAY,QAAA;AAAA;AAAA,UAGP,kBAAA;EAzBf;EA2BA,MAAA;AAAA;AAAA,UAKe,kBAAA;EA7BkB;EA+BjC,KAAA,QAAa,CAAA;EA7Bb;EA+BA,EAAA,GAAK,IAAA,EAAM,CAAA;EA1BI;EA4Bf,SAAA,GAAY,KAAA,EAAO,CAAA;EA5Be;EA8BlC,IAAA;AAAA;AAAA,UAGe,iBAA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