@molecule/app-ui-react-native 2.0.1 → 2.2.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 (193) hide show
  1. package/README.md +81 -10
  2. package/dist/components/Alert.d.ts.map +1 -1
  3. package/dist/components/Alert.js +2 -3
  4. package/dist/components/Button.d.ts +3 -1
  5. package/dist/components/Button.d.ts.map +1 -1
  6. package/dist/components/Button.js +35 -3
  7. package/dist/components/Skeleton.d.ts.map +1 -1
  8. package/dist/components/Skeleton.js +13 -12
  9. package/dist/components/Spinner.js +2 -2
  10. package/dist/elements/Anchor.d.ts +15 -0
  11. package/dist/elements/Anchor.d.ts.map +1 -0
  12. package/dist/elements/Anchor.js +57 -0
  13. package/dist/elements/Box.d.ts +19 -0
  14. package/dist/elements/Box.d.ts.map +1 -0
  15. package/dist/elements/Box.js +157 -0
  16. package/dist/elements/CheckField.d.ts +18 -0
  17. package/dist/elements/CheckField.d.ts.map +1 -0
  18. package/dist/elements/CheckField.js +103 -0
  19. package/dist/elements/Disclosure.d.ts +11 -0
  20. package/dist/elements/Disclosure.d.ts.map +1 -0
  21. package/dist/elements/Disclosure.js +67 -0
  22. package/dist/elements/Fieldset.d.ts +16 -0
  23. package/dist/elements/Fieldset.d.ts.map +1 -0
  24. package/dist/elements/Fieldset.js +34 -0
  25. package/dist/elements/FileField.d.ts +12 -0
  26. package/dist/elements/FileField.d.ts.map +1 -0
  27. package/dist/elements/FileField.js +111 -0
  28. package/dist/elements/FormArea.d.ts +18 -0
  29. package/dist/elements/FormArea.d.ts.map +1 -0
  30. package/dist/elements/FormArea.js +42 -0
  31. package/dist/elements/GlyphIcon.d.ts +19 -0
  32. package/dist/elements/GlyphIcon.d.ts.map +1 -0
  33. package/dist/elements/GlyphIcon.js +43 -0
  34. package/dist/elements/Image.d.ts +17 -0
  35. package/dist/elements/Image.d.ts.map +1 -0
  36. package/dist/elements/Image.js +26 -0
  37. package/dist/elements/Link.d.ts +20 -0
  38. package/dist/elements/Link.d.ts.map +1 -0
  39. package/dist/elements/Link.js +53 -0
  40. package/dist/elements/Pressable.d.ts +18 -0
  41. package/dist/elements/Pressable.d.ts.map +1 -0
  42. package/dist/elements/Pressable.js +108 -0
  43. package/dist/elements/PulseDots.d.ts +15 -0
  44. package/dist/elements/PulseDots.d.ts.map +1 -0
  45. package/dist/elements/PulseDots.js +78 -0
  46. package/dist/elements/RangeField.d.ts +11 -0
  47. package/dist/elements/RangeField.d.ts.map +1 -0
  48. package/dist/elements/RangeField.js +266 -0
  49. package/dist/elements/RichText.d.ts +23 -0
  50. package/dist/elements/RichText.d.ts.map +1 -0
  51. package/dist/elements/RichText.js +55 -0
  52. package/dist/elements/Rule.d.ts +11 -0
  53. package/dist/elements/Rule.d.ts.map +1 -0
  54. package/dist/elements/Rule.js +19 -0
  55. package/dist/elements/ScrollArea.d.ts +21 -0
  56. package/dist/elements/ScrollArea.d.ts.map +1 -0
  57. package/dist/elements/ScrollArea.js +101 -0
  58. package/dist/elements/SelectAction.d.ts +20 -0
  59. package/dist/elements/SelectAction.d.ts.map +1 -0
  60. package/dist/elements/SelectAction.js +117 -0
  61. package/dist/elements/SelectField.d.ts +11 -0
  62. package/dist/elements/SelectField.d.ts.map +1 -0
  63. package/dist/elements/SelectField.js +220 -0
  64. package/dist/elements/SelectMenu.d.ts +19 -0
  65. package/dist/elements/SelectMenu.d.ts.map +1 -0
  66. package/dist/elements/SelectMenu.js +122 -0
  67. package/dist/elements/Svg.d.ts +155 -0
  68. package/dist/elements/Svg.d.ts.map +1 -0
  69. package/dist/elements/Svg.js +535 -0
  70. package/dist/elements/TableBox.d.ts +19 -0
  71. package/dist/elements/TableBox.d.ts.map +1 -0
  72. package/dist/elements/TableBox.js +87 -0
  73. package/dist/elements/TableCell.d.ts +16 -0
  74. package/dist/elements/TableCell.d.ts.map +1 -0
  75. package/dist/elements/TableCell.js +69 -0
  76. package/dist/elements/Text.d.ts +17 -0
  77. package/dist/elements/Text.d.ts.map +1 -0
  78. package/dist/elements/Text.js +96 -0
  79. package/dist/elements/TextField.d.ts +25 -0
  80. package/dist/elements/TextField.d.ts.map +1 -0
  81. package/dist/elements/TextField.js +257 -0
  82. package/dist/elements/accessibility.d.ts +36 -0
  83. package/dist/elements/accessibility.d.ts.map +1 -0
  84. package/dist/elements/accessibility.js +244 -0
  85. package/dist/elements/className.d.ts +45 -0
  86. package/dist/elements/className.d.ts.map +1 -0
  87. package/dist/elements/className.js +8 -0
  88. package/dist/elements/decimal.d.ts +5 -0
  89. package/dist/elements/decimal.d.ts.map +1 -0
  90. package/dist/elements/decimal.js +11 -0
  91. package/dist/elements/documentUrl.d.ts +35 -0
  92. package/dist/elements/documentUrl.d.ts.map +1 -0
  93. package/dist/elements/documentUrl.js +89 -0
  94. package/dist/elements/drag-drop.d.ts +11 -0
  95. package/dist/elements/drag-drop.d.ts.map +1 -0
  96. package/dist/elements/drag-drop.js +277 -0
  97. package/dist/elements/drag.d.ts +53 -0
  98. package/dist/elements/drag.d.ts.map +1 -0
  99. package/dist/elements/drag.js +520 -0
  100. package/dist/elements/dragModifiers.d.ts +22 -0
  101. package/dist/elements/dragModifiers.d.ts.map +1 -0
  102. package/dist/elements/dragModifiers.js +62 -0
  103. package/dist/elements/events.d.ts +45 -0
  104. package/dist/elements/events.d.ts.map +1 -0
  105. package/dist/elements/events.js +101 -0
  106. package/dist/elements/fieldBounds.d.ts +5 -0
  107. package/dist/elements/fieldBounds.d.ts.map +1 -0
  108. package/dist/elements/fieldBounds.js +60 -0
  109. package/dist/elements/flow.d.ts +36 -0
  110. package/dist/elements/flow.d.ts.map +1 -0
  111. package/dist/elements/flow.js +47 -0
  112. package/dist/elements/form.d.ts +48 -0
  113. package/dist/elements/form.d.ts.map +1 -0
  114. package/dist/elements/form.js +112 -0
  115. package/dist/elements/grid.d.ts +96 -0
  116. package/dist/elements/grid.d.ts.map +1 -0
  117. package/dist/elements/grid.js +272 -0
  118. package/dist/elements/index.d.ts +36 -0
  119. package/dist/elements/index.d.ts.map +1 -0
  120. package/dist/elements/index.js +35 -0
  121. package/dist/elements/inherited.d.ts +181 -0
  122. package/dist/elements/inherited.d.ts.map +1 -0
  123. package/dist/elements/inherited.js +512 -0
  124. package/dist/elements/labels.d.ts +39 -0
  125. package/dist/elements/labels.d.ts.map +1 -0
  126. package/dist/elements/labels.js +163 -0
  127. package/dist/elements/measure.d.ts +27 -0
  128. package/dist/elements/measure.d.ts.map +1 -0
  129. package/dist/elements/measure.js +24 -0
  130. package/dist/elements/outsidePress.d.ts +31 -0
  131. package/dist/elements/outsidePress.d.ts.map +1 -0
  132. package/dist/elements/outsidePress.js +94 -0
  133. package/dist/elements/paste.d.ts +22 -0
  134. package/dist/elements/paste.d.ts.map +1 -0
  135. package/dist/elements/paste.js +49 -0
  136. package/dist/elements/press.d.ts +41 -0
  137. package/dist/elements/press.d.ts.map +1 -0
  138. package/dist/elements/press.js +131 -0
  139. package/dist/elements/rangeKeyboard.d.ts +41 -0
  140. package/dist/elements/rangeKeyboard.d.ts.map +1 -0
  141. package/dist/elements/rangeKeyboard.js +58 -0
  142. package/dist/elements/rangeValues.d.ts +20 -0
  143. package/dist/elements/rangeValues.d.ts.map +1 -0
  144. package/dist/elements/rangeValues.js +101 -0
  145. package/dist/elements/ref.d.ts +16 -0
  146. package/dist/elements/ref.d.ts.map +1 -0
  147. package/dist/elements/ref.js +22 -0
  148. package/dist/elements/reveal.d.ts +8 -0
  149. package/dist/elements/reveal.d.ts.map +1 -0
  150. package/dist/elements/reveal.js +10 -0
  151. package/dist/elements/scrollReveal.d.ts +19 -0
  152. package/dist/elements/scrollReveal.d.ts.map +1 -0
  153. package/dist/elements/scrollReveal.js +52 -0
  154. package/dist/elements/selectOptions.d.ts +25 -0
  155. package/dist/elements/selectOptions.d.ts.map +1 -0
  156. package/dist/elements/selectOptions.js +60 -0
  157. package/dist/elements/style.d.ts +30 -0
  158. package/dist/elements/style.d.ts.map +1 -0
  159. package/dist/elements/style.js +368 -0
  160. package/dist/elements/svgHover.d.ts +41 -0
  161. package/dist/elements/svgHover.d.ts.map +1 -0
  162. package/dist/elements/svgHover.js +152 -0
  163. package/dist/elements/table.d.ts +52 -0
  164. package/dist/elements/table.d.ts.map +1 -0
  165. package/dist/elements/table.js +104 -0
  166. package/dist/elements/types.d.ts +25 -0
  167. package/dist/elements/types.d.ts.map +1 -0
  168. package/dist/elements/types.js +8 -0
  169. package/dist/elements/viewport.d.ts +53 -0
  170. package/dist/elements/viewport.d.ts.map +1 -0
  171. package/dist/elements/viewport.js +62 -0
  172. package/dist/elements/wheelZoom.d.ts +12 -0
  173. package/dist/elements/wheelZoom.d.ts.map +1 -0
  174. package/dist/elements/wheelZoom.js +8 -0
  175. package/dist/index.d.ts +9 -4
  176. package/dist/index.d.ts.map +1 -1
  177. package/dist/index.js +9 -4
  178. package/dist/platform/focus.d.ts +31 -0
  179. package/dist/platform/focus.d.ts.map +1 -0
  180. package/dist/platform/focus.js +93 -0
  181. package/dist/platform/index.d.ts +31 -0
  182. package/dist/platform/index.d.ts.map +1 -0
  183. package/dist/platform/index.js +179 -0
  184. package/dist/platform/layout.d.ts +13 -0
  185. package/dist/platform/layout.d.ts.map +1 -0
  186. package/dist/platform/layout.js +15 -0
  187. package/dist/platform/position.d.ts +5 -0
  188. package/dist/platform/position.d.ts.map +1 -0
  189. package/dist/platform/position.js +177 -0
  190. package/dist/platform/stack.d.ts +86 -0
  191. package/dist/platform/stack.d.ts.map +1 -0
  192. package/dist/platform/stack.js +318 -0
  193. package/package.json +67 -8
@@ -0,0 +1,277 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * React Native drag gestures and accessible destination controls.
4
+ *
5
+ * @module
6
+ */
7
+ import { createContext, useCallback, useContext, useLayoutEffect, useMemo, useRef, useState, } from 'react';
8
+ import { PanResponder, View } from 'react-native';
9
+ import { DragDropRendererProvider, } from '@molecule/app-drag-drop/react';
10
+ import { measureElement } from './measure.js';
11
+ import { Pressable } from './Pressable.js';
12
+ const ScopeContext = createContext(null);
13
+ const DRAG_THRESHOLD = 8;
14
+ const MEASUREMENT_TIMEOUT_MS = 250;
15
+ /** Measures a snapshot of the targets registered to the current gesture scope. */
16
+ function measureTargets(targets) {
17
+ return new Promise((resolve) => {
18
+ const views = [...targets];
19
+ const positions = [];
20
+ let pending = views.length;
21
+ if (!pending) {
22
+ resolve(positions);
23
+ return;
24
+ }
25
+ // An unmounted view may never call back. Finish with the views that still measured.
26
+ const timeout = setTimeout(() => resolve([...positions]), MEASUREMENT_TIMEOUT_MS);
27
+ for (const [id, measure] of views) {
28
+ measure((box) => {
29
+ if (box.width > 0 && box.height > 0)
30
+ positions.push({ ...box, id, measure });
31
+ pending--;
32
+ if (!pending) {
33
+ clearTimeout(timeout);
34
+ resolve(positions);
35
+ }
36
+ });
37
+ }
38
+ });
39
+ }
40
+ /** Finds a mounted target in the current scope whose measured bounds contain the position. */
41
+ function targetAt(targets, positions, x, y) {
42
+ return positions.find((position) => targets.get(position.id) === position.measure &&
43
+ x >= position.x &&
44
+ x < position.x + position.width &&
45
+ y >= position.y &&
46
+ y < position.y + position.height);
47
+ }
48
+ /** Bounds each drag gesture and the target registry to one feature instance. */
49
+ function DragScope({ children, onDragStart, onDragMove, onDragEnd, retainTarget = false, }) {
50
+ const handlers = useRef({ onDragStart, onDragMove, onDragEnd });
51
+ const active = useRef(null);
52
+ useLayoutEffect(() => {
53
+ handlers.current = { onDragStart, onDragMove, onDragEnd };
54
+ }, [onDragStart, onDragMove, onDragEnd]);
55
+ const scope = useMemo(() => {
56
+ const targets = new Map();
57
+ const end = (gesture, reason, target) => {
58
+ if (active.current !== gesture)
59
+ return;
60
+ active.current = null;
61
+ const over = target ?? (retainTarget && reason !== 'unmount' ? gesture.over : undefined);
62
+ const overId = over && targets.get(over.id) === over.measure ? over.id : undefined;
63
+ handlers.current.onDragEnd?.({ ...gesture.token, overId, reason });
64
+ };
65
+ const visit = (gesture, positions, { x, y }) => {
66
+ const over = targetAt(targets, positions, x, y);
67
+ if ((!over && retainTarget) || over?.measure === gesture.over?.measure)
68
+ return;
69
+ gesture.over = over;
70
+ handlers.current.onDragMove?.({ ...gesture.token, overId: over?.id });
71
+ };
72
+ return {
73
+ register: (id, measure) => {
74
+ targets.set(id, measure);
75
+ return () => {
76
+ if (targets.get(id) === measure)
77
+ targets.delete(id);
78
+ };
79
+ },
80
+ begin: (source) => {
81
+ if (active.current)
82
+ end(active.current, 'cancel');
83
+ // The source keeps only this identity. Measured views belong to the active scope.
84
+ const token = { ...source };
85
+ const gesture = { token, pending: [] };
86
+ active.current = gesture;
87
+ handlers.current.onDragStart?.(source);
88
+ if (retainTarget || handlers.current.onDragMove) {
89
+ void measureTargets(targets).then((positions) => {
90
+ if (active.current !== gesture)
91
+ return;
92
+ gesture.positions = positions;
93
+ for (const point of gesture.pending.splice(0))
94
+ visit(gesture, positions, point);
95
+ if (gesture.ending === 'cancel')
96
+ end(gesture, 'cancel');
97
+ });
98
+ }
99
+ return token;
100
+ },
101
+ hover: (token, x, y) => {
102
+ const gesture = active.current;
103
+ if (gesture?.token !== token || gesture.ending)
104
+ return;
105
+ if (gesture.positions)
106
+ visit(gesture, gesture.positions, { x, y });
107
+ else if (retainTarget)
108
+ gesture.pending.push({ x, y });
109
+ },
110
+ release: (token, x, y) => {
111
+ const gesture = active.current;
112
+ if (gesture?.token !== token || gesture.ending)
113
+ return;
114
+ gesture.ending = 'drop';
115
+ void measureTargets(targets).then((positions) => {
116
+ if (active.current !== gesture || gesture.ending !== 'drop')
117
+ return;
118
+ for (const point of gesture.pending.splice(0))
119
+ visit(gesture, positions, point);
120
+ end(gesture, 'drop', targetAt(targets, positions, x, y));
121
+ });
122
+ },
123
+ cancel: (token, reason = 'cancel') => {
124
+ const gesture = active.current;
125
+ if (gesture?.token !== token)
126
+ return;
127
+ // A fast interruption can arrive before the bridge measures the targets.
128
+ if (reason === 'cancel' && gesture.pending.length)
129
+ gesture.ending = reason;
130
+ else
131
+ end(gesture, reason);
132
+ },
133
+ activate: (source, targetId) => {
134
+ if (!targets.has(targetId))
135
+ return;
136
+ if (active.current)
137
+ end(active.current, 'cancel');
138
+ handlers.current.onDragEnd?.({ ...source, overId: targetId, reason: 'drop' });
139
+ },
140
+ };
141
+ }, [retainTarget]);
142
+ useLayoutEffect(() => () => {
143
+ if (active.current)
144
+ scope.cancel(active.current.token, 'unmount');
145
+ }, [scope]);
146
+ return _jsx(ScopeContext.Provider, { value: scope, children: children });
147
+ }
148
+ /** Reads the interaction scope that owns this source or target. */
149
+ function useGestureScope() {
150
+ const scope = useContext(ScopeContext);
151
+ if (!scope)
152
+ throw new Error('Native drag sources and targets require a drag scope.');
153
+ return scope;
154
+ }
155
+ /** Registers the native host whose measured bounds can accept a drop. */
156
+ function useTargetRef(id, measure) {
157
+ const { register } = useGestureScope();
158
+ const unregister = useRef(null);
159
+ return useCallback((host) => {
160
+ unregister.current?.();
161
+ unregister.current = host ? register(id, (receive) => measure(host, receive)) : null;
162
+ }, [id, measure, register]);
163
+ }
164
+ /** Matches the root coordinates emitted by the legacy PanResponder source. */
165
+ function measureInRoot(view, receive) {
166
+ view.measure((_left, _top, width, height, x, y) => receive({ x, y, width, height }));
167
+ }
168
+ /** Measures and registers the native host that accepts a drop. */
169
+ function DropTarget({ id, children }) {
170
+ const setView = useTargetRef(id, measureInRoot);
171
+ return (_jsx(View, { collapsable: false, ref: setView, children: children }));
172
+ }
173
+ /** Binds a native responder and provides individually accessible move actions. */
174
+ function DragSource({ source, controls, children }) {
175
+ const scope = useGestureScope();
176
+ const currentSource = useRef(source);
177
+ const gesture = useRef(null);
178
+ useLayoutEffect(() => {
179
+ currentSource.current = source;
180
+ }, [source]);
181
+ useLayoutEffect(() => () => {
182
+ if (gesture.current)
183
+ scope.cancel(gesture.current, 'unmount');
184
+ }, [scope]);
185
+ const { panHandlers } = useMemo(() => {
186
+ const cancel = () => {
187
+ if (gesture.current)
188
+ scope.cancel(gesture.current);
189
+ gesture.current = null;
190
+ };
191
+ return PanResponder.create({
192
+ onMoveShouldSetPanResponder: (_event, { dx, dy, numberActiveTouches }) => numberActiveTouches === 1 && Math.hypot(dx, dy) >= DRAG_THRESHOLD,
193
+ onPanResponderGrant: () => {
194
+ gesture.current = scope.begin(currentSource.current);
195
+ },
196
+ onPanResponderStart: (_event, { numberActiveTouches }) => {
197
+ if (numberActiveTouches > 1)
198
+ cancel();
199
+ },
200
+ onPanResponderMove: (_event, { moveX, moveY }) => {
201
+ if (gesture.current)
202
+ scope.hover(gesture.current, moveX, moveY);
203
+ },
204
+ onPanResponderRelease: ({ nativeEvent: { pageX, pageY } }) => {
205
+ if (gesture.current)
206
+ scope.release(gesture.current, pageX, pageY);
207
+ },
208
+ onPanResponderTerminationRequest: () => true,
209
+ onPanResponderReject: cancel,
210
+ onPanResponderTerminate: cancel,
211
+ });
212
+ }, [scope]);
213
+ return (_jsxs(_Fragment, { children: [_jsx(View, { accessible: false, ...panHandlers, children: children }), _jsx(MoveControls, { source: source, controls: controls })] }));
214
+ }
215
+ /** Offers accessible move actions using the same target IDs as a drag. */
216
+ function MoveControls({ source, controls, }) {
217
+ const scope = useGestureScope();
218
+ const [expanded, setExpanded] = useState(false);
219
+ if (!controls || controls.choices.length === 0)
220
+ return null;
221
+ const controlLabel = expanded ? controls.cancelLabel : controls.label;
222
+ return (_jsxs(_Fragment, { children: [_jsx(Pressable, { as: "button", type: "button", className: controls.className, "data-mol-id": controls.id, "aria-label": controlLabel, "aria-expanded": expanded, onClick: () => setExpanded(!expanded), children: controlLabel }), expanded &&
223
+ controls.choices.map(({ targetId, label }) => (_jsx(Pressable, { as: "button", type: "button", className: controls.className, "data-mol-id": `${controls.id}-to-${targetId}`, "aria-label": label, onClick: () => {
224
+ setExpanded(false);
225
+ scope.activate(source, targetId);
226
+ }, children: label }, targetId)))] }));
227
+ }
228
+ /** Keeps the current target when dragging between renders. */
229
+ function ScopedScope(props) {
230
+ return _jsx(DragScope, { ...props, retainTarget: true });
231
+ }
232
+ /** Binds a draggable element and its move controls to the scope. */
233
+ function ScopedSource({ source, controls, disabled, children, }) {
234
+ const scope = useGestureScope();
235
+ const token = useRef(null);
236
+ useLayoutEffect(() => () => {
237
+ if (token.current)
238
+ scope.cancel(token.current, 'unmount');
239
+ token.current = null;
240
+ }, [scope, source.id, disabled]);
241
+ /** Sends the element contact to the scope in window coordinates. */
242
+ function move({ x, y, bounds }, terminal) {
243
+ if (!token.current)
244
+ return;
245
+ const send = terminal ? scope.release : scope.hover;
246
+ send(token.current, bounds.x + x, bounds.y + y);
247
+ }
248
+ const drag = disabled
249
+ ? undefined
250
+ : {
251
+ onStart: () => {
252
+ token.current = scope.begin(source);
253
+ },
254
+ onMove: (point) => move(point, false),
255
+ onEnd: (point) => move(point, true),
256
+ onCancel: () => {
257
+ if (token.current)
258
+ scope.cancel(token.current);
259
+ },
260
+ };
261
+ return (_jsxs(_Fragment, { children: [children({ drag }), !disabled && _jsx(MoveControls, { source: source, controls: controls })] }));
262
+ }
263
+ /** Wires an element as a target, optionally with a drag source. */
264
+ function ScopedTarget({ id, source, children }) {
265
+ const ref = useTargetRef(id, measureElement);
266
+ return source ? (_jsx(ScopedSource, { ...source, source: { id }, children: ({ drag }) => children({ ref, drag }) })) : (_jsx(_Fragment, { children: children({ ref }) }));
267
+ }
268
+ const nativeDragDrop = {
269
+ Scope: DragScope,
270
+ Source: DragSource,
271
+ Target: DropTarget,
272
+ scoped: { Scope: ScopedScope, Source: ScopedSource, Target: ScopedTarget },
273
+ };
274
+ /** Enables React Native drag-and-drop gestures and move controls in the subtree. */
275
+ export function NativeDragDropProvider({ children }) {
276
+ return _jsx(DragDropRendererProvider, { value: nativeDragDrop, children: children });
277
+ }
@@ -0,0 +1,53 @@
1
+ import { type RefCallback, type RefObject } from 'react';
2
+ import type { PressableProps, View, ViewProps } from 'react-native';
3
+ import type { BoxProps, ElementDrag, ElementZoom, InteractionProps } from '@molecule/app-ui';
4
+ import { type DragModifiers } from './dragModifiers.js';
5
+ type FrameHost = Pick<View, 'measure' | 'measureInWindow'>;
6
+ type FrameRef = RefObject<FrameHost | null>;
7
+ type PressHandlers = Pick<PressableProps, 'onPress' | 'onPressIn' | 'onPressOut' | 'onLongPress'>;
8
+ type AccessiblePressHandlers = Pick<PressableProps, 'onFocus' | 'onBlur' | 'focusable' | 'onPointerDown' | 'accessibilityActions' | 'onAccessibilityAction'>;
9
+ type Options = {
10
+ drag?: ElementDrag;
11
+ zoom?: ElementZoom;
12
+ modifiers?: DragModifiers;
13
+ secondary?: BoxProps['secondaryAction'];
14
+ press?: PressHandlers;
15
+ };
16
+ type Responder = Pick<ViewProps, 'onStartShouldSetResponder' | 'onResponderGrant' | 'onResponderStart' | 'onResponderMove' | 'onResponderEnd' | 'onResponderRelease' | 'onResponderTerminate' | 'onResponderTerminationRequest' | 'onLayout' | 'onPointerDownCapture' | 'onPointerMoveCapture' | 'onPointerUpCapture'>;
17
+ /** The viewport and pointer stream shared by the shapes in a native SVG canvas. */
18
+ export declare const SvgDragScope: import("react").Context<{
19
+ frame: FrameRef;
20
+ modifiers: DragModifiers;
21
+ } | null>;
22
+ /** Lets a descendant with a secondary tap action negotiate its ancestor's long-press drag. */
23
+ export declare const LongPressDragScope: import("react").Context<{
24
+ frame: FrameRef;
25
+ drag: ElementDrag;
26
+ } | null>;
27
+ /**
28
+ * Preserves hover, focus and assistive activation when a View owns the touch responder.
29
+ *
30
+ * @param props - The element's hover callbacks.
31
+ * @param press - The press interaction's focus and assistive actions.
32
+ * @param activate - The primary assistive activation, if present.
33
+ * @param secondary - The localized secondary action, if present.
34
+ * @returns Props for the same View that owns the drag.
35
+ */
36
+ export declare function dragViewActions(props: InteractionProps, press: AccessiblePressHandlers, activate?: () => void, secondary?: BoxProps['secondaryAction']): ViewProps & Pick<PressableProps, 'onFocus' | 'onBlur'>;
37
+ /**
38
+ * Retains a measurable host and forwards the original ref to its caller.
39
+ *
40
+ * @param forward - The caller's host ref.
41
+ * @returns The frame ref and the callback to attach to the host.
42
+ */
43
+ export declare function useDragFrame(forward?: RefCallback<View>): [RefObject<View | null>, RefCallback<View>];
44
+ /**
45
+ * Owns contact, tap and drag through one native gesture responder on a View or SVG shape.
46
+ *
47
+ * @param frame - The receiving View, or the enclosing SVG viewport.
48
+ * @param options - The drag and tap behavior to dispatch.
49
+ * @returns Responder props, or undefined when ordinary pressability should own the host.
50
+ */
51
+ export declare function useNativeDrag(frame: FrameRef | null, options: Options): Responder | undefined;
52
+ export {};
53
+ //# sourceMappingURL=drag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drag.d.ts","sourceRoot":"","sources":["../../src/elements/drag.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,SAAS,EAIf,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAGV,cAAc,EACd,IAAI,EACJ,SAAS,EACV,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EACV,QAAQ,EAER,WAAW,EAEX,WAAW,EACX,gBAAgB,EAEjB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,oBAAoB,CAAA;AAGzE,KAAK,SAAS,GAAG,IAAI,CAAC,IAAI,EAAE,SAAS,GAAG,iBAAiB,CAAC,CAAA;AAC1D,KAAK,QAAQ,GAAG,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC,CAAA;AAY3C,KAAK,aAAa,GAAG,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,WAAW,GAAG,YAAY,GAAG,aAAa,CAAC,CAAA;AACjG,KAAK,uBAAuB,GAAG,IAAI,CACjC,cAAc,EACZ,SAAS,GACT,QAAQ,GACR,WAAW,GACX,eAAe,GACf,sBAAsB,GACtB,uBAAuB,CAC1B,CAAA;AACD,KAAK,OAAO,GAAG;IACb,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB,SAAS,CAAC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAA;IACvC,KAAK,CAAC,EAAE,aAAa,CAAA;CACtB,CAAA;AACD,KAAK,SAAS,GAAG,IAAI,CACnB,SAAS,EACP,2BAA2B,GAC3B,kBAAkB,GAClB,kBAAkB,GAClB,iBAAiB,GACjB,gBAAgB,GAChB,oBAAoB,GACpB,sBAAsB,GACtB,+BAA+B,GAC/B,UAAU,GACV,sBAAsB,GACtB,sBAAsB,GACtB,oBAAoB,CACvB,CAAA;AA6BD,mFAAmF;AACnF,eAAO,MAAM,YAAY;WAA0B,QAAQ;eAAa,aAAa;SAEpF,CAAA;AAED,8FAA8F;AAC9F,eAAO,MAAM,kBAAkB;WAA0B,QAAQ;UAAQ,WAAW;SAAgB,CAAA;AAEpG;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,gBAAgB,EACvB,KAAK,EAAE,uBAAuB,EAC9B,QAAQ,CAAC,EAAE,MAAM,IAAI,EACrB,SAAS,CAAC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GACtC,SAAS,GAAG,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,QAAQ,CAAC,CAkCxD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,OAAO,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,GAC1B,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAU7C;AAmED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAwX7F"}