UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

117 lines (115 loc) • 4.98 kB
"use strict"; 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); var DEFAULT_SIZE = 80; var DEFAULT_CURVE = "smooth"; var 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)) { var _prop_size, _prop_curve; return { size: (_prop_size = prop.size) !== null && _prop_size !== void 0 ? _prop_size : size, curve: (_prop_curve = prop.curve) !== null && _prop_curve !== void 0 ? _prop_curve : curve, color: prop.color }; } return null; } function resolveEdges(props, isRTL) { var _props_size, _props_curve, _props_mode, _props_blurRadius, _props_frostProgression; var size = (_props_size = props.size) !== null && _props_size !== void 0 ? _props_size : DEFAULT_SIZE; var curve = (_props_curve = props.curve) !== null && _props_curve !== void 0 ? _props_curve : DEFAULT_CURVE; var leftLogical = isRTL ? props.end : props.start; var rightLogical = isRTL ? props.start : props.end; var top = resolveEdge(props.top, size, curve); var bottom = resolveEdge(props.bottom, size, curve); var left = resolveEdge(leftLogical !== null && leftLogical !== void 0 ? leftLogical : props.left, size, curve); var right = resolveEdge(rightLogical !== null && rightLogical !== void 0 ? rightLogical : props.right, size, curve); var hasColor = props.color != null || (top === null || top === void 0 ? void 0 : top.color) != null || (bottom === null || bottom === void 0 ? void 0 : bottom.color) != null || (left === null || left === void 0 ? void 0 : left.color) != null || (right === null || right === void 0 ? void 0 : right.color) != null; var mode = (_props_mode = props.mode) !== null && _props_mode !== void 0 ? _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 === null || top === void 0 ? void 0 : top.color) != null || (bottom === null || bottom === void 0 ? void 0 : bottom.color) != null || (left === null || left === void 0 ? void 0 : left.color) != null || (right === null || right === void 0 ? void 0 : 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 = props.blurRadius) !== null && _props_blurRadius !== void 0 ? _props_blurRadius : DEFAULT_BLUR_RADIUS), frostProgression: Math.max(.05, Math.min(1, (_props_frostProgression = props.frostProgression) !== null && _props_frostProgression !== void 0 ? _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) { var into = {}; mergeStyle(style, into); return into; } function mergeStyle(entry, into) { var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0; if (Array.isArray(entry)) try { for (var _iterator = entry[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var inner = _step.value; mergeStyle(inner, into); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } else if (entry && typeof entry === "object") Object.assign(into, entry); }