react-native-nitro-modal 0.3.7-rc → 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.
- package/README.md +2 -0
- package/android/src/main/java/com/margelo/nitro/nitromodal/BottomSheetPresenter.kt +0 -10
- package/android/src/main/java/com/margelo/nitro/nitromodal/HybridNitroModal.kt +0 -2
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalContentRoot.kt +83 -4
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalPresenter.kt +0 -2
- package/android/src/main/java/com/margelo/nitro/nitromodal/NitroModalHostView.kt +1 -3
- package/android/src/main/java/com/margelo/nitro/nitromodal/NitroModalViewManager.kt +0 -2
- package/ios/HybridNitroModal.swift +0 -1
- package/ios/HybridNitroModalComponent+Children.mm +59 -1
- package/ios/ModalConfig.swift +0 -1
- package/ios/NitroModalHostView.swift +0 -1
- package/ios/PopupViewController.swift +0 -1
- package/ios/SheetView.swift +0 -5
- package/lib/module/NitroModalView.js +0 -5
- package/lib/module/NitroModalView.js.map +1 -1
- package/lib/module/NitroModalView.web.js +0 -2
- package/lib/module/NitroModalView.web.js.map +1 -1
- package/lib/module/web/AnimatedValue.js +0 -4
- package/lib/module/web/AnimatedValue.js.map +1 -1
- package/lib/module/web/ModalConfig.js.map +1 -1
- package/lib/module/web/ModalController.js +0 -16
- package/lib/module/web/ModalController.js.map +1 -1
- package/lib/module/web/ModalPresenter.js +0 -1
- package/lib/module/web/ModalPresenter.js.map +1 -1
- package/lib/module/web/SheetPresenter.js +0 -17
- package/lib/module/web/SheetPresenter.js.map +1 -1
- package/lib/module/web/dom.js +0 -4
- package/lib/module/web/dom.js.map +1 -1
- package/lib/typescript/src/NitroModal.nitro.d.ts +0 -2
- package/lib/typescript/src/NitroModal.nitro.d.ts.map +1 -1
- package/lib/typescript/src/NitroModalView.d.ts.map +1 -1
- package/lib/typescript/src/NitroModalView.web.d.ts.map +1 -1
- package/lib/typescript/src/web/AnimatedValue.d.ts +0 -2
- package/lib/typescript/src/web/AnimatedValue.d.ts.map +1 -1
- package/lib/typescript/src/web/ModalConfig.d.ts +0 -1
- package/lib/typescript/src/web/ModalConfig.d.ts.map +1 -1
- package/lib/typescript/src/web/ModalController.d.ts +0 -3
- package/lib/typescript/src/web/ModalController.d.ts.map +1 -1
- package/lib/typescript/src/web/ModalPresenter.d.ts +0 -3
- package/lib/typescript/src/web/ModalPresenter.d.ts.map +1 -1
- package/lib/typescript/src/web/SheetPresenter.d.ts +0 -6
- package/lib/typescript/src/web/SheetPresenter.d.ts.map +1 -1
- package/lib/typescript/src/web/dom.d.ts +0 -2
- package/lib/typescript/src/web/dom.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NitroModal.nitro.ts +0 -2
- package/src/NitroModalView.tsx +0 -4
- package/src/NitroModalView.web.tsx +0 -2
- package/src/web/AnimatedValue.ts +0 -2
- package/src/web/ModalConfig.ts +0 -1
- package/src/web/ModalController.ts +0 -11
- package/src/web/ModalPresenter.ts +0 -3
- package/src/web/SheetPresenter.ts +0 -12
- package/src/web/dom.ts +0 -2
|
@@ -56,7 +56,6 @@ export class ModalController implements PresenterListener {
|
|
|
56
56
|
private wantsOpen = false;
|
|
57
57
|
/** A present request was accepted and its `onDismiss` is still owed. */
|
|
58
58
|
private sessionActive = false;
|
|
59
|
-
/** `onPresent` was sent for the current session. */
|
|
60
59
|
private presentSent = false;
|
|
61
60
|
private dismissReason: DismissReason = 'programmatic';
|
|
62
61
|
private reconcileScheduled = false;
|
|
@@ -70,8 +69,6 @@ export class ModalController implements PresenterListener {
|
|
|
70
69
|
/** `setMounted` renders (or removes) the modal's elements. */
|
|
71
70
|
constructor(private readonly setMounted: (mounted: boolean) => void) {}
|
|
72
71
|
|
|
73
|
-
// Host view lifecycle
|
|
74
|
-
|
|
75
72
|
attach() {
|
|
76
73
|
this.isAttached = true;
|
|
77
74
|
window.addEventListener('resize', this.handleWindowResize);
|
|
@@ -95,7 +92,6 @@ export class ModalController implements PresenterListener {
|
|
|
95
92
|
this.setMounted(false);
|
|
96
93
|
}
|
|
97
94
|
|
|
98
|
-
/** The host view rendered with new props. */
|
|
99
95
|
update(props: NitroModalProps) {
|
|
100
96
|
this.props = props;
|
|
101
97
|
const next = makeConfig(props);
|
|
@@ -117,7 +113,6 @@ export class ModalController implements PresenterListener {
|
|
|
117
113
|
}
|
|
118
114
|
}
|
|
119
115
|
|
|
120
|
-
/** Inline: the element the sheet fills, rendered in place. */
|
|
121
116
|
hostDidChange(host: HTMLElement | null) {
|
|
122
117
|
if (host === this.host) return;
|
|
123
118
|
this.host = host;
|
|
@@ -151,8 +146,6 @@ export class ModalController implements PresenterListener {
|
|
|
151
146
|
this.reconcile();
|
|
152
147
|
};
|
|
153
148
|
|
|
154
|
-
// State machine
|
|
155
|
-
|
|
156
149
|
private get isVisible(): boolean {
|
|
157
150
|
return this.phase === 'presenting' || this.phase === 'presented';
|
|
158
151
|
}
|
|
@@ -256,8 +249,6 @@ export class ModalController implements PresenterListener {
|
|
|
256
249
|
}
|
|
257
250
|
}
|
|
258
251
|
|
|
259
|
-
// PresenterListener
|
|
260
|
-
|
|
261
252
|
onPresented() {
|
|
262
253
|
if (this.phase !== 'presenting') return;
|
|
263
254
|
this.phase = 'presented';
|
|
@@ -302,8 +293,6 @@ export class ModalController implements PresenterListener {
|
|
|
302
293
|
this.props?.onContentAreaChange?.(area);
|
|
303
294
|
}
|
|
304
295
|
|
|
305
|
-
// Helpers
|
|
306
|
-
|
|
307
296
|
/** Lets React size the content before the first presentation. */
|
|
308
297
|
private reportEstimatedContentArea() {
|
|
309
298
|
const { config } = this;
|
|
@@ -20,7 +20,6 @@ export interface ModalElements {
|
|
|
20
20
|
backdrop: HTMLElement;
|
|
21
21
|
/** The sheet or the popup card. */
|
|
22
22
|
surface: HTMLElement;
|
|
23
|
-
/** Hosts the React content. */
|
|
24
23
|
content: HTMLElement;
|
|
25
24
|
grabber: HTMLElement;
|
|
26
25
|
/** Above the content, following the surface's corners. */
|
|
@@ -37,7 +36,6 @@ export interface PresenterListener {
|
|
|
37
36
|
/** The exit transition finished. Called at most once per presenter. */
|
|
38
37
|
onDismissed(): void;
|
|
39
38
|
onBackdropPress(): void;
|
|
40
|
-
/** The user swiped the sheet down far enough to dismiss it. */
|
|
41
39
|
onSwipeDismiss(): void;
|
|
42
40
|
onDetentChange(index: number): void;
|
|
43
41
|
onContentAreaChange(width: number, height: number): void;
|
|
@@ -64,7 +62,6 @@ export abstract class ModalPresenter {
|
|
|
64
62
|
protected insets: Insets = ZERO_INSETS;
|
|
65
63
|
/** Part of the viewport covered by the on-screen keyboard, from the bottom. */
|
|
66
64
|
protected keyboardHeight = 0;
|
|
67
|
-
/** Measured size of the React content. */
|
|
68
65
|
protected contentSize: Size = { width: 0, height: 0 };
|
|
69
66
|
protected entering = false;
|
|
70
67
|
protected isDismissing = false;
|
|
@@ -152,7 +152,6 @@ export class SheetPresenter extends ModalPresenter {
|
|
|
152
152
|
private drag: Drag | null = null;
|
|
153
153
|
/** Vertical velocity of the swipe that requested the dismissal. */
|
|
154
154
|
private releaseVelocity = 0;
|
|
155
|
-
/** The sheet rests below its lowest detent, the indicator spinning above it. */
|
|
156
155
|
private refreshing = false;
|
|
157
156
|
private refreshSpin: Animation | null = null;
|
|
158
157
|
/** The sheet's top edge in the viewport. */
|
|
@@ -245,8 +244,6 @@ export class SheetPresenter extends ModalPresenter {
|
|
|
245
244
|
surface?.removeEventListener('pointerdown', this.handlePointerDown);
|
|
246
245
|
}
|
|
247
246
|
|
|
248
|
-
// Layout
|
|
249
|
-
|
|
250
247
|
private get detents(): SheetDetent[] {
|
|
251
248
|
return this.config.detents.length > 0
|
|
252
249
|
? this.config.detents
|
|
@@ -295,7 +292,6 @@ export class SheetPresenter extends ModalPresenter {
|
|
|
295
292
|
return this.detents.map((_, index) => this.restingTop(index));
|
|
296
293
|
}
|
|
297
294
|
|
|
298
|
-
/** Where the sheet settles on `detents[index]`: held below the lowest detent while refreshing. */
|
|
299
295
|
private settledTop(index: number): number {
|
|
300
296
|
const top = this.restingTop(index);
|
|
301
297
|
if (!this.refreshing || Math.abs(top - Math.max(...this.detentTops)) >= 1)
|
|
@@ -365,10 +361,6 @@ export class SheetPresenter extends ModalPresenter {
|
|
|
365
361
|
return { sheetTop: lowest, pull: top - lowest };
|
|
366
362
|
}
|
|
367
363
|
|
|
368
|
-
/**
|
|
369
|
-
* Centered in the gap a pull uncovers above the content, fading in as the
|
|
370
|
-
* pull nears the threshold.
|
|
371
|
-
*/
|
|
372
364
|
private renderRefreshIndicator(pull: number) {
|
|
373
365
|
const { refreshIndicator, refreshSpinner } = this.elements!;
|
|
374
366
|
const progress = Math.min(Math.max(pull / REFRESH_THRESHOLD, 0), 1);
|
|
@@ -418,8 +410,6 @@ export class SheetPresenter extends ModalPresenter {
|
|
|
418
410
|
this.settle(SETTLE);
|
|
419
411
|
}
|
|
420
412
|
|
|
421
|
-
// Dragging
|
|
422
|
-
|
|
423
413
|
private canDrag(): boolean {
|
|
424
414
|
return !this.entering && !this.isDismissing && !this.isOffscreen;
|
|
425
415
|
}
|
|
@@ -687,8 +677,6 @@ export class SheetPresenter extends ModalPresenter {
|
|
|
687
677
|
this.release(drag);
|
|
688
678
|
};
|
|
689
679
|
|
|
690
|
-
// Mouse and pen input.
|
|
691
|
-
|
|
692
680
|
private handlePointerDown = (event: PointerEvent) => {
|
|
693
681
|
if (
|
|
694
682
|
event.pointerType === 'touch' ||
|
package/src/web/dom.ts
CHANGED
|
@@ -17,7 +17,6 @@ export const ZERO_INSETS: Insets = { top: 0, right: 0, bottom: 0, left: 0 };
|
|
|
17
17
|
export const canUseDOM =
|
|
18
18
|
typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
19
19
|
|
|
20
|
-
/** Width and height of the pull-to-refresh indicator. */
|
|
21
20
|
export const REFRESH_INDICATOR_SIZE = 24;
|
|
22
21
|
|
|
23
22
|
/** Converts a color from `processColor` (0xAARRGGBB) to CSS, scaling its alpha by `opacity`. */
|
|
@@ -85,7 +84,6 @@ export function readKeyboardHeight(layoutHeight: number): number {
|
|
|
85
84
|
return covered >= 1 ? Math.round(covered) : 0;
|
|
86
85
|
}
|
|
87
86
|
|
|
88
|
-
/** The size of the viewport before anything is on screen. */
|
|
89
87
|
export function estimateViewport(): Size {
|
|
90
88
|
return {
|
|
91
89
|
width: document.documentElement.clientWidth || window.innerWidth,
|