react-native-web-internals
Version:
React Native for Web
77 lines (76 loc) • 4.63 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: !0 });
}, __copyProps = (to, from, except, desc) => {
if (from && typeof from == "object" || typeof from == "function")
for (let key of __getOwnPropNames(from))
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
mod
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
var preprocess_exports = {};
__export(preprocess_exports, {
createBoxShadowValue: () => createBoxShadowValue,
createTextShadowValue: () => createTextShadowValue,
preprocess: () => preprocess,
processStyle: () => processStyle
});
module.exports = __toCommonJS(preprocess_exports);
var import_normalizeColor = __toESM(require("./compiler/normalizeColor")), import_normalizeValueWithProperty = __toESM(require("./compiler/normalizeValueWithProperty")), emptyObject = {}, defaultOffset = {
height: 0,
width: 0
}, createBoxShadowValue = function(style) {
var { shadowColor, shadowOffset, shadowOpacity, shadowRadius } = style, { height, width } = shadowOffset || defaultOffset, offsetX = (0, import_normalizeValueWithProperty.default)(width), offsetY = (0, import_normalizeValueWithProperty.default)(height), blurRadius = (0, import_normalizeValueWithProperty.default)(shadowRadius || 0), color = (0, import_normalizeColor.default)(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 = (0, import_normalizeValueWithProperty.default)(width), offsetY = (0, import_normalizeValueWithProperty.default)(height), blurRadius = (0, import_normalizeValueWithProperty.default)(radius), color = (0, import_normalizeValueWithProperty.default)(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;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
createBoxShadowValue,
createTextShadowValue,
preprocess,
processStyle
});
//# sourceMappingURL=preprocess.js.map