|
| 1 | +/** |
| 2 | +* ReactXP.ts |
| 3 | +* |
| 4 | +* Copyright (c) Microsoft Corporation. All rights reserved. |
| 5 | +* Licensed under the MIT license. |
| 6 | +* |
| 7 | +* Wrapper for all ReactXP functionality. Users of ReactXP should import just this |
| 8 | +* file instead of internals. |
| 9 | +*/ |
| 10 | + |
| 11 | +import React = require('react'); |
| 12 | + |
| 13 | +import RXInterface = require('../common/Interfaces'); |
| 14 | +import RXTypes = require('../common/Types'); |
| 15 | +import AnimatedImpl = require('../native-common/Animated'); |
| 16 | + |
| 17 | +// -- STRANGE THINGS GOING ON HERE -- |
| 18 | +// See web/ReactXP.tsx for more details. |
| 19 | + |
| 20 | +import { default as AccessibilityImpl, Accessibility as AccessibilityType } from './Accessibility'; |
| 21 | +import { default as ActivityIndicatorImpl, ActivityIndicator as ActivityIndicatorType } from '../native-common/ActivityIndicator'; |
| 22 | +import { default as AlertImpl, Alert as AlertType } from '../native-common/Alert'; |
| 23 | +import { default as AppImpl, App as AppType } from '../native-common/App'; |
| 24 | +import { default as ButtonImpl, Button as ButtonType } from '../native-common/Button'; |
| 25 | +import { default as PickerImpl, Picker as PickerType } from '../native-common/Picker'; |
| 26 | +import { default as ImageImpl, Image as ImageType } from '../native-common/Image'; |
| 27 | +import { default as InputImpl, Input as InputType } from '../native-common/Input'; |
| 28 | +import { default as ClipboardImpl, Clipboard as ClipboardType } from '../native-common/Clipboard'; |
| 29 | +import { default as GestureViewImpl, GestureView as GestureViewType } from './GestureView'; |
| 30 | +import { default as InternationalImpl, International as InternationalType } from '../native-common/International'; |
| 31 | +import { default as LinkImpl, Link as LinkType } from '../native-common/Link'; |
| 32 | +import { default as LinkingImpl, Linking as LinkingType } from './Linking'; |
| 33 | +import { default as LocationImpl, Location as LocationType } from '../common/Location'; |
| 34 | +import { default as ModalImpl, Modal as ModalType } from '../native-common/Modal'; |
| 35 | +import { default as NetworkImpl, Network as NetworkType } from '../native-common/Network'; |
| 36 | +import { default as PlatformImpl, Platform as PlatformType } from '../native-common/Platform'; |
| 37 | +import { default as PopupImpl, Popup as PopupType } from '../native-common/Popup'; |
| 38 | +import { default as ScrollViewImpl, ScrollView as ScrollViewType } from '../native-common/ScrollView'; |
| 39 | +import { default as StatusBarImpl, StatusBar as StatusBarType } from './StatusBar'; |
| 40 | +import { default as StorageImpl, Storage as StorageType } from '../native-common/Storage'; |
| 41 | +import { default as StylesImpl, Styles as StylesType } from '../native-common/Styles'; |
| 42 | +import { default as TextImpl, Text as TextType } from '../native-common/Text'; |
| 43 | +import { default as TextInputImpl, TextInput as TextInputType } from '../native-common/TextInput'; |
| 44 | +import { default as UserInterfaceImpl, UserInterface as UserInterfaceType } from '../native-common/UserInterface'; |
| 45 | +import { default as UserPresenceImpl, UserPresence as UserPresenceType } from '../native-common/UserPresence'; |
| 46 | +import { default as ViewImpl, View as ViewType } from '../native-common/View'; |
| 47 | +import { default as WebViewImpl, WebView as WebViewType } from '../native-common/WebView'; |
| 48 | +import ViewBase from '../native-common/ViewBase'; |
| 49 | + |
| 50 | +// Initialize the MacOS default view style. This is required because on RN for MacOS, the default |
| 51 | +// overflow is 'visible', but we want it to be 'hidden' (the default for ReactXP and RN Android). |
| 52 | +const _defaultViewStyle = StylesImpl.createViewStyle({ |
| 53 | + overflow: 'hidden' |
| 54 | +}); |
| 55 | +ViewBase.setDefaultViewStyle(_defaultViewStyle); |
| 56 | + |
| 57 | +// Initialize MacOS implementation of platform accessibility helpers inside the singleton |
| 58 | +// instance of native-common AccessibilityUtil. This is to let native-common components access |
| 59 | +// platform specific APIs through native-common implementation itself. |
| 60 | +import AccessibilityUtil from '../native-common/AccessibilityUtil'; |
| 61 | +import AccessibilityPlatformUtil from './AccessibilityUtil'; |
| 62 | + |
| 63 | +AccessibilityUtil.setAccessibilityPlatformUtil(AccessibilityPlatformUtil); |
| 64 | + |
| 65 | +// -- STRANGE THINGS GOING ON HERE -- |
| 66 | +// See web/ReactXP.tsx for more details. |
| 67 | + |
| 68 | +module ReactXP { |
| 69 | + export type Accessibility = AccessibilityType; |
| 70 | + export var Accessibility = AccessibilityImpl; |
| 71 | + export import Animated = AnimatedImpl.Animated; |
| 72 | + export type ActivityIndicator = ActivityIndicatorType; |
| 73 | + export var ActivityIndicator = ActivityIndicatorImpl; |
| 74 | + export type Alert = AlertType; |
| 75 | + export var Alert = AlertImpl; |
| 76 | + export type App = AppType; |
| 77 | + export var App = AppImpl; |
| 78 | + export type Button = ButtonType; |
| 79 | + export var Button = ButtonImpl; |
| 80 | + export type Picker = PickerType; |
| 81 | + export var Picker = PickerImpl; |
| 82 | + export type Clipboard = ClipboardType; |
| 83 | + export var Clipboard = ClipboardImpl; |
| 84 | + export type GestureView = GestureViewType; |
| 85 | + export var GestureView = GestureViewImpl; |
| 86 | + export type Image = ImageType; |
| 87 | + export var Image = ImageImpl; |
| 88 | + export type Input = InputType; |
| 89 | + export var Input = InputImpl; |
| 90 | + export type International = InternationalType; |
| 91 | + export var International = InternationalImpl; |
| 92 | + export type Link = LinkType; |
| 93 | + export var Link = LinkImpl; |
| 94 | + export type Linking = LinkingType; |
| 95 | + export var Linking = LinkingImpl; |
| 96 | + export type Location = LocationType; |
| 97 | + export var Location = LocationImpl; |
| 98 | + export type Modal = ModalType; |
| 99 | + export var Modal = ModalImpl; |
| 100 | + export type Network = NetworkType; |
| 101 | + export var Network = NetworkImpl; |
| 102 | + export type Platform = PlatformType; |
| 103 | + export var Platform = PlatformImpl; |
| 104 | + export type Popup = PopupType; |
| 105 | + export var Popup = PopupImpl; |
| 106 | + export type ScrollView = ScrollViewType; |
| 107 | + export var ScrollView = ScrollViewImpl; |
| 108 | + export type StatusBar = StatusBarType; |
| 109 | + export var StatusBar = StatusBarImpl; |
| 110 | + export type Storage = StorageType; |
| 111 | + export var Storage = StorageImpl; |
| 112 | + export type Styles = StylesType; |
| 113 | + export var Styles = StylesImpl; |
| 114 | + export type Text = TextType; |
| 115 | + export var Text = TextImpl; |
| 116 | + export type TextInput = TextInputType; |
| 117 | + export var TextInput = TextInputImpl; |
| 118 | + export type UserInterface = UserInterfaceType; |
| 119 | + export var UserInterface = UserInterfaceImpl; |
| 120 | + export type UserPresence = UserPresenceType; |
| 121 | + export var UserPresence = UserPresenceImpl; |
| 122 | + export type View = ViewType; |
| 123 | + export var View = ViewImpl; |
| 124 | + export type WebView = WebViewType; |
| 125 | + export var WebView = WebViewImpl; |
| 126 | + |
| 127 | + export import CommonProps = RXTypes.CommonProps; |
| 128 | + export import CommonStyledProps = RXTypes.CommonStyledProps; |
| 129 | + export import Types = RXTypes; |
| 130 | + |
| 131 | + export import Component = React.Component; |
| 132 | + export import createElement = React.createElement; |
| 133 | + export import Children = React.Children; |
| 134 | + export var __spread = (React as any).__spread; |
| 135 | +} |
| 136 | + |
| 137 | +export = ReactXP; |
| 138 | + |
| 139 | +// -- STRANGE THINGS GOING ON HERE -- |
| 140 | +// See web/ReactXP.tsx for more details. |
| 141 | + |
| 142 | +/* tslint:disable:no-unused-variable */ |
| 143 | +var _rxImplementsRxInterface: RXInterface.ReactXP = ReactXP; |
| 144 | +/* tslint:enable:no-unused-variable */ |
| 145 | + |
| 146 | +/* |
| 147 | +var rx = module.exports; |
| 148 | +Object.keys(rx) |
| 149 | + .filter(key => rx[key] && rx[key].prototype instanceof React.Component && !rx[key].displayName) |
| 150 | + .forEach(key => rx[key].displayName = 'RX.' + key + ''); |
| 151 | +*/ |
0 commit comments