@lodev09/react-native-true-sheet 3.11.9 → 3.11.10
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/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterView.kt +6 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +7 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +21 -3
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +20 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetBottomSheetView.kt +17 -4
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDetentCalculator.kt +12 -1
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetGrabberView.kt +30 -7
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetStackManager.kt +52 -0
- package/ios/TrueSheetView.mm +3 -0
- package/ios/TrueSheetViewController.h +8 -0
- package/ios/TrueSheetViewController.mm +43 -5
- package/ios/core/TrueSheetDetentCalculator.h +6 -0
- package/ios/core/TrueSheetGrabberView.h +4 -0
- package/ios/core/TrueSheetGrabberView.mm +15 -5
- package/ios/core/TrueSheetKeyboardObserver.mm +15 -0
- package/lib/module/TrueSheet.js +20 -1
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/TrueSheet.web.js +2 -1
- package/lib/module/TrueSheet.web.js.map +1 -1
- package/lib/module/fabric/TrueSheetViewNativeComponent.ts +12 -0
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.types.d.ts +69 -0
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.web.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +11 -0
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/navigation/types.d.ts +1 -1
- package/lib/typescript/src/navigation/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/TrueSheet.tsx +22 -1
- package/src/TrueSheet.types.ts +71 -0
- package/src/TrueSheet.web.tsx +4 -1
- package/src/fabric/TrueSheetViewNativeComponent.ts +12 -0
- package/src/navigation/types.ts +1 -0
package/src/TrueSheet.tsx
CHANGED
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
findNodeHandle,
|
|
43
43
|
processColor,
|
|
44
44
|
type NativeEventSubscription,
|
|
45
|
+
type GestureResponderEvent,
|
|
45
46
|
} from 'react-native';
|
|
46
47
|
|
|
47
48
|
const LINKING_ERROR =
|
|
@@ -57,6 +58,13 @@ if (!TrueSheetModule) {
|
|
|
57
58
|
|
|
58
59
|
type NativeRef = ComponentRef<typeof TrueSheetViewNativeComponent>;
|
|
59
60
|
|
|
61
|
+
// Claim touches that no descendant claimed so the responder negotiation
|
|
62
|
+
// doesn't bubble up to touchables outside the sheet
|
|
63
|
+
const absorbUnclaimedTouches = () => true;
|
|
64
|
+
|
|
65
|
+
// Stop raw touch events from bubbling past the sheet to outside ancestors
|
|
66
|
+
const stopTouchPropagation = (event: GestureResponderEvent) => event.stopPropagation();
|
|
67
|
+
|
|
60
68
|
interface TrueSheetState {
|
|
61
69
|
shouldRenderNativeView: boolean;
|
|
62
70
|
}
|
|
@@ -357,12 +365,18 @@ export class TrueSheet
|
|
|
357
365
|
private handleBackPress(): boolean {
|
|
358
366
|
if (!this.isPresented || !this.isSheetVisible) return false;
|
|
359
367
|
|
|
368
|
+
// The native view can be detached (e.g. host screen unmounted by navigation)
|
|
369
|
+
// before onDidDismiss removes this subscription. Treat back press as a no-op
|
|
370
|
+
// instead of throwing from the handle getter.
|
|
371
|
+
const nodeHandle = findNodeHandle(this.nativeRef.current);
|
|
372
|
+
if (nodeHandle == null || nodeHandle === -1) return false;
|
|
373
|
+
|
|
360
374
|
// When not dismissible, let back propagate (e.g. navigation goes back to the previous screen)
|
|
361
375
|
if (this.props.dismissible === false) {
|
|
362
376
|
return this.props.onBackPress?.() ?? false;
|
|
363
377
|
}
|
|
364
378
|
|
|
365
|
-
TrueSheetModule?.handleBackPress(
|
|
379
|
+
TrueSheetModule?.handleBackPress(nodeHandle);
|
|
366
380
|
return this.props.onBackPress?.() ?? true;
|
|
367
381
|
}
|
|
368
382
|
|
|
@@ -446,6 +460,7 @@ export class TrueSheet
|
|
|
446
460
|
draggable = true,
|
|
447
461
|
grabber = true,
|
|
448
462
|
grabberOptions,
|
|
463
|
+
accessibilityOptions,
|
|
449
464
|
dimmed = true,
|
|
450
465
|
initialDetentIndex = -1,
|
|
451
466
|
initialDetentAnimated = true,
|
|
@@ -504,6 +519,7 @@ export class TrueSheet
|
|
|
504
519
|
cornerRadius={cornerRadius}
|
|
505
520
|
grabber={grabber}
|
|
506
521
|
grabberOptions={this.resolvedGrabberOptions}
|
|
522
|
+
accessibilityOptions={accessibilityOptions}
|
|
507
523
|
dimmed={dimmed}
|
|
508
524
|
dimmedDetentIndex={dimmedDetentIndex}
|
|
509
525
|
initialDetentIndex={initialDetentIndex}
|
|
@@ -538,6 +554,11 @@ export class TrueSheet
|
|
|
538
554
|
{this.state.shouldRenderNativeView && (
|
|
539
555
|
<TrueSheetContainerViewNativeComponent
|
|
540
556
|
style={scrollable ? styles.scrollableContainer : undefined}
|
|
557
|
+
onStartShouldSetResponder={absorbUnclaimedTouches}
|
|
558
|
+
onTouchStart={stopTouchPropagation}
|
|
559
|
+
onTouchMove={stopTouchPropagation}
|
|
560
|
+
onTouchEnd={stopTouchPropagation}
|
|
561
|
+
onTouchCancel={stopTouchPropagation}
|
|
541
562
|
>
|
|
542
563
|
{header && (
|
|
543
564
|
<TrueSheetHeaderViewNativeComponent style={[styles.header, headerStyle]}>
|
package/src/TrueSheet.types.ts
CHANGED
|
@@ -88,6 +88,71 @@ export interface GrabberOptions {
|
|
|
88
88
|
adaptive?: boolean;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Options for customizing (e.g. localizing) the accessibility strings
|
|
93
|
+
* announced by screen readers.
|
|
94
|
+
*
|
|
95
|
+
* On iOS, the grabber strings only apply when `grabberOptions` is provided.
|
|
96
|
+
* Without it, iOS uses the system grabber which is already localized.
|
|
97
|
+
*/
|
|
98
|
+
export interface AccessibilityOptions {
|
|
99
|
+
/**
|
|
100
|
+
* The accessibility label of the grabber.
|
|
101
|
+
*
|
|
102
|
+
* @default iOS: 'Sheet Grabber', Android: 'Drag handle'
|
|
103
|
+
*/
|
|
104
|
+
grabberLabel?: string;
|
|
105
|
+
/**
|
|
106
|
+
* The accessibility hint of the grabber.
|
|
107
|
+
*
|
|
108
|
+
* @platform ios
|
|
109
|
+
* @default 'Double-tap to expand. Swipe up or down to resize the sheet'
|
|
110
|
+
*/
|
|
111
|
+
grabberHint?: string;
|
|
112
|
+
/**
|
|
113
|
+
* The value announced when the sheet is at the last detent.
|
|
114
|
+
*
|
|
115
|
+
* @default 'Expanded'
|
|
116
|
+
*/
|
|
117
|
+
expandedValue?: string;
|
|
118
|
+
/**
|
|
119
|
+
* The value announced when the sheet is at the first detent.
|
|
120
|
+
*
|
|
121
|
+
* @default 'Collapsed'
|
|
122
|
+
*/
|
|
123
|
+
collapsedValue?: string;
|
|
124
|
+
/**
|
|
125
|
+
* The value announced when the sheet is at an intermediate detent.
|
|
126
|
+
* Supports `{index}` and `{count}` placeholders.
|
|
127
|
+
*
|
|
128
|
+
* @default 'Detent {index} of {count}'
|
|
129
|
+
*/
|
|
130
|
+
detentValue?: string;
|
|
131
|
+
/**
|
|
132
|
+
* The label of the expand accessibility action.
|
|
133
|
+
*
|
|
134
|
+
* @platform android
|
|
135
|
+
* @default 'Expand'
|
|
136
|
+
*/
|
|
137
|
+
expandActionLabel?: string;
|
|
138
|
+
/**
|
|
139
|
+
* The label of the collapse accessibility action.
|
|
140
|
+
*
|
|
141
|
+
* @platform android
|
|
142
|
+
* @default 'Collapse'
|
|
143
|
+
*/
|
|
144
|
+
collapseActionLabel?: string;
|
|
145
|
+
/**
|
|
146
|
+
* The title announced when the sheet appears.
|
|
147
|
+
* Sets the accessibility pane title on Android and the
|
|
148
|
+
* hidden dialog title on Web.
|
|
149
|
+
*
|
|
150
|
+
* @platform android, web
|
|
151
|
+
* @default Android: 'Bottom sheet', Web: 'Sheet'
|
|
152
|
+
*/
|
|
153
|
+
paneTitle?: string;
|
|
154
|
+
}
|
|
155
|
+
|
|
91
156
|
/**
|
|
92
157
|
* Scroll edge effect style for iOS 26+.
|
|
93
158
|
* Controls the blur/gradient overlay applied to scroll view edges.
|
|
@@ -354,6 +419,12 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
354
419
|
*/
|
|
355
420
|
grabberOptions?: GrabberOptions;
|
|
356
421
|
|
|
422
|
+
/**
|
|
423
|
+
* Options for customizing (e.g. localizing) the accessibility strings
|
|
424
|
+
* announced by screen readers.
|
|
425
|
+
*/
|
|
426
|
+
accessibilityOptions?: AccessibilityOptions;
|
|
427
|
+
|
|
357
428
|
/**
|
|
358
429
|
* Controls the sheet presentation style on iPad and web (landscape/tablet).
|
|
359
430
|
* - `'page'`: bottom-attached page sheet (full or readable width).
|
package/src/TrueSheet.web.tsx
CHANGED
|
@@ -69,6 +69,7 @@ const TrueSheetComponent = forwardRef<TrueSheetMethods, TrueSheetProps>((props,
|
|
|
69
69
|
anchorOffset = DEFAULT_ANCHOR_OFFSET,
|
|
70
70
|
grabber = true,
|
|
71
71
|
grabberOptions,
|
|
72
|
+
accessibilityOptions,
|
|
72
73
|
detents = [0.5, 1],
|
|
73
74
|
dimmed = true,
|
|
74
75
|
dimmedDetentIndex = 0,
|
|
@@ -999,7 +1000,9 @@ const TrueSheetComponent = forwardRef<TrueSheetMethods, TrueSheetProps>((props,
|
|
|
999
1000
|
) : undefined
|
|
1000
1001
|
}
|
|
1001
1002
|
>
|
|
1002
|
-
<Drawer.Title style={visuallyHiddenStyle}>
|
|
1003
|
+
<Drawer.Title style={visuallyHiddenStyle}>
|
|
1004
|
+
{accessibilityOptions?.paneTitle ?? 'Sheet'}
|
|
1005
|
+
</Drawer.Title>
|
|
1003
1006
|
{grabber && <Drawer.Handle style={handleStyle} />}
|
|
1004
1007
|
{scrollable ? (
|
|
1005
1008
|
// vaul wraps children in `[data-vaul-auto-size-wrapper]` (display:
|
|
@@ -16,6 +16,17 @@ type GrabberOptionsType = Readonly<{
|
|
|
16
16
|
adaptive?: WithDefault<boolean, true>;
|
|
17
17
|
}>;
|
|
18
18
|
|
|
19
|
+
type AccessibilityOptionsType = Readonly<{
|
|
20
|
+
grabberLabel?: WithDefault<string, 'Sheet Grabber'>;
|
|
21
|
+
grabberHint?: WithDefault<string, 'Double-tap to expand. Swipe up or down to resize the sheet'>;
|
|
22
|
+
expandedValue?: WithDefault<string, 'Expanded'>;
|
|
23
|
+
collapsedValue?: WithDefault<string, 'Collapsed'>;
|
|
24
|
+
detentValue?: WithDefault<string, 'Detent {index} of {count}'>;
|
|
25
|
+
expandActionLabel?: WithDefault<string, 'Expand'>;
|
|
26
|
+
collapseActionLabel?: WithDefault<string, 'Collapse'>;
|
|
27
|
+
paneTitle?: WithDefault<string, 'Bottom sheet'>;
|
|
28
|
+
}>;
|
|
29
|
+
|
|
19
30
|
type BlurOptionsType = Readonly<{
|
|
20
31
|
intensity?: WithDefault<Double, -1>;
|
|
21
32
|
interaction?: WithDefault<boolean, true>;
|
|
@@ -99,6 +110,7 @@ export interface NativeProps extends ViewProps {
|
|
|
99
110
|
// Boolean properties - match defaults from TrueSheet.types.ts
|
|
100
111
|
grabber?: WithDefault<boolean, true>;
|
|
101
112
|
grabberOptions?: GrabberOptionsType;
|
|
113
|
+
accessibilityOptions?: AccessibilityOptionsType;
|
|
102
114
|
dismissible?: WithDefault<boolean, true>;
|
|
103
115
|
draggable?: WithDefault<boolean, true>;
|
|
104
116
|
dimmed?: WithDefault<boolean, true>;
|