UNPKG

react-native-week-schedule-1

Version:
73 lines (72 loc) 2.31 kB
"use strict"; import { useMemo } from "react"; import { View } from "react-native"; import { getStyles } from "./styles.js"; import { findConflicts } from "../../utils/findConflicts.js"; import { Item } from "../item/index.js"; import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime"; ; export function Content({ data, currentItem, dataKey, titleKey, scrollY, contentHeight, onDataPress, scrollOnDrag, onDragEnd, renderItem }) { const styles = useMemo(() => getStyles(), []); const overlappingIds = useMemo(() => { const formattedSessions = {}; data.forEach((localItem, _, array) => { const conflicts = findConflicts(localItem, array.filter(item => item?.[dataKey] !== localItem?.[dataKey])); const conflictsOfConflicts = conflicts.map(item => findConflicts(item, array.filter(arrayItem => arrayItem?.[dataKey] !== localItem?.[dataKey]))).flat(); conflicts.push(...conflictsOfConflicts); if (conflicts.length) { const uniqConflicts = [...new Set(conflicts.map(item => item?.[dataKey]))]; formattedSessions[`${localItem?.[dataKey]}`] = [localItem?.[dataKey], ...uniqConflicts]; } ; }); return formattedSessions; }, [data, dataKey]); return /*#__PURE__*/_jsx(View, { style: styles.container, pointerEvents: "box-none", children: data?.map(item => renderItem ? /*#__PURE__*/_jsx(RenderWrapper, { children: renderItem({ overlappingIds: overlappingIds[item?.[dataKey]] || [], titleKey: titleKey, dataKey: dataKey, item: item, currentItem: currentItem, scrollY: scrollY, contentHeight: contentHeight, onPress: onDataPress, scrollOnDrag: scrollOnDrag, onDragEnd: onDragEnd }) }, item?.[dataKey]) : /*#__PURE__*/_jsx(Item, { overlappingIds: overlappingIds[item?.[dataKey]] || [], titleKey: titleKey, dataKey: dataKey, item: item, currentItem: currentItem, scrollY: scrollY, contentHeight: contentHeight, onPress: onDataPress, scrollOnDrag: scrollOnDrag, onDragEnd: onDragEnd }, item?.[dataKey])) }); } ; const RenderWrapper = ({ children }) => /*#__PURE__*/_jsx(_Fragment, { children: children }); //# sourceMappingURL=index.js.map