UNPKG

react-native-web-internals

Version:

React Native for Web

76 lines (75 loc) 3.03 kB
import normalizeColor from "./compiler/normalizeColor.native.js"; import normalizeValueWithProperty from "./compiler/normalizeValueWithProperty.native.js"; var emptyObject = {}, defaultOffset = { height: 0, width: 0 }, createBoxShadowValue = function (style) { var { shadowColor, shadowOffset, shadowOpacity, shadowRadius } = style, { height, width } = shadowOffset || defaultOffset, offsetX = normalizeValueWithProperty(width), offsetY = normalizeValueWithProperty(height), blurRadius = normalizeValueWithProperty(shadowRadius || 0), color = normalizeColor(shadowColor || "black", shadowOpacity); if (color != null && offsetX != null && offsetY != null && blurRadius != null) return `${offsetX} ${offsetY} ${blurRadius} ${color}`; }, createTextShadowValue = function (style) { var { textShadowColor, textShadowOffset, textShadowRadius } = style, { height, width } = textShadowOffset || defaultOffset, radius = textShadowRadius || 0, offsetX = normalizeValueWithProperty(width), offsetY = normalizeValueWithProperty(height), blurRadius = normalizeValueWithProperty(radius), color = normalizeValueWithProperty(textShadowColor, "textShadowColor"); if (color && (height !== 0 || width !== 0 || radius !== 0) && offsetX != null && offsetY != null && blurRadius != null) return `${offsetX} ${offsetY} ${blurRadius} ${color}`; }, preprocess = function (originalStyle) { var style = originalStyle || emptyObject, nextStyle = {}; for (var originalProp in style) { var originalValue = style[originalProp], prop = originalProp, value = originalValue; if (!(!Object.prototype.hasOwnProperty.call(style, originalProp) || originalValue == null)) { if (prop === "shadowColor" || prop === "shadowOffset" || prop === "shadowOpacity" || prop === "shadowRadius") { var boxShadowValue = createBoxShadowValue(style); if (boxShadowValue != null && nextStyle.boxShadow == null) { var { boxShadow } = style; prop = "boxShadow", value = boxShadow ? `${boxShadow}, ${boxShadowValue}` : boxShadowValue; } else continue; } if (prop === "textShadowColor" || prop === "textShadowOffset" || prop === "textShadowRadius") { var textShadowValue = createTextShadowValue(style); if (textShadowValue != null && nextStyle.textShadow == null) { var { textShadow } = style; prop = "textShadow", value = textShadow ? `${textShadow}, ${textShadowValue}` : textShadowValue; } else continue; } nextStyle[prop] = value; } } return nextStyle; }, processStyle = preprocess; export { createBoxShadowValue, createTextShadowValue, preprocess, processStyle }; //# sourceMappingURL=preprocess.native.js.map