one
Version:
One is a React framework for web, iOS, and Android apps.
94 lines (93 loc) • 3.38 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all) __defProp(target, name, {
get: all[name],
enumerable: true
});
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: () => from[key],
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var normalize_exports = {};
__export(normalize_exports, {
DEFAULT_CURVE: () => DEFAULT_CURVE,
flattenStyle: () => flattenStyle,
resolveEdges: () => resolveEdges,
resolveRadius: () => resolveRadius
});
module.exports = __toCommonJS(normalize_exports);
const DEFAULT_SIZE = 80;
const DEFAULT_CURVE = "smooth";
const DEFAULT_BLUR_RADIUS = 28;
function resolveEdge(prop, size, curve) {
if (!prop) return null;
if (prop === true) return {
size,
curve
};
if (typeof prop === "number") return {
size: prop,
curve
};
if (typeof prop === "object" && prop !== null && (prop.size != null || prop.curve != null || prop.color != null)) {
return {
size: prop.size ?? size,
curve: prop.curve ?? curve,
color: prop.color
};
}
return null;
}
function resolveEdges(props, isRTL) {
const size = props.size ?? DEFAULT_SIZE;
const curve = props.curve ?? DEFAULT_CURVE;
const leftLogical = isRTL ? props.end : props.start;
const rightLogical = isRTL ? props.start : props.end;
const top = resolveEdge(props.top, size, curve);
const bottom = resolveEdge(props.bottom, size, curve);
const left = resolveEdge(leftLogical ?? props.left, size, curve);
const right = resolveEdge(rightLogical ?? props.right, size, curve);
const hasColor = props.color != null || top?.color != null || bottom?.color != null || left?.color != null || right?.color != null;
const mode = props.mode ?? (hasColor ? "overlay" : "mask");
if (hasColor && props.mode === "mask") {
console.warn("[EdgeFade] `color` is ignored when `mode=\"mask\"` is set explicitly. either remove `color` or switch to `mode=\"overlay\"`.");
}
if (props.mode === "blur" && (top?.color != null || bottom?.color != null || left?.color != null || right?.color != null)) {
console.warn("[EdgeFade] per-edge `color` is ignored in blur mode: the frost veil uses the global `color` only.");
}
return {
top,
bottom,
left,
right,
mode,
color: props.color,
blurRadius: Math.max(0, props.blurRadius ?? DEFAULT_BLUR_RADIUS),
frostProgression: Math.max(.05, Math.min(1, props.frostProgression ?? 1))
};
}
function resolveRadius(radius, styleRadius) {
if (styleRadius != null) {
console.warn("[EdgeFade] `style.borderRadius` is ignored — use the `radius` prop instead so the corner clip integrates with the fade.");
}
return radius;
}
function flattenStyle(style) {
const into = {};
mergeStyle(style, into);
return into;
}
function mergeStyle(entry, into) {
if (Array.isArray(entry)) for (const inner of entry) mergeStyle(inner, into);
else if (entry && typeof entry === "object") Object.assign(into, entry);
}