|
@@ -0,0 +1,358 @@
|
|
1
|
+import { ComponentType, ReactElement, ReactNode } from 'react';
|
|
2
|
+import { Insets, NativeSyntheticEvent, StyleProp, ViewProps, ViewStyle } from 'react-native';
|
|
3
|
+declare module 'react-native' {
|
|
4
|
+ interface UIManagerStatic {
|
|
5
|
+ dispatchViewManagerCommand(node: any, callback: any, x: any): void;
|
|
6
|
+ RNCUIWebView: any;
|
|
7
|
+ RNCWKWebView: any;
|
|
8
|
+ RNCWebView: any;
|
|
9
|
+ }
|
|
10
|
+}
|
|
11
|
+export interface WebViewNativeEvent {
|
|
12
|
+ readonly url: string;
|
|
13
|
+ readonly loading: boolean;
|
|
14
|
+ readonly title: string;
|
|
15
|
+ readonly canGoBack: boolean;
|
|
16
|
+ readonly canGoForward: boolean;
|
|
17
|
+}
|
|
18
|
+export interface WebViewIOSLoadRequestEvent extends WebViewNativeEvent {
|
|
19
|
+ target: number;
|
|
20
|
+ lockIdentifier: number;
|
|
21
|
+ navigationType: 'click' | 'formsubmit' | 'backforward' | 'reload' | 'formresubmit' | 'other';
|
|
22
|
+}
|
|
23
|
+export interface WebViewProgressEvent extends WebViewNativeEvent {
|
|
24
|
+ readonly progress: number;
|
|
25
|
+}
|
|
26
|
+export interface WebViewNavigation extends WebViewNativeEvent {
|
|
27
|
+ readonly navigationType: 'click' | 'formsubmit' | 'backforward' | 'reload' | 'formresubmit' | 'other';
|
|
28
|
+}
|
|
29
|
+export interface WebViewMessage extends WebViewNativeEvent {
|
|
30
|
+ readonly data: string;
|
|
31
|
+}
|
|
32
|
+export interface WebViewError extends WebViewNativeEvent {
|
|
33
|
+ readonly domain?: string;
|
|
34
|
+ readonly code: number;
|
|
35
|
+ readonly description: string;
|
|
36
|
+}
|
|
37
|
+export declare type WebViewEvent = NativeSyntheticEvent<WebViewNativeEvent>;
|
|
38
|
+export declare type WebViewNavigationEvent = NativeSyntheticEvent<WebViewNavigation>;
|
|
39
|
+export declare type WebViewMessageEvent = NativeSyntheticEvent<WebViewMessage>;
|
|
40
|
+export declare type WebViewErrorEvent = NativeSyntheticEvent<WebViewError>;
|
|
41
|
+export declare type DataDetectorTypes = 'phoneNumber' | 'link' | 'address' | 'calendarEvent' | 'trackingNumber' | 'flightNumber' | 'lookupSuggestion' | 'none' | 'all';
|
|
42
|
+export declare type OverScrollModeType = 'always' | 'content' | 'never';
|
|
43
|
+export interface WebViewSourceUri {
|
|
44
|
+ /**
|
|
45
|
+ * The URI to load in the `WebView`. Can be a local or remote file.
|
|
46
|
+ */
|
|
47
|
+ uri?: string;
|
|
48
|
+ /**
|
|
49
|
+ * The HTTP Method to use. Defaults to GET if not specified.
|
|
50
|
+ * NOTE: On Android, only GET and POST are supported.
|
|
51
|
+ */
|
|
52
|
+ method?: string;
|
|
53
|
+ /**
|
|
54
|
+ * Additional HTTP headers to send with the request.
|
|
55
|
+ * NOTE: On Android, this can only be used with GET requests.
|
|
56
|
+ */
|
|
57
|
+ headers?: {
|
|
58
|
+ [key: string]: string;
|
|
59
|
+ };
|
|
60
|
+ /**
|
|
61
|
+ * The HTTP body to send with the request. This must be a valid
|
|
62
|
+ * UTF-8 string, and will be sent exactly as specified, with no
|
|
63
|
+ * additional encoding (e.g. URL-escaping or base64) applied.
|
|
64
|
+ * NOTE: On Android, this can only be used with POST requests.
|
|
65
|
+ */
|
|
66
|
+ body?: string;
|
|
67
|
+}
|
|
68
|
+export interface WebViewSourceHtml {
|
|
69
|
+ /**
|
|
70
|
+ * A static HTML page to display in the WebView.
|
|
71
|
+ */
|
|
72
|
+ html?: string;
|
|
73
|
+ /**
|
|
74
|
+ * The base URL to be used for any relative links in the HTML.
|
|
75
|
+ */
|
|
76
|
+ baseUrl?: string;
|
|
77
|
+}
|
|
78
|
+export declare type WebViewSource = WebViewSourceUri | WebViewSourceHtml;
|
|
79
|
+export interface WebViewNativeConfig {
|
|
80
|
+ component?: ComponentType<WebViewSharedProps>;
|
|
81
|
+ props?: any;
|
|
82
|
+ viewManager?: any;
|
|
83
|
+}
|
|
84
|
+export interface IOSWebViewProps {
|
|
85
|
+ /**
|
|
86
|
+ * If true, use WKWebView instead of UIWebView.
|
|
87
|
+ * @platform ios
|
|
88
|
+ */
|
|
89
|
+ useWebKit?: boolean;
|
|
90
|
+ /**
|
|
91
|
+ * Boolean value that determines whether the web view bounces
|
|
92
|
+ * when it reaches the edge of the content. The default value is `true`.
|
|
93
|
+ * @platform ios
|
|
94
|
+ */
|
|
95
|
+ bounces?: boolean;
|
|
96
|
+ /**
|
|
97
|
+ * A floating-point number that determines how quickly the scroll view
|
|
98
|
+ * decelerates after the user lifts their finger. You may also use the
|
|
99
|
+ * string shortcuts `"normal"` and `"fast"` which match the underlying iOS
|
|
100
|
+ * settings for `UIScrollViewDecelerationRateNormal` and
|
|
101
|
+ * `UIScrollViewDecelerationRateFast` respectively:
|
|
102
|
+ *
|
|
103
|
+ * - normal: 0.998
|
|
104
|
+ * - fast: 0.99 (the default for iOS web view)
|
|
105
|
+ * @platform ios
|
|
106
|
+ */
|
|
107
|
+ decelerationRate?: 'fast' | 'normal' | number;
|
|
108
|
+ /**
|
|
109
|
+ * Boolean value that determines whether scrolling is enabled in the
|
|
110
|
+ * `WebView`. The default value is `true`.
|
|
111
|
+ * @platform ios
|
|
112
|
+ */
|
|
113
|
+ scrollEnabled?: boolean;
|
|
114
|
+ /**
|
|
115
|
+ * If the value of this property is true, the scroll view stops on multiples
|
|
116
|
+ * of the scroll view’s bounds when the user scrolls.
|
|
117
|
+ * The default value is false.
|
|
118
|
+ * @platform ios
|
|
119
|
+ */
|
|
120
|
+ pagingEnabled?: boolean;
|
|
121
|
+ /**
|
|
122
|
+ * The amount by which the web view content is inset from the edges of
|
|
123
|
+ * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
|
|
124
|
+ * @platform ios
|
|
125
|
+ */
|
|
126
|
+ contentInset?: Insets;
|
|
127
|
+ /**
|
|
128
|
+ * Determines the types of data converted to clickable URLs in the web view's content.
|
|
129
|
+ * By default only phone numbers are detected.
|
|
130
|
+ *
|
|
131
|
+ * You can provide one type or an array of many types.
|
|
132
|
+ *
|
|
133
|
+ * Possible values for `dataDetectorTypes` are:
|
|
134
|
+ *
|
|
135
|
+ * - `'phoneNumber'`
|
|
136
|
+ * - `'link'`
|
|
137
|
+ * - `'address'`
|
|
138
|
+ * - `'calendarEvent'`
|
|
139
|
+ * - `'none'`
|
|
140
|
+ * - `'all'`
|
|
141
|
+ *
|
|
142
|
+ * With the new WebKit implementation, we have three new values:
|
|
143
|
+ * - `'trackingNumber'`,
|
|
144
|
+ * - `'flightNumber'`,
|
|
145
|
+ * - `'lookupSuggestion'`,
|
|
146
|
+ *
|
|
147
|
+ * @platform ios
|
|
148
|
+ */
|
|
149
|
+ dataDetectorTypes?: DataDetectorTypes | DataDetectorTypes[];
|
|
150
|
+ /**
|
|
151
|
+ * Function that allows custom handling of any web view requests. Return
|
|
152
|
+ * `true` from the function to continue loading the request and `false`
|
|
153
|
+ * to stop loading.
|
|
154
|
+ * @platform ios
|
|
155
|
+ */
|
|
156
|
+ onShouldStartLoadWithRequest?: (event: WebViewIOSLoadRequestEvent) => any;
|
|
157
|
+ /**
|
|
158
|
+ * Boolean that determines whether HTML5 videos play inline or use the
|
|
159
|
+ * native full-screen controller. The default value is `false`.
|
|
160
|
+ *
|
|
161
|
+ * **NOTE** : In order for video to play inline, not only does this
|
|
162
|
+ * property need to be set to `true`, but the video element in the HTML
|
|
163
|
+ * document must also include the `webkit-playsinline` attribute.
|
|
164
|
+ * @platform ios
|
|
165
|
+ */
|
|
166
|
+ allowsInlineMediaPlayback?: boolean;
|
|
167
|
+ /**
|
|
168
|
+ * Hide the accessory view when the keyboard is open. Default is false to be
|
|
169
|
+ * backward compatible.
|
|
170
|
+ */
|
|
171
|
+ hideKeyboardAccessoryView?: boolean;
|
|
172
|
+ /**
|
|
173
|
+ * If true, this will be able horizontal swipe gestures when using the WKWebView. The default value is `false`.
|
|
174
|
+ */
|
|
175
|
+ allowsBackForwardNavigationGestures?: boolean;
|
|
176
|
+ /**
|
|
177
|
+ * A Boolean value that determines whether pressing on a link
|
|
178
|
+ * displays a preview of the destination for the link.
|
|
179
|
+ *
|
|
180
|
+ * This property is available on devices that support 3D Touch.
|
|
181
|
+ * In iOS 10 and later, the default value is `true`; before that, the default value is `false`.
|
|
182
|
+ * @platform ios
|
|
183
|
+ */
|
|
184
|
+ allowsLinkPreview?: boolean;
|
|
185
|
+}
|
|
186
|
+export interface AndroidWebViewProps {
|
|
187
|
+ onNavigationStateChange?: (event: WebViewNavigation) => any;
|
|
188
|
+ onContentSizeChange?: (event: WebViewEvent) => any;
|
|
189
|
+ /**
|
|
190
|
+ * https://developer.android.com/reference/android/view/View#OVER_SCROLL_NEVER
|
|
191
|
+ * Sets the overScrollMode. Possible values are:
|
|
192
|
+ *
|
|
193
|
+ * - `'always'` (default)
|
|
194
|
+ * - `'content'`
|
|
195
|
+ * - `'never'`
|
|
196
|
+ *
|
|
197
|
+ * @platform android
|
|
198
|
+ */
|
|
199
|
+ overScrollMode?: OverScrollModeType;
|
|
200
|
+ /**
|
|
201
|
+ * Sets whether Geolocation is enabled. The default is false.
|
|
202
|
+ * @platform android
|
|
203
|
+ */
|
|
204
|
+ geolocationEnabled?: boolean;
|
|
205
|
+ /**
|
|
206
|
+ * Boolean that sets whether JavaScript running in the context of a file
|
|
207
|
+ * scheme URL should be allowed to access content from any origin.
|
|
208
|
+ * Including accessing content from other file scheme URLs
|
|
209
|
+ * @platform android
|
|
210
|
+ */
|
|
211
|
+ allowUniversalAccessFromFileURLs?: boolean;
|
|
212
|
+ /**
|
|
213
|
+ * Sets whether the webview allow access to file system.
|
|
214
|
+ * @platform android
|
|
215
|
+ */
|
|
216
|
+ allowFileAccess?: boolean;
|
|
217
|
+ /**
|
|
218
|
+ * Used on Android only, controls whether form autocomplete data should be saved
|
|
219
|
+ * @platform android
|
|
220
|
+ */
|
|
221
|
+ saveFormDataDisabled?: boolean;
|
|
222
|
+ urlPrefixesForDefaultIntent?: string[];
|
|
223
|
+ /**
|
|
224
|
+ * Boolean value to enable JavaScript in the `WebView`. Used on Android only
|
|
225
|
+ * as JavaScript is enabled by default on iOS. The default value is `true`.
|
|
226
|
+ * @platform android
|
|
227
|
+ */
|
|
228
|
+ javaScriptEnabled?: boolean;
|
|
229
|
+ /**
|
|
230
|
+ * Boolean value to enable third party cookies in the `WebView`. Used on
|
|
231
|
+ * Android Lollipop and above only as third party cookies are enabled by
|
|
232
|
+ * default on Android Kitkat and below and on iOS. The default value is `true`.
|
|
233
|
+ * @platform android
|
|
234
|
+ */
|
|
235
|
+ thirdPartyCookiesEnabled?: boolean;
|
|
236
|
+ /**
|
|
237
|
+ * Boolean value to control whether DOM Storage is enabled. Used only in
|
|
238
|
+ * Android.
|
|
239
|
+ * @platform android
|
|
240
|
+ */
|
|
241
|
+ domStorageEnabled?: boolean;
|
|
242
|
+ /**
|
|
243
|
+ * Sets the user-agent for the `WebView`.
|
|
244
|
+ * @platform android
|
|
245
|
+ */
|
|
246
|
+ userAgent?: string;
|
|
247
|
+ /**
|
|
248
|
+ * Specifies the mixed content mode. i.e WebView will allow a secure origin to load content from any other origin.
|
|
249
|
+ *
|
|
250
|
+ * Possible values for `mixedContentMode` are:
|
|
251
|
+ *
|
|
252
|
+ * - `'never'` (default) - WebView will not allow a secure origin to load content from an insecure origin.
|
|
253
|
+ * - `'always'` - WebView will allow a secure origin to load content from any other origin, even if that origin is insecure.
|
|
254
|
+ * - `'compatibility'` - WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content.
|
|
255
|
+ * @platform android
|
|
256
|
+ */
|
|
257
|
+ mixedContentMode?: 'never' | 'always' | 'compatibility';
|
|
258
|
+}
|
|
259
|
+export interface WebViewSharedProps extends ViewProps, IOSWebViewProps, AndroidWebViewProps {
|
|
260
|
+ /**
|
|
261
|
+ * @Deprecated. Use `source` instead.
|
|
262
|
+ */
|
|
263
|
+ url?: string;
|
|
264
|
+ /**
|
|
265
|
+ * @Deprecated. Use `source` instead.
|
|
266
|
+ */
|
|
267
|
+ html?: string;
|
|
268
|
+ /**
|
|
269
|
+ * Loads static html or a uri (with optional headers) in the WebView.
|
|
270
|
+ */
|
|
271
|
+ source?: WebViewSource;
|
|
272
|
+ /**
|
|
273
|
+ * Function that returns a view to show if there's an error.
|
|
274
|
+ */
|
|
275
|
+ renderError?: (errorDomain: string | undefined, errorCode: number, errorDesc: string) => ReactElement<any>;
|
|
276
|
+ /**
|
|
277
|
+ * Function that returns a loading indicator.
|
|
278
|
+ */
|
|
279
|
+ renderLoading?: () => ReactElement<any>;
|
|
280
|
+ /**
|
|
281
|
+ * Function that is invoked when the `WebView` has finished loading.
|
|
282
|
+ */
|
|
283
|
+ onLoad?: (event: WebViewNavigationEvent) => any;
|
|
284
|
+ /**
|
|
285
|
+ * Function that is invoked when the `WebView` load succeeds or fails.
|
|
286
|
+ */
|
|
287
|
+ onLoadEnd?: (event: WebViewNavigationEvent | WebViewErrorEvent) => any;
|
|
288
|
+ /**
|
|
289
|
+ * Function that is invoked when the `WebView` starts loading.
|
|
290
|
+ */
|
|
291
|
+ onLoadStart?: (event: WebViewNavigationEvent) => any;
|
|
292
|
+ /**
|
|
293
|
+ * Function that is invoked when the `WebView` load fails.
|
|
294
|
+ */
|
|
295
|
+ onError?: (event: WebViewErrorEvent) => any;
|
|
296
|
+ /**
|
|
297
|
+ * Controls whether to adjust the content inset for web views that are
|
|
298
|
+ * placed behind a navigation bar, tab bar, or toolbar. The default value
|
|
299
|
+ * is `true`.
|
|
300
|
+ */
|
|
301
|
+ automaticallyAdjustContentInsets?: boolean;
|
|
302
|
+ /**
|
|
303
|
+ * Function that is invoked when the `WebView` loading starts or ends.
|
|
304
|
+ */
|
|
305
|
+ onNavigationStateChange?: (event: WebViewNavigation) => any;
|
|
306
|
+ /**
|
|
307
|
+ * A function that is invoked when the webview calls `window.postMessage`.
|
|
308
|
+ * Setting this property will inject a `postMessage` global into your
|
|
309
|
+ * webview, but will still call pre-existing values of `postMessage`.
|
|
310
|
+ *
|
|
311
|
+ * `window.postMessage` accepts one argument, `data`, which will be
|
|
312
|
+ * available on the event object, `event.nativeEvent.data`. `data`
|
|
313
|
+ * must be a string.
|
|
314
|
+ */
|
|
315
|
+ onMessage?: (event: WebViewMessageEvent) => any;
|
|
316
|
+ /**
|
|
317
|
+ * Function that is invoked when the `WebView` is loading.
|
|
318
|
+ */
|
|
319
|
+ onLoadProgress?: (event: NativeSyntheticEvent<WebViewProgressEvent>) => any;
|
|
320
|
+ /**
|
|
321
|
+ * Boolean value that forces the `WebView` to show the loading view
|
|
322
|
+ * on the first load.
|
|
323
|
+ */
|
|
324
|
+ startInLoadingState?: boolean;
|
|
325
|
+ /**
|
|
326
|
+ * Set this to provide JavaScript that will be injected into the web page
|
|
327
|
+ * when the view loads.
|
|
328
|
+ */
|
|
329
|
+ injectedJavaScript?: string;
|
|
330
|
+ /**
|
|
331
|
+ * Boolean that controls whether the web content is scaled to fit
|
|
332
|
+ * the view and enables the user to change the scale. The default value
|
|
333
|
+ * is `true`.
|
|
334
|
+ *
|
|
335
|
+ * On iOS, when `useWebKit=true`, this prop will not work.
|
|
336
|
+ */
|
|
337
|
+ scalesPageToFit?: boolean;
|
|
338
|
+ /**
|
|
339
|
+ * Boolean that determines whether HTML5 audio and video requires the user
|
|
340
|
+ * to tap them before they start playing. The default value is `true`.
|
|
341
|
+ */
|
|
342
|
+ mediaPlaybackRequiresUserAction?: boolean;
|
|
343
|
+ /**
|
|
344
|
+ * List of origin strings to allow being navigated to. The strings allow
|
|
345
|
+ * wildcards and get matched against *just* the origin (not the full URL).
|
|
346
|
+ * If the user taps to navigate to a new page but the new page is not in
|
|
347
|
+ * this whitelist, we will open the URL in Safari.
|
|
348
|
+ * The default whitelisted origins are "http://*" and "https://*".
|
|
349
|
+ */
|
|
350
|
+ originWhitelist?: string[];
|
|
351
|
+ /**
|
|
352
|
+ * Override the native component used to render the WebView. Enables a custom native
|
|
353
|
+ * WebView which uses the same JavaScript as the original WebView.
|
|
354
|
+ */
|
|
355
|
+ nativeConfig?: WebViewNativeConfig;
|
|
356
|
+ style?: StyleProp<ViewStyle>;
|
|
357
|
+ children?: ReactNode;
|
|
358
|
+}
|