Преглед изворни кода

ref: define state and property types (2)

master
Lyubo Marinov пре 7 година
родитељ
комит
75bf7638b3

+ 51
- 28
react/features/always-on-top/AlwaysOnTop.js Прегледај датотеку

1
+// @flow
2
+
1
 import React, { Component } from 'react';
3
 import React, { Component } from 'react';
2
 
4
 
3
 import StatelessToolbar from '../toolbox/components/StatelessToolbar';
5
 import StatelessToolbar from '../toolbox/components/StatelessToolbar';
6
 
8
 
7
 const { api } = window.alwaysOnTop;
9
 const { api } = window.alwaysOnTop;
8
 
10
 
9
-/**
10
- * The timeout in ms for hidding the toolbar.
11
- */
12
-const TOOLBAR_TIMEOUT = 4000;
13
-
14
 /**
11
 /**
15
  * Map with toolbar button descriptors.
12
  * Map with toolbar button descriptors.
16
  */
13
  */
17
-const toolbarButtons = {
14
+const TOOLBAR_BUTTONS = {
18
     /**
15
     /**
19
      * The descriptor of the camera toolbar button.
16
      * The descriptor of the camera toolbar button.
20
      */
17
      */
54
 };
51
 };
55
 
52
 
56
 /**
53
 /**
57
- * Defines the state for <tt>AlwaysOnTop</tt> component.
54
+ * The timeout in ms for hidding the toolbar.
55
+ */
56
+const TOOLBAR_TIMEOUT = 4000;
57
+
58
+/**
59
+ * The type of the React {@code Component} state of {@link FeedbackButton}.
58
  */
60
  */
59
-type AlwaysOnTopState = {
60
-    visible: boolean,
61
+type State = {
62
+    audioAvailable: boolean,
61
     audioMuted: boolean,
63
     audioMuted: boolean,
64
+    videoAvailable: boolean,
62
     videoMuted: boolean,
65
     videoMuted: boolean,
63
-    audioAvailable: boolean,
64
-    videoAvailable: boolean
65
-}
66
+    visible: boolean
67
+};
66
 
68
 
67
 /**
69
 /**
68
  * Represents the always on top page.
70
  * Represents the always on top page.
70
  * @class AlwaysOnTop
72
  * @class AlwaysOnTop
71
  * @extends Component
73
  * @extends Component
72
  */
74
  */
73
-export default class AlwaysOnTop extends Component<*, AlwaysOnTopState> {
75
+export default class AlwaysOnTop extends Component<*, State> {
76
+    _hovered: boolean;
77
+
74
     /**
78
     /**
75
      * Initializes new AlwaysOnTop instance.
79
      * Initializes new AlwaysOnTop instance.
76
      *
80
      *
77
-     * @param {Object} props - The read-only properties with which the new
78
-     * instance is to be initialized.
81
+     * @param {*} props - The read-only properties with which the new instance
82
+     * is to be initialized.
79
      */
83
      */
80
-    constructor(props) {
84
+    constructor(props: *) {
81
         super(props);
85
         super(props);
82
 
86
 
83
         this.state = {
87
         this.state = {
88
             videoAvailable: false
92
             videoAvailable: false
89
         };
93
         };
90
 
94
 
91
-        this._hovered = false;
92
-
95
+        // Bind event handlers so they are only bound once per instance.
93
         this._audioAvailabilityListener
96
         this._audioAvailabilityListener
94
             = this._audioAvailabilityListener.bind(this);
97
             = this._audioAvailabilityListener.bind(this);
95
         this._audioMutedListener = this._audioMutedListener.bind(this);
98
         this._audioMutedListener = this._audioMutedListener.bind(this);
96
         this._mouseMove = this._mouseMove.bind(this);
99
         this._mouseMove = this._mouseMove.bind(this);
97
-        this._onMouseOver = this._onMouseOver.bind(this);
98
         this._onMouseOut = this._onMouseOut.bind(this);
100
         this._onMouseOut = this._onMouseOut.bind(this);
101
+        this._onMouseOver = this._onMouseOver.bind(this);
99
         this._videoAvailabilityListener
102
         this._videoAvailabilityListener
100
             = this._videoAvailabilityListener.bind(this);
103
             = this._videoAvailabilityListener.bind(this);
101
         this._videoMutedListener = this._videoMutedListener.bind(this);
104
         this._videoMutedListener = this._videoMutedListener.bind(this);
102
     }
105
     }
103
 
106
 
107
+    _audioAvailabilityListener: ({ available: boolean }) => void;
108
+
104
     /**
109
     /**
105
      * Handles audio available api events.
110
      * Handles audio available api events.
106
      *
111
      *
111
         this.setState({ audioAvailable: available });
116
         this.setState({ audioAvailable: available });
112
     }
117
     }
113
 
118
 
119
+    _audioMutedListener: ({ muted: boolean }) => void;
120
+
114
     /**
121
     /**
115
      * Handles audio muted api events.
122
      * Handles audio muted api events.
116
      *
123
      *
137
         }, TOOLBAR_TIMEOUT);
144
         }, TOOLBAR_TIMEOUT);
138
     }
145
     }
139
 
146
 
147
+    _mouseMove: () => void;
148
+
140
     /**
149
     /**
141
      * Handles mouse move events.
150
      * Handles mouse move events.
142
      *
151
      *
148
         }
157
         }
149
     }
158
     }
150
 
159
 
160
+    _onMouseOut: () => void;
161
+
151
     /**
162
     /**
152
-     * Toolbar mouse over handler.
163
+     * Toolbar mouse out handler.
153
      *
164
      *
154
      * @returns {void}
165
      * @returns {void}
155
      */
166
      */
156
-    _onMouseOver() {
157
-        this._hovered = true;
167
+    _onMouseOut() {
168
+        this._hovered = false;
158
     }
169
     }
159
 
170
 
171
+    _onMouseOver: () => void;
172
+
160
     /**
173
     /**
161
-     * Toolbar mouse out handler.
174
+     * Toolbar mouse over handler.
162
      *
175
      *
163
      * @returns {void}
176
      * @returns {void}
164
      */
177
      */
165
-    _onMouseOut() {
166
-        this._hovered = false;
178
+    _onMouseOver() {
179
+        this._hovered = true;
167
     }
180
     }
168
 
181
 
182
+    _videoAvailabilityListener: ({ available: boolean }) => void;
183
+
169
     /**
184
     /**
170
      * Handles audio available api events.
185
      * Handles audio available api events.
171
      *
186
      *
176
         this.setState({ videoAvailable: available });
191
         this.setState({ videoAvailable: available });
177
     }
192
     }
178
 
193
 
194
+    _videoMutedListener: ({ muted: boolean }) => void;
195
+
179
     /**
196
     /**
180
      * Handles video muted api events.
197
      * Handles video muted api events.
181
      *
198
      *
248
      * @inheritdoc
265
      * @inheritdoc
249
      * @returns {void}
266
      * @returns {void}
250
      */
267
      */
251
-    componentWillUpdate(nextProps, nextState) {
268
+    componentWillUpdate(nextProps: *, nextState: State) {
252
         if (!this.state.visible && nextState.visible) {
269
         if (!this.state.visible && nextState.visible) {
253
             this._hideToolbarAfterTimeout();
270
             this._hideToolbarAfterTimeout();
254
         }
271
         }
271
                 onMouseOut = { this._onMouseOut }
288
                 onMouseOut = { this._onMouseOut }
272
                 onMouseOver = { this._onMouseOver }>
289
                 onMouseOver = { this._onMouseOver }>
273
                 {
290
                 {
274
-                    Object.entries(toolbarButtons).map(([ key, button ]) => {
291
+                    Object.entries(TOOLBAR_BUTTONS).map(([ key, button ]) => {
292
+                        // XXX The following silences a couple of flow errors:
293
+                        if (button === null || typeof button !== 'object') {
294
+                            return null;
295
+                        }
296
+
275
                         const { onClick } = button;
297
                         const { onClick } = button;
276
-                        let enabled = false, toggled = false;
298
+                        let enabled = false;
299
+                        let toggled = false;
277
 
300
 
278
                         switch (key) {
301
                         switch (key) {
279
                         case 'microphone':
302
                         case 'microphone':

+ 3
- 0
react/features/authentication/actions.js Прегледај датотеку

71
  * }}
71
  * }}
72
  */
72
  */
73
 export function cancelLogin() {
73
 export function cancelLogin() {
74
+    // FIXME Like cancelWaitForOwner, dispatch conferenceLeft to notify the
75
+    // external-api.
76
+
74
     return {
77
     return {
75
         type: CANCEL_LOGIN
78
         type: CANCEL_LOGIN
76
     };
79
     };

+ 1
- 1
react/features/authentication/components/LoginDialog.native.js Прегледај датотеку

226
      */
226
      */
227
     _onLogin() {
227
     _onLogin() {
228
         const { _conference: conference, dispatch } = this.props;
228
         const { _conference: conference, dispatch } = this.props;
229
-        const { username, password } = this.state;
229
+        const { password, username } = this.state;
230
         const jid = toJid(username, this.props._configHosts);
230
         const jid = toJid(username, this.props._configHosts);
231
         let r;
231
         let r;
232
 
232
 

+ 4
- 4
react/features/authentication/components/WaitForOwnerDialog.native.js Прегледај датотеку

11
 import styles from './styles';
11
 import styles from './styles';
12
 
12
 
13
 /**
13
 /**
14
- * WaitForOwnerDialog component's property types.
14
+ * The type of the React {@code Component} props of {@link WaitForOwnerDialog}.
15
  */
15
  */
16
-type WaitForOwnerDialogPropTypes = {
16
+type Props = {
17
 
17
 
18
     /**
18
     /**
19
      * The name of the conference room (without the domain part).
19
      * The name of the conference room (without the domain part).
20
      */
20
      */
21
-    _room: String,
21
+    _room: string,
22
 
22
 
23
     /**
23
     /**
24
      * Redux store dispatch function.
24
      * Redux store dispatch function.
37
  *
37
  *
38
  * See {@link LoginDialog} description for more details.
38
  * See {@link LoginDialog} description for more details.
39
  */
39
  */
40
-class WaitForOwnerDialog extends Component<WaitForOwnerDialogPropTypes> {
40
+class WaitForOwnerDialog extends Component<Props> {
41
     /**
41
     /**
42
      * Initializes a new WaitForWonderDialog instance.
42
      * Initializes a new WaitForWonderDialog instance.
43
      *
43
      *

+ 4
- 0
react/features/authentication/middleware.js Прегледај датотеку

59
 
59
 
60
             // Go back to the app's entry point.
60
             // Go back to the app's entry point.
61
             _hideLoginDialog(store);
61
             _hideLoginDialog(store);
62
+
63
+            // FIXME Like cancelWaitForOwner, dispatch conferenceLeft to notify
64
+            // the external-api.
65
+
62
             dispatch(appNavigate(undefined));
66
             dispatch(appNavigate(undefined));
63
         }
67
         }
64
         break;
68
         break;

+ 14
- 23
react/features/base/dialog/components/AbstractDialog.js Прегледај датотеку

1
 // @flow
1
 // @flow
2
 
2
 
3
-import * as React from 'react';
3
+import { Component } from 'react';
4
 
4
 
5
 import { hideDialog } from '../actions';
5
 import { hideDialog } from '../actions';
6
-import { DialogPropTypes } from '../constants';
6
+import type { DialogProps } from '../constants';
7
 
7
 
8
 /**
8
 /**
9
- * Defines the property types for AbstractDialog.
9
+ * The type of the React {@code Component} props of {@link AbstractDialog}.
10
  */
10
  */
11
-export type AbstractDialogPropTypes = {
12
-    ...DialogPropTypes,
13
-
14
-    /**
15
-     * The React {@code Component} children of {@code AbstractDialog}
16
-     * which represents the dialog's body.
17
-     */
18
-    children: React.Node,
11
+export type Props = {
12
+    ...DialogProps,
19
 
13
 
20
     /**
14
     /**
21
      * Used to show/hide the dialog on cancel.
15
      * Used to show/hide the dialog on cancel.
22
      */
16
      */
23
     dispatch: Dispatch<*>
17
     dispatch: Dispatch<*>
24
-}
18
+};
25
 
19
 
26
 /**
20
 /**
27
- * Defines the state for AbstractDialog.
21
+ * The type of the React {@code Component} state of {@link AbstractDialog}.
28
  */
22
  */
29
-type AbstractDialogState = {
30
-    submitting: boolean
31
-}
23
+export type State = {
24
+    submitting: ?boolean
25
+};
32
 
26
 
33
 /**
27
 /**
34
  * An abstract implementation of a dialog on Web/React and mobile/react-native.
28
  * An abstract implementation of a dialog on Web/React and mobile/react-native.
35
  */
29
  */
36
-export default class AbstractDialog
37
-    extends React.Component<AbstractDialogPropTypes, AbstractDialogState> {
38
-    _mounted: boolean;
30
+export default class AbstractDialog<P : Props, S : State>
31
+    extends Component<P, S> {
39
 
32
 
40
-    state = {
41
-        submitting: false
42
-    };
33
+    _mounted: boolean;
43
 
34
 
44
     /**
35
     /**
45
      * Initializes a new {@code AbstractDialog} instance.
36
      * Initializes a new {@code AbstractDialog} instance.
47
      * @param {Object} props - The read-only React {@code Component} props with
38
      * @param {Object} props - The read-only React {@code Component} props with
48
      * which the new instance is to be initialized.
39
      * which the new instance is to be initialized.
49
      */
40
      */
50
-    constructor(props: Object) {
41
+    constructor(props: P) {
51
         super(props);
42
         super(props);
52
 
43
 
53
         // Bind event handlers so they are only bound once per instance.
44
         // Bind event handlers so they are only bound once per instance.

+ 54
- 45
react/features/base/dialog/components/Dialog.native.js Прегледај датотеку

1
+// @flow
2
+
3
+import _ from 'lodash';
1
 import React from 'react';
4
 import React from 'react';
2
 import { Modal, StyleSheet, TextInput } from 'react-native';
5
 import { Modal, StyleSheet, TextInput } from 'react-native';
3
 import Prompt from 'react-native-prompt';
6
 import Prompt from 'react-native-prompt';
7
 import { LoadingIndicator } from '../../react';
10
 import { LoadingIndicator } from '../../react';
8
 import { set } from '../../redux';
11
 import { set } from '../../redux';
9
 
12
 
10
-import AbstractDialog, { AbstractDialogPropTypes } from './AbstractDialog';
13
+import AbstractDialog from './AbstractDialog';
14
+import type {
15
+    Props as AbstractDialogProps,
16
+    State as AbstractDialogState
17
+} from './AbstractDialog';
11
 import { dialog as styles } from './styles';
18
 import { dialog as styles } from './styles';
12
 
19
 
13
 /**
20
 /**
27
 const _TAG_KEY = '_TAG_KEY';
34
 const _TAG_KEY = '_TAG_KEY';
28
 
35
 
29
 /**
36
 /**
30
- * {@code Dialog}'s React {@code Component} prop types.
37
+ * The type of the React {@code Component} props of {@link Dialog}.
31
  */
38
  */
32
-type DialogPropTypes = {
33
-    ...AbstractDialogPropTypes,
39
+type Props = {
40
+    ...AbstractDialogProps,
34
 
41
 
35
     /**
42
     /**
36
      * I18n key to put as body title.
43
      * I18n key to put as body title.
37
      */
44
      */
38
-    bodyKey: String
39
-}
45
+    bodyKey: String,
46
+
47
+    textInputProps: Object
48
+};
40
 
49
 
41
 /**
50
 /**
42
- * Defines {@code Dialog}'s state.
51
+ * The type of the React {@code Component} state of {@link Dialog}.
43
  */
52
  */
44
-type DialogState = {
53
+type State = {
54
+    ...AbstractDialogState,
45
 
55
 
46
     /**
56
     /**
47
      * The text of the {@link TextInput} rendered by {@link Prompt} in
57
      * The text of the {@link TextInput} rendered by {@link Prompt} in
50
      * functionality of {@code Prompt} because this {@code Dialog} does not
60
      * functionality of {@code Prompt} because this {@code Dialog} does not
51
      * really render the (whole) {@code Prompt}.
61
      * really render the (whole) {@code Prompt}.
52
      */
62
      */
53
-    text: String
54
-}
63
+    text: string
64
+};
55
 
65
 
56
 /**
66
 /**
57
  * Implements {@code AbstractDialog} on react-native using {@code Prompt}.
67
  * Implements {@code AbstractDialog} on react-native using {@code Prompt}.
58
  */
68
  */
59
-class Dialog extends AbstractDialog<DialogPropTypes, DialogState> {
60
-
61
-    state = {
62
-        text: ''
63
-    };
64
-
69
+class Dialog extends AbstractDialog<Props, State> {
65
     /**
70
     /**
66
      * Initailizes a new {@code Dialog} instance.
71
      * Initailizes a new {@code Dialog} instance.
67
      *
72
      *
71
     constructor(props: Object) {
76
     constructor(props: Object) {
72
         super(props);
77
         super(props);
73
 
78
 
79
+        this.state.text = '';
80
+
74
         // Bind event handlers so they are only bound once per instance.
81
         // Bind event handlers so they are only bound once per instance.
75
         this._onChangeText = this._onChangeText.bind(this);
82
         this._onChangeText = this._onChangeText.bind(this);
76
         this._onSubmit = this._onSubmit.bind(this);
83
         this._onSubmit = this._onSubmit.bind(this);
89
             cancelTitleKey = 'dialog.Cancel',
96
             cancelTitleKey = 'dialog.Cancel',
90
             okDisabled,
97
             okDisabled,
91
             okTitleKey = 'dialog.Ok',
98
             okTitleKey = 'dialog.Ok',
92
-            t,
99
+            t /* XXX The following silences flow errors: */ = _.identity,
93
             titleKey,
100
             titleKey,
94
             titleString
101
             titleString
95
         } = this.props;
102
         } = this.props;
104
             [_TAG_KEY]: _SUBMIT_TEXT_TAG_VALUE
111
             [_TAG_KEY]: _SUBMIT_TEXT_TAG_VALUE
105
         };
112
         };
106
 
113
 
107
-        // eslint-disable-next-line no-extra-parens
108
-        let element = (
114
+        let el: ?React$Element<*> = ( // eslint-disable-line no-extra-parens
109
             <Prompt
115
             <Prompt
110
                 cancelButtonTextStyle = { cancelButtonTextStyle }
116
                 cancelButtonTextStyle = { cancelButtonTextStyle }
111
                 cancelText = { t(cancelTitleKey) }
117
                 cancelText = { t(cancelTitleKey) }
112
-
113
-                // $FlowFixMeState
114
                 defaultValue = { this.state.text }
118
                 defaultValue = { this.state.text }
115
                 onCancel = { this._onCancel }
119
                 onCancel = { this._onCancel }
116
                 onChangeText = { this._onChangeText }
120
                 onChangeText = { this._onChangeText }
126
         // XXX The following implements workarounds with knowledge of
130
         // XXX The following implements workarounds with knowledge of
127
         // react-native-prompt/Prompt's implementation.
131
         // react-native-prompt/Prompt's implementation.
128
 
132
 
129
-        // eslint-disable-next-line no-extra-parens, new-cap
130
-        element = (new (element.type)(element.props)).render();
133
+        if (el) {
134
+            // eslint-disable-next-line new-cap, no-extra-parens
135
+            el = (new (el.type)(el.props)).render();
136
+        }
131
 
137
 
132
         let { children } = this.props;
138
         let { children } = this.props;
133
 
139
 
134
         children = React.Children.count(children) ? children : undefined;
140
         children = React.Children.count(children) ? children : undefined;
135
 
141
 
136
         // eslint-disable-next-line no-shadow
142
         // eslint-disable-next-line no-shadow
137
-        element = this._mapReactElement(element, element => {
138
-            const { type } = element;
143
+        el = this._mapReactElement(el, (el: React$Element<*>) => {
144
+            const { type } = el;
139
 
145
 
140
             if (type === Modal) {
146
             if (type === Modal) {
141
                 // * Modal handles hardware button presses for back navigation.
147
                 // * Modal handles hardware button presses for back navigation.
144
                 //   Secondly, we cannot get Prompt's default behavior anyway
150
                 //   Secondly, we cannot get Prompt's default behavior anyway
145
                 //   because we've removed Prompt and we're preserving whatever
151
                 //   because we've removed Prompt and we're preserving whatever
146
                 //   it's rendered only.
152
                 //   it's rendered only.
147
-                return this._cloneElement(element, /* props */ {
153
+                return this._cloneElement(el, /* props */ {
148
                     onRequestClose: this._onCancel
154
                     onRequestClose: this._onCancel
149
                 });
155
                 });
150
             }
156
             }
153
                 // * If this Dialog has children, they are to be rendered
159
                 // * If this Dialog has children, they are to be rendered
154
                 //   instead of Prompt's TextInput.
160
                 //   instead of Prompt's TextInput.
155
                 if (children) {
161
                 if (children) {
156
-                    element = children; // eslint-disable-line no-param-reassign
162
+                    // $FlowFixMe
163
+                    el = children; // eslint-disable-line no-param-reassign
157
                     children = undefined;
164
                     children = undefined;
158
                 }
165
                 }
159
 
166
 
160
             } else {
167
             } else {
161
-                let { style } = element.props;
168
+                let { style } = el.props;
162
 
169
 
163
                 if (style
170
                 if (style
164
                         && (style = StyleSheet.flatten(style))
171
                         && (style = StyleSheet.flatten(style))
177
                         break;
184
                         break;
178
                     }
185
                     }
179
 
186
 
180
-                    return this._cloneElement(element, /* props */ {
187
+                    return this._cloneElement(el, /* props */ {
181
                         style: set(style, _TAG_KEY, undefined)
188
                         style: set(style, _TAG_KEY, undefined)
182
                     });
189
                     });
183
                 }
190
                 }
184
             }
191
             }
185
 
192
 
186
-            return element;
193
+            return el;
187
         });
194
         });
188
 
195
 
189
-        return element;
196
+        return el;
190
     }
197
     }
191
 
198
 
192
     /**
199
     /**
193
      * Clones a specific {@code ReactElement} and adds/merges specific props
200
      * Clones a specific {@code ReactElement} and adds/merges specific props
194
      * into the clone.
201
      * into the clone.
195
      *
202
      *
196
-     * @param {ReactElement} element - The {@code ReactElement} to clone.
203
+     * @param {ReactElement} el - The {@code ReactElement} to clone.
197
      * @param {Object} props - The props to add/merge into the clone.
204
      * @param {Object} props - The props to add/merge into the clone.
198
-     * @returns {ReactElement} The close of the specified {@code element} with
205
+     * @returns {ReactElement} The close of the specified {@code el} with
199
      * the specified {@code props} added/merged.
206
      * the specified {@code props} added/merged.
200
      */
207
      */
201
-    _cloneElement(element, props) {
208
+    _cloneElement(el: React$Element<*>, props) {
202
         return (
209
         return (
203
             React.cloneElement(
210
             React.cloneElement(
204
-                element,
211
+                el,
205
                 props,
212
                 props,
206
-                ...React.Children.toArray(element.props.children)));
213
+                ...React.Children.toArray(el.props.children)));
207
     }
214
     }
208
 
215
 
209
     /**
216
     /**
211
      * of calling a specific function on every node of a specific
218
      * of calling a specific function on every node of a specific
212
      * {@code ReactElement} tree.
219
      * {@code ReactElement} tree.
213
      *
220
      *
214
-     * @param {ReactElement} element - The {@code ReactElement} to clone and
221
+     * @param {ReactElement} el - The {@code ReactElement} to clone and
215
      * call the specified {@code f} on.
222
      * call the specified {@code f} on.
216
      * @param {Function} f - The function to call on every node of the
223
      * @param {Function} f - The function to call on every node of the
217
-     * {@code ReactElement} tree represented by the specified {@code element}.
224
+     * {@code ReactElement} tree represented by the specified {@code el}.
218
      * @private
225
      * @private
219
      * @returns {ReactElement}
226
      * @returns {ReactElement}
220
      */
227
      */
221
-    _mapReactElement(element, f) {
222
-        if (!element || !element.props || !element.type) {
223
-            return element;
228
+    _mapReactElement(
229
+            el: ?React$Element<*>,
230
+            f: (React$Element<*>) => ?React$Element<*>): ?React$Element<*> {
231
+        if (!el || !el.props || !el.type) {
232
+            return el;
224
         }
233
         }
225
 
234
 
226
-        let mapped = f(element);
235
+        let mapped = f(el);
227
 
236
 
228
         if (mapped) {
237
         if (mapped) {
229
             const { children } = mapped.props;
238
             const { children } = mapped.props;
230
 
239
 
231
-            if (mapped === element || React.Children.count(children)) {
240
+            if (mapped === el || React.Children.count(children)) {
232
                 mapped
241
                 mapped
233
                     = React.cloneElement(
242
                     = React.cloneElement(
234
                         mapped,
243
                         mapped,
235
                         /* props */ {},
244
                         /* props */ {},
236
                         ...React.Children.toArray(React.Children.map(
245
                         ...React.Children.toArray(React.Children.map(
237
                             children,
246
                             children,
238
-                            function(element) { // eslint-disable-line no-shadow
247
+                            function(el) { // eslint-disable-line no-shadow
239
                                 // eslint-disable-next-line no-invalid-this
248
                                 // eslint-disable-next-line no-invalid-this
240
-                                return this._mapReactElement(element, f);
249
+                                return this._mapReactElement(el, f);
241
                             },
250
                             },
242
                             this)));
251
                             this)));
243
             }
252
             }

+ 15
- 7
react/features/base/dialog/components/Dialog.web.js Прегледај датотеку

1
+// @flow
2
+
1
 import React from 'react';
3
 import React from 'react';
2
 import { connect } from 'react-redux';
4
 import { connect } from 'react-redux';
3
 
5
 
4
-import AbstractDialog, { AbstractDialogPropTypes } from './AbstractDialog';
6
+import AbstractDialog from './AbstractDialog';
7
+import type { Props as AbstractDialogProps, State } from './AbstractDialog';
5
 import StatelessDialog from './StatelessDialog';
8
 import StatelessDialog from './StatelessDialog';
6
 
9
 
7
 /**
10
 /**
8
- * Web dialog component's property types.
11
+ * The type of the React {@code Component} props of {@link Dialog}.
9
  */
12
  */
10
-type DialogPropTypes = {
11
-    ...AbstractDialogPropTypes,
13
+type Props = {
14
+    ...AbstractDialogProps,
12
 
15
 
13
     /**
16
     /**
14
      * Whether the dialog is modal. This means clicking on the blanket will
17
      * Whether the dialog is modal. This means clicking on the blanket will
28
      * - integer value for pixel width
31
      * - integer value for pixel width
29
      * - string value for percentage
32
      * - string value for percentage
30
      */
33
      */
31
-    width: String
32
-}
34
+    width: string
35
+};
33
 
36
 
34
 /**
37
 /**
35
  * Web dialog that uses atlaskit modal-dialog to display dialogs.
38
  * Web dialog that uses atlaskit modal-dialog to display dialogs.
36
  */
39
  */
37
-class Dialog extends AbstractDialog<DialogPropTypes> {
40
+class Dialog extends AbstractDialog<Props, State> {
38
     /**
41
     /**
39
      * Initializes a new Dialog instance.
42
      * Initializes a new Dialog instance.
40
      *
43
      *
44
     constructor(props) {
47
     constructor(props) {
45
         super(props);
48
         super(props);
46
 
49
 
50
+        // Bind event handlers so they are only bound once per instance.
47
         this._onCancel = this._onCancel.bind(this);
51
         this._onCancel = this._onCancel.bind(this);
48
         this._onSubmit = this._onSubmit.bind(this);
52
         this._onSubmit = this._onSubmit.bind(this);
49
     }
53
     }
66
         return <StatelessDialog { ...props } />;
70
         return <StatelessDialog { ...props } />;
67
     }
71
     }
68
 
72
 
73
+    _onCancel: () => void;
74
+
69
     /**
75
     /**
70
      * Dispatches action to hide the dialog.
76
      * Dispatches action to hide the dialog.
71
      *
77
      *
74
     _onCancel() {
80
     _onCancel() {
75
         this.props.isModal || super._onCancel();
81
         this.props.isModal || super._onCancel();
76
     }
82
     }
83
+
84
+    _onSubmit: (?string) => void;
77
 }
85
 }
78
 
86
 
79
 export default connect()(Dialog);
87
 export default connect()(Dialog);

+ 82
- 56
react/features/base/dialog/components/StatelessDialog.web.js Прегледај датотеку

1
+// @flow
2
+
1
 import Button, { ButtonGroup } from '@atlaskit/button';
3
 import Button, { ButtonGroup } from '@atlaskit/button';
2
 import ModalDialog from '@atlaskit/modal-dialog';
4
 import ModalDialog from '@atlaskit/modal-dialog';
3
 import { AtlasKitThemeProvider } from '@atlaskit/theme';
5
 import { AtlasKitThemeProvider } from '@atlaskit/theme';
4
-import PropTypes from 'prop-types';
6
+import _ from 'lodash';
5
 import React, { Component } from 'react';
7
 import React, { Component } from 'react';
6
 
8
 
7
 import { translate } from '../../i18n';
9
 import { translate } from '../../i18n';
8
 
10
 
9
-import { DIALOG_PROP_TYPES } from '../constants';
11
+import type { DialogProps } from '../constants';
10
 
12
 
11
 /**
13
 /**
12
  * The ID to be used for the cancel button if enabled.
14
  * The ID to be used for the cancel button if enabled.
21
 const OK_BUTTON_ID = 'modal-dialog-ok-button';
23
 const OK_BUTTON_ID = 'modal-dialog-ok-button';
22
 
24
 
23
 /**
25
 /**
24
- * Web dialog that uses atlaskit modal-dialog to display dialogs.
26
+ * The type of the React {@code Component} props of {@link StatelessDialog}.
27
+ *
28
+ * @static
25
  */
29
  */
26
-class StatelessDialog extends Component {
30
+type Props = {
31
+    ...DialogProps,
32
+
27
     /**
33
     /**
28
-     * {@code StatelessDialog} component's property types.
29
-     *
30
-     * @static
34
+     * Disables dismissing the dialog when the blanket is clicked. Enabled
35
+     * by default.
36
+     */
37
+    disableBlanketClickDismiss: boolean,
38
+
39
+    /**
40
+     * Whether the dialog is modal. This means clicking on the blanket will
41
+     * leave the dialog open. No cancel button.
31
      */
42
      */
32
-    static propTypes = {
33
-        ...DIALOG_PROP_TYPES,
34
-
35
-        /**
36
-         * This is the body of the dialog, the component children.
37
-         */
38
-        children: PropTypes.node,
39
-
40
-        /**
41
-         * Disables dismissing the dialog when the blanket is clicked. Enabled
42
-         * by default.
43
-         */
44
-        disableBlanketClickDismiss: PropTypes.bool,
45
-
46
-        /**
47
-         * Whether the dialog is modal. This means clicking on the blanket will
48
-         * leave the dialog open. No cancel button.
49
-         */
50
-        isModal: PropTypes.bool,
51
-
52
-        /**
53
-         * Disables rendering of the submit button.
54
-         */
55
-        submitDisabled: PropTypes.bool,
56
-
57
-        /**
58
-         * Width of the dialog, can be:
59
-         * - 'small' (400px), 'medium' (600px), 'large' (800px),
60
-         *   'x-large' (968px)
61
-         * - integer value for pixel width
62
-         * - string value for percentage
63
-         */
64
-        width: PropTypes.string
65
-    };
43
+    isModal: boolean,
44
+
45
+    /**
46
+     * Disables rendering of the submit button.
47
+     */
48
+    submitDisabled: boolean,
49
+
50
+    /**
51
+     * Width of the dialog, can be:
52
+     * - 'small' (400px), 'medium' (600px), 'large' (800px),
53
+     *   'x-large' (968px)
54
+     * - integer value for pixel width
55
+     * - string value for percentage
56
+     */
57
+    width: string
58
+};
59
+
60
+/**
61
+ * Web dialog that uses atlaskit modal-dialog to display dialogs.
62
+ */
63
+class StatelessDialog extends Component<Props> {
64
+    _dialogElement: ?HTMLElement;
66
 
65
 
67
     /**
66
     /**
68
      * Initializes a new {@code StatelessDialog} instance.
67
      * Initializes a new {@code StatelessDialog} instance.
100
         // if there is an update in any of the buttons enable/disable props
99
         // if there is an update in any of the buttons enable/disable props
101
         // update the focus if needed
100
         // update the focus if needed
102
         if (prevProps.okDisabled !== this.props.okDisabled
101
         if (prevProps.okDisabled !== this.props.okDisabled
103
-            || prevProps.cancelDisabled !== this.props.cancelDisabled
104
-            || prevProps.submitDisabled !== this.props.submitDisabled) {
102
+                || prevProps.cancelDisabled !== this.props.cancelDisabled
103
+                || prevProps.submitDisabled !== this.props.submitDisabled) {
105
             this._updateButtonFocus();
104
             this._updateButtonFocus();
106
         }
105
         }
107
     }
106
     }
143
         );
142
         );
144
     }
143
     }
145
 
144
 
145
+    _onCancel: () => void;
146
+
146
     /**
147
     /**
147
      * Dispatches action to hide the dialog.
148
      * Dispatches action to hide the dialog.
148
      *
149
      *
150
      */
151
      */
151
     _onCancel() {
152
     _onCancel() {
152
         if (!this.props.isModal) {
153
         if (!this.props.isModal) {
153
-            this.props.onCancel();
154
+            const { onCancel } = this.props;
155
+
156
+            onCancel && onCancel();
154
         }
157
         }
155
     }
158
     }
156
 
159
 
160
+    _onDialogDismissed: () => void;
161
+
157
     /**
162
     /**
158
      * Handles click on the blanket area.
163
      * Handles click on the blanket area.
159
      *
164
      *
165
         }
170
         }
166
     }
171
     }
167
 
172
 
173
+    _onSubmit: (?string) => void;
174
+
168
     /**
175
     /**
169
      * Dispatches the action when submitting the dialog.
176
      * Dispatches the action when submitting the dialog.
170
      *
177
      *
173
      * @returns {void}
180
      * @returns {void}
174
      */
181
      */
175
     _onSubmit(value) {
182
     _onSubmit(value) {
176
-        this.props.onSubmit(value);
183
+        const { onSubmit } = this.props;
184
+
185
+        onSubmit && onSubmit(value);
177
     }
186
     }
178
 
187
 
179
     /**
188
     /**
187
             return null;
196
             return null;
188
         }
197
         }
189
 
198
 
199
+        const {
200
+            t /* The following fixes a flow error: */ = _.identity
201
+        } = this.props;
202
+
190
         return (
203
         return (
191
             <Button
204
             <Button
192
                 appearance = 'subtle'
205
                 appearance = 'subtle'
194
                 key = 'cancel'
207
                 key = 'cancel'
195
                 onClick = { this._onCancel }
208
                 onClick = { this._onCancel }
196
                 type = 'button'>
209
                 type = 'button'>
197
-                { this.props.t(this.props.cancelTitleKey || 'dialog.Cancel') }
210
+                { t(this.props.cancelTitleKey || 'dialog.Cancel') }
198
             </Button>
211
             </Button>
199
         );
212
         );
200
     }
213
     }
229
      * @returns {ReactElement}
242
      * @returns {ReactElement}
230
      */
243
      */
231
     _renderHeader() {
244
     _renderHeader() {
232
-        const { t } = this.props;
245
+        const {
246
+            t /* The following fixes a flow error: */ = _.identity
247
+        } = this.props;
233
 
248
 
234
         return (
249
         return (
235
             <header>
250
             <header>
251
             return null;
266
             return null;
252
         }
267
         }
253
 
268
 
269
+        const {
270
+            t /* The following fixes a flow error: */ = _.identity
271
+        } = this.props;
272
+
254
         return (
273
         return (
255
             <Button
274
             <Button
256
                 appearance = 'primary'
275
                 appearance = 'primary'
260
                 key = 'submit'
279
                 key = 'submit'
261
                 onClick = { this._onSubmit }
280
                 onClick = { this._onSubmit }
262
                 type = 'button'>
281
                 type = 'button'>
263
-                { this.props.t(this.props.okTitleKey || 'dialog.Ok') }
282
+                { t(this.props.okTitleKey || 'dialog.Ok') }
264
             </Button>
283
             </Button>
265
         );
284
         );
266
     }
285
     }
267
 
286
 
287
+    _setDialogElement: (?HTMLElement) => void;
288
+
268
     /**
289
     /**
269
      * Sets the instance variable for the div containing the component's dialog
290
      * Sets the instance variable for the div containing the component's dialog
270
      * element so it can be accessed directly.
291
      * element so it can be accessed directly.
271
      *
292
      *
272
-     * @param {Object} element - The DOM element for the component's dialog.
293
+     * @param {HTMLElement} element - The DOM element for the component's
294
+     * dialog.
273
      * @private
295
      * @private
274
      * @returns {void}
296
      * @returns {void}
275
      */
297
      */
276
-    _setDialogElement(element) {
298
+    _setDialogElement(element: ?HTMLElement) {
277
         this._dialogElement = element;
299
         this._dialogElement = element;
278
     }
300
     }
279
 
301
 
302
+    _onKeyDown: (Object) => void;
303
+
280
     /**
304
     /**
281
      * Handles 'Enter' key in the dialog to submit/hide dialog depending on
305
      * Handles 'Enter' key in the dialog to submit/hide dialog depending on
282
      * the available buttons and their disabled state.
306
      * the available buttons and their disabled state.
312
      * @returns {void}
336
      * @returns {void}
313
      */
337
      */
314
     _updateButtonFocus() {
338
     _updateButtonFocus() {
315
-        if (this._dialogElement) {
339
+        const dialogElement = this._dialogElement;
340
+
341
+        if (dialogElement) {
316
 
342
 
317
             // if we have a focused element inside the dialog, skip changing
343
             // if we have a focused element inside the dialog, skip changing
318
             // the focus
344
             // the focus
319
-            if (this._dialogElement.contains(document.activeElement)) {
345
+            if (dialogElement.contains(document.activeElement)) {
320
                 return;
346
                 return;
321
             }
347
             }
322
 
348
 
323
             let buttonToFocus;
349
             let buttonToFocus;
324
 
350
 
325
             if (this.props.submitDisabled) {
351
             if (this.props.submitDisabled) {
326
-                buttonToFocus = this._dialogElement
327
-                    .querySelector(`[id=${CANCEL_BUTTON_ID}]`);
352
+                buttonToFocus
353
+                    = dialogElement.querySelector(`[id=${CANCEL_BUTTON_ID}]`);
328
             } else if (!this.props.okDisabled) {
354
             } else if (!this.props.okDisabled) {
329
-                buttonToFocus = this._dialogElement
330
-                    .querySelector(`[id=${OK_BUTTON_ID}]`);
355
+                buttonToFocus
356
+                    = dialogElement.querySelector(`[id=${OK_BUTTON_ID}]`);
331
             }
357
             }
332
 
358
 
333
             if (buttonToFocus) {
359
             if (buttonToFocus) {

+ 11
- 5
react/features/base/dialog/constants.js Прегледај датотеку

1
+// @flow
1
 
2
 
2
-export type DialogPropTypes = {
3
+export type DialogProps = {
3
 
4
 
4
     /**
5
     /**
5
      * Whether cancel button is disabled. Enabled by default.
6
      * Whether cancel button is disabled. Enabled by default.
9
     /**
10
     /**
10
      * Optional i18n key to change the cancel button title.
11
      * Optional i18n key to change the cancel button title.
11
      */
12
      */
12
-    cancelTitleKey: String,
13
+    cancelTitleKey: string,
14
+
15
+    /**
16
+     * The React {@code Component} children which represents the dialog's body.
17
+     */
18
+    children: React$Node,
13
 
19
 
14
     /**
20
     /**
15
      * Is ok button enabled/disabled. Enabled by default.
21
      * Is ok button enabled/disabled. Enabled by default.
19
     /**
25
     /**
20
      * Optional i18n key to change the ok button title.
26
      * Optional i18n key to change the ok button title.
21
      */
27
      */
22
-    okTitleKey: String,
28
+    okTitleKey: string,
23
 
29
 
24
     /**
30
     /**
25
      * The handler for onCancel event.
31
      * The handler for onCancel event.
39
     /**
45
     /**
40
      * Key to use for showing a title.
46
      * Key to use for showing a title.
41
      */
47
      */
42
-    titleKey: String,
48
+    titleKey: string,
43
 
49
 
44
     /**
50
     /**
45
      * The string to use as a title instead of {@code titleKey}. If a truthy
51
      * The string to use as a title instead of {@code titleKey}. If a truthy
46
      * value is specified, it takes precedence over {@code titleKey} i.e.
52
      * value is specified, it takes precedence over {@code titleKey} i.e.
47
      * the latter is unused.
53
      * the latter is unused.
48
      */
54
      */
49
-    titleString: String
55
+    titleString: string
50
 };
56
 };

+ 14
- 5
react/features/conference/components/Conference.native.js Прегледај датотеку

1
+// @flow
2
+
1
 import React, { Component } from 'react';
3
 import React, { Component } from 'react';
2
 
4
 
3
 // eslint-disable-next-line react-native/split-platform-components
5
 // eslint-disable-next-line react-native/split-platform-components
25
 const _TOOLBOX_TIMEOUT_MS = 5000;
27
 const _TOOLBOX_TIMEOUT_MS = 5000;
26
 
28
 
27
 /**
29
 /**
28
- * Conference component's property types.
29
- *
30
- * @static
30
+ * The type of the React {@code Component} props of {@link Conference}.
31
  */
31
  */
32
-type ConferencePropTypes = {
32
+type Props = {
33
 
33
 
34
     /**
34
     /**
35
      * The indicator which determines that we are still connecting to the
35
      * The indicator which determines that we are still connecting to the
85
 /**
85
 /**
86
  * The conference page of the mobile (i.e. React Native) application.
86
  * The conference page of the mobile (i.e. React Native) application.
87
  */
87
  */
88
-class Conference extends Component<ConferencePropTypes> {
88
+class Conference extends Component<Props> {
89
+    _backHandler: ?BackHandler;
90
+
91
+    _toolboxTimeout: ?number;
92
+
89
     /**
93
     /**
90
      * Initializes a new Conference instance.
94
      * Initializes a new Conference instance.
91
      *
95
      *
237
         }
241
         }
238
     }
242
     }
239
 
243
 
244
+    _onClick: () => void;
245
+
240
     /**
246
     /**
241
      * Changes the value of the toolboxVisible state, thus allowing us to switch
247
      * Changes the value of the toolboxVisible state, thus allowing us to switch
242
      * between Toolbox and Filmstrip and change their visibility.
248
      * between Toolbox and Filmstrip and change their visibility.
254
         this._clearToolboxTimeout();
260
         this._clearToolboxTimeout();
255
     }
261
     }
256
 
262
 
263
+    _onHardwareBackPress: () => boolean;
264
+
257
     /**
265
     /**
258
      * Handles a hardware button press for back navigation.
266
      * Handles a hardware button press for back navigation.
259
      *
267
      *
393
     };
401
     };
394
 }
402
 }
395
 
403
 
404
+// $FlowFixMe
396
 export default reactReduxConnect(_mapStateToProps, _mapDispatchToProps)(
405
 export default reactReduxConnect(_mapStateToProps, _mapDispatchToProps)(
397
     Conference);
406
     Conference);

+ 5
- 5
react/features/feedback/components/FeedbackButton.web.js Прегледај датотеку

1
-/* @flow */
1
+// @flow
2
 
2
 
3
 import Tooltip from '@atlaskit/tooltip';
3
 import Tooltip from '@atlaskit/tooltip';
4
 import React, { Component } from 'react';
4
 import React, { Component } from 'react';
9
 import { openFeedbackDialog } from '../actions';
9
 import { openFeedbackDialog } from '../actions';
10
 
10
 
11
 /**
11
 /**
12
- * Defines property types for the FeedbackButton component.
12
+ * The type of the React {@code Component} props of {@link FeedbackButton}.
13
  */
13
  */
14
-type FeedbackButtonPropTypes = {
14
+type Props = {
15
 
15
 
16
     /**
16
     /**
17
      * The JitsiConference for which the feedback will be about.
17
      * The JitsiConference for which the feedback will be about.
34
     /**
34
     /**
35
      * From which side of the button the tooltip should appear from.
35
      * From which side of the button the tooltip should appear from.
36
      */
36
      */
37
-    tooltipPosition: String
37
+    tooltipPosition: string
38
 }
38
 }
39
 
39
 
40
 /**
40
 /**
41
  * Implements a Web/React Component which renders a feedback button.
41
  * Implements a Web/React Component which renders a feedback button.
42
  */
42
  */
43
-class FeedbackButton extends Component<FeedbackButtonPropTypes> {
43
+class FeedbackButton extends Component<Props> {
44
     _onClick: Function;
44
     _onClick: Function;
45
 
45
 
46
     /**
46
     /**

Loading…
Откажи
Сачувај