瀏覽代碼

ref: define state and property types

j8
paweldomas 7 年之前
父節點
當前提交
379bad0ce6

+ 12
- 1
react/features/always-on-top/AlwaysOnTop.js 查看文件

@@ -53,13 +53,24 @@ const toolbarButtons = {
53 53
     }
54 54
 };
55 55
 
56
+/**
57
+ * Defines the state for <tt>AlwaysOnTop</tt> component.
58
+ */
59
+type AlwaysOnTopState = {
60
+    visible: boolean,
61
+    audioMuted: boolean,
62
+    videoMuted: boolean,
63
+    audioAvailable: boolean,
64
+    videoAvailable: boolean
65
+}
66
+
56 67
 /**
57 68
  * Represents the always on top page.
58 69
  *
59 70
  * @class AlwaysOnTop
60 71
  * @extends Component
61 72
  */
62
-export default class AlwaysOnTop extends Component<*> {
73
+export default class AlwaysOnTop extends Component<*, AlwaysOnTopState> {
63 74
     /**
64 75
      * Initializes new AlwaysOnTop instance.
65 76
      *

+ 22
- 24
react/features/authentication/components/WaitForOwnerDialog.native.js 查看文件

@@ -1,6 +1,5 @@
1 1
 // @flow
2 2
 
3
-import PropTypes from 'prop-types';
4 3
 import React, { Component } from 'react';
5 4
 import { Text } from 'react-native';
6 5
 import { connect } from 'react-redux';
@@ -11,35 +10,34 @@ import { translate } from '../../base/i18n';
11 10
 import { cancelWaitForOwner, _openLoginDialog } from '../actions';
12 11
 import styles from './styles';
13 12
 
13
+/**
14
+ * WaitForOwnerDialog component's property types.
15
+ */
16
+type WaitForOwnerDialogPropTypes = {
17
+
18
+    /**
19
+     * The name of the conference room (without the domain part).
20
+     */
21
+    _room: String,
22
+
23
+    /**
24
+     * Redux store dispatch function.
25
+     */
26
+    dispatch: Dispatch<*>,
27
+
28
+    /**
29
+     * Invoked to obtain translated strings.
30
+     */
31
+    t: Function
32
+};
33
+
14 34
 /**
15 35
  * The dialog is display in XMPP password + guest access configuration, after
16 36
  * user connects from anonymous domain and the conference does not exist yet.
17 37
  *
18 38
  * See {@link LoginDialog} description for more details.
19 39
  */
20
-class WaitForOwnerDialog extends Component<*> {
21
-    /**
22
-     * WaitForOwnerDialog component's property types.
23
-     *
24
-     * @static
25
-     */
26
-    static propTypes = {
27
-        /**
28
-         * The name of the conference room (without the domain part).
29
-         */
30
-        _room: PropTypes.string,
31
-
32
-        /**
33
-         * Redux store dispatch function.
34
-         */
35
-        dispatch: PropTypes.func,
36
-
37
-        /**
38
-         * Invoked to obtain translated strings.
39
-         */
40
-        t: PropTypes.func
41
-    };
42
-
40
+class WaitForOwnerDialog extends Component<WaitForOwnerDialogPropTypes> {
43 41
     /**
44 42
      * Initializes a new WaitForWonderDialog instance.
45 43
      *

+ 28
- 22
react/features/base/dialog/components/AbstractDialog.js 查看文件

@@ -1,38 +1,44 @@
1 1
 // @flow
2 2
 
3
-import PropTypes from 'prop-types';
4
-import { Component } from 'react';
3
+import * as React from 'react';
5 4
 
6 5
 import { hideDialog } from '../actions';
7
-import { DIALOG_PROP_TYPES } from '../constants';
6
+import { DialogPropTypes } from '../constants';
8 7
 
9 8
 /**
10
- * An abstract implementation of a dialog on Web/React and mobile/react-native.
9
+ * Defines the property types for AbstractDialog.
11 10
  */
12
-export default class AbstractDialog extends Component<*, *> {
11
+export type AbstractDialogPropTypes = {
12
+    ...DialogPropTypes,
13
+
13 14
     /**
14
-     * {@code AbstractDialog} React {@code Component}'s prop types.
15
-     *
16
-     * @static
15
+     * The React {@code Component} children of {@code AbstractDialog}
16
+     * which represents the dialog's body.
17 17
      */
18
-    static propTypes = {
19
-        ...DIALOG_PROP_TYPES,
20
-
21
-        /**
22
-         * The React {@code Component} children of {@code AbstractDialog}
23
-         * which represents the dialog's body.
24
-         */
25
-        children: PropTypes.node,
26
-
27
-        /**
28
-         * Used to show/hide the dialog on cancel.
29
-         */
30
-        dispatch: PropTypes.func
31
-    };
18
+    children: React.Node,
19
+
20
+    /**
21
+     * Used to show/hide the dialog on cancel.
22
+     */
23
+    dispatch: Dispatch<*>
24
+}
32 25
 
26
+/**
27
+ * Defines the state for AbstractDialog.
28
+ */
29
+type AbstractDialogState = {
30
+    submitting: boolean
31
+}
32
+
33
+/**
34
+ * An abstract implementation of a dialog on Web/React and mobile/react-native.
35
+ */
36
+export default class AbstractDialog
37
+    extends React.Component<AbstractDialogPropTypes, AbstractDialogState> {
33 38
     _mounted: boolean;
34 39
 
35 40
     state = {
41
+        submitting: false
36 42
     };
37 43
 
38 44
     /**

+ 27
- 25
react/features/base/dialog/components/Dialog.native.js 查看文件

@@ -1,6 +1,3 @@
1
-// @flow
2
-
3
-import PropTypes from 'prop-types';
4 1
 import React from 'react';
5 2
 import { Modal, StyleSheet, TextInput } from 'react-native';
6 3
 import Prompt from 'react-native-prompt';
@@ -10,7 +7,7 @@ import { translate } from '../../i18n';
10 7
 import { LoadingIndicator } from '../../react';
11 8
 import { set } from '../../redux';
12 9
 
13
-import AbstractDialog from './AbstractDialog';
10
+import AbstractDialog, { AbstractDialogPropTypes } from './AbstractDialog';
14 11
 import { dialog as styles } from './styles';
15 12
 
16 13
 /**
@@ -30,33 +27,38 @@ const _SUBMIT_TEXT_TAG_VALUE = '_SUBMIT_TEXT_TAG_VALUE';
30 27
 const _TAG_KEY = '_TAG_KEY';
31 28
 
32 29
 /**
33
- * Implements {@code AbstractDialog} on react-native using {@code Prompt}.
30
+ * {@code Dialog}'s React {@code Component} prop types.
34 31
  */
35
-class Dialog extends AbstractDialog {
32
+type DialogPropTypes = {
33
+    ...AbstractDialogPropTypes,
34
+
36 35
     /**
37
-     * {@code AbstractDialog}'s React {@code Component} prop types.
38
-     *
39
-     * @static
36
+     * I18n key to put as body title.
40 37
      */
41
-    static propTypes = {
42
-        ...AbstractDialog.propTypes,
38
+    bodyKey: String
39
+}
43 40
 
44
-        /**
45
-         * I18n key to put as body title.
46
-         */
47
-        bodyKey: PropTypes.string
48
-    };
41
+/**
42
+ * Defines {@code Dialog}'s state.
43
+ */
44
+type DialogState = {
45
+
46
+    /**
47
+     * The text of the {@link TextInput} rendered by {@link Prompt} in
48
+     * general and by this {@code Dialog} in particular if no
49
+     * {@code children} are specified to it. It mimics/reimplements the
50
+     * functionality of {@code Prompt} because this {@code Dialog} does not
51
+     * really render the (whole) {@code Prompt}.
52
+     */
53
+    text: String
54
+}
55
+
56
+/**
57
+ * Implements {@code AbstractDialog} on react-native using {@code Prompt}.
58
+ */
59
+class Dialog extends AbstractDialog<DialogPropTypes, DialogState> {
49 60
 
50 61
     state = {
51
-        /**
52
-         * The text of the {@link TextInput} rendered by {@link Prompt} in
53
-         * general and by this {@code Dialog} in particular if no
54
-         * {@code children} are specified to it. It mimics/reimplements the
55
-         * functionality of {@code Prompt} because this {@code Dialog} does not
56
-         * really render the (whole) {@code Prompt}.
57
-         *
58
-         * @type {string}
59
-         */
60 62
         text: ''
61 63
     };
62 64
 

+ 25
- 28
react/features/base/dialog/components/Dialog.web.js 查看文件

@@ -1,43 +1,40 @@
1
-import PropTypes from 'prop-types';
2 1
 import React from 'react';
3 2
 import { connect } from 'react-redux';
4 3
 
5
-import AbstractDialog from './AbstractDialog';
4
+import AbstractDialog, { AbstractDialogPropTypes } from './AbstractDialog';
6 5
 import StatelessDialog from './StatelessDialog';
7 6
 
8 7
 /**
9
- * Web dialog that uses atlaskit modal-dialog to display dialogs.
8
+ * Web dialog component's property types.
10 9
  */
11
-class Dialog extends AbstractDialog {
10
+type DialogPropTypes = {
11
+    ...AbstractDialogPropTypes,
12
+
12 13
     /**
13
-     * Web dialog component's property types.
14
-     *
15
-     * @static
14
+     * Whether the dialog is modal. This means clicking on the blanket will
15
+     * leave the dialog open. No cancel button.
16 16
      */
17
-    static propTypes = {
18
-        ...AbstractDialog.propTypes,
17
+    isModal: boolean,
19 18
 
20
-        /**
21
-         * Whether the dialog is modal. This means clicking on the blanket will
22
-         * leave the dialog open. No cancel button.
23
-         */
24
-        isModal: PropTypes.bool,
25
-
26
-        /**
27
-         * Disables rendering of the submit button.
28
-         */
29
-        submitDisabled: PropTypes.bool,
19
+    /**
20
+     * Disables rendering of the submit button.
21
+     */
22
+    submitDisabled: boolean,
30 23
 
31
-        /**
32
-         * Width of the dialog, can be:
33
-         * - 'small' (400px), 'medium' (600px), 'large' (800px),
34
-         * 'x-large' (968px)
35
-         * - integer value for pixel width
36
-         * - string value for percentage
37
-         */
38
-        width: PropTypes.string
39
-    };
24
+    /**
25
+     * Width of the dialog, can be:
26
+     * - 'small' (400px), 'medium' (600px), 'large' (800px),
27
+     * 'x-large' (968px)
28
+     * - integer value for pixel width
29
+     * - string value for percentage
30
+     */
31
+    width: String
32
+}
40 33
 
34
+/**
35
+ * Web dialog that uses atlaskit modal-dialog to display dialogs.
36
+ */
37
+class Dialog extends AbstractDialog<DialogPropTypes> {
41 38
     /**
42 39
      * Initializes a new Dialog instance.
43 40
      *

+ 11
- 11
react/features/base/dialog/constants.js 查看文件

@@ -1,50 +1,50 @@
1
-import PropTypes from 'prop-types';
2 1
 
3
-export const DIALOG_PROP_TYPES = {
2
+export type DialogPropTypes = {
3
+
4 4
     /**
5 5
      * Whether cancel button is disabled. Enabled by default.
6 6
      */
7
-    cancelDisabled: PropTypes.bool,
7
+    cancelDisabled: boolean,
8 8
 
9 9
     /**
10 10
      * Optional i18n key to change the cancel button title.
11 11
      */
12
-    cancelTitleKey: PropTypes.string,
12
+    cancelTitleKey: String,
13 13
 
14 14
     /**
15 15
      * Is ok button enabled/disabled. Enabled by default.
16 16
      */
17
-    okDisabled: PropTypes.bool,
17
+    okDisabled: boolean,
18 18
 
19 19
     /**
20 20
      * Optional i18n key to change the ok button title.
21 21
      */
22
-    okTitleKey: PropTypes.string,
22
+    okTitleKey: String,
23 23
 
24 24
     /**
25 25
      * The handler for onCancel event.
26 26
      */
27
-    onCancel: PropTypes.func,
27
+    onCancel: Function,
28 28
 
29 29
     /**
30 30
      * The handler for the event when submitting the dialog.
31 31
      */
32
-    onSubmit: PropTypes.func,
32
+    onSubmit: Function,
33 33
 
34 34
     /**
35 35
      * Used to obtain translations in children classes.
36 36
      */
37
-    t: PropTypes.func,
37
+    t: Function,
38 38
 
39 39
     /**
40 40
      * Key to use for showing a title.
41 41
      */
42
-    titleKey: PropTypes.string,
42
+    titleKey: String,
43 43
 
44 44
     /**
45 45
      * The string to use as a title instead of {@code titleKey}. If a truthy
46 46
      * value is specified, it takes precedence over {@code titleKey} i.e.
47 47
      * the latter is unused.
48 48
      */
49
-    titleString: PropTypes.string
49
+    titleString: String
50 50
 };

+ 51
- 51
react/features/conference/components/Conference.native.js 查看文件

@@ -1,4 +1,3 @@
1
-import PropTypes from 'prop-types';
2 1
 import React, { Component } from 'react';
3 2
 
4 3
 // eslint-disable-next-line react-native/split-platform-components
@@ -26,66 +25,67 @@ import styles from './styles';
26 25
 const _TOOLBOX_TIMEOUT_MS = 5000;
27 26
 
28 27
 /**
29
- * The conference page of the mobile (i.e. React Native) application.
28
+ * Conference component's property types.
29
+ *
30
+ * @static
30 31
  */
31
-class Conference extends Component {
32
+type ConferencePropTypes = {
33
+
32 34
     /**
33
-     * Conference component's property types.
35
+     * The indicator which determines that we are still connecting to the
36
+     * conference which includes establishing the XMPP connection and then
37
+     * joining the room. If truthy, then an activity/loading indicator will
38
+     * be rendered.
34 39
      *
35
-     * @static
40
+     * @private
36 41
      */
37
-    static propTypes = {
38
-        /**
39
-         * The indicator which determines that we are still connecting to the
40
-         * conference which includes establishing the XMPP connection and then
41
-         * joining the room. If truthy, then an activity/loading indicator will
42
-         * be rendered.
43
-         *
44
-         * @private
45
-         */
46
-        _connecting: PropTypes.bool,
42
+    _connecting: boolean,
47 43
 
48
-        /**
49
-         * The handler which dispatches the (redux) action connect.
50
-         *
51
-         * @private
52
-         */
53
-        _onConnect: PropTypes.func,
44
+    /**
45
+     * The handler which dispatches the (redux) action connect.
46
+     *
47
+     * @private
48
+     */
49
+    _onConnect: Function,
54 50
 
55
-        /**
56
-         * The handler which dispatches the (redux) action disconnect.
57
-         *
58
-         * @private
59
-         */
60
-        _onDisconnect: PropTypes.func,
51
+    /**
52
+     * The handler which dispatches the (redux) action disconnect.
53
+     *
54
+     * @private
55
+     */
56
+    _onDisconnect: Function,
61 57
 
62
-        /**
63
-         * Handles a hardware button press for back navigation. Leaves the
64
-         * associated {@code Conference}.
65
-         *
66
-         * @private
67
-         * @returns {boolean} As the associated conference is unconditionally
68
-         * left and exiting the app while it renders a {@code Conference} is
69
-         * undesired, {@code true} is always returned.
70
-         */
71
-        _onHardwareBackPress: PropTypes.func,
58
+    /**
59
+     * Handles a hardware button press for back navigation. Leaves the
60
+     * associated {@code Conference}.
61
+     *
62
+     * @private
63
+     * @returns {boolean} As the associated conference is unconditionally
64
+     * left and exiting the app while it renders a {@code Conference} is
65
+     * undesired, {@code true} is always returned.
66
+     */
67
+    _onHardwareBackPress: Function,
72 68
 
73
-        /**
74
-         * The handler which dispatches the (redux) action setToolboxVisible to
75
-         * show/hide the Toolbox.
76
-         *
77
-         * @private
78
-         */
79
-        _setToolboxVisible: PropTypes.func,
69
+    /**
70
+     * The handler which dispatches the (redux) action setToolboxVisible to
71
+     * show/hide the Toolbox.
72
+     *
73
+     * @private
74
+     */
75
+    _setToolboxVisible: Function,
80 76
 
81
-        /**
82
-         * The indicator which determines whether the Toolbox is visible.
83
-         *
84
-         * @private
85
-         */
86
-        _toolboxVisible: PropTypes.bool
87
-    };
77
+    /**
78
+     * The indicator which determines whether the Toolbox is visible.
79
+     *
80
+     * @private
81
+     */
82
+    _toolboxVisible: boolean
83
+};
88 84
 
85
+/**
86
+ * The conference page of the mobile (i.e. React Native) application.
87
+ */
88
+class Conference extends Component<ConferencePropTypes> {
89 89
     /**
90 90
      * Initializes a new Conference instance.
91 91
      *

+ 28
- 21
react/features/feedback/components/FeedbackButton.web.js 查看文件

@@ -1,7 +1,6 @@
1 1
 /* @flow */
2 2
 
3 3
 import Tooltip from '@atlaskit/tooltip';
4
-import PropTypes from 'prop-types';
5 4
 import React, { Component } from 'react';
6 5
 import { connect } from 'react-redux';
7 6
 
@@ -10,31 +9,39 @@ import { translate } from '../../base/i18n';
10 9
 import { openFeedbackDialog } from '../actions';
11 10
 
12 11
 /**
13
- * Implements a Web/React Component which renders a feedback button.
12
+ * Defines property types for the FeedbackButton component.
14 13
  */
15
-class FeedbackButton extends Component<*> {
16
-    _onClick: Function;
14
+type FeedbackButtonPropTypes = {
17 15
 
18
-    static propTypes = {
19
-        /**
20
-         * The JitsiConference for which the feedback will be about.
21
-         *
22
-         * @type {JitsiConference}
23
-         */
24
-        _conference: PropTypes.object,
16
+    /**
17
+     * The JitsiConference for which the feedback will be about.
18
+     *
19
+     * FIXME define JitsiConference type
20
+     * @type {JitsiConference}
21
+     */
22
+    _conference: Object,
25 23
 
26
-        dispatch: PropTypes.func,
24
+    /**
25
+     * Redux store dispatch function.
26
+     */
27
+    dispatch: Dispatch<*>,
27 28
 
28
-        /**
29
-         * Invoked to obtain translated strings.
30
-         */
31
-        t: PropTypes.func,
29
+    /**
30
+     * Invoked to obtain translated strings.
31
+     */
32
+    t: Function,
32 33
 
33
-        /**
34
-         * From which side of the button the tooltip should appear from.
35
-         */
36
-        tooltipPosition: PropTypes.string
37
-    };
34
+    /**
35
+     * From which side of the button the tooltip should appear from.
36
+     */
37
+    tooltipPosition: String
38
+}
39
+
40
+/**
41
+ * Implements a Web/React Component which renders a feedback button.
42
+ */
43
+class FeedbackButton extends Component<FeedbackButtonPropTypes> {
44
+    _onClick: Function;
38 45
 
39 46
     /**
40 47
      * Initializes a new FeedbackButton instance.

Loading…
取消
儲存