UNPKG

react-native-week-schedule-1

Version:
31 lines (30 loc) 995 B
"use strict"; import { memo, useCallback, useMemo } from "react"; import { getStyles } from "./styles.js"; import { View } from "react-native"; import { GridRow } from "../gridRow/index.js"; import { getTime } from "../../utils/getTime.js"; import { jsx as _jsx } from "react/jsx-runtime"; export const Grid = /*#__PURE__*/memo(({ hours, dates, onSlotPress }) => { const styles = useMemo(() => getStyles(), []); const handleOnSlotPress = useMemo(() => !onSlotPress ? undefined : value => { onSlotPress({ ...value, date: dates ? `${dates[value.day]?.split('T')[0]}T${getTime(value.time)}:00:00.604Z` : undefined }); }, [dates, onSlotPress]); const renderItem = useCallback((item, index) => /*#__PURE__*/_jsx(GridRow, { item: item, index: index, onPress: handleOnSlotPress }, item), [handleOnSlotPress]); return /*#__PURE__*/_jsx(View, { style: styles.container, children: hours.map(renderItem) }); }); //# sourceMappingURL=index.js.map