diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js
index 57d07fb542393f..e87b61e06cf0ec 100644
--- a/Libraries/Alert/Alert.js
+++ b/Libraries/Alert/Alert.js
@@ -46,10 +46,11 @@ class Alert {
buttons?: Buttons,
options?: Options,
): void {
- if (Platform.OS === 'ios') {
+ if (
+ Platform.OS === 'ios' ||
+ Platform.OS === 'macos' /* TODO(macOS ISS#2323203) */
+ ) {
Alert.prompt(title, message, buttons, 'default');
- } else if (Platform.OS === 'macos' /* TODO[(macOS ISS#2323203) */) {
- AlertMacOS.prompt(title, message, buttons); // TODO](macOS ISS#2323203)
} else if (Platform.OS === 'android') {
if (!NativeDialogManagerAndroid) {
return;
@@ -172,7 +173,12 @@ class Alert {
cb && cb(value);
},
);
+ // [TODO(macOS ISS#2323203)
+ } else if (Platform.OS === 'macos') {
+ const defaultInputs = [{default: defaultValue}];
+ AlertMacOS.prompt(title, message, callbackOrButtons, type, defaultInputs);
}
+ // ]TODO(macOS ISS#2323203)
}
}
diff --git a/RNTester/js/examples/Alert/AlertMacOSExample.js b/RNTester/js/examples/Alert/AlertMacOSExample.js
new file mode 100644
index 00000000000000..297f21083c1848
--- /dev/null
+++ b/RNTester/js/examples/Alert/AlertMacOSExample.js
@@ -0,0 +1,264 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @format
+ * @flow
+ */
+
+'use strict';
+
+var React = require('react');
+var ReactNative = require('react-native');
+var {StyleSheet, View, Text, TouchableHighlight, AlertMacOS} = ReactNative;
+
+var {SimpleAlertExampleBlock} = require('./AlertExample');
+
+exports.framework = 'React';
+exports.title = 'AlertMacOS';
+exports.description = 'macOS alerts';
+exports.examples = [
+ {
+ title: 'Alerts',
+ render() {
+ return ;
+ },
+ },
+ {
+ title: 'Prompt Options',
+ render(): React.Element {
+ return ;
+ },
+ },
+ {
+ title: 'Prompt Types',
+ render() {
+ return (
+
+ AlertMacOS.prompt('Plain Text Entry')}>
+
+ plain-text
+
+
+
+ AlertMacOS.prompt('Secure Text', null, null, 'secure-text')
+ }>
+
+ secure-text
+
+
+
+ AlertMacOS.prompt(
+ 'Login & Password',
+ null,
+ null,
+ 'login-password',
+ [
+ {default: '', placeholder: 'login'},
+ {default: '', placeholder: 'Password'},
+ ],
+ )
+ }>
+
+ login-password
+
+
+
+ );
+ },
+ },
+ {
+ title: 'Prompt Presentation',
+ render() {
+ return (
+
+
+ AlertMacOS.prompt(
+ 'Default sheet',
+ null,
+ null,
+ 'default',
+ [{default: '', placeholder: ''}],
+ false,
+ )
+ }>
+
+ Default sheet
+
+
+
+ AlertMacOS.prompt(
+ 'Modal',
+ null,
+ null,
+ 'default',
+ [{default: '', placeholder: ''}],
+ true,
+ )
+ }>
+
+ Modal
+
+
+
+ );
+ },
+ },
+ {
+ title: 'Prompt Style',
+ render() {
+ return (
+
+
+ AlertMacOS.prompt('Default warning style', null, null, 'default')
+ }>
+
+ Default warning style
+
+
+
+ AlertMacOS.prompt(
+ 'Critical',
+ null,
+ null,
+ 'default',
+ [{default: '', placeholder: ''}],
+ false,
+ true,
+ )
+ }>
+
+ Critical
+
+
+
+ );
+ },
+ },
+];
+
+class PromptOptions extends React.Component<$FlowFixMeProps, any> {
+ state: any;
+ customButtons: Array