Files
react-native/Libraries/Components/View/ReactNativeStyleAttributes.js
T
Kacie Bawiec 0afd71a18d Convert require to import in Libraries/Components
Summary:
Changelog:
[General][Changed] Convert require statements to use import from in Libraries/Components

Reviewed By: lunaleaps

Differential Revision: D27921557

fbshipit-source-id: 3f1618455a47a56c4a090f3ececfef88476c0b8a
2021-04-26 12:50:59 -07:00

86 lines
3.4 KiB
JavaScript

/**
* 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 strict-local
* @flow
*/
'use strict';
import DeprecatedImageStylePropTypes from '../../DeprecatedPropTypes/DeprecatedImageStylePropTypes';
import DeprecatedTextStylePropTypes from '../../DeprecatedPropTypes/DeprecatedTextStylePropTypes';
import DeprecatedViewStylePropTypes from '../../DeprecatedPropTypes/DeprecatedViewStylePropTypes';
import processColor from '../../StyleSheet/processColor';
import processTransform from '../../StyleSheet/processTransform';
import sizesDiffer from '../../Utilities/differ/sizesDiffer';
type ReturnBoolType = <V>(V) => true;
type BoolifiedDeprecatedViewStylePropTypes = $ObjMap<
typeof DeprecatedViewStylePropTypes,
ReturnBoolType,
>;
type BoolifiedDeprecatedTextStylePropTypes = $ObjMapi<
typeof DeprecatedTextStylePropTypes,
ReturnBoolType,
>;
type BoolifiedDeprecatedImageStylePropTypes = $ObjMapi<
typeof DeprecatedImageStylePropTypes,
ReturnBoolType,
>;
type StyleAttributesType = {
...BoolifiedDeprecatedViewStylePropTypes,
...BoolifiedDeprecatedTextStylePropTypes,
...BoolifiedDeprecatedImageStylePropTypes,
transform: $ReadOnly<{|process: typeof processTransform|}> | true,
shadowOffset: $ReadOnly<{|diff: typeof sizesDiffer|}> | true,
backgroundColor: typeof colorAttributes | true,
borderBottomColor: typeof colorAttributes | true,
borderColor: typeof colorAttributes | true,
borderLeftColor: typeof colorAttributes | true,
borderRightColor: typeof colorAttributes | true,
borderTopColor: typeof colorAttributes | true,
borderStartColor: typeof colorAttributes | true,
borderEndColor: typeof colorAttributes | true,
color: typeof colorAttributes | true,
shadowColor: typeof colorAttributes | true,
textDecorationColor: typeof colorAttributes | true,
tintColor: typeof colorAttributes | true,
textShadowColor: typeof colorAttributes | true,
overlayColor: typeof colorAttributes | true,
...
};
const ReactNativeStyleAttributes: StyleAttributesType = {};
for (const attributeName of Object.keys({
...DeprecatedViewStylePropTypes,
...DeprecatedTextStylePropTypes,
...DeprecatedImageStylePropTypes,
})) {
ReactNativeStyleAttributes[attributeName] = true;
}
ReactNativeStyleAttributes.transform = {process: processTransform};
ReactNativeStyleAttributes.shadowOffset = {diff: sizesDiffer};
const colorAttributes = {process: processColor};
ReactNativeStyleAttributes.backgroundColor = colorAttributes;
ReactNativeStyleAttributes.borderBottomColor = colorAttributes;
ReactNativeStyleAttributes.borderColor = colorAttributes;
ReactNativeStyleAttributes.borderLeftColor = colorAttributes;
ReactNativeStyleAttributes.borderRightColor = colorAttributes;
ReactNativeStyleAttributes.borderTopColor = colorAttributes;
ReactNativeStyleAttributes.borderStartColor = colorAttributes;
ReactNativeStyleAttributes.borderEndColor = colorAttributes;
ReactNativeStyleAttributes.color = colorAttributes;
ReactNativeStyleAttributes.shadowColor = colorAttributes;
ReactNativeStyleAttributes.textDecorationColor = colorAttributes;
ReactNativeStyleAttributes.tintColor = colorAttributes;
ReactNativeStyleAttributes.textShadowColor = colorAttributes;
ReactNativeStyleAttributes.overlayColor = colorAttributes;
module.exports = ReactNativeStyleAttributes;