@super-calendar/native 2.14.2 → 2.15.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/README.md CHANGED
@@ -70,6 +70,14 @@ On the time grid, dragging any segment of a multi-day event previews the whole
70
70
  range moving together and preserves its duration. Drag a resize grip to change
71
71
  only the start or end. See the [dragging guide](https://super-calendar.afonsojramos.me/guides/dragging).
72
72
 
73
+ After edge paging, the floating event's horizontal centre selects the destination
74
+ day, and its top edge selects the time.
75
+
76
+ Set an event's `dragHandleColor` to colour its resize grips in `TimeGrid` and
77
+ `ResourceTimeline` (both orientations). It defaults to `theme.colors.eventText`.
78
+ `showDragHandle={false}` still hides the time-grid grips.
79
+ You can toggle it after mounting without replacing the `events` array.
80
+
73
81
  ## Styling with Tailwind
74
82
 
75
83
  Every styleable part is a named slot that accepts a class (resolved by a Tailwind runtime such as [uniwind](https://docs.uniwind.dev) or NativeWind) and/or a style override. A classed slot drops its built-in themed styles, so your classes own the look:
package/dist/index.js CHANGED
@@ -1442,7 +1442,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
1442
1442
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
1443
1443
  testID: "resize-handle-top",
1444
1444
  style: styles$1.resizeHandleTop,
1445
- children: showDragHandle ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: [styles$1.resizeGrip, { backgroundColor: theme.colors.eventText }] }) : null
1445
+ children: showDragHandle ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: [styles$1.resizeGrip, { backgroundColor: positioned.event.dragHandleColor ?? theme.colors.eventText }] }) : null
1446
1446
  })
1447
1447
  }) : null,
1448
1448
  resizable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_gesture_handler.GestureDetector, {
@@ -1450,7 +1450,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
1450
1450
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
1451
1451
  testID: "resize-handle",
1452
1452
  style: styles$1.resizeHandle,
1453
- children: showDragHandle ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: [styles$1.resizeGrip, { backgroundColor: theme.colors.eventText }] }) : null
1453
+ children: showDragHandle ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: [styles$1.resizeGrip, { backgroundColor: positioned.event.dragHandleColor ?? theme.colors.eventText }] }) : null
1454
1454
  })
1455
1455
  }) : null
1456
1456
  ]
@@ -2213,7 +2213,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2213
2213
  clearLift();
2214
2214
  if (!ev || !onDrag || days.length === 0) return;
2215
2215
  const dayWidth = cw / days.length;
2216
- const col = Math.min(Math.max(Math.floor(ghostLocalX / dayWidth), 0), days.length - 1);
2216
+ const col = Math.min(Math.max(Math.floor((ghostLocalX + ghostW.value / 2) / dayWidth), 0), days.length - 1);
2217
2217
  const rawMinutes = (min + (ghostLocalY - headerH - laneHeight.value - HOUR_LABEL_TOP_INSET) / cellHeight.value) * MINUTES_PER_HOUR$1;
2218
2218
  const minutes = (0, _super_calendar_core.clampMoveStartMinutes)(Math.round(rawMinutes / snap) * snap, min, max, snap);
2219
2219
  const start = new Date(days[col]);
@@ -2223,7 +2223,8 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2223
2223
  }, [
2224
2224
  clearLift,
2225
2225
  cellHeight,
2226
- laneHeight
2226
+ laneHeight,
2227
+ ghostW
2227
2228
  ]);
2228
2229
  const edgePaging = (0, react.useMemo)(() => ({
2229
2230
  pagerLeft,
@@ -2657,11 +2658,13 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2657
2658
  const listExtraData = (0, react.useMemo)(() => ({
2658
2659
  events,
2659
2660
  activeIndex,
2660
- columnsWidth
2661
+ columnsWidth,
2662
+ showDragHandle
2661
2663
  }), [
2662
2664
  events,
2663
2665
  activeIndex,
2664
- columnsWidth
2666
+ columnsWidth,
2667
+ showDragHandle
2665
2668
  ]);
2666
2669
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MonthList.SlotStylesProvider, {
2667
2670
  classNames,
@@ -3594,7 +3597,7 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
3594
3597
  gesture: resizeGesture,
3595
3598
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
3596
3599
  testID: "resource-resize-grip",
3597
- style: [vertical ? styles.resizeGripBottom : styles.resizeGrip, { backgroundColor: theme.colors.eventText }],
3600
+ style: [vertical ? styles.resizeGripBottom : styles.resizeGrip, { backgroundColor: pe.event.dragHandleColor ?? theme.colors.eventText }],
3598
3601
  accessibilityElementsHidden: true,
3599
3602
  importantForAccessibility: "no"
3600
3603
  })
package/dist/index.mjs CHANGED
@@ -1418,7 +1418,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
1418
1418
  children: /* @__PURE__ */ jsx(Animated.View, {
1419
1419
  testID: "resize-handle-top",
1420
1420
  style: styles$1.resizeHandleTop,
1421
- children: showDragHandle ? /* @__PURE__ */ jsx(View, { style: [styles$1.resizeGrip, { backgroundColor: theme.colors.eventText }] }) : null
1421
+ children: showDragHandle ? /* @__PURE__ */ jsx(View, { style: [styles$1.resizeGrip, { backgroundColor: positioned.event.dragHandleColor ?? theme.colors.eventText }] }) : null
1422
1422
  })
1423
1423
  }) : null,
1424
1424
  resizable ? /* @__PURE__ */ jsx(GestureDetector, {
@@ -1426,7 +1426,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
1426
1426
  children: /* @__PURE__ */ jsx(Animated.View, {
1427
1427
  testID: "resize-handle",
1428
1428
  style: styles$1.resizeHandle,
1429
- children: showDragHandle ? /* @__PURE__ */ jsx(View, { style: [styles$1.resizeGrip, { backgroundColor: theme.colors.eventText }] }) : null
1429
+ children: showDragHandle ? /* @__PURE__ */ jsx(View, { style: [styles$1.resizeGrip, { backgroundColor: positioned.event.dragHandleColor ?? theme.colors.eventText }] }) : null
1430
1430
  })
1431
1431
  }) : null
1432
1432
  ]
@@ -2189,7 +2189,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2189
2189
  clearLift();
2190
2190
  if (!ev || !onDrag || days.length === 0) return;
2191
2191
  const dayWidth = cw / days.length;
2192
- const col = Math.min(Math.max(Math.floor(ghostLocalX / dayWidth), 0), days.length - 1);
2192
+ const col = Math.min(Math.max(Math.floor((ghostLocalX + ghostW.value / 2) / dayWidth), 0), days.length - 1);
2193
2193
  const rawMinutes = (min + (ghostLocalY - headerH - laneHeight.value - HOUR_LABEL_TOP_INSET) / cellHeight.value) * MINUTES_PER_HOUR$1;
2194
2194
  const minutes = clampMoveStartMinutes(Math.round(rawMinutes / snap) * snap, min, max, snap);
2195
2195
  const start = new Date(days[col]);
@@ -2199,7 +2199,8 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2199
2199
  }, [
2200
2200
  clearLift,
2201
2201
  cellHeight,
2202
- laneHeight
2202
+ laneHeight,
2203
+ ghostW
2203
2204
  ]);
2204
2205
  const edgePaging = useMemo(() => ({
2205
2206
  pagerLeft,
@@ -2633,11 +2634,13 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2633
2634
  const listExtraData = useMemo(() => ({
2634
2635
  events,
2635
2636
  activeIndex,
2636
- columnsWidth
2637
+ columnsWidth,
2638
+ showDragHandle
2637
2639
  }), [
2638
2640
  events,
2639
2641
  activeIndex,
2640
- columnsWidth
2642
+ columnsWidth,
2643
+ showDragHandle
2641
2644
  ]);
2642
2645
  return /* @__PURE__ */ jsx(SlotStylesProvider, {
2643
2646
  classNames,
@@ -3570,7 +3573,7 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
3570
3573
  gesture: resizeGesture,
3571
3574
  children: /* @__PURE__ */ jsx(View, {
3572
3575
  testID: "resource-resize-grip",
3573
- style: [vertical ? styles.resizeGripBottom : styles.resizeGrip, { backgroundColor: theme.colors.eventText }],
3576
+ style: [vertical ? styles.resizeGripBottom : styles.resizeGrip, { backgroundColor: pe.event.dragHandleColor ?? theme.colors.eventText }],
3574
3577
  accessibilityElementsHidden: true,
3575
3578
  importantForAccessibility: "no"
3576
3579
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-calendar/native",
3
- "version": "2.14.2",
3
+ "version": "2.15.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.14.2"
67
+ "@super-calendar/core": "2.15.0"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@legendapp/list": ">=3",
@@ -535,7 +535,7 @@ function ResourceBar<T>({
535
535
  testID="resource-resize-grip"
536
536
  style={[
537
537
  vertical ? styles.resizeGripBottom : styles.resizeGrip,
538
- { backgroundColor: theme.colors.eventText },
538
+ { backgroundColor: pe.event.dragHandleColor ?? theme.colors.eventText },
539
539
  ]}
540
540
  accessibilityElementsHidden
541
541
  importantForAccessibility="no"
@@ -1151,7 +1151,12 @@ function AnimatedEventBoxInner<T>({
1151
1151
  <GestureDetector gesture={resizeStartGesture}>
1152
1152
  <Animated.View testID="resize-handle-top" style={styles.resizeHandleTop}>
1153
1153
  {showDragHandle ? (
1154
- <View style={[styles.resizeGrip, { backgroundColor: theme.colors.eventText }]} />
1154
+ <View
1155
+ style={[
1156
+ styles.resizeGrip,
1157
+ { backgroundColor: positioned.event.dragHandleColor ?? theme.colors.eventText },
1158
+ ]}
1159
+ />
1155
1160
  ) : null}
1156
1161
  </Animated.View>
1157
1162
  </GestureDetector>
@@ -1162,7 +1167,12 @@ function AnimatedEventBoxInner<T>({
1162
1167
  {/* The grip is the only visible drag affordance; hiding it keeps the
1163
1168
  resize gesture working but removes the indicator. */}
1164
1169
  {showDragHandle ? (
1165
- <View style={[styles.resizeGrip, { backgroundColor: theme.colors.eventText }]} />
1170
+ <View
1171
+ style={[
1172
+ styles.resizeGrip,
1173
+ { backgroundColor: positioned.event.dragHandleColor ?? theme.colors.eventText },
1174
+ ]}
1175
+ />
1166
1176
  ) : null}
1167
1177
  </Animated.View>
1168
1178
  </GestureDetector>
@@ -2678,12 +2688,15 @@ function TimeGridInner<T>(
2678
2688
  clearLift();
2679
2689
  if (!ev || !onDrag || days.length === 0) return;
2680
2690
  // Map the ghost's drawn position on the page it landed on back to a cell:
2681
- // its left edge picks the day column, its top edge picks the time. Both are
2691
+ // its centre picks the day column, its top edge picks the time. Both are
2682
2692
  // pager-local, and the pager is the scrolling content itself, so the top
2683
2693
  // edge only needs the page's all-day band and label inset taken off before
2684
2694
  // the live row height (pinch) converts it to hours.
2685
2695
  const dayWidth = cw / days.length;
2686
- const col = Math.min(Math.max(Math.floor(ghostLocalX / dayWidth), 0), days.length - 1);
2696
+ const col = Math.min(
2697
+ Math.max(Math.floor((ghostLocalX + ghostW.value / 2) / dayWidth), 0),
2698
+ days.length - 1,
2699
+ );
2687
2700
  const hoursFromMin =
2688
2701
  (ghostLocalY - headerH - laneHeight.value - HOUR_LABEL_TOP_INSET) / cellHeight.value;
2689
2702
  const rawMinutes = (min + hoursFromMin) * MINUTES_PER_HOUR;
@@ -2699,7 +2712,7 @@ function TimeGridInner<T>(
2699
2712
  // reads as a visible snap-back instead of the event seeming to vanish.
2700
2713
  if (onDrag(ev, start, end) === false) onDate(ev.start);
2701
2714
  },
2702
- [clearLift, cellHeight, laneHeight],
2715
+ [clearLift, cellHeight, laneHeight, ghostW],
2703
2716
  );
2704
2717
  const edgePaging = useMemo<EdgePaging>(
2705
2718
  () => ({
@@ -3277,9 +3290,10 @@ function TimeGridInner<T>(
3277
3290
  // `isActive` updates as you swipe). Without `activeIndex`, a page that pages in
3278
3291
  // never learns it became active, so its zoom source and now line would lag.
3279
3292
  // `columnsWidth` resizes the mounted pages when the grid is re-measured.
3293
+ // `showDragHandle` refreshes grips without requiring an event-data change.
3280
3294
  const listExtraData = useMemo(
3281
- () => ({ events, activeIndex, columnsWidth }),
3282
- [events, activeIndex, columnsWidth],
3295
+ () => ({ events, activeIndex, columnsWidth, showDragHandle }),
3296
+ [events, activeIndex, columnsWidth, showDragHandle],
3283
3297
  );
3284
3298
 
3285
3299
  return (