diff --git a/Libraries/Components/Slider/Slider.js b/Libraries/Components/Slider/Slider.js index e0e22b335c6..f7b47992e30 100644 --- a/Libraries/Components/Slider/Slider.js +++ b/Libraries/Components/Slider/Slider.js @@ -11,7 +11,7 @@ 'use strict'; const Platform = require('../../Utilities/Platform'); -const RCTSliderNativeComponent = require('./RCTSliderNativeComponent'); +const SliderNativeComponent = require('./SliderNativeComponent'); const React = require('react'); const ReactNative = require('../../Renderer/shims/ReactNative'); const StyleSheet = require('../../StyleSheet/StyleSheet'); @@ -197,7 +197,7 @@ type Props = $ReadOnly<{| */ const Slider = ( props: Props, - forwardedRef?: ?React.Ref, + forwardedRef?: ?React.Ref, ) => { const style = StyleSheet.compose( styles.slider, @@ -227,7 +227,7 @@ const Slider = ( : null; return ( - ; -module.exports = ((requireNativeComponent('RCTSlider'): any): SliderType); +module.exports = ((require('SliderNativeViewConfig'): any): SliderType); diff --git a/Libraries/Components/Slider/SliderNativeViewConfig.js b/Libraries/Components/Slider/SliderNativeViewConfig.js new file mode 100644 index 00000000000..92abe056836 --- /dev/null +++ b/Libraries/Components/Slider/SliderNativeViewConfig.js @@ -0,0 +1,76 @@ + +/** + * 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. + * + * @flow + */ + +'use strict'; + +const ReactNativeViewConfigRegistry = require('ReactNativeViewConfigRegistry'); +const ReactNativeViewViewConfig = require('ReactNativeViewViewConfig'); +const verifyComponentAttributeEquivalence = require('verifyComponentAttributeEquivalence'); + +const SliderViewConfig = { + uiViewClassName: 'RCTSlider', + Commands: {}, + + bubblingEventTypes: { + ...ReactNativeViewViewConfig.bubblingEventTypes, + + topChange: { + phasedRegistrationNames: { + captured: 'onChangeCapture', + bubbled: 'onChange', + }, + }, + + topValueChange: { + phasedRegistrationNames: { + captured: 'onValueChangeCapture', + bubbled: 'onValueChange', + }, + }, + }, + + directEventTypes: { + ...ReactNativeViewViewConfig.directEventTypes, + + topSlidingComplete: { + registrationName: 'onSlidingComplete', + }, + }, + + validAttributes: { + ...ReactNativeViewViewConfig.validAttributes, + disabled: true, + enabled: true, + maximumTrackImage: { process: require('resolveAssetSource') }, + maximumTrackTintColor: { process: require('processColor') }, + maximumValue: true, + minimumTrackImage: { process: require('resolveAssetSource') }, + minimumTrackTintColor: { process: require('processColor') }, + minimumValue: true, + step: true, + testID: true, + thumbImage: { process: require('resolveAssetSource') }, + thumbTintColor: { process: require('processColor') }, + trackImage: { process: require('resolveAssetSource') }, + value: true, + onChange: true, + onValueChange: true, + onSlidingComplete: true, + }, +}; + +verifyComponentAttributeEquivalence('RCTSlider', SliderViewConfig); + +ReactNativeViewConfigRegistry.register( + 'RCTSlider', + () => SliderViewConfig, +); + +module.exports = 'RCTSlider'; // RCT prefix present for paper support diff --git a/Libraries/Components/Slider/SliderSchema.js b/Libraries/Components/Slider/SliderSchema.js index f3e75ad491a..32d954ca9cc 100644 --- a/Libraries/Components/Slider/SliderSchema.js +++ b/Libraries/Components/Slider/SliderSchema.js @@ -18,6 +18,7 @@ const SliderSchema: SchemaType = { components: { Slider: { interfaceOnly: true, + isDeprecatedPaperComponentNameRCT: true, extendsProps: [ { type: 'ReactNativeBuiltInType', diff --git a/packages/react-native-codegen/src/cli/viewconfigs/generate-view-configs-cli.js b/packages/react-native-codegen/src/cli/viewconfigs/generate-view-configs-cli.js index 68fc84cb1f8..eccf262a8d6 100644 --- a/packages/react-native-codegen/src/cli/viewconfigs/generate-view-configs-cli.js +++ b/packages/react-native-codegen/src/cli/viewconfigs/generate-view-configs-cli.js @@ -23,7 +23,7 @@ const yargv = yargs.strict().option('t', { const argv = yargv.argv; const fileList = argv._[0].split('\n'); -const CURRENT_VIEW_CONFIG_FILES = []; +const CURRENT_VIEW_CONFIG_FILES = ['SliderNativeComponent.js']; generate( fileList.filter(fileName =>