react-native-drax 0.11.0-alpha.2 → 1.0.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.
Files changed (246) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +385 -227
  3. package/lib/module/DebugOverlay.js +121 -0
  4. package/lib/module/DebugOverlay.js.map +1 -0
  5. package/lib/module/Drax.js +36 -0
  6. package/lib/module/Drax.js.map +1 -0
  7. package/lib/module/DraxContext.js +6 -0
  8. package/lib/module/DraxContext.js.map +1 -0
  9. package/lib/module/DraxHandle.js +47 -0
  10. package/lib/module/DraxHandle.js.map +1 -0
  11. package/lib/module/DraxHandleContext.js +11 -0
  12. package/lib/module/DraxHandleContext.js.map +1 -0
  13. package/lib/module/DraxList.js +108 -0
  14. package/lib/module/DraxList.js.map +1 -0
  15. package/lib/module/DraxProvider.js +203 -0
  16. package/lib/module/DraxProvider.js.map +1 -0
  17. package/lib/module/DraxScrollView.js +167 -0
  18. package/lib/module/DraxScrollView.js.map +1 -0
  19. package/lib/module/DraxSubprovider.js +21 -0
  20. package/lib/module/DraxSubprovider.js.map +1 -0
  21. package/lib/module/DraxView.js +348 -0
  22. package/lib/module/DraxView.js.map +1 -0
  23. package/lib/module/HoverLayer.js +152 -0
  24. package/lib/module/HoverLayer.js.map +1 -0
  25. package/lib/module/SortableBoardContainer.js +386 -0
  26. package/lib/module/SortableBoardContainer.js.map +1 -0
  27. package/lib/module/SortableBoardContext.js +6 -0
  28. package/lib/module/SortableBoardContext.js.map +1 -0
  29. package/lib/module/SortableContainer.js +561 -0
  30. package/lib/module/SortableContainer.js.map +1 -0
  31. package/lib/module/SortableItem.js +226 -0
  32. package/lib/module/SortableItem.js.map +1 -0
  33. package/lib/module/SortableItemContext.js +38 -0
  34. package/lib/module/SortableItemContext.js.map +1 -0
  35. package/lib/module/compat/detectVersion.js +19 -0
  36. package/lib/module/compat/detectVersion.js.map +1 -0
  37. package/lib/module/compat/index.js +5 -0
  38. package/lib/module/compat/index.js.map +1 -0
  39. package/lib/module/compat/types.js +4 -0
  40. package/lib/module/compat/types.js.map +1 -0
  41. package/lib/module/compat/useDraxPanGesture.js +94 -0
  42. package/lib/module/compat/useDraxPanGesture.js.map +1 -0
  43. package/lib/module/hooks/index.js +5 -0
  44. package/lib/module/hooks/index.js.map +1 -0
  45. package/lib/module/hooks/useCallbackDispatch.js +681 -0
  46. package/lib/module/hooks/useCallbackDispatch.js.map +1 -0
  47. package/lib/module/hooks/useDragGesture.js +240 -0
  48. package/lib/module/hooks/useDragGesture.js.map +1 -0
  49. package/lib/module/hooks/useDraxContext.js +12 -0
  50. package/lib/module/hooks/useDraxContext.js.map +1 -0
  51. package/lib/module/hooks/useDraxId.js +13 -0
  52. package/lib/module/hooks/useDraxId.js.map +1 -0
  53. package/lib/module/hooks/useDraxMethods.js +73 -0
  54. package/lib/module/hooks/useDraxMethods.js.map +1 -0
  55. package/lib/module/hooks/useDraxScrollHandler.js +97 -0
  56. package/lib/module/hooks/useDraxScrollHandler.js.map +1 -0
  57. package/lib/module/hooks/useSortableBoard.js +37 -0
  58. package/lib/module/hooks/useSortableBoard.js.map +1 -0
  59. package/lib/module/hooks/useSortableList.js +824 -0
  60. package/lib/module/hooks/useSortableList.js.map +1 -0
  61. package/lib/module/hooks/useSpatialIndex.js +283 -0
  62. package/lib/module/hooks/useSpatialIndex.js.map +1 -0
  63. package/lib/module/hooks/useViewStyles.js +158 -0
  64. package/lib/module/hooks/useViewStyles.js.map +1 -0
  65. package/lib/module/hooks/useWebScrollFreeze.js +52 -0
  66. package/lib/module/hooks/useWebScrollFreeze.js.map +1 -0
  67. package/lib/module/index.js +37 -0
  68. package/lib/module/index.js.map +1 -0
  69. package/lib/module/math.js +222 -0
  70. package/lib/module/math.js.map +1 -0
  71. package/lib/module/package.json +1 -0
  72. package/lib/module/params.js +88 -0
  73. package/lib/module/params.js.map +1 -0
  74. package/lib/module/types.js +213 -0
  75. package/lib/module/types.js.map +1 -0
  76. package/lib/typescript/package.json +1 -0
  77. package/lib/typescript/src/DebugOverlay.d.ts +17 -0
  78. package/lib/typescript/src/DebugOverlay.d.ts.map +1 -0
  79. package/lib/typescript/src/Drax.d.ts +28 -0
  80. package/lib/typescript/src/Drax.d.ts.map +1 -0
  81. package/lib/typescript/src/DraxContext.d.ts +3 -0
  82. package/lib/typescript/src/DraxContext.d.ts.map +1 -0
  83. package/lib/typescript/src/DraxHandle.d.ts +25 -0
  84. package/lib/typescript/src/DraxHandle.d.ts.map +1 -0
  85. package/lib/typescript/src/DraxHandleContext.d.ts +12 -0
  86. package/lib/typescript/src/DraxHandleContext.d.ts.map +1 -0
  87. package/lib/typescript/src/DraxList.d.ts +66 -0
  88. package/lib/typescript/src/DraxList.d.ts.map +1 -0
  89. package/lib/typescript/src/DraxProvider.d.ts +4 -0
  90. package/lib/typescript/src/DraxProvider.d.ts.map +1 -0
  91. package/lib/typescript/src/DraxScrollView.d.ts +7 -0
  92. package/lib/typescript/src/DraxScrollView.d.ts.map +1 -0
  93. package/lib/typescript/src/DraxSubprovider.d.ts +4 -0
  94. package/lib/typescript/src/DraxSubprovider.d.ts.map +1 -0
  95. package/lib/typescript/src/DraxView.d.ts +4 -0
  96. package/lib/typescript/src/DraxView.d.ts.map +1 -0
  97. package/lib/typescript/src/HoverLayer.d.ts +38 -0
  98. package/lib/typescript/src/HoverLayer.d.ts.map +1 -0
  99. package/lib/typescript/src/SortableBoardContainer.d.ts +11 -0
  100. package/lib/typescript/src/SortableBoardContainer.d.ts.map +1 -0
  101. package/lib/typescript/src/SortableBoardContext.d.ts +4 -0
  102. package/lib/typescript/src/SortableBoardContext.d.ts.map +1 -0
  103. package/lib/typescript/src/SortableContainer.d.ts +13 -0
  104. package/lib/typescript/src/SortableContainer.d.ts.map +1 -0
  105. package/lib/typescript/src/SortableItem.d.ts +14 -0
  106. package/lib/typescript/src/SortableItem.d.ts.map +1 -0
  107. package/lib/typescript/src/SortableItemContext.d.ts +37 -0
  108. package/lib/typescript/src/SortableItemContext.d.ts.map +1 -0
  109. package/lib/typescript/src/compat/detectVersion.d.ts +2 -0
  110. package/lib/typescript/src/compat/detectVersion.d.ts.map +1 -0
  111. package/lib/typescript/src/compat/index.d.ts +4 -0
  112. package/lib/typescript/src/compat/index.d.ts.map +1 -0
  113. package/lib/typescript/src/compat/types.d.ts +33 -0
  114. package/lib/typescript/src/compat/types.d.ts.map +1 -0
  115. package/lib/typescript/src/compat/useDraxPanGesture.d.ts +8 -0
  116. package/lib/typescript/src/compat/useDraxPanGesture.d.ts.map +1 -0
  117. package/lib/typescript/src/hooks/index.d.ts +3 -0
  118. package/lib/typescript/src/hooks/index.d.ts.map +1 -0
  119. package/lib/typescript/src/hooks/useCallbackDispatch.d.ts +40 -0
  120. package/lib/typescript/src/hooks/useCallbackDispatch.d.ts.map +1 -0
  121. package/lib/typescript/src/hooks/useDragGesture.d.ts +17 -0
  122. package/lib/typescript/src/hooks/useDragGesture.d.ts.map +1 -0
  123. package/lib/typescript/src/hooks/useDraxContext.d.ts +2 -0
  124. package/lib/typescript/src/hooks/useDraxContext.d.ts.map +1 -0
  125. package/{build → lib/typescript/src}/hooks/useDraxId.d.ts +1 -0
  126. package/lib/typescript/src/hooks/useDraxId.d.ts.map +1 -0
  127. package/lib/typescript/src/hooks/useDraxMethods.d.ts +13 -0
  128. package/lib/typescript/src/hooks/useDraxMethods.d.ts.map +1 -0
  129. package/lib/typescript/src/hooks/useDraxScrollHandler.d.ts +27 -0
  130. package/lib/typescript/src/hooks/useDraxScrollHandler.d.ts.map +1 -0
  131. package/lib/typescript/src/hooks/useSortableBoard.d.ts +10 -0
  132. package/lib/typescript/src/hooks/useSortableBoard.d.ts.map +1 -0
  133. package/lib/typescript/src/hooks/useSortableList.d.ts +11 -0
  134. package/lib/typescript/src/hooks/useSortableList.d.ts.map +1 -0
  135. package/lib/typescript/src/hooks/useSpatialIndex.d.ts +22 -0
  136. package/lib/typescript/src/hooks/useSpatialIndex.d.ts.map +1 -0
  137. package/lib/typescript/src/hooks/useViewStyles.d.ts +183 -0
  138. package/lib/typescript/src/hooks/useViewStyles.d.ts.map +1 -0
  139. package/lib/typescript/src/hooks/useWebScrollFreeze.d.ts +14 -0
  140. package/lib/typescript/src/hooks/useWebScrollFreeze.d.ts.map +1 -0
  141. package/lib/typescript/src/index.d.ts +25 -0
  142. package/lib/typescript/src/index.d.ts.map +1 -0
  143. package/lib/typescript/src/math.d.ts +52 -0
  144. package/lib/typescript/src/math.d.ts.map +1 -0
  145. package/{build → lib/typescript/src}/params.d.ts +13 -9
  146. package/lib/typescript/src/params.d.ts.map +1 -0
  147. package/lib/typescript/src/types.d.ts +743 -0
  148. package/lib/typescript/src/types.d.ts.map +1 -0
  149. package/package.json +164 -34
  150. package/src/DebugOverlay.tsx +140 -0
  151. package/src/Drax.ts +33 -0
  152. package/src/DraxContext.ts +8 -0
  153. package/src/DraxHandle.tsx +52 -0
  154. package/src/DraxHandleContext.ts +15 -0
  155. package/src/DraxList.tsx +181 -0
  156. package/src/DraxProvider.tsx +224 -0
  157. package/src/DraxScrollView.tsx +180 -0
  158. package/src/DraxSubprovider.tsx +22 -0
  159. package/src/DraxView.tsx +430 -0
  160. package/src/HoverLayer.tsx +167 -0
  161. package/src/SortableBoardContainer.tsx +439 -0
  162. package/src/SortableBoardContext.ts +6 -0
  163. package/src/SortableContainer.tsx +642 -0
  164. package/src/SortableItem.tsx +264 -0
  165. package/src/SortableItemContext.ts +46 -0
  166. package/src/compat/detectVersion.ts +17 -0
  167. package/src/compat/index.ts +7 -0
  168. package/src/compat/types.ts +35 -0
  169. package/src/compat/useDraxPanGesture.ts +112 -0
  170. package/src/hooks/index.ts +2 -0
  171. package/src/hooks/useCallbackDispatch.tsx +823 -0
  172. package/src/hooks/useDragGesture.ts +273 -0
  173. package/src/hooks/useDraxContext.ts +11 -0
  174. package/src/hooks/useDraxId.ts +11 -0
  175. package/src/hooks/useDraxMethods.ts +71 -0
  176. package/src/hooks/useDraxScrollHandler.ts +121 -0
  177. package/src/hooks/useSortableBoard.ts +44 -0
  178. package/src/hooks/useSortableList.ts +868 -0
  179. package/src/hooks/useSpatialIndex.ts +336 -0
  180. package/src/hooks/useViewStyles.ts +180 -0
  181. package/src/hooks/useWebScrollFreeze.ts +60 -0
  182. package/src/index.ts +110 -0
  183. package/src/math.ts +251 -0
  184. package/src/params.ts +74 -0
  185. package/src/types.ts +919 -0
  186. package/.editorconfig +0 -15
  187. package/.eslintrc.js +0 -4
  188. package/.prettierrc +0 -16
  189. package/CHANGELOG.md +0 -270
  190. package/CODE-OF-CONDUCT.md +0 -85
  191. package/CONTRIBUTING.md +0 -15
  192. package/FUNDING.yml +0 -4
  193. package/build/AllHoverViews.d.ts +0 -0
  194. package/build/AllHoverViews.js +0 -30
  195. package/build/DraxContext.d.ts +0 -2
  196. package/build/DraxContext.js +0 -6
  197. package/build/DraxList.d.ts +0 -8
  198. package/build/DraxList.js +0 -512
  199. package/build/DraxListItem.d.ts +0 -7
  200. package/build/DraxListItem.js +0 -121
  201. package/build/DraxProvider.d.ts +0 -2
  202. package/build/DraxProvider.js +0 -704
  203. package/build/DraxScrollView.d.ts +0 -6
  204. package/build/DraxScrollView.js +0 -136
  205. package/build/DraxSubprovider.d.ts +0 -3
  206. package/build/DraxSubprovider.js +0 -18
  207. package/build/DraxView.d.ts +0 -8
  208. package/build/DraxView.js +0 -93
  209. package/build/HoverView.d.ts +0 -8
  210. package/build/HoverView.js +0 -40
  211. package/build/PanGestureDetector.d.ts +0 -3
  212. package/build/PanGestureDetector.js +0 -49
  213. package/build/hooks/index.d.ts +0 -4
  214. package/build/hooks/index.js +0 -11
  215. package/build/hooks/useContent.d.ts +0 -23
  216. package/build/hooks/useContent.js +0 -212
  217. package/build/hooks/useDraxContext.d.ts +0 -1
  218. package/build/hooks/useDraxContext.js +0 -13
  219. package/build/hooks/useDraxId.js +0 -13
  220. package/build/hooks/useDraxProtocol.d.ts +0 -5
  221. package/build/hooks/useDraxProtocol.js +0 -32
  222. package/build/hooks/useDraxRegistry.d.ts +0 -78
  223. package/build/hooks/useDraxRegistry.js +0 -714
  224. package/build/hooks/useDraxScrollHandler.d.ts +0 -25
  225. package/build/hooks/useDraxScrollHandler.js +0 -89
  226. package/build/hooks/useDraxState.d.ts +0 -10
  227. package/build/hooks/useDraxState.js +0 -132
  228. package/build/hooks/useMeasurements.d.ts +0 -9
  229. package/build/hooks/useMeasurements.js +0 -119
  230. package/build/hooks/useStatus.d.ts +0 -11
  231. package/build/hooks/useStatus.js +0 -96
  232. package/build/index.d.ts +0 -9
  233. package/build/index.js +0 -33
  234. package/build/math.d.ts +0 -22
  235. package/build/math.js +0 -68
  236. package/build/params.js +0 -27
  237. package/build/transform.d.ts +0 -11
  238. package/build/transform.js +0 -59
  239. package/build/types.d.ts +0 -807
  240. package/build/types.js +0 -46
  241. package/docs/concept.md +0 -79
  242. package/docs/images/color-drag-drop.gif +0 -0
  243. package/docs/images/deck-cards.gif +0 -0
  244. package/docs/images/drag-drop-events.jpg +0 -0
  245. package/docs/images/knight-moves.gif +0 -0
  246. package/docs/images/reorderable-list.gif +0 -0
@@ -0,0 +1,222 @@
1
+ "use strict";
2
+
3
+ export const getRelativePosition = ({
4
+ x,
5
+ y
6
+ }, {
7
+ width,
8
+ height,
9
+ x: x0,
10
+ y: y0
11
+ }) => {
12
+ 'worklet';
13
+
14
+ const rx = x - x0;
15
+ const ry = y - y0;
16
+ return {
17
+ relativePosition: {
18
+ x: rx,
19
+ y: ry
20
+ },
21
+ // Guard against division by zero for zero-dimension views
22
+ relativePositionRatio: {
23
+ x: rx / (width || 1),
24
+ y: ry / (height || 1)
25
+ }
26
+ };
27
+ };
28
+ export const generateRandomId = () => `${Math.random().toString(36).substring(2)}${Math.random().toString(36).substring(2)}`;
29
+
30
+ /**
31
+ * Compute the absolute position of a spatial entry by walking the parent chain.
32
+ * Accounts for scroll offsets at each level.
33
+ */
34
+ export const computeAbsolutePositionWorklet = (entryIndex, entries, scrollOffsets) => {
35
+ 'worklet';
36
+
37
+ const entry = entries[entryIndex];
38
+ if (!entry) return {
39
+ x: 0,
40
+ y: 0
41
+ };
42
+ let absX = entry.x;
43
+ let absY = entry.y;
44
+ let parentIdx = entry.parentIndex;
45
+ while (parentIdx >= 0) {
46
+ const parent = entries[parentIdx];
47
+ if (!parent) break;
48
+ const parentScroll = scrollOffsets[parentIdx] || {
49
+ x: 0,
50
+ y: 0
51
+ };
52
+ absX += parent.x - parentScroll.x;
53
+ absY += parent.y - parentScroll.y;
54
+ parentIdx = parent.parentIndex;
55
+ }
56
+ return {
57
+ x: absX,
58
+ y: absY
59
+ };
60
+ };
61
+
62
+ /**
63
+ * Extra padding (in points) applied to monitoring views during hit-testing.
64
+ * During auto-scroll the hover center can drift outside the container's visible
65
+ * bounds. This padding prevents false monitor exits that would prematurely end
66
+ * the drag. Receptive views keep exact bounds for precise drop targeting.
67
+ */
68
+ const MONITOR_HIT_TEST_PADDING = 100;
69
+
70
+ /**
71
+ * Hit-test all views in the spatial index against a given absolute position.
72
+ * Runs entirely on the UI thread as a worklet.
73
+ * Returns the deepest receptive view and all monitoring views that contain the point.
74
+ *
75
+ * @param position - Center of the hover view (absolute)
76
+ * @param entries - Spatial index entries
77
+ * @param scrollOffsets - Scroll offsets per entry
78
+ * @param excludeId - ID of the dragged view (excluded from hit-testing)
79
+ * @param draggedDimensions - Optional dimensions of the dragged view (needed for intersect/contain)
80
+ */
81
+ export const hitTestWorklet = (position, entries, scrollOffsets, excludeId, draggedDimensions) => {
82
+ 'worklet';
83
+
84
+ let receiverId = '';
85
+ const monitorIds = [];
86
+
87
+ // Find the dragged item's parent index for rejectOwnChildren check
88
+ let draggedParentIndex = -1;
89
+ for (let i = 0; i < entries.length; i++) {
90
+ if (entries[i]?.id === excludeId) {
91
+ draggedParentIndex = entries[i].parentIndex;
92
+ break;
93
+ }
94
+ }
95
+
96
+ // Dragged view bounds (for intersect/contain algorithms)
97
+ const dw = draggedDimensions?.width ?? 0;
98
+ const dh = draggedDimensions?.height ?? 0;
99
+ // position is the center of the hover view; compute top-left
100
+ const dragLeft = position.x - dw / 2;
101
+ const dragTop = position.y - dh / 2;
102
+ const dragRight = dragLeft + dw;
103
+ const dragBottom = dragTop + dh;
104
+ for (let i = 0; i < entries.length; i++) {
105
+ const entry = entries[i];
106
+ if (!entry) continue;
107
+ if (entry.id === excludeId) continue;
108
+ if (!entry.receptive && !entry.monitoring) continue;
109
+
110
+ // Skip views with zero dimensions (not yet measured)
111
+ if (entry.width === 0 || entry.height === 0) continue;
112
+
113
+ // Compute absolute position by walking parent chain
114
+ const absPos = computeAbsolutePositionWorklet(i, entries, scrollOffsets);
115
+ const recLeft = absPos.x;
116
+ const recTop = absPos.y;
117
+ const recRight = recLeft + entry.width;
118
+ const recBottom = recTop + entry.height;
119
+ let isHit;
120
+ const algo = entry.collisionAlgorithm;
121
+ if (algo === 'intersect' && dw > 0 && dh > 0) {
122
+ // Any overlap between dragged view and receiver
123
+ isHit = dragLeft < recRight && dragRight > recLeft && dragTop < recBottom && dragBottom > recTop;
124
+ } else if (algo === 'contain' && dw > 0 && dh > 0) {
125
+ // Dragged view is fully inside receiver
126
+ isHit = dragLeft >= recLeft && dragRight <= recRight && dragTop >= recTop && dragBottom <= recBottom;
127
+ } else {
128
+ // Default 'center': hover center is inside receiver
129
+ isHit = position.x >= recLeft && position.y >= recTop && position.x < recRight && position.y < recBottom;
130
+ }
131
+ if (isHit) {
132
+ if (entry.monitoring) monitorIds.push(entry.id);
133
+ // Take the last (deepest/most recently registered) receptive match
134
+ // Skip if this receiver rejects drags from its own children
135
+ if (entry.receptive) {
136
+ if (entry.rejectOwnChildren && i === draggedParentIndex) {
137
+ // This receiver is the parent of the dragged item — skip
138
+ } else {
139
+ receiverId = entry.id;
140
+ }
141
+ }
142
+ } else if (entry.monitoring) {
143
+ // Padded bounds check for monitoring views only (tolerates hover drift during auto-scroll)
144
+ const isPaddedHit = position.x >= recLeft - MONITOR_HIT_TEST_PADDING && position.y >= recTop - MONITOR_HIT_TEST_PADDING && position.x < recRight + MONITOR_HIT_TEST_PADDING && position.y < recBottom + MONITOR_HIT_TEST_PADDING;
145
+ if (isPaddedHit) {
146
+ monitorIds.push(entry.id);
147
+ }
148
+ }
149
+ }
150
+ return {
151
+ receiverId,
152
+ monitorIds
153
+ };
154
+ };
155
+
156
+ // ─── Snap Alignment Helper ──────────────────────────────────────────────
157
+
158
+ /** Named alignment positions for snap targets within a receiver */
159
+
160
+ /**
161
+ * Compute a snap target position that aligns a dragged view within a receiver
162
+ * at the specified alignment point, with an optional pixel offset.
163
+ *
164
+ * Use as the return value from onDragDrop/onReceiveDragDrop/onMonitorDragDrop:
165
+ * ```
166
+ * onReceiveDragDrop={({ dragged, receiver }) =>
167
+ * snapToAlignment(receiver.measurements, dragged.measurements, 'top-left', { x: 8, y: 8 })
168
+ * }
169
+ * ```
170
+ */
171
+ export const snapToAlignment = (receiver, dragged, alignment = 'center', offset = {
172
+ x: 0,
173
+ y: 0
174
+ }) => {
175
+ const dw = dragged?.width ?? 0;
176
+ const dh = dragged?.height ?? 0;
177
+ let x;
178
+ let y;
179
+ switch (alignment) {
180
+ case 'top-left':
181
+ x = receiver.x;
182
+ y = receiver.y;
183
+ break;
184
+ case 'top-center':
185
+ x = receiver.x + (receiver.width - dw) / 2;
186
+ y = receiver.y;
187
+ break;
188
+ case 'top-right':
189
+ x = receiver.x + receiver.width - dw;
190
+ y = receiver.y;
191
+ break;
192
+ case 'center-left':
193
+ x = receiver.x;
194
+ y = receiver.y + (receiver.height - dh) / 2;
195
+ break;
196
+ case 'center':
197
+ x = receiver.x + (receiver.width - dw) / 2;
198
+ y = receiver.y + (receiver.height - dh) / 2;
199
+ break;
200
+ case 'center-right':
201
+ x = receiver.x + receiver.width - dw;
202
+ y = receiver.y + (receiver.height - dh) / 2;
203
+ break;
204
+ case 'bottom-left':
205
+ x = receiver.x;
206
+ y = receiver.y + receiver.height - dh;
207
+ break;
208
+ case 'bottom-center':
209
+ x = receiver.x + (receiver.width - dw) / 2;
210
+ y = receiver.y + receiver.height - dh;
211
+ break;
212
+ case 'bottom-right':
213
+ x = receiver.x + receiver.width - dw;
214
+ y = receiver.y + receiver.height - dh;
215
+ break;
216
+ }
217
+ return {
218
+ x: x + offset.x,
219
+ y: y + offset.y
220
+ };
221
+ };
222
+ //# sourceMappingURL=math.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getRelativePosition","x","y","width","height","x0","y0","rx","ry","relativePosition","relativePositionRatio","generateRandomId","Math","random","toString","substring","computeAbsolutePositionWorklet","entryIndex","entries","scrollOffsets","entry","absX","absY","parentIdx","parentIndex","parent","parentScroll","MONITOR_HIT_TEST_PADDING","hitTestWorklet","position","excludeId","draggedDimensions","receiverId","monitorIds","draggedParentIndex","i","length","id","dw","dh","dragLeft","dragTop","dragRight","dragBottom","receptive","monitoring","absPos","recLeft","recTop","recRight","recBottom","isHit","algo","collisionAlgorithm","push","rejectOwnChildren","isPaddedHit","snapToAlignment","receiver","dragged","alignment","offset"],"sourceRoot":"../../src","sources":["math.ts"],"mappings":";;AAQA,OAAO,MAAMA,mBAAmB,GAAGA,CACjC;EAAEC,CAAC;EAAEC;AAAY,CAAC,EAClB;EAAEC,KAAK;EAAEC,MAAM;EAAEH,CAAC,EAAEI,EAAE;EAAEH,CAAC,EAAEI;AAAyB,CAAC,KAClD;EACH,SAAS;;EACT,MAAMC,EAAE,GAAGN,CAAC,GAAGI,EAAE;EACjB,MAAMG,EAAE,GAAGN,CAAC,GAAGI,EAAE;EACjB,OAAO;IACLG,gBAAgB,EAAE;MAAER,CAAC,EAAEM,EAAE;MAAEL,CAAC,EAAEM;IAAG,CAAC;IAClC;IACAE,qBAAqB,EAAE;MAAET,CAAC,EAAEM,EAAE,IAAIJ,KAAK,IAAI,CAAC,CAAC;MAAED,CAAC,EAAEM,EAAE,IAAIJ,MAAM,IAAI,CAAC;IAAE;EACvE,CAAC;AACH,CAAC;AAED,OAAO,MAAMO,gBAAgB,GAAGA,CAAA,KAC9B,GAAGC,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F,KAAK,cAAc;MACjBtC,CAAC,GAAGyD,QAAQ,CAACzD,CAAC,GAAGyD,QAAQ,CAACvD,KAAK,GAAGmC,EAAE;MACpCpC,CAAC,GAAGwD,QAAQ,CAACxD,CAAC,GAAGwD,QAAQ,CAACtD,MAAM,GAAGmC,EAAE;MACrC;EACJ;EAEA,OAAO;IAAEtC,CAAC,EAAEA,CAAC,GAAG4D,MAAM,CAAC5D,CAAC;IAAEC,CAAC,EAAEA,CAAC,GAAG2D,MAAM,CAAC3D;EAAE,CAAC;AAC7C,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ /** Default snapback delay in milliseconds */
4
+ export const defaultSnapbackDelay = 100;
5
+
6
+ /** Default snapback duration in milliseconds */
7
+ export const defaultSnapbackDuration = 250;
8
+
9
+ /** Default pre-drag long press delay in milliseconds */
10
+ export const defaultLongPressDelay = 0;
11
+
12
+ /** Default pre-drag long press delay in milliseconds for DraxList items */
13
+ export const defaultListItemLongPressDelay = 250;
14
+
15
+ /** Default scroll event throttle (number of events per second) for DraxScrollView */
16
+ export const defaultScrollEventThrottle = 8;
17
+
18
+ /** Default interval length in milliseconds for auto-scrolling jumps */
19
+ export const defaultAutoScrollIntervalLength = 250;
20
+
21
+ /** Default auto-scroll jump distance, as a fraction relative to content width/length */
22
+ export const defaultAutoScrollJumpRatio = 0.2;
23
+
24
+ /** Default drag-over maximum position threshold for auto-scroll back, as a fraction relative to content width/length */
25
+ export const defaultAutoScrollBackThreshold = 0.1;
26
+
27
+ /** Default drag-over minimum position threshold for auto-scroll forward, as a fraction relative to content width/length */
28
+ export const defaultAutoScrollForwardThreshold = 0.9;
29
+
30
+ /** Duration in milliseconds for list item shift/reorder animations */
31
+ export const ITEM_SHIFT_ANIMATION_DURATION = 200;
32
+
33
+ /** Resolved animation configuration for sortable item shifts */
34
+
35
+ // Frozen preset singletons — avoids object allocation on every call.
36
+ const PRESET_DEFAULT = Object.freeze({
37
+ useSpring: false,
38
+ shiftDuration: 200,
39
+ springDamping: 15,
40
+ springStiffness: 150,
41
+ springMass: 1
42
+ });
43
+ const PRESET_SPRING = Object.freeze({
44
+ useSpring: true,
45
+ shiftDuration: 200,
46
+ springDamping: 15,
47
+ springStiffness: 150,
48
+ springMass: 1
49
+ });
50
+ const PRESET_GENTLE = Object.freeze({
51
+ useSpring: true,
52
+ shiftDuration: 200,
53
+ springDamping: 20,
54
+ springStiffness: 100,
55
+ springMass: 1.2
56
+ });
57
+ const PRESET_SNAPPY = Object.freeze({
58
+ useSpring: true,
59
+ shiftDuration: 200,
60
+ springDamping: 20,
61
+ springStiffness: 300,
62
+ springMass: 0.8
63
+ });
64
+ const PRESET_NONE = Object.freeze({
65
+ useSpring: false,
66
+ shiftDuration: 0,
67
+ springDamping: 15,
68
+ springStiffness: 150,
69
+ springMass: 1
70
+ });
71
+
72
+ /** Resolve a SortableAnimationConfig (preset or custom) to concrete values */
73
+ export function resolveAnimationConfig(config) {
74
+ if (!config || config === 'default') return PRESET_DEFAULT;
75
+ if (config === 'spring') return PRESET_SPRING;
76
+ if (config === 'gentle') return PRESET_GENTLE;
77
+ if (config === 'snappy') return PRESET_SNAPPY;
78
+ if (config === 'none') return PRESET_NONE;
79
+ // Custom config — only case that allocates
80
+ return {
81
+ useSpring: config.useSpring ?? false,
82
+ shiftDuration: config.shiftDuration ?? 200,
83
+ springDamping: config.springDamping ?? 15,
84
+ springStiffness: config.springStiffness ?? 150,
85
+ springMass: config.springMass ?? 1
86
+ };
87
+ }
88
+ //# sourceMappingURL=params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["defaultSnapbackDelay","defaultSnapbackDuration","defaultLongPressDelay","defaultListItemLongPressDelay","defaultScrollEventThrottle","defaultAutoScrollIntervalLength","defaultAutoScrollJumpRatio","defaultAutoScrollBackThreshold","defaultAutoScrollForwardThreshold","ITEM_SHIFT_ANIMATION_DURATION","PRESET_DEFAULT","Object","freeze","useSpring","shiftDuration","springDamping","springStiffness","springMass","PRESET_SPRING","PRESET_GENTLE","PRESET_SNAPPY","PRESET_NONE","resolveAnimationConfig","config"],"sourceRoot":"../../src","sources":["params.ts"],"mappings":";;AAAA;AACA,OAAO,MAAMA,oBAAoB,GAAG,GAAG;;AAEvC;AACA,OAAO,MAAMC,uBAAuB,GAAG,GAAG;;AAE1C;AACA,OAAO,MAAMC,qBAAqB,GAAG,CAAC;;AAEtC;AACA,OAAO,MAAMC,6BAA6B,GAAG,GAAG;;AAEhD;AACA,OAAO,MAAMC,0BAA0B,GAAG,CAAC;;AAE3C;AACA,OAAO,MAAMC,+BAA+B,GAAG,GAAG;;AAElD;AACA,OAAO,MAAMC,0BAA0B,GAAG,GAAG;;AAE7C;AACA,OAAO,MAAMC,8BAA8B,GAAG,GAAG;;AAEjD;AACA,OAAO,MAAMC,iCAAiC,GAAG,GAAG;;AAEpD;AACA,OAAO,MAAMC,6BAA6B,GAAG,GAAG;;AAEhD;;AASA;AACA,MAAMC,cAAuC,GAAGC,MAAM,CAACC,MAAM,CAAC;EAC5DC,SAAS,EAAE,KAAK;EAAEC,aAAa,EAAE,GAAG;EAAEC,aAAa,EAAE,EAAE;EAAEC,eAAe,EAAE,GAAG;EAAEC,UAAU,EAAE;AAC7F,CAAC,CAAC;AACF,MAAMC,aAAsC,GAAGP,MAAM,CAACC,MAAM,CAAC;EAC3DC,SAAS,EAAE,IAAI;EAAEC,aAAa,EAAE,GAAG;EAAEC,aAAa,EAAE,EAAE;EAAEC,eAAe,EAAE,GAAG;EAAEC,UAAU,EAAE;AAC5F,CAAC,CAAC;AACF,MAAME,aAAsC,GAAGR,MAAM,CAACC,MAAM,CAAC;EAC3DC,SAAS,EAAE,IAAI;EAAEC,aAAa,EAAE,GAAG;EAAEC,aAAa,EAAE,EAAE;EAAEC,eAAe,EAAE,GAAG;EAAEC,UAAU,EAAE;AAC5F,CAAC,CAAC;AACF,MAAMG,aAAsC,GAAGT,MAAM,CAACC,MAAM,CAAC;EAC3DC,SAAS,EAAE,IAAI;EAAEC,aAAa,EAAE,GAAG;EAAEC,aAAa,EAAE,EAAE;EAAEC,eAAe,EAAE,GAAG;EAAEC,UAAU,EAAE;AAC5F,CAAC,CAAC;AACF,MAAMI,WAAoC,GAAGV,MAAM,CAACC,MAAM,CAAC;EACzDC,SAAS,EAAE,KAAK;EAAEC,aAAa,EAAE,CAAC;EAAEC,aAAa,EAAE,EAAE;EAAEC,eAAe,EAAE,GAAG;EAAEC,UAAU,EAAE;AAC3F,CAAC,CAAC;;AAEF;AACA,OAAO,SAASK,sBAAsBA,CACpCC,MAA6D,EACpC;EACzB,IAAI,CAACA,MAAM,IAAIA,MAAM,KAAK,SAAS,EAAE,OAAOb,cAAc;EAC1D,IAAIa,MAAM,KAAK,QAAQ,EAAE,OAAOL,aAAa;EAC7C,IAAIK,MAAM,KAAK,QAAQ,EAAE,OAAOJ,aAAa;EAC7C,IAAII,MAAM,KAAK,QAAQ,EAAE,OAAOH,aAAa;EAC7C,IAAIG,MAAM,KAAK,MAAM,EAAE,OAAOF,WAAW;EACzC;EACA,OAAO;IACLR,SAAS,EAAEU,MAAM,CAACV,SAAS,IAAI,KAAK;IACpCC,aAAa,EAAES,MAAM,CAACT,aAAa,IAAI,GAAG;IAC1CC,aAAa,EAAEQ,MAAM,CAACR,aAAa,IAAI,EAAE;IACzCC,eAAe,EAAEO,MAAM,CAACP,eAAe,IAAI,GAAG;IAC9CC,UAAU,EAAEM,MAAM,CAACN,UAAU,IAAI;EACnC,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+
3
+ // ─── Core Geometry Types ───────────────────────────────────────────────────
4
+
5
+ /** An xy-coordinate position value */
6
+
7
+ /** Predicate for checking if something is a Position */
8
+ export const isPosition = something => typeof something === 'object' && something !== null && 'x' in something && 'y' in something && typeof something.x === 'number' && typeof something.y === 'number';
9
+
10
+ /** Dimensions of a view */
11
+
12
+ /** Measurements of a Drax view for bounds checking purposes */
13
+
14
+ // ─── Drag Phase & Status Types ─────────────────────────────────────────────
15
+
16
+ /** Phase of a drag operation — drives all animated styles */
17
+
18
+ /** The states a dragged view can be in */
19
+ export let DraxViewDragStatus = /*#__PURE__*/function (DraxViewDragStatus) {
20
+ DraxViewDragStatus[DraxViewDragStatus["Inactive"] = 0] = "Inactive";
21
+ DraxViewDragStatus[DraxViewDragStatus["Dragging"] = 1] = "Dragging";
22
+ DraxViewDragStatus[DraxViewDragStatus["Released"] = 2] = "Released";
23
+ return DraxViewDragStatus;
24
+ }({});
25
+
26
+ /** The states a receiver view can be in */
27
+ export let DraxViewReceiveStatus = /*#__PURE__*/function (DraxViewReceiveStatus) {
28
+ DraxViewReceiveStatus[DraxViewReceiveStatus["Inactive"] = 0] = "Inactive";
29
+ DraxViewReceiveStatus[DraxViewReceiveStatus["Receiving"] = 1] = "Receiving";
30
+ return DraxViewReceiveStatus;
31
+ }({});
32
+
33
+ // ─── Collision Algorithm ────────────────────────────────────────────────────
34
+
35
+ /** Algorithm used to determine if a dragged view is over a receiver */
36
+
37
+ // ─── Spatial Index (SharedValue, UI Thread) ────────────────────────────────
38
+
39
+ /** Entry in the spatial index SharedValue, accessed from worklets for hit-testing */
40
+
41
+ /** Result of a UI-thread hit test */
42
+
43
+ // ─── Event Data Types (Public API) ─────────────────────────────────────────
44
+
45
+ /** Data about a view involved in a Drax event */
46
+
47
+ /** Data about a dragged view involved in a Drax event */
48
+
49
+ /** Data about a receiver view involved in a Drax event */
50
+
51
+ /** Data about a Drax drag event */
52
+
53
+ /** Supplemental type for adding a cancelled flag */
54
+
55
+ /** Predicate for checking if something has a cancelled flag */
56
+ export const isWithCancelledFlag = something => typeof something === 'object' && something !== null && 'cancelled' in something && typeof something.cancelled === 'boolean';
57
+
58
+ /** Data about a Drax drag end event */
59
+
60
+ /** Data about a Drax drag event that involves a receiver */
61
+
62
+ /** Data about a Drax drag/receive end event */
63
+
64
+ /** Data about a Drax monitor event */
65
+
66
+ /** Data about a Drax monitor drag end event */
67
+
68
+ /** Data about a Drax monitor drag-drop event */
69
+
70
+ // ─── Snap Types ────────────────────────────────────────────────────────────
71
+
72
+ /** Preset values for specifying snap targets without a Position */
73
+ export let DraxSnapbackTargetPreset = /*#__PURE__*/function (DraxSnapbackTargetPreset) {
74
+ DraxSnapbackTargetPreset[DraxSnapbackTargetPreset["Default"] = 0] = "Default";
75
+ DraxSnapbackTargetPreset[DraxSnapbackTargetPreset["None"] = 1] = "None";
76
+ return DraxSnapbackTargetPreset;
77
+ }({});
78
+
79
+ /** Target for snap hover view release animation: none, default, or specified Position */
80
+
81
+ /** Response type for drag end callbacks, allowing override of default release snap behavior */
82
+
83
+ /** Data about a Drax snap, used for custom animations */
84
+
85
+ /** Data passed to onSnapEnd and onReceiveSnapEnd callbacks */
86
+
87
+ // ─── Render Content Props ──────────────────────────────────────────────────
88
+
89
+ /** Simplified view state for render content props */
90
+
91
+ /** Tracking status indicating whether anything is being dragged/received */
92
+
93
+ /** Props provided to a render function for a Drax view */
94
+
95
+ /** Props provided to a render function for a hovering copy of a Drax view */
96
+
97
+ // ─── Style Types ───────────────────────────────────────────────────────────
98
+
99
+ /** Style prop for DraxView drag/receive states (flattened for worklets) */
100
+
101
+ /** Style prop for hover views (supports animated styles) */
102
+
103
+ /** Style-related props for a Drax view */
104
+
105
+ // ─── Custom render functions ───────────────────────────────────────────────
106
+
107
+ /** Custom render function for content of a DraxView */
108
+
109
+ /** Custom render function for content of hovering copy of a DraxView */
110
+
111
+ // ─── View Props ────────────────────────────────────────────────────────────
112
+
113
+ /** Props for a DraxView */
114
+
115
+ // ─── View Registry (JS Thread) ─────────────────────────────────────────────
116
+
117
+ /** Entry in the JS-thread view registry Map */
118
+
119
+ // ─── Context Value ─────────────────────────────────────────────────────────
120
+
121
+ /** Context value used internally by Drax provider */
122
+
123
+ /** Payload for registering a Drax view */
124
+
125
+ // ─── Provider / Subprovider Props ──────────────────────────────────────────
126
+
127
+ /** Event data for provider-level drag callbacks */
128
+
129
+ /** Optional props that can be passed to a DraxProvider */
130
+
131
+ /** Props that are passed to a DraxSubprovider */
132
+
133
+ // ─── External Registration ─────────────────────────────────────────────────
134
+
135
+ /** Methods provided by a DraxView when registered externally */
136
+
137
+ /** Information about the parent of a nested DraxView */
138
+
139
+ /** Function that receives a Drax view measurement */
140
+
141
+ // ─── Auto-scroll Types ─────────────────────────────────────────────────────
142
+
143
+ /** Auto-scroll direction used internally by DraxScrollView and DraxList */
144
+ export let AutoScrollDirection = /*#__PURE__*/function (AutoScrollDirection) {
145
+ AutoScrollDirection[AutoScrollDirection["Back"] = -1] = "Back";
146
+ AutoScrollDirection[AutoScrollDirection["None"] = 0] = "None";
147
+ AutoScrollDirection[AutoScrollDirection["Forward"] = 1] = "Forward";
148
+ return AutoScrollDirection;
149
+ }({});
150
+
151
+ /** Auto-scroll state used internally by DraxScrollView */
152
+
153
+ /** Props for auto-scroll options */
154
+
155
+ // ─── ScrollView Props ──────────────────────────────────────────────────────
156
+
157
+ /** Props for a DraxScrollView */
158
+
159
+ // ─── Sortable Types (List-Agnostic) ─────────────────────────────────────────
160
+
161
+ /** Reorder strategy for sortable lists */
162
+
163
+ /** Named animation preset for sortable item shift animations */
164
+
165
+ /** Custom animation configuration for sortable item shifts */
166
+
167
+ /** Animation configuration: a preset name or custom config object */
168
+
169
+ /** Measurement for a single sortable item, keyed by item key */
170
+
171
+ /** Internal payload attached to each SortableItem's DraxView */
172
+
173
+ /** Type guard for SortableItemPayload */
174
+ export function isSortableItemPayload(value) {
175
+ return typeof value === 'object' && value !== null && 'index' in value && 'originalIndex' in value && typeof value.index === 'number' && typeof value.originalIndex === 'number';
176
+ }
177
+
178
+ /** Event data for sortable drag start */
179
+
180
+ /** Event data for sortable drag position change */
181
+
182
+ /** Event data for sortable drag end */
183
+
184
+ /** Event data for sortable item reorder */
185
+
186
+ /** Props for rendering a drop indicator in a sortable container */
187
+
188
+ /** Options for useSortableList hook */
189
+
190
+ /** Handle returned by useSortableList — pass to SortableContainer and SortableItem */
191
+
192
+ /** Internal state of the sortable list (not part of public API contract) */
193
+
194
+ // ─── Board Types (Cross-Container Sortable) ──────────────────────────────
195
+
196
+ /** Phantom slot for cross-container drag: virtual space in target column */
197
+
198
+ /** Event data for cross-container item transfer */
199
+
200
+ /** Options for useSortableBoard hook */
201
+
202
+ /** Handle returned by useSortableBoard — pass to SortableBoardContainer */
203
+
204
+ /** Transfer state during cross-container drag */
205
+
206
+ /** Internal state of the sortable board (not part of public API contract) */
207
+
208
+ /** Context value for board coordination.
209
+ * Uses Pick to avoid generic variance issues — consumers only need
210
+ * transferState and finalizeTransfer, not typed item fields. */
211
+
212
+ // ─── Utility Types ─────────────────────────────────────────────────────────
213
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isPosition","something","x","y","DraxViewDragStatus","DraxViewReceiveStatus","isWithCancelledFlag","cancelled","DraxSnapbackTargetPreset","AutoScrollDirection","isSortableItemPayload","value","index","originalIndex"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;AAgBA;;AAEA;;AAQA;AACA,OAAO,MAAMA,UAAU,GAAIC,SAAkB,IAC3C,OAAOA,SAAS,KAAK,QAAQ,IAC7BA,SAAS,KAAK,IAAI,IAClB,GAAG,IAAIA,SAAS,IAChB,GAAG,IAAIA,SAAS,IAChB,OAAOA,SAAS,CAACC,CAAC,KAAK,QAAQ,IAC/B,OAAOD,SAAS,CAACE,CAAC,KAAK,QAAQ;;AAEjC;;AAMA;;AAOA;;AAEA;;AAGA;AACA,WAAYC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;;AAM9B;AACA,WAAYC,qBAAqB,0BAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAAA,OAArBA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MA;;AAQA;;AAQA;;AAUA;;AAQA;;AAwCA;;AAcA;;AAoGA;;AAEA;;AAOA;;AASA;;AAMA;;AAKA;;AAWA;;AAYA;AACA;AACA;;AAOA","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,17 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { SharedValue } from 'react-native-reanimated';
3
+ import type { Position, SpatialEntry } from './types';
4
+ interface DebugOverlayProps {
5
+ spatialIndexSV: SharedValue<SpatialEntry[]>;
6
+ scrollOffsetsSV: SharedValue<Position[]>;
7
+ }
8
+ /**
9
+ * Debug overlay that visualizes all registered Drax views.
10
+ * Reads the spatial index SharedValue and renders colored borders
11
+ * showing view bounds, roles (draggable/receptive/monitoring), and IDs.
12
+ *
13
+ * Rendered as an absolute-fill sibling in DraxProvider when debug={true}.
14
+ */
15
+ export declare const DebugOverlay: ({ spatialIndexSV, scrollOffsetsSV, }: DebugOverlayProps) => ReactNode;
16
+ export {};
17
+ //# sourceMappingURL=DebugOverlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DebugOverlay.d.ts","sourceRoot":"","sources":["../../../src/DebugOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEtD,UAAU,iBAAiB;IACzB,cAAc,EAAE,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC;IAC5C,eAAe,EAAE,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;CAC1C;AA4CD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,sCAG1B,iBAAiB,KAAG,SAkDtB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { DraxHandle } from './DraxHandle';
2
+ /**
3
+ * Namespace object for convenient access to all Drax components.
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * import { Drax } from 'react-native-drax';
8
+ *
9
+ * <Drax.Provider>
10
+ * <Drax.View draggable>
11
+ * <Drax.Handle><GripIcon /></Drax.Handle>
12
+ * </Drax.View>
13
+ * </Drax.Provider>
14
+ * ```
15
+ */
16
+ export declare const Drax: {
17
+ readonly Handle: typeof DraxHandle;
18
+ readonly List: <T>({ component: ListComponent, ref, id, data, keyExtractor, onReorder, renderItem, reorderStrategy, longPressDelay, lockToMainAxis, animationConfig, inactiveItemStyle, itemEntering, itemExiting, itemDraxViewProps, containerDraxViewProps, containerStyle, onDragStart, onDragPositionChange, onDragEnd, style, horizontal, numColumns, ...listProps }: import("./DraxList").DraxListProps<T> & Record<string, any>) => import("react").ReactNode;
19
+ readonly Provider: ({ style, debug, onDragStart: onProviderDragStart, onDrag: onProviderDrag, onDragEnd: onProviderDragEnd, children, }: import("./types").DraxProviderProps) => import("react").ReactNode;
20
+ readonly ScrollView: (props: import("react").PropsWithChildren<import("./types").DraxScrollViewProps> & {
21
+ ref?: import("react").Ref<import("react-native").ScrollView>;
22
+ }) => import("react/jsx-runtime").JSX.Element;
23
+ readonly View: import("react").MemoExoticComponent<(props: import("./types").DraxViewProps) => import("react").ReactNode>;
24
+ readonly SortableBoardContainer: <TItem>({ board, style, children, draxViewProps, }: import("./SortableBoardContainer").SortableBoardContainerProps<TItem>) => import("react/jsx-runtime").JSX.Element;
25
+ readonly SortableContainer: ({ sortable, scrollRef, style, children, draxViewProps, renderDropIndicator, }: import("./SortableContainer").SortableContainerProps) => import("react/jsx-runtime").JSX.Element;
26
+ readonly SortableItem: ({ sortable, index, fixed, children, ...draxViewProps }: import("./SortableItem").SortableItemProps) => import("react/jsx-runtime").JSX.Element;
27
+ };
28
+ //# sourceMappingURL=Drax.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Drax.d.ts","sourceRoot":"","sources":["../../../src/Drax.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAS1C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,IAAI;;;;;WAMf,CAAA;;;;;;CAGQ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { DraxContextValue } from './types';
2
+ export declare const DraxContext: import("react").Context<DraxContextValue | undefined>;
3
+ //# sourceMappingURL=DraxContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DraxContext.d.ts","sourceRoot":"","sources":["../../../src/DraxContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,WAAW,uDAEvB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { StyleProp, ViewStyle } from 'react-native';
3
+ export interface DraxHandleProps {
4
+ children: ReactNode;
5
+ style?: StyleProp<ViewStyle>;
6
+ }
7
+ /**
8
+ * Drag handle component — only touches on this area will start a drag.
9
+ *
10
+ * Must be a descendant of a `DraxView` that has `dragHandle={true}`.
11
+ * The parent DraxView provides its gesture via context; this component
12
+ * attaches it to the handle's touch area via GestureDetector.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * <DraxView dragHandle style={styles.row}>
17
+ * <DraxHandle style={styles.grip}>
18
+ * <GripIcon />
19
+ * </DraxHandle>
20
+ * <Text>Item content</Text>
21
+ * </DraxView>
22
+ * ```
23
+ */
24
+ export declare function DraxHandle({ children, style }: DraxHandleProps): import("react/jsx-runtime").JSX.Element;
25
+ //# sourceMappingURL=DraxHandle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DraxHandle.d.ts","sourceRoot":"","sources":["../../../src/DraxHandle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMzD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,eAAe,2CAqB9D"}