react-native-nitro-modal 0.2.0 → 0.3.1-rc
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 +52 -4
- package/android/src/main/java/com/margelo/nitro/nitromodal/BottomSheetPresenter.kt +399 -34
- package/android/src/main/java/com/margelo/nitro/nitromodal/HybridNitroModal.kt +67 -22
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalConfig.kt +35 -1
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalContentRoot.kt +48 -5
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalPresenter.kt +63 -4
- package/android/src/main/java/com/margelo/nitro/nitromodal/NitroModalHostView.kt +68 -8
- package/ios/HybridNitroModal.swift +115 -20
- package/ios/ModalConfig.swift +48 -2
- package/ios/NitroModalHostView.swift +73 -8
- package/ios/SheetView.swift +647 -0
- package/ios/SheetViewController.swift +19 -450
- package/lib/module/NitroModal.js +54 -6
- package/lib/module/NitroModal.js.map +1 -1
- package/lib/module/NitroModalView.web.js +86 -26
- package/lib/module/NitroModalView.web.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/web/AnimatedValue.js +3 -0
- package/lib/module/web/AnimatedValue.js.map +1 -1
- package/lib/module/web/ModalConfig.js +10 -4
- package/lib/module/web/ModalConfig.js.map +1 -1
- package/lib/module/web/ModalController.js +29 -2
- package/lib/module/web/ModalController.js.map +1 -1
- package/lib/module/web/ModalPresenter.js +47 -12
- package/lib/module/web/ModalPresenter.js.map +1 -1
- package/lib/module/web/SheetPresenter.js +118 -34
- package/lib/module/web/SheetPresenter.js.map +1 -1
- package/lib/module/web/dom.js +16 -0
- package/lib/module/web/dom.js.map +1 -1
- package/lib/typescript/src/NitroModal.d.ts +42 -2
- package/lib/typescript/src/NitroModal.d.ts.map +1 -1
- package/lib/typescript/src/NitroModal.nitro.d.ts +37 -2
- package/lib/typescript/src/NitroModal.nitro.d.ts.map +1 -1
- package/lib/typescript/src/NitroModalView.web.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/web/AnimatedValue.d.ts +1 -0
- package/lib/typescript/src/web/AnimatedValue.d.ts.map +1 -1
- package/lib/typescript/src/web/ModalConfig.d.ts +10 -0
- package/lib/typescript/src/web/ModalConfig.d.ts.map +1 -1
- package/lib/typescript/src/web/ModalController.d.ts +5 -0
- package/lib/typescript/src/web/ModalController.d.ts.map +1 -1
- package/lib/typescript/src/web/ModalPresenter.d.ts +13 -0
- package/lib/typescript/src/web/ModalPresenter.d.ts.map +1 -1
- package/lib/typescript/src/web/SheetPresenter.d.ts +13 -2
- package/lib/typescript/src/web/SheetPresenter.d.ts.map +1 -1
- package/lib/typescript/src/web/dom.d.ts +4 -0
- package/lib/typescript/src/web/dom.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridNitroModalSpec.cpp +78 -6
- package/nitrogen/generated/android/c++/JHybridNitroModalSpec.hpp +14 -2
- package/nitrogen/generated/android/c++/JNamedSheetDetent.hpp +64 -0
- package/nitrogen/generated/android/c++/JSheetDetent.cpp +26 -0
- package/nitrogen/generated/android/c++/JSheetDetent.hpp +42 -37
- package/nitrogen/generated/android/c++/views/JHybridNitroModalStateUpdater.cpp +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/HybridNitroModalSpec.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/NamedSheetDetent.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/SheetDetent.kt +47 -10
- package/nitrogen/generated/android/nitromodal+autolinking.cmake +1 -0
- package/nitrogen/generated/ios/NitroModal-Swift-Cxx-Bridge.hpp +68 -8
- package/nitrogen/generated/ios/NitroModal-Swift-Cxx-Umbrella.hpp +4 -3
- package/nitrogen/generated/ios/c++/HybridNitroModalSpecSwift.hpp +46 -5
- package/nitrogen/generated/ios/c++/views/HybridNitroModalComponent.mm +36 -0
- package/nitrogen/generated/ios/swift/HybridNitroModalSpec.swift +6 -0
- package/nitrogen/generated/ios/swift/HybridNitroModalSpec_cxx.swift +158 -5
- package/nitrogen/generated/ios/swift/NamedSheetDetent.swift +48 -0
- package/nitrogen/generated/ios/swift/SheetDetent.swift +15 -33
- package/nitrogen/generated/shared/c++/HybridNitroModalSpec.cpp +12 -0
- package/nitrogen/generated/shared/c++/HybridNitroModalSpec.hpp +18 -5
- package/nitrogen/generated/shared/c++/{SheetDetent.hpp → NamedSheetDetent.hpp} +17 -17
- package/nitrogen/generated/shared/c++/views/HybridNitroModalComponent.cpp +13 -1
- package/nitrogen/generated/shared/c++/views/HybridNitroModalComponent.hpp +21 -2
- package/nitrogen/generated/shared/json/NitroModalConfig.json +6 -0
- package/package.json +1 -1
- package/src/NitroModal.nitro.ts +38 -2
- package/src/NitroModal.tsx +93 -4
- package/src/NitroModalView.web.tsx +79 -12
- package/src/index.tsx +2 -0
- package/src/web/AnimatedValue.ts +4 -0
- package/src/web/ModalConfig.ts +19 -3
- package/src/web/ModalController.ts +35 -2
- package/src/web/ModalPresenter.ts +50 -11
- package/src/web/SheetPresenter.ts +169 -37
- package/src/web/dom.ts +20 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useImperativeHandle","useLayoutEffect","useMemo","useRef","useState","processColor","StyleSheet","useWindowDimensions","View","callback","NitroModalView","jsx","_jsx","DEFAULT_DETENTS","BLACK","toNativeColor","color","undefined","processed","NitroModal","isOpen","mode","detents","initialDetentIndex","backdropColor","backdropOpacity","backdropBlur","dismissOnBackdropPress","dismissOnSwipe","dismissOnBackButton","showGrabber","cornerRadius","backgroundColor","keyboardBehavior","popupAnimation","contentContainerStyle","onPresent","onDismiss","onDetentChange","onBackdropPress","onBackButtonPress","children","testID","ref","isControlled","internalOpen","setInternalOpen","open","sessionActive","setSessionActive","prevOpen","setPrevOpen","renderContent","area","setArea","hybridRef","latest","current","nativeCallbacks","instance","reason","index","onContentAreaChange","next","width","height","present","console","warn","dismiss","snapToDetent","detentsKey","join","nativeDetents","Set","split","windowSize","contentArea","containerStyle","maxWidth","maxHeight","includes","
|
|
1
|
+
{"version":3,"names":["useEffect","useImperativeHandle","useLayoutEffect","useMemo","useRef","useState","processColor","StyleSheet","useWindowDimensions","View","callback","NitroModalView","jsx","_jsx","DEFAULT_DETENTS","BLACK","parseDetent","value","points","Number","isFinite","toNativeColor","color","undefined","processed","NitroModal","isOpen","mode","presentation","style","detents","initialDetentIndex","backdropColor","backdropOpacity","backdropBlur","dismissOnBackdropPress","dismissOnSwipe","dismissOnBackButton","showGrabber","cornerRadius","backgroundColor","keyboardBehavior","popupAnimation","contentContainerStyle","onPresent","onDismiss","onDetentChange","onBackdropPress","onBackButtonPress","onPullToRefresh","refreshing","refreshIndicatorColor","children","testID","ref","isControlled","isInline","internalOpen","setInternalOpen","open","sessionActive","setSessionActive","prevOpen","setPrevOpen","renderContent","area","setArea","restingTop","setRestingTop","isRefreshControlled","pullPending","setPullPending","hybridRef","latest","current","nativeCallbacks","instance","reason","index","onRestingTopChange","top","onContentAreaChange","next","width","height","present","console","warn","dismiss","snapToDetent","detentsKey","join","nativeDetents","Set","split","map","windowSize","contentArea","containerStyle","maxWidth","maxHeight","includes","absoluteFill","styles","host","pointerEvents","backdropBlurRadius","grabberVisible","contentBackgroundColor","pullToRefreshEnabled","collapsable","container","create","position","left"],"sourceRoot":"../../src","sources":["NitroModal.tsx"],"mappings":";;AAAA,SACEA,SAAS,EACTC,mBAAmB,EACnBC,eAAe,EACfC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAGH,OAAO;AACd,SACEC,YAAY,EACZC,UAAU,EACVC,mBAAmB,EACnBC,IAAI,QAIC,cAAc;AAWrB,SAASC,QAAQ,EAAEC,cAAc,QAAQ,kBAAkB;;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AANA,SAAAC,GAAA,IAAAC,IAAA;AAiGA,MAAMC,eAA8B,GAAG,CAAC,YAA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AEA,gBAAiB;IACnCC,cAAc,EAAEA,cAAe;IAC/BmE,oBAAoB,EAAE5D,eAAe,IAAI,IAAK;IAC9CC,UAAU,EAAEmB,mBAAmB,GAAGnB,UAAU,IAAIoB,WAAW,GAAG/C,SAAU;IACxE4B,qBAAqB,EAAE9B,aAAa,CAAC8B,qBAAqB,CAAE;IAAA,GACxDwB,eAAe;IAAAvB,QAAA,EAElBY,aAAa,gBACZnD,IAAA,CAACJ,IAAI;MACHqG,WAAW,EAAE,KAAM;MACnBzD,MAAM,EAAEA,MAAO;MACfxB,KAAK,EAAE,CACL0E,MAAM,CAACQ,SAAS,EAChBb,cAAc,EACdvD,qBAAqB,EACrBa,QAAQ,IAAIW,UAAU,GAAG,CAAC,GAAG;QAAEa,GAAG,EAAEb;MAAW,CAAC,GAAG,IAAI,CACvD;MAAAf,QAAA,EAEDA;IAAQ,CACL,CAAC,GACL;EAAI,CACM,CAAC;AAErB;AAEA,MAAMmD,MAAM,GAAGhG,UAAU,CAACyG,MAAM,CAAC;EAC/B;EACA;EACAR,IAAI,EAAE;IACJS,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPlC,GAAG,EAAE,CAAC;IACNG,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACV,CAAC;EACD;EACA;EACA2B,SAAS,EAAE;IACTE,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPlC,GAAG,EAAE;EACP;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
/// <reference lib="dom" />
|
|
4
4
|
|
|
5
|
-
import { useLayoutEffect, useRef, useState } from 'react';
|
|
6
|
-
import { Modal } from 'react-native';
|
|
5
|
+
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
6
|
+
import { Modal, View } from 'react-native';
|
|
7
|
+
import { clipOverflow, REFRESH_INDICATOR_SIZE } from "./web/dom.js";
|
|
7
8
|
import { ModalController } from "./web/ModalController.js";
|
|
8
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
/** The web view takes plain functions; only native host components need them wrapped. */
|
|
@@ -16,12 +17,16 @@ export function callback(func) {
|
|
|
16
17
|
* Native Web's `Modal` (a portal with focus trapping, Escape handling and
|
|
17
18
|
* stacking with other modals) and is laid out and animated by the presenters
|
|
18
19
|
* in `./web`. In place, it renders nothing.
|
|
20
|
+
*
|
|
21
|
+
* An inline sheet renders in place instead: a view laid out with `style`,
|
|
22
|
+
* holding the sheet's elements.
|
|
19
23
|
*/
|
|
20
24
|
function WebNitroModalView(props) {
|
|
21
25
|
const {
|
|
22
26
|
hybridRef,
|
|
23
27
|
children
|
|
24
28
|
} = props;
|
|
29
|
+
const isInline = props.isInline && props.mode === 'bottomSheet';
|
|
25
30
|
const [mounted, setMounted] = useState(false);
|
|
26
31
|
const [controller] = useState(() => new ModalController(setMounted));
|
|
27
32
|
const overlay = useRef(null);
|
|
@@ -29,6 +34,8 @@ function WebNitroModalView(props) {
|
|
|
29
34
|
const surface = useRef(null);
|
|
30
35
|
const content = useRef(null);
|
|
31
36
|
const grabber = useRef(null);
|
|
37
|
+
const refreshIndicator = useRef(null);
|
|
38
|
+
const refreshSpinner = useRef(null);
|
|
32
39
|
useLayoutEffect(() => {
|
|
33
40
|
controller.attach();
|
|
34
41
|
return () => controller.detach();
|
|
@@ -46,7 +53,9 @@ function WebNitroModalView(props) {
|
|
|
46
53
|
backdrop: backdrop.current,
|
|
47
54
|
surface: surface.current,
|
|
48
55
|
content: content.current,
|
|
49
|
-
grabber: grabber.current
|
|
56
|
+
grabber: grabber.current,
|
|
57
|
+
refreshIndicator: refreshIndicator.current,
|
|
58
|
+
refreshSpinner: refreshSpinner.current
|
|
50
59
|
});
|
|
51
60
|
return () => controller.elementsWillUnmount();
|
|
52
61
|
}, [controller, mounted]);
|
|
@@ -55,37 +64,63 @@ function WebNitroModalView(props) {
|
|
|
55
64
|
controller.contentDidRender();
|
|
56
65
|
}
|
|
57
66
|
});
|
|
58
|
-
|
|
67
|
+
const hostRef = useCallback(node => {
|
|
68
|
+
controller.hostDidChange(node instanceof HTMLElement ? node : null);
|
|
69
|
+
}, [controller]);
|
|
59
70
|
|
|
60
71
|
// Styles set here never change; the presenters write sizes, positions,
|
|
61
72
|
// colors and animated values straight to the elements.
|
|
73
|
+
const layer = mounted ?
|
|
74
|
+
/*#__PURE__*/
|
|
75
|
+
// Focusable so the modal's focus trap lands here first rather than on the first input.
|
|
76
|
+
_jsxs("div", {
|
|
77
|
+
ref: overlay,
|
|
78
|
+
tabIndex: -1,
|
|
79
|
+
style: isInline ? {
|
|
80
|
+
...styles.inlineOverlay,
|
|
81
|
+
overflow: clipOverflow()
|
|
82
|
+
} : styles.overlay,
|
|
83
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
84
|
+
ref: backdrop,
|
|
85
|
+
"aria-hidden": true,
|
|
86
|
+
style: styles.backdrop
|
|
87
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
88
|
+
ref: refreshIndicator,
|
|
89
|
+
"aria-hidden": true,
|
|
90
|
+
style: styles.refreshIndicator,
|
|
91
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
92
|
+
ref: refreshSpinner,
|
|
93
|
+
style: styles.refreshSpinner
|
|
94
|
+
})
|
|
95
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
96
|
+
ref: surface,
|
|
97
|
+
style: styles.surface,
|
|
98
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
99
|
+
ref: content,
|
|
100
|
+
style: styles.content,
|
|
101
|
+
children: children
|
|
102
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
103
|
+
ref: grabber,
|
|
104
|
+
"aria-hidden": true,
|
|
105
|
+
style: styles.grabber
|
|
106
|
+
})]
|
|
107
|
+
})]
|
|
108
|
+
}) : null;
|
|
109
|
+
if (isInline) {
|
|
110
|
+
return /*#__PURE__*/_jsx(View, {
|
|
111
|
+
ref: hostRef,
|
|
112
|
+
style: props.style,
|
|
113
|
+
pointerEvents: "box-none",
|
|
114
|
+
children: layer
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (!layer) return null;
|
|
62
118
|
return /*#__PURE__*/_jsx(Modal, {
|
|
63
119
|
visible: true,
|
|
64
120
|
transparent: true,
|
|
65
121
|
animationType: "none",
|
|
66
122
|
onRequestClose: controller.handleBackPress,
|
|
67
|
-
children:
|
|
68
|
-
ref: overlay,
|
|
69
|
-
tabIndex: -1,
|
|
70
|
-
style: styles.overlay,
|
|
71
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
72
|
-
ref: backdrop,
|
|
73
|
-
"aria-hidden": true,
|
|
74
|
-
style: styles.backdrop
|
|
75
|
-
}), /*#__PURE__*/_jsxs("div", {
|
|
76
|
-
ref: surface,
|
|
77
|
-
style: styles.surface,
|
|
78
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
79
|
-
ref: content,
|
|
80
|
-
style: styles.content,
|
|
81
|
-
children: children
|
|
82
|
-
}), /*#__PURE__*/_jsx("div", {
|
|
83
|
-
ref: grabber,
|
|
84
|
-
"aria-hidden": true,
|
|
85
|
-
style: styles.grabber
|
|
86
|
-
})]
|
|
87
|
-
})]
|
|
88
|
-
})
|
|
123
|
+
children: layer
|
|
89
124
|
});
|
|
90
125
|
}
|
|
91
126
|
const styles = {
|
|
@@ -94,6 +129,13 @@ const styles = {
|
|
|
94
129
|
inset: 0,
|
|
95
130
|
outline: 'none'
|
|
96
131
|
},
|
|
132
|
+
// Fills the host view; the sheet hides below its bottom edge.
|
|
133
|
+
inlineOverlay: {
|
|
134
|
+
position: 'absolute',
|
|
135
|
+
inset: 0,
|
|
136
|
+
outline: 'none',
|
|
137
|
+
pointerEvents: 'none'
|
|
138
|
+
},
|
|
97
139
|
backdrop: {
|
|
98
140
|
position: 'absolute',
|
|
99
141
|
inset: 0,
|
|
@@ -123,6 +165,24 @@ const styles = {
|
|
|
123
165
|
borderRadius: 2.5,
|
|
124
166
|
backgroundColor: 'rgba(127, 127, 127, 0.4)',
|
|
125
167
|
pointerEvents: 'none'
|
|
168
|
+
},
|
|
169
|
+
refreshIndicator: {
|
|
170
|
+
position: 'absolute',
|
|
171
|
+
left: 0,
|
|
172
|
+
top: 0,
|
|
173
|
+
width: REFRESH_INDICATOR_SIZE,
|
|
174
|
+
height: REFRESH_INDICATOR_SIZE,
|
|
175
|
+
opacity: 0,
|
|
176
|
+
pointerEvents: 'none'
|
|
177
|
+
},
|
|
178
|
+
// Colored through `color` by the presenter.
|
|
179
|
+
refreshSpinner: {
|
|
180
|
+
width: '100%',
|
|
181
|
+
height: '100%',
|
|
182
|
+
boxSizing: 'border-box',
|
|
183
|
+
borderRadius: '50%',
|
|
184
|
+
border: '2.5px solid currentColor',
|
|
185
|
+
borderTopColor: 'transparent'
|
|
126
186
|
}
|
|
127
187
|
};
|
|
128
188
|
export const NitroModalView = WebNitroModalView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useLayoutEffect","useRef","useState","Modal","ModalController","jsx","_jsx","jsxs","_jsxs","callback","func","WebNitroModalView","props","hybridRef","children","mounted","setMounted","controller","overlay","backdrop","surface","content","grabber","attach","detach","methods","update","undefined","elementsDidMount","current","elementsWillUnmount","contentDidRender","
|
|
1
|
+
{"version":3,"names":["useCallback","useLayoutEffect","useRef","useState","Modal","View","clipOverflow","REFRESH_INDICATOR_SIZE","ModalController","jsx","_jsx","jsxs","_jsxs","callback","func","WebNitroModalView","props","hybridRef","children","isInline","mode","mounted","setMounted","controller","overlay","backdrop","surface","content","grabber","refreshIndicator","refreshSpinner","attach","detach","methods","update","undefined","elementsDidMount","current","elementsWillUnmount","contentDidRender","hostRef","node","hostDidChange","HTMLElement","layer","ref","tabIndex","style","styles","inlineOverlay","overflow","pointerEvents","visible","transparent","animationType","onRequestClose","handleBackPress","position","inset","outline","touchAction","left","top","boxSizing","willChange","width","height","marginLeft","borderRadius","backgroundColor","opacity","border","borderTopColor","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SAAS,EAAE,YAAY;IACvBK,YAAY,EAAE,KAAK;IACnBG,MAAM,EAAE,0BAA0B;IAClCC,cAAc,EAAE;EAClB;AACF,CAAyC;AAEzC,OAAO,MAAMC,cAAc,GAAG1D,iBAG7B","ignoreList":[]}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NitroModal"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SACEA,UAAU,
|
|
1
|
+
{"version":3,"names":["NitroModal"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SACEA,UAAU,QAIL,iBAAc","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["INSTANT","type","duration","easing","t","MAX_FRAME_SECONDS","SPRING_STEP_SECONDS","AnimatedValue","speed","run","frame","lastTime","constructor","value","precision","onChange","current","set","stop","cancelAnimationFrame","animateTo","target","motion","options","velocity","undefined","now","performance","from","startTime","side","Math","sign","requestAnimationFrame","step","time","dt","min","max","done","stepTiming","stepSpring","onEnd","progress","next","omega","PI","response","stiffness","damping","dampingRatio","offset","steps","ceil","i","h","stopAtTarget","abs"],"sourceRoot":"../../../src","sources":["web/AnimatedValue.ts"],"mappings":";;AAAA;;AAEA;;AAgBA;AACA,OAAO,MAAMA,OAAe,GAAG;EAC7BC,IAAI,EAAE,QAAQ;EACdC,QAAQ,EAAE,CAAC;EACXC,MAAM,EAAGC,CAAC,IAAKA;AACjB,CAAC;AAqBD;AACA,MAAMC,iBAAiB,GAAG,KAAK;AAC/B,MAAMC,mBAAmB,GAAG,KAAK;;AAEjC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,CAAC;EAEjBC,KAAK,GAAG,CAAC;EACTC,GAAG,GAAe,IAAI;EACtBC,KAAK,GAAkB,IAAI;EAC3BC,QAAQ,GAAG,CAAC;;EAEpB;EACAC,WAAWA,CACTC,KAAa,EACIC,SAAiB,EACjBC,QAAiC,EAClD;IAAA,KAFiBD,SAAiB,GAAjBA,SAAiB;IAAA,KACjBC,QAAiC,GAAjCA,QAAiC;IAElD,IAAI,CAACC,OAAO,GAAGH,KAAK;EACtB;EAEA,IAAIA,KAAKA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACG,OAAO;EACrB;;EAEA;
|
|
1
|
+
{"version":3,"names":["INSTANT","type","duration","easing","t","MAX_FRAME_SECONDS","SPRING_STEP_SECONDS","AnimatedValue","speed","run","frame","lastTime","constructor","value","precision","onChange","current","isAnimating","set","stop","cancelAnimationFrame","animateTo","target","motion","options","velocity","undefined","now","performance","from","startTime","side","Math","sign","requestAnimationFrame","step","time","dt","min","max","done","stepTiming","stepSpring","onEnd","progress","next","omega","PI","response","stiffness","damping","dampingRatio","offset","steps","ceil","i","h","stopAtTarget","abs"],"sourceRoot":"../../../src","sources":["web/AnimatedValue.ts"],"mappings":";;AAAA;;AAEA;;AAgBA;AACA,OAAO,MAAMA,OAAe,GAAG;EAC7BC,IAAI,EAAE,QAAQ;EACdC,QAAQ,EAAE,CAAC;EACXC,MAAM,EAAGC,CAAC,IAAKA;AACjB,CAAC;AAqBD;AACA,MAAMC,iBAAiB,GAAG,KAAK;AAC/B,MAAMC,mBAAmB,GAAG,KAAK;;AAEjC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,CAAC;EAEjBC,KAAK,GAAG,CAAC;EACTC,GAAG,GAAe,IAAI;EACtBC,KAAK,GAAkB,IAAI;EAC3BC,QAAQ,GAAG,CAAC;;EAEpB;EACAC,WAAWA,CACTC,KAAa,EACIC,SAAiB,EACjBC,QAAiC,EAClD;IAAA,KAFiBD,SAAiB,GAAjBA,SAAiB;IAAA,KACjBC,QAAiC,GAAjCA,QAAiC;IAElD,IAAI,CAACC,OAAO,GAAGH,KAAK;EACtB;EAEA,IAAIA,KAAKA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACG,OAAO;EACrB;EAEA,IAAIC,WAAWA,CAAA,EAAY;IACzB,OA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;IACA,IAAI,CAACxC,OAAO,GAAGP,GAAG,CAACa,MAAM,GAAG8B,MAAM;IAClC,IAAI,CAAC5C,KAAK,GAAGiB,QAAQ;IAErB,IACEhB,GAAG,CAACe,OAAO,CAACiC,YAAY,KACvBhD,GAAG,CAACsB,IAAI,KAAK,CAAC,IAAIC,IAAI,CAACC,IAAI,CAACmB,MAAM,CAAC,KAAK3C,GAAG,CAACsB,IAAI,CAAC,EAClD;MACA,OAAO,IAAI;IACb;IACA,OACEC,IAAI,CAAC0B,GAAG,CAACN,MAAM,CAAC,GAAG,IAAI,CAACtC,SAAS,IACjCkB,IAAI,CAAC0B,GAAG,CAACjC,QAAQ,CAAC,GAAG,IAAI,CAACX,SAAS,GAAG,EAAE;EAE5C;AACF","ignoreList":[]}
|
|
@@ -3,21 +3,27 @@
|
|
|
3
3
|
/** Snapshot of the props that shape a presentation. */
|
|
4
4
|
|
|
5
5
|
export function makeConfig(props) {
|
|
6
|
+
// An inline sheet is part of the page; the user can't dismiss it.
|
|
7
|
+
const isInline = props.isInline && props.mode === 'bottomSheet';
|
|
6
8
|
return {
|
|
7
9
|
mode: props.mode,
|
|
10
|
+
isInline,
|
|
8
11
|
detents: props.detents,
|
|
9
12
|
initialDetentIndex: Number.isFinite(props.initialDetentIndex) ? Math.trunc(props.initialDetentIndex) : 0,
|
|
10
13
|
backdropColor: props.backdropColor,
|
|
11
14
|
backdropOpacity: props.backdropOpacity,
|
|
12
15
|
backdropBlurRadius: props.backdropBlurRadius,
|
|
13
|
-
dismissOnBackdropPress: props.dismissOnBackdropPress,
|
|
14
|
-
dismissOnSwipe: props.dismissOnSwipe,
|
|
15
|
-
dismissOnBackButton: props.dismissOnBackButton,
|
|
16
|
+
dismissOnBackdropPress: props.dismissOnBackdropPress && !isInline,
|
|
17
|
+
dismissOnSwipe: props.dismissOnSwipe && !isInline,
|
|
18
|
+
dismissOnBackButton: props.dismissOnBackButton && !isInline,
|
|
16
19
|
grabberVisible: props.grabberVisible,
|
|
17
20
|
cornerRadius: props.cornerRadius >= 0 ? props.cornerRadius : null,
|
|
18
21
|
contentBackgroundColor: props.contentBackgroundColor ?? null,
|
|
19
22
|
keyboardBehavior: props.keyboardBehavior,
|
|
20
|
-
popupAnimation: props.popupAnimation
|
|
23
|
+
popupAnimation: props.popupAnimation,
|
|
24
|
+
pullToRefreshEnabled: props.pullToRefreshEnabled,
|
|
25
|
+
refreshing: props.refreshing ?? null,
|
|
26
|
+
refreshIndicatorColor: props.refreshIndicatorColor ?? null
|
|
21
27
|
};
|
|
22
28
|
}
|
|
23
29
|
export function isSameConfig(a, b) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["makeConfig","props","mode","detents","initialDetentIndex","Number","isFinite","Math","trunc","backdropColor","backdropOpacity","backdropBlurRadius","dismissOnBackdropPress","dismissOnSwipe","dismissOnBackButton","grabberVisible","cornerRadius","contentBackgroundColor","keyboardBehavior","popupAnimation","isSameConfig","a","b","Object","keys","every","key","join"],"sourceRoot":"../../../src","sources":["web/ModalConfig.ts"],"mappings":";;AAQA;;
|
|
1
|
+
{"version":3,"names":["makeConfig","props","isInline","mode","detents","initialDetentIndex","Number","isFinite","Math","trunc","backdropColor","backdropOpacity","backdropBlurRadius","dismissOnBackdropPress","dismissOnSwipe","dismissOnBackButton","grabberVisible","cornerRadius","contentBackgroundColor","keyboardBehavior","popupAnimation","pullToRefreshEnabled","refreshing","refreshIndicatorColor","isSameConfig","a","b","Object","keys","every","key","join"],"sourceRoot":"../../../src","sources":["web/ModalConfig.ts"],"mappings":";;AAQA;;AA+BA,OAAO,SAASA,UAAUA,CAACC,KAAsB,EAAe;EAC9D;EACA,MAAMC,QAAQ,GAAGD,KAAK,CAACC,QAAQ,IAAID,KAAK,CAACE,IAAI,KAAK,aAAa;EAC/D,OAAO;IACLA,IAAI,EAAEF,KAAK,CAACE,IAAI;IAChBD,QAAQ;IACRE,OAAO,EAAEH,KAAK,CAACG,OAAO;IACtBC,kBAAkB,EAAEC,MAA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2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/// <reference lib="dom" />
|
|
4
4
|
|
|
5
|
-
import { canUseDOM, estimateViewport, readSafeAreaInsets } from "./dom.js";
|
|
5
|
+
import { canUseDOM, estimateViewport, inlineInsets, readSafeAreaInsets } from "./dom.js";
|
|
6
6
|
import { isSameConfig, makeConfig } from "./ModalConfig.js";
|
|
7
7
|
import { popupContentArea, PopupPresenter } from "./PopupPresenter.js";
|
|
8
8
|
import { sheetContentArea, SheetPresenter } from "./SheetPresenter.js";
|
|
@@ -42,6 +42,8 @@ export class ModalController {
|
|
|
42
42
|
isAttached = false;
|
|
43
43
|
presenter = null;
|
|
44
44
|
elements = null;
|
|
45
|
+
/** Inline: the element the sheet fills. */
|
|
46
|
+
host = null;
|
|
45
47
|
lastContentArea = null;
|
|
46
48
|
|
|
47
49
|
/** `setMounted` renders (or removes) the modal's elements. */
|
|
@@ -95,6 +97,15 @@ export class ModalController {
|
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
99
|
}
|
|
100
|
+
|
|
101
|
+
/** Inline: the element the sheet fills, rendered in place. */
|
|
102
|
+
hostDidChange(host) {
|
|
103
|
+
if (host === this.host) return;
|
|
104
|
+
this.host = host;
|
|
105
|
+
if (!this.presenter) {
|
|
106
|
+
this.reportEstimatedContentArea();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
98
109
|
elementsDidMount(elements) {
|
|
99
110
|
this.elements = elements;
|
|
100
111
|
if (this.presenter && !this.presenter.isShown) {
|
|
@@ -245,6 +256,9 @@ export class ModalController {
|
|
|
245
256
|
onDetentChange(index) {
|
|
246
257
|
this.props?.onDetentChange?.(index);
|
|
247
258
|
}
|
|
259
|
+
onPullToRefresh() {
|
|
260
|
+
this.props?.onPullToRefresh?.();
|
|
261
|
+
}
|
|
248
262
|
onContentAreaChange(width, height) {
|
|
249
263
|
const area = {
|
|
250
264
|
width: Math.floor(width),
|
|
@@ -265,9 +279,22 @@ export class ModalController {
|
|
|
265
279
|
config
|
|
266
280
|
} = this;
|
|
267
281
|
if (!canUseDOM || !this.isAttached || !config) return;
|
|
282
|
+
if (config.isInline) {
|
|
283
|
+
const {
|
|
284
|
+
host
|
|
285
|
+
} = this;
|
|
286
|
+
if (!host || host.clientWidth === 0 || host.clientHeight === 0) return;
|
|
287
|
+
const viewport = {
|
|
288
|
+
width: host.clientWidth,
|
|
289
|
+
height: host.clientHeight
|
|
290
|
+
};
|
|
291
|
+
const area = sheetContentArea(config.detents, viewport, inlineInsets(host), true);
|
|
292
|
+
this.onContentAreaChange(area.width, area.height);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
268
295
|
const viewport = estimateViewport();
|
|
269
296
|
const insets = readSafeAreaInsets();
|
|
270
|
-
const area = config.mode === 'popup' ? popupContentArea(viewport, insets) : sheetContentArea(config.detents, viewport, insets);
|
|
297
|
+
const area = config.mode === 'popup' ? popupContentArea(viewport, insets) : sheetContentArea(config.detents, viewport, insets, false);
|
|
271
298
|
this.onContentAreaChange(area.width, area.height);
|
|
272
299
|
}
|
|
273
300
|
handleWindowResize = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["canUseDOM","estimateViewport","readSafeAreaInsets","isSameConfig","makeConfig","popupContentArea","PopupPresenter","sheetContentArea","SheetPresenter","ModalController","methods","present","requestPresent","dismiss","requestDismiss","snapToDetent","index","Number","isFinite","presenter","Math","trunc","props","config","isOpen","phase","wantsOpen","sessionActive","presentSent","dismissReason","reconcileScheduled","isAttached","elements","lastContentArea","constructor","setMounted","attach","window","addEventListener","handleWindowResize","detach","removeEventListener","destroy","update","next","reportEstimatedContentArea","elementsDidMount","isShown","show","elementsWillUnmount","contentDidRender","handleBackPress","isVisible","onBackButtonPress","dismissOnBackButton","reconcile","scheduleReconcile","reason","queueMicrotask","startDismiss","cancelDismiss","startPresent","endSession","mode","finishDismiss","onDismiss","onPresented","onPresent","onDismissed","onBackdropPress","dismissOnBackdropPress","onSwipeDismiss","dismissOnSwipe","onDetentChange","onContentAreaChange","width","height","area","floor","last","
|
|
1
|
+
{"version":3,"names":["canUseDOM","estimateViewport","inlineInsets","readSafeAreaInsets","isSameConfig","makeConfig","popupContentArea","PopupPresenter","sheetContentArea","SheetPresenter","ModalController","methods","present","requestPresent","dismiss","requestDismiss","snapToDetent","index","Number","isFinite","presenter","Math","trunc","props","config","isOpen","phase","wantsOpen","sessionActive","presentSent","dismissReason","reconcileScheduled","isAttached","elements","host","lastContentArea","constructor","setMounted","attach","window","addEventListener","handleWindowResize","detach","removeEventListener","destroy","update","next","reportEstimatedContentArea","hostDidChange","elementsDidMount","isShown","show","elementsWillUnmount","contentDidRender","handleBackPress","isVisible","onBackButtonPress","dismissOnBackButton","reconcile","scheduleReconcile","reason","queueMicrotask","startDismiss","cancelDismiss","startPresent","endSession","mode","finishDismiss","onDismiss","onPresented","onPresent","onDismissed","onBackdropPress","dismissOnBackdropPress","onSwipeDismiss","dismissOnSwipe","onDetentChange","onPullToRefresh","onContentAreaChange","width","height","area","floor","last","isInline","clientWidth","clientHeight","viewport","detents","insets"],"sourceRoot":"../../../src","sources":["web/ModalController.ts"],"mappings":";;AAAA;;AAQA,SACEA,SAAS,EACTC,gBAAgB,EAChBC,YAAY,EACZC,kBAAkB,QACb,UAAO;AACd,SAASC,YAAY,EAAEC,UAAU,QAA0B,kBAAe;AAM1E,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,qBAAkB;AACnE,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,qBAAkB;AAInE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,CAA8B;EAC/CC,OAAO,GAGZ;IACFC,OAAO,EAAEA,CAAA,KAAM,IAAI,CAACC,cAAc,CAAC,CAAC;IACpCC,OAAO,EAAEA,CAAA,KAAM,IAAI,CAACC,cAAc,CAAC,cAAc,CAAC;IAClDC,YAAY,EAAGC,KAAa,IAAK;MAC/B,IAAIC,MAAM,CAACC,QAAQ,CAACF,KA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import { canScrollWithin, clipOverflow, readKeyboardHeight, readSafeAreaInsets, toCSSColor, ZERO_INSETS } from "./dom.js";
|
|
5
|
+
import { canScrollWithin, clipOverflow, inlineInsets, readKeyboardHeight, readSafeAreaInsets, toCSSColor, ZERO_INSETS } from "./dom.js";
|
|
6
6
|
|
|
7
7
|
/** DOM rendered by the web host view for one presentation. */
|
|
8
8
|
|
|
@@ -15,6 +15,9 @@ import { canScrollWithin, clipOverflow, readKeyboardHeight, readSafeAreaInsets,
|
|
|
15
15
|
* Transitions are interruptible: dismissing mid-enter turns the enter around,
|
|
16
16
|
* and `cancelDismiss` turns an exit back around. Once an exit starts the modal
|
|
17
17
|
* stops taking input.
|
|
18
|
+
*
|
|
19
|
+
* Inline, the elements fill the host view in place of a full-window layer:
|
|
20
|
+
* only the surface takes input, and the keyboard is left to the page.
|
|
18
21
|
*/
|
|
19
22
|
export class ModalPresenter {
|
|
20
23
|
elements = null;
|
|
@@ -35,6 +38,8 @@ export class ModalPresenter {
|
|
|
35
38
|
finished = false;
|
|
36
39
|
observedContent = null;
|
|
37
40
|
resizeObserver = null;
|
|
41
|
+
/** Inline: follows the host's size, which can change without a window resize. */
|
|
42
|
+
hostObserver = null;
|
|
38
43
|
constructor(config, listener) {
|
|
39
44
|
this.config = config;
|
|
40
45
|
this.listener = listener;
|
|
@@ -48,17 +53,25 @@ export class ModalPresenter {
|
|
|
48
53
|
if (this.elements || this.finished) return;
|
|
49
54
|
this.elements = elements;
|
|
50
55
|
// The elements can outlive a previous presentation (an immediate re-present).
|
|
51
|
-
|
|
56
|
+
this.setInteractive(true);
|
|
52
57
|
elements.surface.style.overflow = clipOverflow();
|
|
53
58
|
elements.surface.style.opacity = '';
|
|
54
59
|
elements.surface.style.transform = '';
|
|
60
|
+
elements.backdrop.style.display = this.config.isInline ? 'none' : '';
|
|
55
61
|
window.addEventListener('resize', this.handleResize);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
+
if (this.config.isInline) {
|
|
63
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
64
|
+
this.hostObserver = new ResizeObserver(this.handleResize);
|
|
65
|
+
this.hostObserver.observe(elements.overlay);
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
window.visualViewport?.addEventListener('resize', this.handleKeyboard);
|
|
69
|
+
window.visualViewport?.addEventListener('scroll', this.handleKeyboard);
|
|
70
|
+
elements.backdrop.addEventListener('click', this.handleBackdropClick);
|
|
71
|
+
elements.overlay.addEventListener('wheel', this.handleWheel, {
|
|
72
|
+
passive: false
|
|
73
|
+
});
|
|
74
|
+
}
|
|
62
75
|
if (typeof ResizeObserver !== 'undefined') {
|
|
63
76
|
this.resizeObserver = new ResizeObserver(this.handleContentResize);
|
|
64
77
|
}
|
|
@@ -93,7 +106,7 @@ export class ModalPresenter {
|
|
|
93
106
|
if (!elements || this.isDismissing || this.finished) return;
|
|
94
107
|
this.isDismissing = true;
|
|
95
108
|
this.entering = false;
|
|
96
|
-
|
|
109
|
+
this.setInteractive(false);
|
|
97
110
|
// Also hides the on-screen keyboard.
|
|
98
111
|
const focused = document.activeElement;
|
|
99
112
|
if (focused instanceof HTMLElement && elements.overlay.contains(focused)) {
|
|
@@ -109,7 +122,7 @@ export class ModalPresenter {
|
|
|
109
122
|
cancelDismiss() {
|
|
110
123
|
if (!this.elements || !this.isDismissing || this.finished) return false;
|
|
111
124
|
this.isDismissing = false;
|
|
112
|
-
this.
|
|
125
|
+
this.setInteractive(true);
|
|
113
126
|
this.entering = true;
|
|
114
127
|
this.animateIn();
|
|
115
128
|
return true;
|
|
@@ -151,6 +164,8 @@ export class ModalPresenter {
|
|
|
151
164
|
this.elements?.overlay.removeEventListener('wheel', this.handleWheel);
|
|
152
165
|
this.resizeObserver?.disconnect();
|
|
153
166
|
this.resizeObserver = null;
|
|
167
|
+
this.hostObserver?.disconnect();
|
|
168
|
+
this.hostObserver = null;
|
|
154
169
|
this.observedContent = null;
|
|
155
170
|
}
|
|
156
171
|
finish() {
|
|
@@ -174,6 +189,20 @@ export class ModalPresenter {
|
|
|
174
189
|
// `Canvas` follows the page's `color-scheme`, like a system background.
|
|
175
190
|
surface.style.backgroundColor = config.contentBackgroundColor != null ? toCSSColor(config.contentBackgroundColor) : 'Canvas';
|
|
176
191
|
}
|
|
192
|
+
|
|
193
|
+
/** Inline, only the surface takes input; the rest reaches the page. */
|
|
194
|
+
setInteractive(interactive) {
|
|
195
|
+
const {
|
|
196
|
+
overlay,
|
|
197
|
+
surface
|
|
198
|
+
} = this.elements;
|
|
199
|
+
if (this.config.isInline) {
|
|
200
|
+
overlay.style.pointerEvents = 'none';
|
|
201
|
+
surface.style.pointerEvents = interactive ? 'auto' : 'none';
|
|
202
|
+
} else {
|
|
203
|
+
overlay.style.pointerEvents = interactive ? '' : 'none';
|
|
204
|
+
}
|
|
205
|
+
}
|
|
177
206
|
measureViewport() {
|
|
178
207
|
const {
|
|
179
208
|
overlay
|
|
@@ -182,8 +211,13 @@ export class ModalPresenter {
|
|
|
182
211
|
width: overlay.clientWidth,
|
|
183
212
|
height: overlay.clientHeight
|
|
184
213
|
};
|
|
185
|
-
this.
|
|
186
|
-
|
|
214
|
+
if (this.config.isInline) {
|
|
215
|
+
this.insets = inlineInsets(overlay);
|
|
216
|
+
this.keyboardHeight = 0;
|
|
217
|
+
} else {
|
|
218
|
+
this.insets = readSafeAreaInsets();
|
|
219
|
+
this.keyboardHeight = readKeyboardHeight(this.viewport.height);
|
|
220
|
+
}
|
|
187
221
|
}
|
|
188
222
|
|
|
189
223
|
/** Re-targets the observer at the content's root element. Returns whether its size changed. */
|
|
@@ -223,6 +257,7 @@ export class ModalPresenter {
|
|
|
223
257
|
this.viewportDidChange();
|
|
224
258
|
};
|
|
225
259
|
handleKeyboard = () => {
|
|
260
|
+
if (this.config.isInline) return;
|
|
226
261
|
const height = readKeyboardHeight(this.viewport.height);
|
|
227
262
|
if (height === this.keyboardHeight) return;
|
|
228
263
|
this.keyboardHeight = height;
|