@@ -521,8 +521,10 @@ const TextInput = React.createClass({
521
521
} ,
522
522
523
523
render : function ( ) {
524
- if ( Platform . OS === 'ios' || Platform . OS === 'macos' ) {
524
+ if ( Platform . OS === 'ios' ) {
525
525
return this . _renderIOS ( ) ;
526
+ } else if ( Platform . OS === 'macos' ) {
527
+ return this . _renderMacOS ( ) ;
526
528
} else if ( Platform . OS === 'android' ) {
527
529
return this . _renderAndroid ( ) ;
528
530
}
@@ -534,6 +536,90 @@ const TextInput = React.createClass({
534
536
this . props . defaultValue ;
535
537
} ,
536
538
539
+ _renderMacOS : function ( ) {
540
+ var textContainer ;
541
+
542
+ var onSelectionChange ;
543
+ if ( this . props . selectionState || this . props . onSelectionChange ) {
544
+ onSelectionChange = ( event : Event ) => {
545
+ if ( this . props . selectionState ) {
546
+ var selection = event . nativeEvent . selection ;
547
+ this . props . selectionState . update ( selection . start , selection . end ) ;
548
+ }
549
+ this . props . onSelectionChange && this . props . onSelectionChange ( event ) ;
550
+ } ;
551
+ }
552
+
553
+ var props = Object . assign ( { } , this . props ) ;
554
+ props . style = [ styles . input , this . props . style ] ;
555
+ if ( ! props . multiline ) {
556
+ if ( __DEV__ ) {
557
+ for ( var propKey in onlyMultiline ) {
558
+ if ( props [ propKey ] ) {
559
+ const error = new Error (
560
+ 'TextInput prop `' + propKey + '` is only supported with multiline.'
561
+ ) ;
562
+ warning ( false , '%s' , error . stack ) ;
563
+ }
564
+ }
565
+ }
566
+ var TextField = props . password ? RCTSecureTextField : RCTTextField ;
567
+ textContainer =
568
+ < TextField
569
+ ref = "input"
570
+ { ...props }
571
+ onFocus = { this . _onFocus }
572
+ onBlur = { this . _onBlur }
573
+ onChange = { this . _onChange }
574
+ onSubmitEditing = { this . props . onSubmitEditing }
575
+ onSelectionChange = { onSelectionChange }
576
+ onSelectionChangeShouldSetResponder = { emptyFunction . thatReturnsTrue }
577
+ text = { this . _getText ( ) }
578
+ /> ;
579
+ } else {
580
+ var children = props . children ;
581
+ var childCount = 0 ;
582
+ ReactChildren . forEach ( children , ( ) => ++ childCount ) ;
583
+ invariant (
584
+ ! ( props . value && childCount ) ,
585
+ 'Cannot specify both value and children.'
586
+ ) ;
587
+ if ( childCount >= 1 ) {
588
+ children = < Text style = { props . style } > { children } </ Text > ;
589
+ }
590
+ if ( props . inputView ) {
591
+ children = [ children , props . inputView ] ;
592
+ }
593
+ textContainer =
594
+ < RCTTextView
595
+ ref = "input"
596
+ { ...props }
597
+ children = { children }
598
+ onFocus = { this . _onFocus }
599
+ onBlur = { this . _onBlur }
600
+ onChange = { this . _onChange }
601
+ onContentSizeChange = { this . props . onContentSizeChange }
602
+ onSelectionChange = { onSelectionChange }
603
+ onSubmitEditing = { this . props . onSubmitEditing }
604
+ onTextInput = { this . _onTextInput }
605
+ onSelectionChangeShouldSetResponder = { emptyFunction . thatReturnsTrue }
606
+ placeholderTextColor = { processColor ( props . placeholderTextColor ) }
607
+ text = { this . _getText ( ) }
608
+ dataDetectorTypes = { this . props . dataDetectorTypes }
609
+ /> ;
610
+ }
611
+
612
+ return (
613
+ < TouchableWithoutFeedback
614
+ onLayout = { props . onLayout }
615
+ onPress = { this . _onPress }
616
+ rejectResponderTermination = { true }
617
+ testID = { props . testID } >
618
+ { textContainer }
619
+ </ TouchableWithoutFeedback >
620
+ ) ;
621
+ } ,
622
+
537
623
_renderIOS : function ( ) {
538
624
var textContainer ;
539
625
0 commit comments