@super-calendar/native 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -378,7 +378,7 @@ const styles$2 = StyleSheet.create({
378
378
  });
379
379
  //#endregion
380
380
  //#region src/components/TimeGrid.tsx
381
- const isWeb = Platform.OS === "web";
381
+ const isWeb$1 = Platform.OS === "web";
382
382
  const MINUTES_PER_HOUR$1 = 60;
383
383
  const HOURS_PER_DAY = 24;
384
384
  const MINUTES_PER_DAY = MINUTES_PER_HOUR$1 * HOURS_PER_DAY;
@@ -393,7 +393,7 @@ const MIN_EVENT_HEIGHT = 32;
393
393
  const EVENT_GAP = 2;
394
394
  const DRAG_ACTIVATE_MS = 300;
395
395
  const MOVE_ACTIVATE_MS$1 = 500;
396
- const DRAG_ACTIVATE_PX = 8;
396
+ const DRAG_ACTIVATE_PX$1 = 8;
397
397
  const RESIZE_HANDLE_HEIGHT = 14;
398
398
  const DEFAULT_DRAG_STEP_MINUTES = 15;
399
399
  const HOUR_LABEL_TOP_INSET = 12;
@@ -492,7 +492,7 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
492
492
  const totalDelta = minuteDelta + dayDelta * MINUTES_PER_DAY;
493
493
  runOnJS(commitDrag)(totalDelta, totalDelta);
494
494
  });
495
- return isWeb ? pan.activeOffsetX([-8, DRAG_ACTIVATE_PX]).activeOffsetY([-8, DRAG_ACTIVATE_PX]) : pan.activateAfterLongPress(MOVE_ACTIVATE_MS$1);
495
+ return isWeb$1 ? pan.activeOffsetX([-8, DRAG_ACTIVATE_PX$1]).activeOffsetY([-8, DRAG_ACTIVATE_PX$1]) : pan.activateAfterLongPress(MOVE_ACTIVATE_MS$1);
496
496
  }, [
497
497
  draggable,
498
498
  snapMinutes,
@@ -708,14 +708,14 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
708
708
  },
709
709
  onEndDrag: (event) => {
710
710
  isDragging.value = false;
711
- if (!isWeb && isActiveShared.value) {
711
+ if (!isWeb$1 && isActiveShared.value) {
712
712
  scrollY.value = event.contentOffset.y;
713
713
  runOnJS(onSettleOffset)(event.contentOffset.y);
714
714
  }
715
715
  },
716
716
  onMomentumEnd: (event) => {
717
717
  isDragging.value = false;
718
- if (!isWeb && isActiveShared.value) {
718
+ if (!isWeb$1 && isActiveShared.value) {
719
719
  scrollY.value = event.contentOffset.y;
720
720
  runOnJS(onSettleOffset)(event.contentOffset.y);
721
721
  }
@@ -725,7 +725,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
725
725
  if (!isActiveShared.value && current !== previous) scrollTo(scrollRef, 0, current, false);
726
726
  });
727
727
  useAnimatedReaction(() => isActiveShared.value, (active, previous) => {
728
- if (isWeb || !active || active === previous) return;
728
+ if (isWeb$1 || !active || active === previous) return;
729
729
  scrollTo(scrollRef, 0, scrollY.value, false);
730
730
  });
731
731
  const days = useMemo(() => getViewDays$1(mode, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn), [
@@ -848,7 +848,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
848
848
  if (createCancelled.value) return;
849
849
  runOnJS(commitCreate)(createStartY.value, createStartY.value + event.translationY, createDayIndex.value);
850
850
  });
851
- return isWeb ? pan.activeOffsetY([-8, DRAG_ACTIVATE_PX]) : pan.activateAfterLongPress(DRAG_ACTIVATE_MS);
851
+ return isWeb$1 ? pan.activeOffsetY([-8, DRAG_ACTIVATE_PX$1]) : pan.activateAfterLongPress(DRAG_ACTIVATE_MS);
852
852
  }, [
853
853
  createEnabled,
854
854
  dayCount,
@@ -867,7 +867,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
867
867
  createCancelled
868
868
  ]);
869
869
  const backgroundGesture = useMemo(() => {
870
- const tap = isWeb && onPressCell != null ? Gesture.Tap().onEnd((event) => {
870
+ const tap = isWeb$1 && onPressCell != null ? Gesture.Tap().onEnd((event) => {
871
871
  runOnJS(tapCell)(event.x, event.y);
872
872
  }) : null;
873
873
  if (createEnabled && tap) return Gesture.Exclusive(createGesture, tap);
@@ -880,7 +880,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
880
880
  tapCell
881
881
  ]);
882
882
  useEffect(() => {
883
- if (!isWeb || !createEnabled) return;
883
+ if (!isWeb$1 || !createEnabled) return;
884
884
  const doc = globalThis.document;
885
885
  if (!doc) return;
886
886
  const handler = (event) => {
@@ -1086,7 +1086,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1086
1086
  offsetSeedRef.current = y;
1087
1087
  }, []);
1088
1088
  const committedCellHeight = useSharedValue(hourHeight);
1089
- useWebGridZoom(isWeb, containerRef, cellHeight, committedCellHeight, minHourHeight, maxHourHeight);
1089
+ useWebGridZoom(isWeb$1, containerRef, cellHeight, committedCellHeight, minHourHeight, maxHourHeight);
1090
1090
  const [anchorDate] = useState(date);
1091
1091
  const anchor = useMemo(() => weekAnchored ? startOfWeek(anchorDate, { weekStartsOn }) : startOfDay(anchorDate), [
1092
1092
  weekAnchored,
@@ -1116,7 +1116,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1116
1116
  weekEndsOn
1117
1117
  ]);
1118
1118
  const handleViewableItemsChanged = useCallback((info) => {
1119
- if (isWeb) return;
1119
+ if (isWeb$1) return;
1120
1120
  const settled = info.viewableItems.find((token) => token.isViewable);
1121
1121
  if (settled?.index == null) return;
1122
1122
  if (pendingScrollIndexRef.current != null) {
@@ -1140,7 +1140,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1140
1140
  });
1141
1141
  }, [activeIndex]);
1142
1142
  useEffect(() => {
1143
- if (!isWeb) return;
1143
+ if (!isWeb$1) return;
1144
1144
  const root = containerRef.current;
1145
1145
  if (!root) return;
1146
1146
  const restoreVisiblePage = () => {
@@ -1167,7 +1167,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1167
1167
  };
1168
1168
  }, [activeIndex, pageHeight]);
1169
1169
  useEffect(() => {
1170
- if (!isWeb) return;
1170
+ if (!isWeb$1) return;
1171
1171
  const root = containerRef.current;
1172
1172
  if (!root) return;
1173
1173
  const onScrollCapture = (event) => {
@@ -1184,7 +1184,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1184
1184
  return () => root.removeEventListener("scroll", onScrollCapture, true);
1185
1185
  }, []);
1186
1186
  useEffect(() => {
1187
- if (!isWeb) return;
1187
+ if (!isWeb$1) return;
1188
1188
  const root = containerRef.current;
1189
1189
  if (!root) return;
1190
1190
  const lockHorizontal = () => {
@@ -1350,14 +1350,14 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1350
1350
  },
1351
1351
  children: /* @__PURE__ */ jsx(LegendList, {
1352
1352
  ref: listRef,
1353
- style: isWeb ? [styles$1.pagerList, styles$1.webNoScroll] : styles$1.pagerList,
1353
+ style: isWeb$1 ? [styles$1.pagerList, styles$1.webNoScroll] : styles$1.pagerList,
1354
1354
  data: pageDates,
1355
1355
  extraData: listExtraData,
1356
1356
  horizontal: true,
1357
1357
  recycleItems: false,
1358
1358
  keyExtractor: keyExtractorList,
1359
1359
  getFixedItemSize,
1360
- ...isWeb ? null : {
1360
+ ...isWeb$1 ? null : {
1361
1361
  scrollEnabled: swipeEnabled,
1362
1362
  pagingEnabled: !freeSwipe,
1363
1363
  snapToIndices: freeSwipe ? snapToIndices : void 0
@@ -1771,7 +1771,9 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
1771
1771
  //#endregion
1772
1772
  //#region src/components/ResourceTimeline.tsx
1773
1773
  const MOVE_ACTIVATE_MS = 250;
1774
+ const DRAG_ACTIVATE_PX = 8;
1774
1775
  const MINUTES_PER_HOUR = 60;
1776
+ const isWeb = Platform.OS === "web";
1775
1777
  const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
1776
1778
  const GUTTER_WIDTH = 56;
1777
1779
  function DefaultBar({ event, width, height }) {
@@ -1804,7 +1806,7 @@ function DefaultBar({ event, width, height }) {
1804
1806
  }) : null]
1805
1807
  });
1806
1808
  }
1807
- function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendererSize, snapMinutes, Renderer, onPress, onDragEvent, theme }) {
1809
+ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendererSize, snapMinutes, Renderer, onPress, onLongPress, onDragEvent, theme }) {
1808
1810
  const moveX = useSharedValue(0);
1809
1811
  const resizeW = useSharedValue(0);
1810
1812
  const latest = useRef({
@@ -1935,6 +1937,7 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
1935
1937
  gesture: moveGesture,
1936
1938
  children: /* @__PURE__ */ jsx(Pressable, {
1937
1939
  onPress,
1940
+ onLongPress,
1938
1941
  accessibilityRole: "button",
1939
1942
  accessibilityLabel: pe.event.title,
1940
1943
  accessibilityActions: barActions,
@@ -1958,6 +1961,115 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
1958
1961
  })]
1959
1962
  });
1960
1963
  }
1964
+ function LaneInteractionLayer({ resource, vertical, hourSize, startHour, date, snapMinutes, onPressCell, onLongPressCell, onCreateEvent, theme }) {
1965
+ const ghostStart = useSharedValue(0);
1966
+ const ghostSize = useSharedValue(0);
1967
+ const ghostVisible = useSharedValue(0);
1968
+ const timeAt = useCallback((px) => cellRangeFromDrag(date, px, px, hourSize, startHour, snapMinutes)?.start, [
1969
+ date,
1970
+ hourSize,
1971
+ startHour,
1972
+ snapMinutes
1973
+ ]);
1974
+ const commitCreate = useCallback((fromPx, toPx) => {
1975
+ const range = cellRangeFromDrag(date, fromPx, toPx, hourSize, startHour, snapMinutes);
1976
+ if (range) onCreateEvent?.(range.start, range.end, resource);
1977
+ }, [
1978
+ date,
1979
+ hourSize,
1980
+ startHour,
1981
+ snapMinutes,
1982
+ onCreateEvent,
1983
+ resource
1984
+ ]);
1985
+ const pressAt = useCallback((px) => {
1986
+ const at = timeAt(px);
1987
+ if (at) onPressCell?.(at, resource);
1988
+ }, [
1989
+ timeAt,
1990
+ onPressCell,
1991
+ resource
1992
+ ]);
1993
+ const laneGesture = useMemo(() => {
1994
+ const pan = onCreateEvent ? Gesture.Pan().onStart((e) => {
1995
+ ghostStart.value = vertical ? e.y : e.x;
1996
+ ghostSize.value = 0;
1997
+ ghostVisible.value = 1;
1998
+ }).onUpdate((e) => {
1999
+ ghostSize.value = (vertical ? e.y : e.x) - ghostStart.value;
2000
+ }).onEnd((e, success) => {
2001
+ ghostVisible.value = 0;
2002
+ if (success) runOnJS(commitCreate)(ghostStart.value, vertical ? e.y : e.x);
2003
+ }).onFinalize(() => {
2004
+ ghostVisible.value = 0;
2005
+ }) : null;
2006
+ const activatedPan = pan ? isWeb ? vertical ? pan.activeOffsetY([-8, DRAG_ACTIVATE_PX]) : pan.activeOffsetX([-8, DRAG_ACTIVATE_PX]) : pan.activateAfterLongPress(MOVE_ACTIVATE_MS) : null;
2007
+ const tap = isWeb && onPressCell ? Gesture.Tap().onEnd((e) => {
2008
+ runOnJS(pressAt)(vertical ? e.y : e.x);
2009
+ }) : null;
2010
+ if (activatedPan && tap) return Gesture.Exclusive(activatedPan, tap);
2011
+ return activatedPan ?? tap;
2012
+ }, [
2013
+ onCreateEvent,
2014
+ onPressCell,
2015
+ vertical,
2016
+ commitCreate,
2017
+ pressAt,
2018
+ ghostStart,
2019
+ ghostSize,
2020
+ ghostVisible
2021
+ ]);
2022
+ const ghostStyle = useAnimatedStyle(() => {
2023
+ const stepPx = snapMinutes / MINUTES_PER_HOUR * hourSize;
2024
+ const snap = (v) => stepPx > 0 ? Math.round(v / stepPx) * stepPx : v;
2025
+ const a = snap(ghostStart.value);
2026
+ const b = snap(ghostStart.value + ghostSize.value);
2027
+ const from = Math.min(a, b);
2028
+ const size = Math.max(Math.abs(b - a), 2);
2029
+ return vertical ? {
2030
+ opacity: ghostVisible.value,
2031
+ top: from,
2032
+ height: size
2033
+ } : {
2034
+ opacity: ghostVisible.value,
2035
+ left: from,
2036
+ width: size
2037
+ };
2038
+ }, [
2039
+ vertical,
2040
+ hourSize,
2041
+ snapMinutes
2042
+ ]);
2043
+ const pxOf = (e) => vertical ? e.nativeEvent.locationY : e.nativeEvent.locationX;
2044
+ const handlePress = onPressCell ? (e) => pressAt(pxOf(e)) : void 0;
2045
+ const handleLongPress = onLongPressCell && !onCreateEvent ? (e) => {
2046
+ const at = timeAt(pxOf(e));
2047
+ if (at) onLongPressCell(at, resource);
2048
+ } : void 0;
2049
+ const layer = /* @__PURE__ */ jsx(Pressable, {
2050
+ testID: "resource-cell-layer",
2051
+ style: StyleSheet.absoluteFill,
2052
+ onPress: handlePress,
2053
+ onLongPress: handleLongPress,
2054
+ accessibilityElementsHidden: true,
2055
+ importantForAccessibility: "no"
2056
+ });
2057
+ return /* @__PURE__ */ jsxs(Fragment, { children: [laneGesture ? /* @__PURE__ */ jsx(GestureDetector, {
2058
+ gesture: laneGesture,
2059
+ children: layer
2060
+ }) : layer, onCreateEvent ? /* @__PURE__ */ jsx(Animated.View, {
2061
+ testID: "resource-create-ghost",
2062
+ pointerEvents: "none",
2063
+ style: [
2064
+ vertical ? styles.vcreateGhost : styles.hcreateGhost,
2065
+ {
2066
+ backgroundColor: theme.colors.eventBackground,
2067
+ borderColor: theme.colors.todayBackground
2068
+ },
2069
+ ghostStyle
2070
+ ]
2071
+ }) : null] });
2072
+ }
1961
2073
  /**
1962
2074
  * A horizontal resource timeline: rows are resources (rooms, people, machines)
1963
2075
  * and the x-axis is one day's hours. Events sit in their resource's row, and
@@ -1976,9 +2088,11 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
1976
2088
  * />
1977
2089
  * ```
1978
2090
  */
1979
- function ResourceTimeline({ date, orientation = "horizontal", resources, events, resourceId = (event) => event.resourceId, startHour = 0, endHour = 24, hourWidth = 80, hourHeight = 48, rowHeight = 56, labelWidth = 140, ampm = false, renderEvent, onPressEvent, onDragEvent, dragStepMinutes = 15 }) {
2091
+ function ResourceTimeline({ date, orientation = "horizontal", resources, events, resourceId = (event) => event.resourceId, startHour = 0, endHour = 24, hourWidth = 80, hourHeight = 48, rowHeight = 56, labelWidth = 140, ampm = false, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, businessHours, dragStepMinutes = 15 }) {
1980
2092
  const theme = useCalendarTheme();
1981
2093
  const Renderer = renderEvent ?? DefaultBar;
2094
+ const cellEnabled = !!onPressCell || !!onLongPressCell || !!onCreateEvent;
2095
+ const bandsFor = (resource) => businessHours ? closedHourBands(date, (d) => businessHours(d, resource), startHour, endHour) : [];
1982
2096
  const hours = useMemo(() => Array.from({ length: Math.max(0, endHour - startHour) }, (_, i) => startHour + i), [startHour, endHour]);
1983
2097
  const trackWidth = (endHour - startHour) * hourWidth;
1984
2098
  const byResource = useMemo(() => {
@@ -2031,58 +2145,84 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2031
2145
  { borderLeftColor: theme.colors.gridLine },
2032
2146
  theme.containers.resourceRow
2033
2147
  ],
2034
- children: [hours.slice(1).map((h) => /* @__PURE__ */ jsx(View, {
2035
- pointerEvents: "none",
2036
- style: [styles.vgridLine, {
2037
- top: (h - startHour) * hourHeight,
2038
- backgroundColor: theme.colors.gridLine
2039
- }]
2040
- }, h)), positioned.map((pe, idx) => {
2041
- const top = clamp(pe.startHours - startHour, 0, endHour - startHour) * hourHeight;
2042
- const bottomPx = clamp(pe.startHours + pe.durationHours - startHour, 0, endHour - startHour) * hourHeight;
2043
- const height = Math.max(bottomPx - top, 2);
2044
- const lanePct = 100 / pe.columns;
2045
- const left = `${pe.column * lanePct}%`;
2046
- const width = `${lanePct}%`;
2047
- const onPress = () => onPressEvent?.(pe.event);
2048
- if (onDragEvent) return /* @__PURE__ */ jsx(ResourceBar, {
2049
- pe,
2148
+ children: [
2149
+ bandsFor(resource).map((b) => /* @__PURE__ */ jsx(View, {
2150
+ pointerEvents: "none",
2151
+ testID: "resource-hours-shade",
2152
+ style: [styles.vshadeBand, {
2153
+ top: (b.start - startHour) * hourHeight,
2154
+ height: (b.end - b.start) * hourHeight,
2155
+ backgroundColor: theme.colors.outsideHoursBackground
2156
+ }]
2157
+ }, `shade-${b.start}`)),
2158
+ hours.slice(1).map((h) => /* @__PURE__ */ jsx(View, {
2159
+ pointerEvents: "none",
2160
+ style: [styles.vgridLine, {
2161
+ top: (h - startHour) * hourHeight,
2162
+ backgroundColor: theme.colors.gridLine
2163
+ }]
2164
+ }, h)),
2165
+ cellEnabled ? /* @__PURE__ */ jsx(LaneInteractionLayer, {
2166
+ resource,
2050
2167
  vertical: true,
2051
2168
  hourSize: hourHeight,
2052
- left,
2053
- top,
2054
- width,
2055
- height,
2056
- rendererSize: {
2057
- width: 0,
2058
- height
2059
- },
2169
+ startHour,
2170
+ date,
2060
2171
  snapMinutes: dragStepMinutes,
2061
- Renderer,
2062
- onPress,
2063
- onDragEvent,
2172
+ onPressCell,
2173
+ onLongPressCell,
2174
+ onCreateEvent,
2064
2175
  theme
2065
- }, idx);
2066
- return /* @__PURE__ */ jsx(Pressable, {
2067
- onPress,
2068
- accessibilityRole: "button",
2069
- accessibilityLabel: pe.event.title,
2070
- style: {
2071
- position: "absolute",
2176
+ }) : null,
2177
+ positioned.map((pe, idx) => {
2178
+ const top = clamp(pe.startHours - startHour, 0, endHour - startHour) * hourHeight;
2179
+ const bottomPx = clamp(pe.startHours + pe.durationHours - startHour, 0, endHour - startHour) * hourHeight;
2180
+ const height = Math.max(bottomPx - top, 2);
2181
+ const lanePct = 100 / pe.columns;
2182
+ const left = `${pe.column * lanePct}%`;
2183
+ const width = `${lanePct}%`;
2184
+ const onPress = () => onPressEvent?.(pe.event);
2185
+ if (onDragEvent) return /* @__PURE__ */ jsx(ResourceBar, {
2186
+ pe,
2187
+ vertical: true,
2188
+ hourSize: hourHeight,
2072
2189
  left,
2073
- width,
2074
2190
  top,
2191
+ width,
2075
2192
  height,
2076
- padding: 1
2077
- },
2078
- children: /* @__PURE__ */ jsx(Renderer, {
2079
- event: pe.event,
2080
- width: 0,
2081
- height,
2082
- onPress
2083
- })
2084
- }, idx);
2085
- })]
2193
+ rendererSize: {
2194
+ width: 0,
2195
+ height
2196
+ },
2197
+ snapMinutes: dragStepMinutes,
2198
+ Renderer,
2199
+ onPress,
2200
+ onLongPress: onLongPressEvent ? () => onLongPressEvent(pe.event) : void 0,
2201
+ onDragEvent,
2202
+ theme
2203
+ }, idx);
2204
+ return /* @__PURE__ */ jsx(Pressable, {
2205
+ onPress,
2206
+ onLongPress: onLongPressEvent ? () => onLongPressEvent(pe.event) : void 0,
2207
+ accessibilityRole: "button",
2208
+ accessibilityLabel: pe.event.title,
2209
+ style: {
2210
+ position: "absolute",
2211
+ left,
2212
+ width,
2213
+ top,
2214
+ height,
2215
+ padding: 1
2216
+ },
2217
+ children: /* @__PURE__ */ jsx(Renderer, {
2218
+ event: pe.event,
2219
+ width: 0,
2220
+ height,
2221
+ onPress
2222
+ })
2223
+ }, idx);
2224
+ })
2225
+ ]
2086
2226
  }, resource.id);
2087
2227
  })]
2088
2228
  })
@@ -2139,52 +2279,78 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2139
2279
  })
2140
2280
  }), /* @__PURE__ */ jsxs(View, {
2141
2281
  style: { width: trackWidth },
2142
- children: [hours.slice(1).map((h) => /* @__PURE__ */ jsx(View, {
2143
- pointerEvents: "none",
2144
- style: [styles.gridLine, {
2145
- left: (h - startHour) * hourWidth,
2146
- backgroundColor: theme.colors.gridLine
2147
- }]
2148
- }, h)), positioned.map((pe, idx) => {
2149
- const left = clamp(pe.startHours - startHour, 0, endHour - startHour) * hourWidth;
2150
- const right = clamp(pe.startHours + pe.durationHours - startHour, 0, endHour - startHour) * hourWidth;
2151
- const width = Math.max(right - left, 2);
2152
- const laneHeight = rowHeight / pe.columns;
2153
- const onPress = () => onPressEvent?.(pe.event);
2154
- if (onDragEvent) return /* @__PURE__ */ jsx(ResourceBar, {
2155
- pe,
2282
+ children: [
2283
+ bandsFor(resource).map((b) => /* @__PURE__ */ jsx(View, {
2284
+ pointerEvents: "none",
2285
+ testID: "resource-hours-shade",
2286
+ style: [styles.hshadeBand, {
2287
+ left: (b.start - startHour) * hourWidth,
2288
+ width: (b.end - b.start) * hourWidth,
2289
+ backgroundColor: theme.colors.outsideHoursBackground
2290
+ }]
2291
+ }, `shade-${b.start}`)),
2292
+ hours.slice(1).map((h) => /* @__PURE__ */ jsx(View, {
2293
+ pointerEvents: "none",
2294
+ style: [styles.gridLine, {
2295
+ left: (h - startHour) * hourWidth,
2296
+ backgroundColor: theme.colors.gridLine
2297
+ }]
2298
+ }, h)),
2299
+ cellEnabled ? /* @__PURE__ */ jsx(LaneInteractionLayer, {
2300
+ resource,
2156
2301
  vertical: false,
2157
2302
  hourSize: hourWidth,
2158
- left,
2159
- top: pe.column * laneHeight,
2160
- width,
2161
- height: laneHeight,
2162
- rendererSize: { width },
2303
+ startHour,
2304
+ date,
2163
2305
  snapMinutes: dragStepMinutes,
2164
- Renderer,
2165
- onPress,
2166
- onDragEvent,
2306
+ onPressCell,
2307
+ onLongPressCell,
2308
+ onCreateEvent,
2167
2309
  theme
2168
- }, idx);
2169
- return /* @__PURE__ */ jsx(Pressable, {
2170
- onPress,
2171
- accessibilityRole: "button",
2172
- accessibilityLabel: pe.event.title,
2173
- style: {
2174
- position: "absolute",
2310
+ }) : null,
2311
+ positioned.map((pe, idx) => {
2312
+ const left = clamp(pe.startHours - startHour, 0, endHour - startHour) * hourWidth;
2313
+ const right = clamp(pe.startHours + pe.durationHours - startHour, 0, endHour - startHour) * hourWidth;
2314
+ const width = Math.max(right - left, 2);
2315
+ const laneHeight = rowHeight / pe.columns;
2316
+ const onPress = () => onPressEvent?.(pe.event);
2317
+ if (onDragEvent) return /* @__PURE__ */ jsx(ResourceBar, {
2318
+ pe,
2319
+ vertical: false,
2320
+ hourSize: hourWidth,
2175
2321
  left,
2176
- width,
2177
2322
  top: pe.column * laneHeight,
2178
- height: laneHeight,
2179
- padding: 1
2180
- },
2181
- children: /* @__PURE__ */ jsx(Renderer, {
2182
- event: pe.event,
2183
2323
  width,
2184
- onPress
2185
- })
2186
- }, idx);
2187
- })]
2324
+ height: laneHeight,
2325
+ rendererSize: { width },
2326
+ snapMinutes: dragStepMinutes,
2327
+ Renderer,
2328
+ onPress,
2329
+ onLongPress: onLongPressEvent ? () => onLongPressEvent(pe.event) : void 0,
2330
+ onDragEvent,
2331
+ theme
2332
+ }, idx);
2333
+ return /* @__PURE__ */ jsx(Pressable, {
2334
+ onPress,
2335
+ onLongPress: onLongPressEvent ? () => onLongPressEvent(pe.event) : void 0,
2336
+ accessibilityRole: "button",
2337
+ accessibilityLabel: pe.event.title,
2338
+ style: {
2339
+ position: "absolute",
2340
+ left,
2341
+ width,
2342
+ top: pe.column * laneHeight,
2343
+ height: laneHeight,
2344
+ padding: 1
2345
+ },
2346
+ children: /* @__PURE__ */ jsx(Renderer, {
2347
+ event: pe.event,
2348
+ width,
2349
+ onPress
2350
+ })
2351
+ }, idx);
2352
+ })
2353
+ ]
2188
2354
  })]
2189
2355
  }, resource.id);
2190
2356
  })]
@@ -2274,6 +2440,34 @@ const styles = StyleSheet.create({
2274
2440
  left: 0,
2275
2441
  right: 0,
2276
2442
  height: StyleSheet.hairlineWidth
2443
+ },
2444
+ vcreateGhost: {
2445
+ position: "absolute",
2446
+ left: 2,
2447
+ right: 2,
2448
+ borderWidth: 1,
2449
+ borderRadius: 6,
2450
+ opacity: 0,
2451
+ zIndex: 2
2452
+ },
2453
+ hcreateGhost: {
2454
+ position: "absolute",
2455
+ top: 2,
2456
+ bottom: 2,
2457
+ borderWidth: 1,
2458
+ borderRadius: 6,
2459
+ opacity: 0,
2460
+ zIndex: 2
2461
+ },
2462
+ hshadeBand: {
2463
+ position: "absolute",
2464
+ top: 0,
2465
+ bottom: 0
2466
+ },
2467
+ vshadeBand: {
2468
+ position: "absolute",
2469
+ left: 0,
2470
+ right: 0
2277
2471
  }
2278
2472
  });
2279
2473
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-calendar/native",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Gesture-driven, virtualized month / week / day calendar and date picker for React Native (and web via react-native-web).",
5
5
  "keywords": [
6
6
  "agenda",
@@ -64,7 +64,7 @@
64
64
  "access": "public"
65
65
  },
66
66
  "dependencies": {
67
- "@super-calendar/core": "2.4.0"
67
+ "@super-calendar/core": "2.5.0"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@legendapp/list": ">=3",