|
@@ -45,6 +45,33 @@ class Dialog extends AbstractDialog {
|
45
|
45
|
bodyKey: PropTypes.string
|
46
|
46
|
};
|
47
|
47
|
|
|
48
|
+ state = {
|
|
49
|
+ /**
|
|
50
|
+ * The text of the {@link TextInput} rendered by {@link Prompt} in
|
|
51
|
+ * general and by this {@code Dialog} in particular if no
|
|
52
|
+ * {@code children} are specified to it. It mimics/reimplements the
|
|
53
|
+ * functionality of {@code Prompt} because this {@code Dialog} does not
|
|
54
|
+ * really render the (whole) {@code Prompt}.
|
|
55
|
+ *
|
|
56
|
+ * @type {string}
|
|
57
|
+ */
|
|
58
|
+ text: ''
|
|
59
|
+ };
|
|
60
|
+
|
|
61
|
+ /**
|
|
62
|
+ * Initailizes a new {@code Dialog} instance.
|
|
63
|
+ *
|
|
64
|
+ * @param {Object} props - The read-only React {@code Component} props with
|
|
65
|
+ * which the new instance is to be initialized.
|
|
66
|
+ */
|
|
67
|
+ constructor(props: Object) {
|
|
68
|
+ super(props);
|
|
69
|
+
|
|
70
|
+ // Bind event handlers so they are only bound once per instance.
|
|
71
|
+ this._onChangeText = this._onChangeText.bind(this);
|
|
72
|
+ this._onSubmit = this._onSubmit.bind(this);
|
|
73
|
+ }
|
|
74
|
+
|
48
|
75
|
/**
|
49
|
76
|
* Implements React's {@link Component#render()}.
|
50
|
77
|
*
|
|
@@ -78,7 +105,9 @@ class Dialog extends AbstractDialog {
|
78
|
105
|
<Prompt
|
79
|
106
|
cancelButtonTextStyle = { cancelButtonTextStyle }
|
80
|
107
|
cancelText = { t(cancelTitleKey) }
|
|
108
|
+ defaultValue = { this.state.text }
|
81
|
109
|
onCancel = { this._onCancel }
|
|
110
|
+ onChangeText = { this._onChangeText }
|
82
|
111
|
onSubmit = { this._onSubmit }
|
83
|
112
|
placeholder = { t(bodyKey) }
|
84
|
113
|
submitButtonTextStyle = { submitButtonTextStyle }
|
|
@@ -209,6 +238,32 @@ class Dialog extends AbstractDialog {
|
209
|
238
|
|
210
|
239
|
return mapped;
|
211
|
240
|
}
|
|
241
|
+
|
|
242
|
+ _onChangeText: (string) => void;
|
|
243
|
+
|
|
244
|
+ /**
|
|
245
|
+ * Notifies this {@code Dialog} that the text/value of the {@code TextInput}
|
|
246
|
+ * rendered by {@code Prompt} has changed.
|
|
247
|
+ *
|
|
248
|
+ * @param {string} text - The new text/value of the {@code TextInput}
|
|
249
|
+ * rendered by {@code Prompt}.
|
|
250
|
+ * @returns {void}
|
|
251
|
+ */
|
|
252
|
+ _onChangeText(text: string) {
|
|
253
|
+ this.setState({ text });
|
|
254
|
+ }
|
|
255
|
+
|
|
256
|
+ /**
|
|
257
|
+ * Submits this {@code Dialog} with the value of the {@link TextInput}
|
|
258
|
+ * rendered by {@link Prompt} unless a value is explicitly specified.
|
|
259
|
+ *
|
|
260
|
+ * @override
|
|
261
|
+ * @param {string} [value] - The submitted value if any.
|
|
262
|
+ * @returns {void}
|
|
263
|
+ */
|
|
264
|
+ _onSubmit(value: ?string) {
|
|
265
|
+ super._onSubmit(value || this.state.text);
|
|
266
|
+ }
|
212
|
267
|
}
|
213
|
268
|
|
214
|
269
|
export default translate(connect()(Dialog));
|