@molecule/app-ui-react-native 2.1.0 → 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.
- package/README.md +41 -5
- package/dist/components/Alert.d.ts.map +1 -1
- package/dist/components/Alert.js +2 -3
- package/dist/components/Button.d.ts +3 -1
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +35 -3
- package/dist/components/Skeleton.d.ts.map +1 -1
- package/dist/components/Skeleton.js +13 -12
- package/dist/components/Spinner.js +2 -2
- package/dist/elements/Box.js +8 -1
- package/dist/elements/Pressable.d.ts.map +1 -1
- package/dist/elements/Pressable.js +1 -0
- package/dist/elements/RangeField.d.ts.map +1 -1
- package/dist/elements/RangeField.js +8 -1
- package/dist/elements/SelectAction.d.ts.map +1 -1
- package/dist/elements/SelectAction.js +4 -0
- package/dist/elements/Svg.d.ts +1 -1
- package/dist/elements/Svg.d.ts.map +1 -1
- package/dist/elements/Svg.js +15 -5
- package/dist/elements/accessibility.d.ts +5 -5
- package/dist/elements/accessibility.d.ts.map +1 -1
- package/dist/elements/accessibility.js +5 -0
- package/dist/elements/drag.d.ts +10 -4
- package/dist/elements/drag.d.ts.map +1 -1
- package/dist/elements/drag.js +221 -63
- package/dist/elements/dragModifiers.d.ts +22 -0
- package/dist/elements/dragModifiers.d.ts.map +1 -0
- package/dist/elements/dragModifiers.js +62 -0
- package/dist/elements/style.d.ts.map +1 -1
- package/dist/elements/style.js +6 -1
- package/dist/elements/wheelZoom.d.ts +2 -1
- package/dist/elements/wheelZoom.d.ts.map +1 -1
- package/dist/elements/wheelZoom.js +2 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/platform/focus.d.ts.map +1 -1
- package/dist/platform/focus.js +13 -6
- package/package.json +8 -7
package/dist/elements/drag.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { createContext, useCallback, useLayoutEffect, useRef, } from 'react';
|
|
2
|
+
import { useDragModifiers } from './dragModifiers.js';
|
|
2
3
|
import { mouseEvent } from './events.js';
|
|
4
|
+
const NO_MODIFIERS = {
|
|
5
|
+
altKey: false,
|
|
6
|
+
ctrlKey: false,
|
|
7
|
+
metaKey: false,
|
|
8
|
+
shiftKey: false,
|
|
9
|
+
};
|
|
3
10
|
const TOUCH_SLOP = 8;
|
|
4
11
|
const LONG_PRESS_MS = 500;
|
|
5
12
|
const DOUBLE_TAP_MS = 300;
|
|
6
13
|
const DOUBLE_TAP_RADIUS = 24;
|
|
7
|
-
/** The viewport
|
|
8
|
-
export const
|
|
14
|
+
/** The viewport and pointer stream shared by the shapes in a native SVG canvas. */
|
|
15
|
+
export const SvgDragScope = createContext(null);
|
|
9
16
|
/** Lets a descendant with a secondary tap action negotiate its ancestor's long-press drag. */
|
|
10
17
|
export const LongPressDragScope = createContext(null);
|
|
11
18
|
/**
|
|
@@ -90,15 +97,22 @@ function measureFrame(host, receive) {
|
|
|
90
97
|
finish();
|
|
91
98
|
});
|
|
92
99
|
}
|
|
100
|
+
/** Copies native contact data before React Native can reuse the event. */
|
|
101
|
+
function snapshot(touch) {
|
|
102
|
+
const { identifier, pageX, pageY, locationX, locationY, timestamp } = touch;
|
|
103
|
+
if (!Number.isFinite(pageX) || !Number.isFinite(pageY))
|
|
104
|
+
return undefined;
|
|
105
|
+
return { identifier, pageX, pageY, locationX, locationY, timestamp };
|
|
106
|
+
}
|
|
107
|
+
/** Reads the touches changed in this notification. */
|
|
108
|
+
function changedTouches({ nativeEvent }) {
|
|
109
|
+
return nativeEvent.changedTouches?.length ? nativeEvent.changedTouches : [nativeEvent];
|
|
110
|
+
}
|
|
93
111
|
/** Looks up the active contact in a responder update. */
|
|
94
112
|
function changed(event, id) {
|
|
95
|
-
const
|
|
96
|
-
const touches = nativeEvent.changedTouches?.length ? nativeEvent.changedTouches : [nativeEvent];
|
|
113
|
+
const touches = changedTouches(event);
|
|
97
114
|
const touch = id === undefined ? touches[0] : touches.find((item) => item.identifier === id);
|
|
98
|
-
|
|
99
|
-
return undefined;
|
|
100
|
-
const { identifier, pageX, pageY } = touch;
|
|
101
|
-
return { identifier, pageX, pageY };
|
|
115
|
+
return touch && snapshot(touch);
|
|
102
116
|
}
|
|
103
117
|
/** Converts a touch root coordinate to a point in the window. */
|
|
104
118
|
function windowPoint(contact, frame) {
|
|
@@ -108,7 +122,7 @@ function windowPoint(contact, frame) {
|
|
|
108
122
|
};
|
|
109
123
|
}
|
|
110
124
|
/** Describes the contact relative to the host and to the drag origin. */
|
|
111
|
-
function sample(contact, frame, origin) {
|
|
125
|
+
function sample(contact, frame, origin, modifiers = NO_MODIFIERS) {
|
|
112
126
|
const position = windowPoint(contact, frame);
|
|
113
127
|
return {
|
|
114
128
|
x: position.x - frame.bounds.x,
|
|
@@ -116,10 +130,7 @@ function sample(contact, frame, origin) {
|
|
|
116
130
|
dx: position.x - origin.x,
|
|
117
131
|
dy: position.y - origin.y,
|
|
118
132
|
bounds: frame.bounds,
|
|
119
|
-
|
|
120
|
-
ctrlKey: false,
|
|
121
|
-
metaKey: false,
|
|
122
|
-
shiftKey: false,
|
|
133
|
+
...modifiers,
|
|
123
134
|
};
|
|
124
135
|
}
|
|
125
136
|
/**
|
|
@@ -137,7 +148,10 @@ export function useNativeDrag(frame, options) {
|
|
|
137
148
|
const pending = useRef([]);
|
|
138
149
|
const lastTap = useRef(null);
|
|
139
150
|
const hasDrag = options.drag !== undefined;
|
|
140
|
-
const
|
|
151
|
+
const localModifiers = useDragModifiers();
|
|
152
|
+
const modifiers = options.modifiers ?? localModifiers;
|
|
153
|
+
const hasZoom = options.zoom !== undefined;
|
|
154
|
+
const enabled = hasDrag || hasZoom || options.secondary !== undefined;
|
|
141
155
|
useLayoutEffect(() => {
|
|
142
156
|
latest.current = options;
|
|
143
157
|
});
|
|
@@ -152,13 +166,14 @@ export function useNativeDrag(frame, options) {
|
|
|
152
166
|
clearTimeout(current?.timer);
|
|
153
167
|
if (last)
|
|
154
168
|
latest.current.drag?.onCancel?.(last);
|
|
155
|
-
}, [enabled, hasDrag, frame]);
|
|
169
|
+
}, [enabled, hasDrag, hasZoom, frame]);
|
|
156
170
|
if (!enabled)
|
|
157
171
|
return undefined;
|
|
158
172
|
/** Delivers responder updates in order even when measurement completes out of order. */
|
|
159
|
-
function enqueue(send, host) {
|
|
173
|
+
function enqueue(send, host, waitForPointer) {
|
|
160
174
|
const queue = pending.current;
|
|
161
|
-
let measured
|
|
175
|
+
let measured;
|
|
176
|
+
let pointerReady = !waitForPointer;
|
|
162
177
|
const delivery = {
|
|
163
178
|
ready: false,
|
|
164
179
|
send() {
|
|
@@ -169,15 +184,22 @@ export function useNativeDrag(frame, options) {
|
|
|
169
184
|
},
|
|
170
185
|
};
|
|
171
186
|
queue.push(delivery);
|
|
172
|
-
const
|
|
187
|
+
const drain = () => {
|
|
173
188
|
if (pending.current !== queue)
|
|
174
189
|
return;
|
|
175
|
-
|
|
176
|
-
delivery.ready = true;
|
|
190
|
+
delivery.ready = measured !== undefined && pointerReady;
|
|
177
191
|
// A fast release can arrive before the first bridge measurement. Deliver in touch order.
|
|
178
192
|
while (queue[0]?.ready && pending.current === queue)
|
|
179
193
|
queue.shift()?.send();
|
|
180
194
|
};
|
|
195
|
+
const ready = (bounds) => {
|
|
196
|
+
measured = bounds;
|
|
197
|
+
drain();
|
|
198
|
+
};
|
|
199
|
+
waitForPointer?.(() => {
|
|
200
|
+
pointerReady = true;
|
|
201
|
+
drain();
|
|
202
|
+
});
|
|
181
203
|
if (host)
|
|
182
204
|
measureFrame(host, ready);
|
|
183
205
|
else
|
|
@@ -185,20 +207,29 @@ export function useNativeDrag(frame, options) {
|
|
|
185
207
|
}
|
|
186
208
|
/** Dispatches the drag phase using the measured host frame. */
|
|
187
209
|
function deliver(current, contact, phase) {
|
|
210
|
+
let keys = modifiers.read(contact, phase);
|
|
211
|
+
const waitForPointer = !keys && Number.isFinite(contact.timestamp)
|
|
212
|
+
? (ready) => queueMicrotask(() => {
|
|
213
|
+
keys = modifiers.read(contact, phase);
|
|
214
|
+
ready();
|
|
215
|
+
})
|
|
216
|
+
: undefined;
|
|
188
217
|
enqueue((bounds) => {
|
|
189
218
|
const drag = latest.current.drag;
|
|
219
|
+
if (phase === 'start')
|
|
220
|
+
current.downModifiers = keys;
|
|
190
221
|
if (!bounds || !drag)
|
|
191
222
|
return;
|
|
192
223
|
if (!current.origin) {
|
|
193
224
|
current.origin = windowPoint(current.down, bounds);
|
|
194
|
-
current.last = sample(current.down, bounds, current.origin);
|
|
225
|
+
current.last = sample(current.down, bounds, current.origin, current.downModifiers);
|
|
195
226
|
started.current = current;
|
|
196
227
|
drag.onStart(current.last);
|
|
197
228
|
}
|
|
198
229
|
if (phase === 'start' || started.current !== current)
|
|
199
230
|
return;
|
|
200
231
|
const previous = current.last;
|
|
201
|
-
const next = sample(contact, bounds, current.origin);
|
|
232
|
+
const next = sample(contact, bounds, current.origin, keys);
|
|
202
233
|
current.last = next;
|
|
203
234
|
if (phase === 'end') {
|
|
204
235
|
started.current = null;
|
|
@@ -209,10 +240,14 @@ export function useNativeDrag(frame, options) {
|
|
|
209
240
|
previous.dx !== next.dx ||
|
|
210
241
|
previous.dy !== next.dy ||
|
|
211
242
|
previous.bounds.width !== next.bounds.width ||
|
|
212
|
-
previous.bounds.height !== next.bounds.height
|
|
243
|
+
previous.bounds.height !== next.bounds.height ||
|
|
244
|
+
previous.altKey !== next.altKey ||
|
|
245
|
+
previous.ctrlKey !== next.ctrlKey ||
|
|
246
|
+
previous.metaKey !== next.metaKey ||
|
|
247
|
+
previous.shiftKey !== next.shiftKey) {
|
|
213
248
|
drag.onMove?.(next);
|
|
214
249
|
}
|
|
215
|
-
}, frame?.current ?? undefined);
|
|
250
|
+
}, frame?.current ?? undefined, waitForPointer);
|
|
216
251
|
}
|
|
217
252
|
/** Records that this contact crossed the drag threshold. */
|
|
218
253
|
function acquire(current) {
|
|
@@ -237,13 +272,14 @@ export function useNativeDrag(frame, options) {
|
|
|
237
272
|
}
|
|
238
273
|
}
|
|
239
274
|
/** Cancels the active drag after already queued updates are delivered. */
|
|
240
|
-
function cancel(current) {
|
|
275
|
+
function cancel(current, takenOver = false) {
|
|
241
276
|
enqueue(() => {
|
|
242
277
|
if (started.current !== current)
|
|
243
278
|
return;
|
|
244
279
|
started.current = null;
|
|
280
|
+
const drag = latest.current.drag;
|
|
245
281
|
if (current.last)
|
|
246
|
-
|
|
282
|
+
(drag?.onCancel ?? (takenOver ? drag?.onEnd : undefined))?.(current.last);
|
|
247
283
|
});
|
|
248
284
|
}
|
|
249
285
|
/** Ends contact and dispatches the terminal gesture and press callbacks. */
|
|
@@ -263,51 +299,154 @@ export function useNativeDrag(frame, options) {
|
|
|
263
299
|
const at = Date.now();
|
|
264
300
|
enqueue(() => {
|
|
265
301
|
latest.current.press?.onPressOut?.(event);
|
|
266
|
-
if (contact &&
|
|
302
|
+
if (contact &&
|
|
303
|
+
!current.fromPinch &&
|
|
304
|
+
!current.moved &&
|
|
305
|
+
!current.yielded &&
|
|
306
|
+
!current.longPressed)
|
|
267
307
|
tap(contact, event, at);
|
|
268
308
|
});
|
|
269
309
|
}
|
|
270
310
|
}
|
|
311
|
+
/** Queues the pair in touch order, using the outer frame of that sample. */
|
|
312
|
+
function pair(pinch, rebase) {
|
|
313
|
+
const [first, second] = pinch.contacts.values();
|
|
314
|
+
if (!first || !second)
|
|
315
|
+
return;
|
|
316
|
+
enqueue((bounds) => {
|
|
317
|
+
if (!bounds) {
|
|
318
|
+
pinch.previous = undefined;
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const at = {
|
|
322
|
+
x: (first.pageX + second.pageX) / 2 - bounds.rootX,
|
|
323
|
+
y: (first.pageY + second.pageY) / 2 - bounds.rootY,
|
|
324
|
+
};
|
|
325
|
+
const distance = Math.hypot(first.pageX - second.pageX, first.pageY - second.pageY);
|
|
326
|
+
const previous = pinch.previous;
|
|
327
|
+
pinch.previous = { at, distance };
|
|
328
|
+
if (rebase || !previous || !(previous.distance > 0) || !(distance > 0))
|
|
329
|
+
return;
|
|
330
|
+
const factor = distance / previous.distance;
|
|
331
|
+
if (factor !== 1 || previous.at.x !== at.x || previous.at.y !== at.y) {
|
|
332
|
+
latest.current.zoom?.onZoom({ kind: 'pinch', from: previous.at, at, factor });
|
|
333
|
+
}
|
|
334
|
+
}, frame?.current ?? undefined);
|
|
335
|
+
}
|
|
336
|
+
/** Refreshes the positions of contacts already accepted by this responder. */
|
|
337
|
+
function updateContacts(pinch, touches) {
|
|
338
|
+
for (const touch of touches) {
|
|
339
|
+
const point = snapshot(touch);
|
|
340
|
+
if (point && pinch.contacts.has(point.identifier))
|
|
341
|
+
pinch.contacts.set(point.identifier, point);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
/** Starts a one-contact session, including a new drag after a pinch. */
|
|
345
|
+
function begin(down, pinch, event) {
|
|
346
|
+
const { drag, press } = latest.current;
|
|
347
|
+
const longPress = drag?.touchStart === 'longPress';
|
|
348
|
+
const both = drag?.axis !== 'horizontal' && drag?.axis !== 'vertical';
|
|
349
|
+
const current = {
|
|
350
|
+
down,
|
|
351
|
+
pinch,
|
|
352
|
+
acquired: false,
|
|
353
|
+
moved: false,
|
|
354
|
+
fromPinch: !event,
|
|
355
|
+
yielded: false,
|
|
356
|
+
longPressed: false,
|
|
357
|
+
axisChosen: Boolean(pinch) || both || longPress,
|
|
358
|
+
};
|
|
359
|
+
active.current = current;
|
|
360
|
+
if (event)
|
|
361
|
+
press?.onPressIn?.(event);
|
|
362
|
+
if (event && drag && !longPress)
|
|
363
|
+
acquire(current);
|
|
364
|
+
if (event && (longPress || press?.onLongPress)) {
|
|
365
|
+
event.persist();
|
|
366
|
+
current.timer = setTimeout(() => {
|
|
367
|
+
if (active.current !== current || (current.pinch && current.pinch.contacts.size > 1))
|
|
368
|
+
return;
|
|
369
|
+
if (current.moved)
|
|
370
|
+
return;
|
|
371
|
+
if (longPress)
|
|
372
|
+
acquire(current);
|
|
373
|
+
else {
|
|
374
|
+
current.longPressed = true;
|
|
375
|
+
latest.current.press?.onLongPress?.(event);
|
|
376
|
+
}
|
|
377
|
+
}, LONG_PRESS_MS);
|
|
378
|
+
}
|
|
379
|
+
return current;
|
|
380
|
+
}
|
|
381
|
+
/** Retires released contacts and establishes a basis for the pair or finger that remains. */
|
|
382
|
+
function lift(current, pinch, ended) {
|
|
383
|
+
const [first, second] = pinch.contacts.keys();
|
|
384
|
+
for (const id of ended)
|
|
385
|
+
pinch.contacts.delete(id);
|
|
386
|
+
if (second === undefined ||
|
|
387
|
+
!(ended.includes(second) || (first !== undefined && ended.includes(first)))) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
const [remaining] = pinch.contacts.values();
|
|
391
|
+
if (pinch.contacts.size >= 2)
|
|
392
|
+
pair(pinch, true);
|
|
393
|
+
else if (remaining)
|
|
394
|
+
begin(remaining, pinch);
|
|
395
|
+
}
|
|
271
396
|
return {
|
|
272
397
|
onStartShouldSetResponder: () => active.current === null,
|
|
273
398
|
onResponderGrant(event) {
|
|
274
399
|
const down = changed(event);
|
|
275
400
|
if (!down || active.current)
|
|
401
|
+
return false;
|
|
402
|
+
const { drag, zoom } = latest.current;
|
|
403
|
+
const pinch = zoom ? { contacts: new Map([[down.identifier, down]]) } : undefined;
|
|
404
|
+
const current = begin(down, pinch, event);
|
|
405
|
+
// Reserve the opted-in touch plane from native scroll interception. Other drags
|
|
406
|
+
// retain their existing axis and long-press negotiation.
|
|
407
|
+
return Boolean(zoom || (drag && drag.touchStart !== 'longPress' && current.axisChosen));
|
|
408
|
+
},
|
|
409
|
+
onResponderStart(event) {
|
|
410
|
+
active.current?.lift?.();
|
|
411
|
+
const current = active.current;
|
|
412
|
+
const pinch = current?.pinch;
|
|
413
|
+
if (!current || !pinch)
|
|
276
414
|
return;
|
|
277
|
-
const
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
acquired: false,
|
|
283
|
-
moved: false,
|
|
284
|
-
yielded: false,
|
|
285
|
-
longPressed: false,
|
|
286
|
-
axisChosen: both || longPress,
|
|
287
|
-
};
|
|
288
|
-
active.current = current;
|
|
289
|
-
press?.onPressIn?.(event);
|
|
290
|
-
if (drag && !longPress)
|
|
291
|
-
acquire(current);
|
|
292
|
-
if (longPress || press?.onLongPress) {
|
|
293
|
-
event.persist();
|
|
294
|
-
current.timer = setTimeout(() => {
|
|
295
|
-
if (active.current !== current || current.moved)
|
|
296
|
-
return;
|
|
297
|
-
if (longPress)
|
|
298
|
-
acquire(current);
|
|
299
|
-
else {
|
|
300
|
-
current.longPressed = true;
|
|
301
|
-
latest.current.press?.onLongPress?.(event);
|
|
302
|
-
}
|
|
303
|
-
}, LONG_PRESS_MS);
|
|
415
|
+
const before = pinch.contacts.size;
|
|
416
|
+
for (const touch of changedTouches(event)) {
|
|
417
|
+
const contact = snapshot(touch);
|
|
418
|
+
if (contact)
|
|
419
|
+
pinch.contacts.set(contact.identifier, contact);
|
|
304
420
|
}
|
|
305
|
-
|
|
306
|
-
|
|
421
|
+
if (before >= 2 || pinch.contacts.size < 2)
|
|
422
|
+
return;
|
|
423
|
+
updateContacts(pinch, event.nativeEvent.touches);
|
|
424
|
+
clearTimeout(current.timer);
|
|
425
|
+
current.moved = true;
|
|
426
|
+
lastTap.current = null;
|
|
427
|
+
if (current.acquired) {
|
|
428
|
+
current.acquired = false;
|
|
429
|
+
cancel(current, true);
|
|
430
|
+
}
|
|
431
|
+
pair(pinch, true);
|
|
307
432
|
},
|
|
308
433
|
onResponderMove(event) {
|
|
434
|
+
active.current?.lift?.();
|
|
309
435
|
const current = active.current;
|
|
310
|
-
if (!current
|
|
436
|
+
if (!current)
|
|
437
|
+
return;
|
|
438
|
+
const pinch = current.pinch;
|
|
439
|
+
if (pinch) {
|
|
440
|
+
updateContacts(pinch, event.nativeEvent.touches);
|
|
441
|
+
if (pinch.contacts.size >= 2) {
|
|
442
|
+
const [first, second] = pinch.contacts.keys();
|
|
443
|
+
if (changedTouches(event).some(({ identifier }) => identifier === first || identifier === second)) {
|
|
444
|
+
pair(pinch, false);
|
|
445
|
+
}
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (current.yielded || current.longPressed)
|
|
311
450
|
return;
|
|
312
451
|
const contact = changed(event, current.down.identifier);
|
|
313
452
|
if (!contact)
|
|
@@ -330,19 +469,34 @@ export function useNativeDrag(frame, options) {
|
|
|
330
469
|
}
|
|
331
470
|
}
|
|
332
471
|
}
|
|
472
|
+
if (current.fromPinch && !current.acquired && latest.current.drag)
|
|
473
|
+
acquire(current);
|
|
333
474
|
if (current.acquired)
|
|
334
475
|
deliver(current, contact, 'move');
|
|
335
476
|
},
|
|
336
477
|
onResponderEnd(event) {
|
|
478
|
+
active.current?.lift?.();
|
|
337
479
|
const current = active.current;
|
|
338
480
|
if (!current)
|
|
339
481
|
return;
|
|
340
|
-
const contact = changed(event, current.down.identifier);
|
|
341
|
-
if (!contact)
|
|
342
|
-
return;
|
|
343
482
|
event.persist();
|
|
344
|
-
|
|
345
|
-
|
|
483
|
+
const contact = changed(event, current.down.identifier);
|
|
484
|
+
const pinch = current.pinch;
|
|
485
|
+
// RN emits responder-end immediately before terminate on cancellation. Let
|
|
486
|
+
// that terminal event win, while preserving order before any later input.
|
|
487
|
+
const retire = () => {
|
|
488
|
+
if (active.current !== current || current.lift !== retire)
|
|
489
|
+
return;
|
|
490
|
+
current.lift = undefined;
|
|
491
|
+
if (pinch && pinch.contacts.size >= 2) {
|
|
492
|
+
updateContacts(pinch, event.nativeEvent.touches);
|
|
493
|
+
lift(current, pinch, changedTouches(event).map(({ identifier }) => identifier));
|
|
494
|
+
}
|
|
495
|
+
else if (contact)
|
|
496
|
+
finish(current, contact, event);
|
|
497
|
+
};
|
|
498
|
+
current.lift = retire;
|
|
499
|
+
queueMicrotask(retire);
|
|
346
500
|
},
|
|
347
501
|
onResponderRelease(event) {
|
|
348
502
|
const current = active.current;
|
|
@@ -354,7 +508,11 @@ export function useNativeDrag(frame, options) {
|
|
|
354
508
|
if (current)
|
|
355
509
|
finish(current, undefined, event);
|
|
356
510
|
},
|
|
357
|
-
onResponderTerminationRequest: () =>
|
|
511
|
+
onResponderTerminationRequest: () => {
|
|
512
|
+
const current = active.current;
|
|
513
|
+
return !current || (!current.pinch && (!current.acquired || !current.axisChosen));
|
|
514
|
+
},
|
|
515
|
+
...(hasDrag && !options.modifiers ? modifiers.handlers : undefined),
|
|
358
516
|
onLayout() {
|
|
359
517
|
cache.current = null;
|
|
360
518
|
},
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { NativeTouchEvent, ViewProps } from 'react-native';
|
|
2
|
+
import type { KitModifierKeys } from '@molecule/app-ui';
|
|
3
|
+
type Phase = 'start' | 'move' | 'end';
|
|
4
|
+
type Contact = Pick<NativeTouchEvent, 'identifier' | 'timestamp' | 'pageX' | 'pageY' | 'locationX' | 'locationY'>;
|
|
5
|
+
/** Modifier metadata captured on the same host as the responder or its SVG viewport. */
|
|
6
|
+
export interface DragModifiers {
|
|
7
|
+
read(contact: Contact, phase: Phase): KitModifierKeys | undefined;
|
|
8
|
+
handlers: Pick<ViewProps, 'onPointerDownCapture' | 'onPointerMoveCapture' | 'onPointerUpCapture'>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Pairs responder samples with optional React Native 0.79 W3C pointer packets in the same dispatch.
|
|
12
|
+
* Android sends the MotionEvent timestamp and ID on both events. iOS allocates IDs separately,
|
|
13
|
+
* so match the dispatched position in the root or target. Responder motion remains the owner.
|
|
14
|
+
*
|
|
15
|
+
* The object is created once per component, so passing it through context or effect
|
|
16
|
+
* dependencies does not re-render or re-run anything.
|
|
17
|
+
*
|
|
18
|
+
* @returns The pointer capture handlers and a reader for responder contact modifiers.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useDragModifiers(): DragModifiers;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=dragModifiers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dragModifiers.d.ts","sourceRoot":"","sources":["../../src/elements/dragModifiers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAEnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAEvD,KAAK,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAA;AACrC,KAAK,OAAO,GAAG,IAAI,CACjB,gBAAgB,EAChB,YAAY,GAAG,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,GAAG,WAAW,CAC3E,CAAA;AAGD,wFAAwF;AACxF,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,eAAe,GAAG,SAAS,CAAA;IACjE,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,sBAAsB,GAAG,sBAAsB,GAAG,oBAAoB,CAAC,CAAA;CAClG;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAGhD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Pairs responder samples with optional React Native 0.79 W3C pointer packets in the same dispatch.
|
|
4
|
+
* Android sends the MotionEvent timestamp and ID on both events. iOS allocates IDs separately,
|
|
5
|
+
* so match the dispatched position in the root or target. Responder motion remains the owner.
|
|
6
|
+
*
|
|
7
|
+
* The object is created once per component, so passing it through context or effect
|
|
8
|
+
* dependencies does not re-render or re-run anything.
|
|
9
|
+
*
|
|
10
|
+
* @returns The pointer capture handlers and a reader for responder contact modifiers.
|
|
11
|
+
*/
|
|
12
|
+
export function useDragModifiers() {
|
|
13
|
+
const [modifiers] = useState(createDragModifiers);
|
|
14
|
+
return modifiers;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates the packet store and its handlers for one host.
|
|
18
|
+
*
|
|
19
|
+
* @returns The pointer capture handlers and a reader for responder contact modifiers.
|
|
20
|
+
*/
|
|
21
|
+
function createDragModifiers() {
|
|
22
|
+
const packets = [];
|
|
23
|
+
/** Retains a pointer packet for the matching responder notification. */
|
|
24
|
+
function remember(phase, pointer) {
|
|
25
|
+
const packet = { phase, pointer };
|
|
26
|
+
packets.push(packet);
|
|
27
|
+
queueMicrotask(() => {
|
|
28
|
+
const index = packets.indexOf(packet);
|
|
29
|
+
if (index !== -1)
|
|
30
|
+
packets.splice(index, 1);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
handlers: {
|
|
35
|
+
onPointerDownCapture: ({ nativeEvent }) => remember('start', nativeEvent),
|
|
36
|
+
onPointerMoveCapture: ({ nativeEvent }) => remember('move', nativeEvent),
|
|
37
|
+
onPointerUpCapture: ({ nativeEvent }) => remember('end', nativeEvent),
|
|
38
|
+
},
|
|
39
|
+
read(contact, phase) {
|
|
40
|
+
const matches = packets.filter(({ phase: kind, pointer }) => {
|
|
41
|
+
if (kind !== phase)
|
|
42
|
+
return false;
|
|
43
|
+
if ('timestamp' in pointer && typeof pointer.timestamp === 'number') {
|
|
44
|
+
return (pointer.timestamp === contact.timestamp &&
|
|
45
|
+
String(pointer.pointerId) === String(contact.identifier));
|
|
46
|
+
}
|
|
47
|
+
return (samePosition(pointer.pageX, pointer.pageY, contact.pageX, contact.pageY) ||
|
|
48
|
+
samePosition(pointer.offsetX, pointer.offsetY, contact.locationX, contact.locationY));
|
|
49
|
+
});
|
|
50
|
+
const [match] = matches;
|
|
51
|
+
if (!match || matches.length !== 1)
|
|
52
|
+
return undefined;
|
|
53
|
+
packets.splice(packets.indexOf(match), 1);
|
|
54
|
+
const { altKey, ctrlKey, metaKey, shiftKey } = match.pointer;
|
|
55
|
+
return { altKey, ctrlKey, metaKey, shiftKey };
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Matches coordinates through the native float conversion. */
|
|
60
|
+
function samePosition(x, y, otherX, otherY) {
|
|
61
|
+
return Math.abs(x - otherX) < 0.001 && Math.abs(y - otherY) < 0.001;
|
|
62
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/elements/style.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAA0B,KAAK,SAAS,IAAI,eAAe,EAAE,MAAM,cAAc,CAAA;AAExF,OAAO,KAAK,EAAE,QAAQ,EAAiB,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AA0HpF;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS,CA+GjD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,EACvC,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAC7B,eAAe,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/elements/style.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAA0B,KAAK,SAAS,IAAI,eAAe,EAAE,MAAM,cAAc,CAAA;AAExF,OAAO,KAAK,EAAE,QAAQ,EAAiB,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AA0HpF;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS,CA+GjD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,EACvC,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAC7B,eAAe,GAAG,SAAS,CAa7B;AA6ED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAMpE,CAAA"}
|
package/dist/elements/style.js
CHANGED
|
@@ -273,8 +273,13 @@ export function nativeStyle(style, webStyle) {
|
|
|
273
273
|
if (!style && !webStyle)
|
|
274
274
|
return undefined;
|
|
275
275
|
const merged = { ...style, ...(webStyle ? drawable(webStyle) : {}) };
|
|
276
|
-
const { lineHeight, ...rest } = merged;
|
|
276
|
+
const { lineHeight, contentTransform, ...rest } = merged;
|
|
277
277
|
const out = lineHeight === undefined ? rest : { ...rest, lineHeight: Number.parseFloat(lineHeight) };
|
|
278
|
+
if (contentTransform) {
|
|
279
|
+
const { translateX, translateY, scale } = contentTransform;
|
|
280
|
+
out.transform = [{ translateX }, { translateY }, { scale }];
|
|
281
|
+
out.transformOrigin = [0, 0, 0];
|
|
282
|
+
}
|
|
278
283
|
const transform = nativeTransform(webStyle?.transform);
|
|
279
284
|
return transform ? { ...out, transform } : out;
|
|
280
285
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ElementHandle } from '@molecule/app-ui';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* React Native View does not emit wheel events. For touch zoom, pass the element's
|
|
4
|
+
* `zoom` prop and consume its pinch samples.
|
|
4
5
|
*
|
|
5
6
|
* @param _ref - The corresponding web surface.
|
|
6
7
|
* @param _onStep - The corresponding web zoom step.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wheelZoom.d.ts","sourceRoot":"","sources":["../../src/elements/wheelZoom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD
|
|
1
|
+
{"version":3,"file":"wheelZoom.d.ts","sourceRoot":"","sources":["../../src/elements/wheelZoom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,EAChD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,GAAG,KAAK,KAAK,IAAI,GAC1C,IAAI,CAAG"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* React Native View does not emit wheel events. For touch zoom, pass the element's
|
|
3
|
+
* `zoom` prop and consume its pinch samples.
|
|
3
4
|
*
|
|
4
5
|
* @param _ref - The corresponding web surface.
|
|
5
6
|
* @param _onStep - The corresponding web zoom step.
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* core `@molecule/app-ui` component interfaces, including Accordion,
|
|
6
6
|
* Alert, Avatar, Badge, Button, Card (+ CardHeader/CardTitle/CardDescription/
|
|
7
7
|
* CardContent/CardFooter), Checkbox, Container, Dropdown, FileField, Flex, Form,
|
|
8
|
-
* FormField, Grid, Input, Label, Modal, Pagination, Progress, RadioGroup,
|
|
9
|
-
* Select, Separator, Skeleton, Spacer, Spinner, Switch, Table, Tabs,
|
|
8
|
+
* FormArea, FormField, Grid, Input, Label, Modal, Pagination, Progress, RadioGroup,
|
|
9
|
+
* Select, Separator, Skeleton, Spacer, Spinner, Switch, Table, Tabs, TextField,
|
|
10
10
|
* Textarea, Toast (+ ToastProvider / ToastContainer / useToast), Tooltip.
|
|
11
11
|
* Prop types build on `@molecule/app-ui`. Web-only extras (Icon,
|
|
12
12
|
* UserMenu, ThemeToggle, PageHeader, …) live in `@molecule/app-ui-react` and
|
|
@@ -50,6 +50,8 @@
|
|
|
50
50
|
*/
|
|
51
51
|
export { Accordion, Alert, Avatar, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Container, Dropdown, DropdownLabel, DropdownSeparator, Flex, Form, FormField, Grid, Input, Label, Modal, Pagination, Progress, RadioGroup, Select, Separator, Skeleton, SkeletonCircle, SkeletonText, Spacer, Spinner, Switch, Table, Tabs, Textarea, Toast, ToastContainer, ToastProvider, Tooltip, useToast, } from './components/index.js';
|
|
52
52
|
export { FileField } from './elements/FileField.js';
|
|
53
|
+
export { FormArea } from './elements/FormArea.js';
|
|
54
|
+
export { TextField } from './elements/TextField.js';
|
|
53
55
|
export type * from './types.js';
|
|
54
56
|
export type { AccordionProps, AlertProps, AvatarProps, BadgeProps, BaseProps, DropdownProps, FormFieldProps, FormProps, ModalProps, PaginationProps, RadioGroupProps, SkeletonProps, SpinnerProps, TableProps, TabsProps, ToastProps, TooltipProps, } from '@molecule/app-ui';
|
|
55
57
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,EACL,SAAS,EACT,KAAK,EACL,MAAM,EACN,KAAK,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,eAAe,EACf,UAAU,EACV,UAAU,EACV,SAAS,EACT,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,EACL,UAAU,EACV,QAAQ,EACR,UAAU,EACV,MAAM,EACN,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,MAAM,EACN,OAAO,EACP,MAAM,EACN,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,cAAc,EACd,aAAa,EACb,OAAO,EACP,QAAQ,GACT,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,mBAAmB,YAAY,CAAA;AAC/B,YAAY,EACV,cAAc,EACd,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,SAAS,EACT,UAAU,EACV,eAAe,EACf,eAAe,EACf,aAAa,EACb,YAAY,EACZ,UAAU,EACV,SAAS,EACT,UAAU,EACV,YAAY,GACb,MAAM,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,EACL,SAAS,EACT,KAAK,EACL,MAAM,EACN,KAAK,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,eAAe,EACf,UAAU,EACV,UAAU,EACV,SAAS,EACT,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,EACL,UAAU,EACV,QAAQ,EACR,UAAU,EACV,MAAM,EACN,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,MAAM,EACN,OAAO,EACP,MAAM,EACN,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,cAAc,EACd,aAAa,EACb,OAAO,EACP,QAAQ,GACT,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,mBAAmB,YAAY,CAAA;AAC/B,YAAY,EACV,cAAc,EACd,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,SAAS,EACT,UAAU,EACV,eAAe,EACf,eAAe,EACf,aAAa,EACb,YAAY,EACZ,UAAU,EACV,SAAS,EACT,UAAU,EACV,YAAY,GACb,MAAM,kBAAkB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* core `@molecule/app-ui` component interfaces, including Accordion,
|
|
6
6
|
* Alert, Avatar, Badge, Button, Card (+ CardHeader/CardTitle/CardDescription/
|
|
7
7
|
* CardContent/CardFooter), Checkbox, Container, Dropdown, FileField, Flex, Form,
|
|
8
|
-
* FormField, Grid, Input, Label, Modal, Pagination, Progress, RadioGroup,
|
|
9
|
-
* Select, Separator, Skeleton, Spacer, Spinner, Switch, Table, Tabs,
|
|
8
|
+
* FormArea, FormField, Grid, Input, Label, Modal, Pagination, Progress, RadioGroup,
|
|
9
|
+
* Select, Separator, Skeleton, Spacer, Spinner, Switch, Table, Tabs, TextField,
|
|
10
10
|
* Textarea, Toast (+ ToastProvider / ToastContainer / useToast), Tooltip.
|
|
11
11
|
* Prop types build on `@molecule/app-ui`. Web-only extras (Icon,
|
|
12
12
|
* UserMenu, ThemeToggle, PageHeader, …) live in `@molecule/app-ui-react` and
|
|
@@ -50,3 +50,5 @@
|
|
|
50
50
|
*/
|
|
51
51
|
export { Accordion, Alert, Avatar, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Container, Dropdown, DropdownLabel, DropdownSeparator, Flex, Form, FormField, Grid, Input, Label, Modal, Pagination, Progress, RadioGroup, Select, Separator, Skeleton, SkeletonCircle, SkeletonText, Spacer, Spinner, Switch, Table, Tabs, Textarea, Toast, ToastContainer, ToastProvider, Tooltip, useToast, } from './components/index.js';
|
|
52
52
|
export { FileField } from './elements/FileField.js';
|
|
53
|
+
export { FormArea } from './elements/FormArea.js';
|
|
54
|
+
export { TextField } from './elements/TextField.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus.d.ts","sourceRoot":"","sources":["../../src/platform/focus.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEL,KAAK,WAAW,EAKjB,MAAM,OAAO,CAAA;AAGd,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAIpF,qEAAqE;AACrE,qBAAa,gBAAgB;IAC3B,QAAQ,CAAC,QAAQ,qBAA2B;IAC5C,QAAQ,CAAC,QAAQ,qBAA2B;IAC5C,OAAO,SAAK;CACb;AAED,mFAAmF;AACnF,eAAO,MAAM,WAAW,2CAAwC,CAAA;AAIhE,+EAA+E;AAC/E,wBAAgB,mBAAmB,IAAI,aAAa,GAAG,SAAS,CAE/D;AAED,2FAA2F;AAC3F,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,aAAa,EACtD,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,EACnC,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GACtC;IAAE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,IAAI,CAAA;CAAE,CAqB3D;AAOD,gGAAgG;AAChG,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"focus.d.ts","sourceRoot":"","sources":["../../src/platform/focus.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEL,KAAK,WAAW,EAKjB,MAAM,OAAO,CAAA;AAGd,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAIpF,qEAAqE;AACrE,qBAAa,gBAAgB;IAC3B,QAAQ,CAAC,QAAQ,qBAA2B;IAC5C,QAAQ,CAAC,QAAQ,qBAA2B;IAC5C,OAAO,SAAK;CACb;AAED,mFAAmF;AACnF,eAAO,MAAM,WAAW,2CAAwC,CAAA;AAIhE,+EAA+E;AAC/E,wBAAgB,mBAAmB,IAAI,aAAa,GAAG,SAAS,CAE/D;AAED,2FAA2F;AAC3F,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,aAAa,EACtD,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,EACnC,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GACtC;IAAE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,IAAI,CAAA;CAAE,CAqB3D;AAOD,gGAAgG;AAChG,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,GAAG,OAAO,CAc5E;AAED,4FAA4F;AAC5F,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG;IAC7D,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,CAeA;AAED,wFAAwF;AACxF,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAKpD"}
|
package/dist/platform/focus.js
CHANGED
|
@@ -47,13 +47,20 @@ function isNativeHost(handle) {
|
|
|
47
47
|
/** Focuses a mounted native target without depending on a React Native renderer private tag. */
|
|
48
48
|
export function focusNativeTarget(target) {
|
|
49
49
|
const node = target?.current;
|
|
50
|
-
if (!node
|
|
50
|
+
if (!node)
|
|
51
51
|
return false;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
if (Platform.OS === 'web') {
|
|
53
|
+
node.focus();
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
if (!isNativeHost(node))
|
|
57
|
+
return false;
|
|
58
|
+
const tag = findNodeHandle(node);
|
|
59
|
+
if (tag === null)
|
|
60
|
+
return false;
|
|
61
|
+
node.focus();
|
|
62
|
+
AccessibilityInfo.setAccessibilityFocus(tag);
|
|
63
|
+
}
|
|
57
64
|
current = target;
|
|
58
65
|
return true;
|
|
59
66
|
}
|