@delacour/react-native-ui 0.11.0-alpha.20261124152158 → 0.11.0-alpha.20261124152420
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/package.json +3 -3
- package/src/components/calendar/AGENTS.md +16 -3
- package/src/components/calendar/calendar-picker.tsx +71 -27
- package/src/components/calendar/calendar.context.tsx +3 -0
- package/src/components/calendar/calendar.render.test.tsx +35 -0
- package/src/components/calendar/calendar.tsx +3 -0
- package/src/components/calendar/calendar.types.ts +11 -0
- package/src/components/date-picker/AGENTS.md +5 -0
- package/src/components/date-picker/date-picker-calendar.tsx +6 -0
- package/src/components/date-picker/date-picker.render.test.tsx +17 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delacour/react-native-ui",
|
|
3
|
-
"version": "0.11.0-alpha.
|
|
3
|
+
"version": "0.11.0-alpha.20261124152420",
|
|
4
4
|
"description": "React Native UI components — Uniwind, Reanimated, Gesture Handler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -186,8 +186,8 @@
|
|
|
186
186
|
"expo-blur": ">=15",
|
|
187
187
|
"@maplibre/maplibre-react-native": "^11.5.0",
|
|
188
188
|
"@central-icons-react-native/round-outlined-radius-1-stroke-1.5": "^1.1",
|
|
189
|
-
"@delacour/react-native-bottom-sheet": "0.11.0-alpha.
|
|
190
|
-
"@delacour/react-native-charts": "0.11.0-alpha.
|
|
189
|
+
"@delacour/react-native-bottom-sheet": "0.11.0-alpha.20261124152420",
|
|
190
|
+
"@delacour/react-native-charts": "0.11.0-alpha.20261124152420",
|
|
191
191
|
"@legendapp/list": ">=3.3",
|
|
192
192
|
"react-native-skia": ">=3.9.0",
|
|
193
193
|
"expo-linear-gradient": ">=15",
|
|
@@ -19,7 +19,7 @@ sheets.
|
|
|
19
19
|
| `calendar-weekdays.tsx` | `Calendar.Weekdays` — short names shown, full names spoken |
|
|
20
20
|
| `calendar-grid.tsx` | `Calendar.Grid` — six weeks, the paging pan and slide, hosts the picker |
|
|
21
21
|
| `calendar-day.tsx` | `Calendar.Day` — one cell: band, circle, number or custom content |
|
|
22
|
-
| `calendar-picker.tsx` | `Calendar.Picker` — the months and years jump views |
|
|
22
|
+
| `calendar-picker.tsx` | `Calendar.Picker` — the months and years jump views; `resolveYearListGesture` |
|
|
23
23
|
| `calendar.context.tsx` | `CalendarContext`, `useCalendar()`, `useCalendarContext()`, `useCalendarPart()` |
|
|
24
24
|
| `calendar.types.ts` | `CalendarSelection` (the mode union), `CalendarProps`, `CalendarCaptionLayout` |
|
|
25
25
|
| `calendar.date.ts` | **Shared leaf.** `CalendarDate` maths, matchers, grid, selection rules, `Intl` formatters. No React Native |
|
|
@@ -114,6 +114,19 @@ sheets.
|
|
|
114
114
|
- **A Gesture Handler pan on `Calendar.Grid`**, `activeOffsetX` ±12 and `failOffsetY` ±12: it
|
|
115
115
|
claims a sideways drag and gives up a vertical one, so the calendar lives inside a `ScrollView`
|
|
116
116
|
or a sheet without stealing its scroll.
|
|
117
|
+
- **In a bottom sheet the year list blocks the sheet's content pan** (`yearListBlocksGesture`,
|
|
118
|
+
`resolveYearListGesture`). The content pan claims a drag after six points, before a `ScrollView`
|
|
119
|
+
starts to scroll, so a slow drag on the years moved the sheet and the list stayed still. Given a
|
|
120
|
+
gesture, the list's native scroll runs beside a plain `Pan` that blocks it, and every drag on the
|
|
121
|
+
years scrolls them; the handle and header still move the sheet. A drag down at the top of the
|
|
122
|
+
list does not pull the sheet down — that is the trade. Three shapes failed on an iOS simulator:
|
|
123
|
+
`Gesture.Native().blocksExternalGesture(…)` (its recognizer only mirrors the scroll view's pan, so
|
|
124
|
+
the sheet still moved), adding `shouldActivateOnStart(true)` (the sheet stopped and so did the
|
|
125
|
+
list), and `simultaneousWithExternalGesture` (both moved). The engine's `BottomSheet.ScrollView`
|
|
126
|
+
is a body scrollable that writes the sheet's content height, so nesting one here would break the
|
|
127
|
+
sheet's sizing. The calendar imports no sheet: it takes the gesture as a prop, and `DatePicker` passes
|
|
128
|
+
its sheet's (`DateTimePicker` turns its sheet's content pan off, so it passes none).
|
|
129
|
+
Without one the list is a plain `ScrollView`.
|
|
117
130
|
- **`resolvePageDirection` is pure and tested.** A quarter of the width, or a release faster than
|
|
118
131
|
500 pt/s, pages; a flick against the drag settles back; it never pages past a bound or on an
|
|
119
132
|
unmeasured grid.
|
|
@@ -144,8 +157,8 @@ sheets.
|
|
|
144
157
|
|
|
145
158
|
- **Parts derive their `testID` from the root's** (`resolvePartTestID`): `testID="booking"`
|
|
146
159
|
names the days `booking-day-2026-10-05`, the arrows `booking-prev`/`booking-next`, the caption
|
|
147
|
-
`booking-caption
|
|
148
|
-
anatomy renders forty-odd parts no caller writes, and an end-to-end test or a recorded preview
|
|
160
|
+
`booking-caption`, the jump-view items `booking-month-10`/`booking-year-2026` and the year list
|
|
161
|
+
`booking-years`. The default anatomy renders forty-odd parts no caller writes, and an end-to-end test or a recorded preview
|
|
149
162
|
flow has to reach one particular day all the same. No root `testID`, no part ids.
|
|
150
163
|
|
|
151
164
|
## Field
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { type ReactElement, useCallback, useMemo, useRef } from "react";
|
|
1
|
+
import { type ReactElement, type ReactNode, useCallback, useMemo, useRef } from "react";
|
|
2
2
|
import { type LayoutChangeEvent, ScrollView, type ScrollViewInstance, View, type ViewProps } from "react-native";
|
|
3
|
+
import {
|
|
4
|
+
Gesture,
|
|
5
|
+
GestureDetector,
|
|
6
|
+
type GestureType,
|
|
7
|
+
type LegacySimultaneousGesture,
|
|
8
|
+
} from "react-native-gesture-handler";
|
|
3
9
|
import Animated, { FadeIn, FadeOut } from "react-native-reanimated";
|
|
4
10
|
import { useCalmMotion } from "../../hooks/use-calm-motion";
|
|
5
11
|
import { cn } from "../../lib/cn";
|
|
@@ -15,6 +21,38 @@ export type CalendarPickerProps = Omit<ViewProps, "children"> & {
|
|
|
15
21
|
|
|
16
22
|
const CROSSFADE_MS = 150;
|
|
17
23
|
|
|
24
|
+
/**
|
|
25
|
+
* The year list's native scroll, run beside a pan that blocks `external` — a bottom sheet's content
|
|
26
|
+
* pan.
|
|
27
|
+
*
|
|
28
|
+
* The content pan claims a touch after six points of vertical travel, before a React Native
|
|
29
|
+
* `ScrollView` starts to scroll, so a slow drag on the years moved the sheet and the list stayed
|
|
30
|
+
* put; only a fast flick scrolled. The native handler cannot hold the pan off by itself on iOS:
|
|
31
|
+
* its recognizer only mirrors the scroll view's pan, so `blocksExternalGesture` on it never makes
|
|
32
|
+
* the content pan wait, and `shouldActivateOnStart` stops the scroll too. A plain `Pan`, recognized
|
|
33
|
+
* together with the native scroll, can block it. A drag on the years now scrolls them; the handle
|
|
34
|
+
* and the header still move or close the sheet.
|
|
35
|
+
*
|
|
36
|
+
* `testID` names the blocking pan for Gesture Handler's Jest utilities.
|
|
37
|
+
*/
|
|
38
|
+
export function resolveYearListGesture(external: GestureType, testID?: string): LegacySimultaneousGesture {
|
|
39
|
+
const blocker = Gesture.Pan().blocksExternalGesture(external);
|
|
40
|
+
return Gesture.Simultaneous(Gesture.Native(), testID ? blocker.withTestId(testID) : blocker);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Wraps the year list in `resolveYearListGesture` when the calendar was given a gesture to block. */
|
|
44
|
+
function YearListGesture({ children }: { children: ReactNode }): ReactElement {
|
|
45
|
+
const { testID, yearListBlocksGesture } = useCalendarPart("Calendar.Picker");
|
|
46
|
+
const panTestID = resolvePartTestID(testID, "years-pan");
|
|
47
|
+
const gesture = useMemo(
|
|
48
|
+
() => (yearListBlocksGesture ? resolveYearListGesture(yearListBlocksGesture, panTestID) : null),
|
|
49
|
+
[panTestID, yearListBlocksGesture]
|
|
50
|
+
);
|
|
51
|
+
if (!gesture) return <>{children}</>;
|
|
52
|
+
return <GestureDetector gesture={gesture}>{children}</GestureDetector>;
|
|
53
|
+
}
|
|
54
|
+
YearListGesture.displayName = "DelacourUI.Calendar.Picker.YearListGesture";
|
|
55
|
+
|
|
18
56
|
/**
|
|
19
57
|
* The months and years jump views, laid over the grid while one is open.
|
|
20
58
|
*
|
|
@@ -95,32 +133,38 @@ export function CalendarPicker({ className, ...props }: CalendarPickerProps): Re
|
|
|
95
133
|
})}
|
|
96
134
|
</View>
|
|
97
135
|
) : (
|
|
98
|
-
<
|
|
99
|
-
<
|
|
100
|
-
{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
136
|
+
<YearListGesture>
|
|
137
|
+
<ScrollView
|
|
138
|
+
ref={scroller}
|
|
139
|
+
showsVerticalScrollIndicator={false}
|
|
140
|
+
testID={resolvePartTestID(calendar.testID, "years")}
|
|
141
|
+
>
|
|
142
|
+
<View accessibilityRole="list" className={slots.pickerGrid()}>
|
|
143
|
+
{years.map((year) => {
|
|
144
|
+
const isCurrent = year === visibleMonth.year;
|
|
145
|
+
const item = calendarVariants({ size, tone: isCurrent ? "selected" : "plain", variant });
|
|
146
|
+
const inBounds =
|
|
147
|
+
(!monthBounds.first || compareMonths({ day: 1, month: 12, year }, monthBounds.first) >= 0) &&
|
|
148
|
+
(!monthBounds.last || compareMonths({ day: 1, month: 1, year }, monthBounds.last) <= 0);
|
|
149
|
+
return (
|
|
150
|
+
<Pressable
|
|
151
|
+
accessibilityState={{ selected: isCurrent }}
|
|
152
|
+
className={item.pickerItem({ className: inBounds ? undefined : "opacity-40" })}
|
|
153
|
+
disabled={isDisabled || !inBounds}
|
|
154
|
+
feedback="fade"
|
|
155
|
+
haptic="selection"
|
|
156
|
+
key={year}
|
|
157
|
+
onLayout={isCurrent ? handleCurrentLayout : undefined}
|
|
158
|
+
onPress={() => pickYear(year)}
|
|
159
|
+
testID={resolvePartTestID(calendar.testID, `year-${year}`)}
|
|
160
|
+
>
|
|
161
|
+
<Text className={item.pickerItemLabel()}>{formatYear(year, locale)}</Text>
|
|
162
|
+
</Pressable>
|
|
163
|
+
);
|
|
164
|
+
})}
|
|
165
|
+
</View>
|
|
166
|
+
</ScrollView>
|
|
167
|
+
</YearListGesture>
|
|
124
168
|
)}
|
|
125
169
|
</Animated.View>
|
|
126
170
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createContext, type ReactElement, type ReactNode, use } from "react";
|
|
2
|
+
import type { GestureType } from "react-native-gesture-handler";
|
|
2
3
|
import type { CalendarDate, CalendarSelectionState, Weekday } from "./calendar.date";
|
|
3
4
|
import type { CalendarCaptionLayout } from "./calendar.types";
|
|
4
5
|
import type { CalendarRangeRole, CalendarSize, CalendarVariant, CalendarView } from "./calendar.variants";
|
|
@@ -49,6 +50,8 @@ export type CalendarContextValue = {
|
|
|
49
50
|
showOutsideDays: boolean;
|
|
50
51
|
selectOutsideDays: boolean;
|
|
51
52
|
swipeToPage: boolean;
|
|
53
|
+
/** The gesture the year list blocks while it scrolls, or `undefined` to scroll as a plain list. */
|
|
54
|
+
yearListBlocksGesture: GestureType | undefined;
|
|
52
55
|
captionLayout: CalendarCaptionLayout;
|
|
53
56
|
/** The calendar's own `testID`, which its parts derive theirs from — see `resolvePartTestID`. */
|
|
54
57
|
testID: string | undefined;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, jest, test } from "@jest/globals";
|
|
2
2
|
import { Text } from "react-native";
|
|
3
|
+
import { Gesture } from "react-native-gesture-handler";
|
|
4
|
+
import { getByGestureTestId } from "react-native-gesture-handler/jest-utils";
|
|
3
5
|
import { fireEvent, renderWithProviders, screen } from "../../test/render";
|
|
4
6
|
import { Field } from "../field";
|
|
5
7
|
import { Calendar } from "./calendar";
|
|
6
8
|
import type { CalendarDate } from "./calendar.date";
|
|
9
|
+
import { resolveYearListGesture } from "./calendar-picker";
|
|
7
10
|
|
|
8
11
|
const day = (year: number, month: number, d: number): CalendarDate => ({ day: d, month, year });
|
|
9
12
|
|
|
@@ -381,6 +384,27 @@ describe("Calendar", () => {
|
|
|
381
384
|
expect(onSelect).toHaveBeenLastCalledWith(day(1990, 3, 23));
|
|
382
385
|
});
|
|
383
386
|
|
|
387
|
+
test("yearListBlocksGesture wraps the year list in a pan that blocks the gesture given", async () => {
|
|
388
|
+
const external = Gesture.Pan();
|
|
389
|
+
await renderWithProviders(
|
|
390
|
+
<Calendar initialView="years" locale="en" testID="cal" yearListBlocksGesture={external} />
|
|
391
|
+
);
|
|
392
|
+
expect(screen.getByTestId("cal-years")).toBeOnTheScreen();
|
|
393
|
+
expect(getByGestureTestId("cal-years-pan").config.blocksHandlers).toEqual([external]);
|
|
394
|
+
|
|
395
|
+
await fireEvent(screen.getByTestId("cal-year-1990"), "accessibilityTap");
|
|
396
|
+
expect(screen.getByRole("button", { name: "1990" })).toBeOnTheScreen();
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
test("without yearListBlocksGesture the year list is a plain scroll view", async () => {
|
|
400
|
+
await renderWithProviders(<Calendar initialView="years" locale="en" testID="cal" />);
|
|
401
|
+
expect(screen.getByTestId("cal-years")).toBeOnTheScreen();
|
|
402
|
+
expect(() => getByGestureTestId("cal-years-pan")).toThrow();
|
|
403
|
+
|
|
404
|
+
await fireEvent(screen.getByTestId("cal-year-1990"), "accessibilityTap");
|
|
405
|
+
expect(screen.getByRole("button", { name: "1990" })).toBeOnTheScreen();
|
|
406
|
+
});
|
|
407
|
+
|
|
384
408
|
test('initialView="months" opens on the months of the visible year', async () => {
|
|
385
409
|
await renderWithProviders(<Calendar initialView="months" locale="en" testID="cal" />);
|
|
386
410
|
expect(screen.getByRole("button", { name: "2026" })).toBeOnTheScreen();
|
|
@@ -441,3 +465,14 @@ describe("Calendar", () => {
|
|
|
441
465
|
});
|
|
442
466
|
});
|
|
443
467
|
});
|
|
468
|
+
|
|
469
|
+
describe("resolveYearListGesture", () => {
|
|
470
|
+
test("runs the native scroll beside a pan that blocks the external gesture", () => {
|
|
471
|
+
const external = Gesture.Pan();
|
|
472
|
+
const [native, blocker] = resolveYearListGesture(external).toGestureArray();
|
|
473
|
+
expect(native?.handlerName).toBe("NativeViewGestureHandler");
|
|
474
|
+
expect(native?.config.blocksHandlers).toBeUndefined();
|
|
475
|
+
expect(blocker?.handlerName).toBe("PanGestureHandler");
|
|
476
|
+
expect(blocker?.config.blocksHandlers).toEqual([external]);
|
|
477
|
+
});
|
|
478
|
+
});
|
|
@@ -132,6 +132,7 @@ function CalendarRoot(props: CalendarProps): ReactElement {
|
|
|
132
132
|
selectOutsideDays = false,
|
|
133
133
|
isBordered = false,
|
|
134
134
|
swipeToPage = true,
|
|
135
|
+
yearListBlocksGesture,
|
|
135
136
|
today: todayOverride,
|
|
136
137
|
className,
|
|
137
138
|
children,
|
|
@@ -306,6 +307,7 @@ function CalendarRoot(props: CalendarProps): ReactElement {
|
|
|
306
307
|
view,
|
|
307
308
|
visibleMonth,
|
|
308
309
|
weekStartsOn: resolvedWeekStart,
|
|
310
|
+
yearListBlocksGesture,
|
|
309
311
|
yearSpan,
|
|
310
312
|
}),
|
|
311
313
|
[
|
|
@@ -335,6 +337,7 @@ function CalendarRoot(props: CalendarProps): ReactElement {
|
|
|
335
337
|
today,
|
|
336
338
|
view,
|
|
337
339
|
visibleMonth,
|
|
340
|
+
yearListBlocksGesture,
|
|
338
341
|
yearSpan,
|
|
339
342
|
]
|
|
340
343
|
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { ViewProps } from "react-native";
|
|
3
|
+
import type { GestureType } from "react-native-gesture-handler";
|
|
3
4
|
import type { CalendarDate, CalendarDateRange, DateMatcher, Weekday } from "./calendar.date";
|
|
4
5
|
import type { CalendarSize, CalendarVariant, CalendarView } from "./calendar.variants";
|
|
5
6
|
|
|
@@ -87,6 +88,16 @@ export type CalendarProps = Omit<ViewProps, "children"> &
|
|
|
87
88
|
isBordered?: boolean;
|
|
88
89
|
/** A horizontal swipe on the grid pages the month. */
|
|
89
90
|
swipeToPage?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* A gesture the year list holds off while it scrolls — a bottom sheet's content pan.
|
|
93
|
+
*
|
|
94
|
+
* The sheet's pan claims a drag after a few points, before a `ScrollView` starts to scroll,
|
|
95
|
+
* so inside a sheet a slow drag on the years moved the sheet instead. Given one, the year list
|
|
96
|
+
* runs its native scroll beside a pan that blocks it (`resolveYearListGesture`). `DatePicker`
|
|
97
|
+
* passes its sheet's; a calendar placed in a sheet by hand passes the engine's
|
|
98
|
+
* `useOptionalBottomSheetInternal()?.pans.content`.
|
|
99
|
+
*/
|
|
100
|
+
yearListBlocksGesture?: GestureType;
|
|
90
101
|
/** Overrides today — for a demo, a screenshot or a test. */
|
|
91
102
|
today?: CalendarDate;
|
|
92
103
|
className?: string;
|
|
@@ -120,6 +120,11 @@ The subpath imports `BottomSheet`, so an app using it installs the optional
|
|
|
120
120
|
abandoned. `isClearable` defaults on for range and multiple, off for single.
|
|
121
121
|
- **The calendar keeps its own size.** `calendarSize` (default `md`) is independent of the trigger's
|
|
122
122
|
`size`: a `sm` field must not shrink day targets below 44pt.
|
|
123
|
+
- **The year list scrolls, not the sheet.** `DatePicker.Calendar` passes the sheet's content pan
|
|
124
|
+
to the calendar as `yearListBlocksGesture`, read with the engine's
|
|
125
|
+
`useOptionalBottomSheetInternal()`, so a slow drag on the years scrolls them instead of moving the
|
|
126
|
+
sheet. Inline, outside a sheet, it passes nothing. The calendar's `AGENTS.md` has the gesture
|
|
127
|
+
and the shapes that failed.
|
|
123
128
|
- **`presentation` is a union, not a boolean**, so an anchored `"popover"` can join it once the
|
|
124
129
|
Overlays category ships one, without a breaking change. Today: `sheet` (default) and `inline`,
|
|
125
130
|
which draws the calendar on a card in place and renders no trigger. There is no popover import
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useOptionalBottomSheetInternal } from "@delacour/react-native-bottom-sheet";
|
|
1
2
|
import type { ReactElement } from "react";
|
|
2
3
|
import { Calendar, type CalendarProps } from "../calendar";
|
|
3
4
|
import { resolvePartTestID } from "../calendar/calendar.variants";
|
|
@@ -27,12 +28,16 @@ export type DatePickerCalendarProps = Omit<
|
|
|
27
28
|
* a single day commits and closes, a range commits and closes once both ends exist, several days
|
|
28
29
|
* commit on every toggle and stay open. Every other `Calendar` prop passes through.
|
|
29
30
|
*
|
|
31
|
+
* Inside a sheet it hands the calendar the sheet's content pan, so a drag on the year list scrolls
|
|
32
|
+
* the years rather than the sheet.
|
|
33
|
+
*
|
|
30
34
|
* Keyed by the picker's `openCount`, so each opening starts on the root's `initialView` (or the
|
|
31
35
|
* picked value's days) even when the sheet engine keeps its content mounted between openings.
|
|
32
36
|
*/
|
|
33
37
|
export function DatePickerCalendar(props: DatePickerCalendarProps): ReactElement {
|
|
34
38
|
const picker = useDatePickerPart("DatePicker.Calendar");
|
|
35
39
|
const { calendar, shown, select } = picker;
|
|
40
|
+
const sheet = useOptionalBottomSheetInternal();
|
|
36
41
|
const common = {
|
|
37
42
|
captionLayout: calendar.captionLayout,
|
|
38
43
|
defaultMonth: picker.hasValue ? undefined : calendar.defaultMonth,
|
|
@@ -51,6 +56,7 @@ export function DatePickerCalendar(props: DatePickerCalendarProps): ReactElement
|
|
|
51
56
|
today: calendar.today,
|
|
52
57
|
testID: resolvePartTestID(picker.testID, "calendar"),
|
|
53
58
|
weekStartsOn: calendar.weekStartsOn,
|
|
59
|
+
yearListBlocksGesture: sheet?.pans.content,
|
|
54
60
|
...props,
|
|
55
61
|
};
|
|
56
62
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BottomSheetProvider } from "@delacour/react-native-bottom-sheet";
|
|
2
2
|
import { afterEach, beforeEach, describe, expect, jest, test } from "@jest/globals";
|
|
3
3
|
import type { ReactElement, ReactNode } from "react";
|
|
4
|
+
import { getByGestureTestId } from "react-native-gesture-handler/jest-utils";
|
|
4
5
|
import { act, fireEvent, renderWithProviders, screen, within } from "../../test/render";
|
|
5
6
|
import type { CalendarDate, CalendarDateRange } from "../calendar/calendar.date";
|
|
6
7
|
import { OverlayProvider } from "../overlay";
|
|
@@ -516,6 +517,22 @@ describe("DatePicker initialView", () => {
|
|
|
516
517
|
expect(year(1990)).not.toBeOnTheScreen();
|
|
517
518
|
});
|
|
518
519
|
|
|
520
|
+
test("in the sheet, the year list blocks the sheet's content pan", async () => {
|
|
521
|
+
await renderWithProviders(<Picker defaultOpen initialView="years" {...bounds} />, { wrapper: Providers });
|
|
522
|
+
expect(screen.getByTestId("stay-calendar-years")).toBeOnTheScreen();
|
|
523
|
+
const blocked = getByGestureTestId("stay-calendar-years-pan").config.blocksHandlers ?? [];
|
|
524
|
+
expect(blocked).toHaveLength(1);
|
|
525
|
+
expect(blocked[0]?.handlerName).toBe("PanGestureHandler");
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
test("inline, the year list blocks nothing", async () => {
|
|
529
|
+
await renderWithProviders(<Picker initialView="years" presentation="inline" {...bounds} />, {
|
|
530
|
+
wrapper: Providers,
|
|
531
|
+
});
|
|
532
|
+
expect(screen.getByTestId("stay-calendar-years")).toBeOnTheScreen();
|
|
533
|
+
expect(() => getByGestureTestId("stay-calendar-years-pan")).toThrow();
|
|
534
|
+
});
|
|
535
|
+
|
|
519
536
|
test("starts again on the years each time the sheet opens while empty", async () => {
|
|
520
537
|
const { rerender } = await renderWithProviders(<Picker initialView="years" isOpen {...bounds} />, {
|
|
521
538
|
wrapper: Providers,
|