|
| 1 | +--- |
| 2 | +id: components/WebView |
| 3 | +title: WebView |
| 4 | +wip: true |
| 5 | +--- |
| 6 | + |
| 7 | +```reason |
| 8 | +type element; |
| 9 | +type ref = React.Ref.t(Js.nullable(element)); |
| 10 | +
|
| 11 | +module Source = { |
| 12 | + type t; |
| 13 | +
|
| 14 | + [@bs.obj] |
| 15 | + external uri: |
| 16 | + ( |
| 17 | + ~uri: string=?, |
| 18 | + ~method: string=?, |
| 19 | + ~headers: Js.t('a)=?, |
| 20 | + ~body: string=?, |
| 21 | + unit |
| 22 | + ) => |
| 23 | + t = |
| 24 | + ""; |
| 25 | +
|
| 26 | + [@bs.obj] |
| 27 | + external html: (~html: string=?, ~baseUrl: string=?, unit) => t = ""; |
| 28 | +}; |
| 29 | +
|
| 30 | +module DataDetectorTypes = WebView_DataDetectorTypes; |
| 31 | +module DecelerationRate = WebView_DecelerationRate; |
| 32 | +
|
| 33 | +type messageEvent = Event.event({. "data": string}); |
| 34 | +
|
| 35 | +type webViewEvent = |
| 36 | + Event.event({ |
| 37 | + . |
| 38 | + "url": string, |
| 39 | + "title": string, |
| 40 | + "loading": bool, |
| 41 | + "canGoBack": bool, |
| 42 | + "canGoForward": bool, |
| 43 | + }); |
| 44 | +
|
| 45 | +type request = { |
| 46 | + . |
| 47 | + "url": string, |
| 48 | + "title": string, |
| 49 | + "loading": bool, |
| 50 | + "canGoBack": bool, |
| 51 | + "canGoForward": bool, |
| 52 | + "lockIdentifier": string, |
| 53 | + "navigationType": string, |
| 54 | +}; |
| 55 | +
|
| 56 | +[@react.component] [@bs.module "react-native"] |
| 57 | +external make: |
| 58 | + ( |
| 59 | + ~allowFileAccess: bool=?, |
| 60 | + ~allowsInlineMediaPlayback: bool=?, |
| 61 | + ~allowUniversalAccessFromFileURLs: bool=?, |
| 62 | + ~automaticallyAdjustContentInsets: bool=?, |
| 63 | + ~bounces: bool=?, |
| 64 | + ~contentInsets: Types.insets=?, |
| 65 | + ~dataDetectorTypes: array(DataDetectorTypes.t)=?, |
| 66 | + ~decelerationRate: DecelerationRate.t=?, |
| 67 | + ~domStorageEnabled: bool=?, |
| 68 | + ~geolocationEnabled: bool=?, |
| 69 | + ~injectedJavaScript: string=?, |
| 70 | + ~injectJavaScript: string => unit=?, |
| 71 | + ~javaScriptEnabled: bool=?, |
| 72 | + ~mediaPlaybackRequiresUserAction: bool=?, |
| 73 | + ~mixedContentMode: [@bs.string] [ | `never | `always | `compatibility]=?, |
| 74 | + ~onError: webViewEvent => unit=?, |
| 75 | + ~onLoad: webViewEvent => unit=?, |
| 76 | + ~onLoadEnd: webViewEvent => unit=?, |
| 77 | + ~onLoadStart: webViewEvent => unit=?, |
| 78 | + ~onMessage: messageEvent => unit=?, |
| 79 | + ~onNavigationStateChange: webViewEvent => unit=?, |
| 80 | + ~onShouldStartLoadWithRequest: request => unit=?, |
| 81 | + ~originWhitelist: array(string)=?, |
| 82 | + ~renderError: string => React.element=?, |
| 83 | + ~renderLoading: unit => React.element=?, |
| 84 | + ~scalesPageToFit: bool=?, |
| 85 | + ~scrollEnabled: bool=?, |
| 86 | + ~source: Source.t=?, |
| 87 | + ~startInLoadingState: bool=?, |
| 88 | + ~thirdPartyCookiesEnabled: bool=?, |
| 89 | + ~userAgent: string=?, |
| 90 | + ~useWebKit: bool=?, |
| 91 | + // View props |
| 92 | + ~accessibilityComponentType: [@bs.string] [ |
| 93 | + | `none |
| 94 | + | `button |
| 95 | + | `radiobutton_checked |
| 96 | + | `radiobutton_unchecked |
| 97 | + ] |
| 98 | + =?, |
| 99 | + ~accessibilityElementsHidden: bool=?, |
| 100 | + ~accessibilityHint: string=?, |
| 101 | + ~accessibilityIgnoresInvertColors: bool=?, |
| 102 | + ~accessibilityLabel: string=?, |
| 103 | + ~accessibilityLiveRegion: [@bs.string] [ | `none | `polite | `assertive]=?, |
| 104 | + ~accessibilityRole: [@bs.string] [ |
| 105 | + | `none |
| 106 | + | `button |
| 107 | + | `link |
| 108 | + | `search |
| 109 | + | `image |
| 110 | + | `keyboardkey |
| 111 | + | `text |
| 112 | + | `adjustable |
| 113 | + | `header |
| 114 | + | `summary |
| 115 | + | `imagebutton |
| 116 | + ] |
| 117 | + =?, |
| 118 | + ~accessibilityStates: array(AccessibilityState.t)=?, |
| 119 | + ~accessibilityTraits: array(AccessibilityTrait.t)=?, |
| 120 | + ~accessibilityViewIsModal: bool=?, |
| 121 | + ~accessible: bool=?, |
| 122 | + ~collapsable: bool=?, |
| 123 | + ~hitSlop: Types.insets=?, |
| 124 | + ~importantForAccessibility: [@bs.string] [ |
| 125 | + | `auto |
| 126 | + | `yes |
| 127 | + | `no |
| 128 | + | [@bs.as "no-hide-descendants"] |
| 129 | + `noHideDescendants |
| 130 | + ] |
| 131 | + =?, |
| 132 | + ~nativeID: string=?, |
| 133 | + ~needsOffscreenAlphaCompositing: bool=?, |
| 134 | + ~onAccessibilityTap: unit => unit=?, |
| 135 | + ~onLayout: Event.layoutEvent => unit=?, |
| 136 | + ~onMagicTap: unit => unit=?, |
| 137 | + // Gesture Responder props |
| 138 | + ~onMoveShouldSetResponder: Event.pressEvent => bool=?, |
| 139 | + ~onMoveShouldSetResponderCapture: Event.pressEvent => bool=?, |
| 140 | + ~onResponderGrant: Event.pressEvent => unit=?, |
| 141 | + ~onResponderMove: Event.pressEvent => unit=?, |
| 142 | + ~onResponderReject: Event.pressEvent => unit=?, |
| 143 | + ~onResponderRelease: Event.pressEvent => unit=?, |
| 144 | + ~onResponderTerminate: Event.pressEvent => unit=?, |
| 145 | + ~onResponderTerminationRequest: Event.pressEvent => unit=?, |
| 146 | + ~onStartShouldSetResponder: Event.pressEvent => bool=?, |
| 147 | + ~onStartShouldSetResponderCapture: Event.pressEvent => bool=?, |
| 148 | + ~pointerEvents: [@bs.string] [ |
| 149 | + | `auto |
| 150 | + | `none |
| 151 | + | [@bs.as "box-none"] `boxNone |
| 152 | + | [@bs.as "box-only"] `boxOnly |
| 153 | + ] |
| 154 | + =?, |
| 155 | + ~removeClippedSubviews: bool=?, |
| 156 | + ~renderToHardwareTextureAndroid: bool=?, |
| 157 | + ~shouldRasterizeIOS: bool=?, |
| 158 | + ~style: Style.t=?, |
| 159 | + ~testID: string=? |
| 160 | + ) => |
| 161 | + React.element = |
| 162 | + "WebView"; |
| 163 | +
|
| 164 | +// Methods |
| 165 | +// static extraNativeComponentConfig() ?? |
| 166 | +[@bs.send] external goForward: element => unit = ""; |
| 167 | +[@bs.send] external goBack: element => unit = ""; |
| 168 | +[@bs.send] external reload: element => unit = ""; |
| 169 | +[@bs.send] external stopLoading: element => unit = ""; |
| 170 | +``` |
0 commit comments