@attio/react-native-bottom-sheet-toolbox
Version:
43 lines (40 loc) • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getSheetPositionValue = getSheetPositionValue;
exports.normalizeSheetPosition = normalizeSheetPosition;
var _constants = require("../utils/constants");
var _getPercentageValue = require("../utils/get-percentage-value");
function getSheetPositionValue(value) {
"worklet";
return value !== null && typeof value === "object" && "value" in value ? value.get() : value;
}
function normalizeSheetPosition({
sheetPosition,
childrenHeightSharedValue,
wrapperHeightSharedValue,
footerHeightSharedValue
}) {
"worklet";
const sheetPositionValue = getSheetPositionValue(sheetPosition);
if (sheetPositionValue === _constants.CONTENT_HEIGHT_SNAP_POINT) {
return childrenHeightSharedValue.get();
} else if (sheetPositionValue === _constants.CONTENT_HEIGHT_WITH_OVERLAY_FOOTER_SNAP_POINT) {
const childrenHeight = childrenHeightSharedValue.get();
const footerHeight = footerHeightSharedValue.get();
return childrenHeight === null || footerHeight === null ? null : childrenHeight + footerHeight;
} else if (typeof sheetPositionValue === "number") {
return sheetPositionValue;
} else if (typeof sheetPositionValue === "string" && sheetPositionValue.endsWith("%")) {
const pv = (0, _getPercentageValue.getPercentageValue)(sheetPositionValue);
if (pv !== null) {
const wrapperHeight = wrapperHeightSharedValue.get();
return wrapperHeight === null ? null : pv * wrapperHeight;
}
} else if (sheetPositionValue === null) {
return null;
}
throw new Error(`Malformed SheetPosition in bottom-sheet: ${JSON.stringify(sheetPosition)}.`);
}
//# sourceMappingURL=normalize-sheet-position.js.map