@delacour/react-native-ui 0.11.0-alpha.20261120181844 → 0.11.0-alpha.20261124152158

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delacour/react-native-ui",
3
- "version": "0.11.0-alpha.20261120181844",
3
+ "version": "0.11.0-alpha.20261124152158",
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.20261120181844",
190
- "@delacour/react-native-charts": "0.11.0-alpha.20261120181844",
189
+ "@delacour/react-native-bottom-sheet": "0.11.0-alpha.20261124152158",
190
+ "@delacour/react-native-charts": "0.11.0-alpha.20261124152158",
191
191
  "@legendapp/list": ">=3.3",
192
192
  "react-native-skia": ">=3.9.0",
193
193
  "expo-linear-gradient": ">=15",
@@ -131,6 +131,15 @@ typed text can become a value.
131
131
  `keyboardDismissMode="none"`. A drag that carries the sheet down still puts
132
132
  it away — the engine does that on any downward release — and every close
133
133
  blurs the field.
134
+ - **The header is pinned while the rows scroll**, as in `Select`. The list
135
+ passes `stickyHeaderIndices={[0]}` — FlatList puts `ListHeaderComponent` at
136
+ child 0 and always mounts it — so the title, chips, search field and result
137
+ count stay at the top of a long result list. The search field is the
138
+ combobox's main control; scrolled off, the next query needed a scroll back
139
+ first. The `header` slot is `bg-popover`, the sheet's colour, so rows pass
140
+ under it unseen, and it carries the list's `pt-2` (`sheetBody` sets `pt-0`)
141
+ so it pins where it rests rather than riding up 8pt first. The header and
142
+ the list carry `${testID}-header` and `${testID}-list`.
134
143
  - **Closing blurs the search field first.** Done, the scrim, the close button
135
144
  and a single pick all `blur()` before the sheet leaves, so the keyboard goes
136
145
  down with it rather than lingering over the screen for a beat.
@@ -57,6 +57,13 @@ describe("Combobox", () => {
57
57
  expect(screen.getAllByRole("radio")).toHaveLength(5);
58
58
  });
59
59
 
60
+ test("the title and search stay pinned while the rows scroll", async () => {
61
+ await render();
62
+ await open();
63
+ expect(screen.getByTestId("cb-list")).toHaveProp("stickyHeaderIndices", [0]);
64
+ expect(screen.getByTestId("cb-header")).toBeOnTheScreen();
65
+ });
66
+
60
67
  test("typing filters the options, reporting each change as a type", async () => {
61
68
  const onInputValueChange = jest.fn();
62
69
  await render({ onInputValueChange });
@@ -108,7 +108,7 @@ type ComboboxBaseProps = {
108
108
  highlight?: boolean;
109
109
  /** Classes for the trigger. */
110
110
  className?: string;
111
- /** On the trigger; rows take `${testID}-option-${value}`, search `-search`, create `-create`, Done `-done`; the trigger's chevron `-chevron`, clear `-clear`, chips `-chip-${value}` and `-remove-${value}`. */
111
+ /** On the trigger; rows take `${testID}-option-${value}`, search `-search`, create `-create`, Done `-done`, header `-header`, list `-list`; the trigger's chevron `-chevron`, clear `-clear`, chips `-chip-${value}` and `-remove-${value}`. */
112
112
  testID?: string;
113
113
  /** `Combobox.Item`, `Combobox.Group`, and optionally `Combobox.Trigger` or `Combobox.Empty`. */
114
114
  children?: ReactNode;
@@ -144,6 +144,8 @@ const NO_VALUES: readonly string[] = [];
144
144
  const DEFAULT_FILTER: ComboboxFilter = { kind: "default" };
145
145
  const IDLE: ComboboxPendingRemoveState = { kind: "idle" };
146
146
  const CLEAR_HIT_SLOP = 8;
147
+ /** FlatList puts `ListHeaderComponent` at child 0, so this pins the header. Module scope keeps one reference across renders. */
148
+ const STICKY_HEADER = [0];
147
149
 
148
150
  /**
149
151
  * Claims the JS responder for a touch inside the sheet.
@@ -463,11 +465,12 @@ function ComboboxRoot(props: ComboboxProps): ReactElement {
463
465
 
464
466
  const searchLabel = field?.label ? `${field.label}, ${searchPlaceholder}` : searchPlaceholder;
465
467
 
466
- // The title, chips and search field ride at the head of the list, so they
467
- // scroll with it.
468
+ // The title, chips and search field ride at the head of the list, and the
469
+ // list pins them (`stickyHeaderIndices`) so the search field stays in reach
470
+ // while the rows scroll under them.
468
471
  const header = (
469
- <View className={slots.header()}>
470
- <BottomSheet.Close />
472
+ <View className={slots.header()} testID={testID ? `${testID}-header` : undefined}>
473
+ <BottomSheet.Close className={slots.headerClose()} />
471
474
  {sheetTitle ? <BottomSheet.Title>{sheetTitle}</BottomSheet.Title> : null}
472
475
  {multiple && selectedOptions.length > 0 ? (
473
476
  <View onStartShouldSetResponder={claimTouch}>
@@ -545,6 +548,8 @@ function ComboboxRoot(props: ComboboxProps): ReactElement {
545
548
  ListEmptyComponent={empty}
546
549
  ListHeaderComponent={header}
547
550
  renderItem={renderRow}
551
+ stickyHeaderIndices={STICKY_HEADER}
552
+ testID={testID ? `${testID}-list` : undefined}
548
553
  />
549
554
  {multiple ? (
550
555
  <BottomSheet.Footer sticky>
@@ -1,5 +1,6 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import { declaredTokens } from "../../styles/theme-tokens.test";
3
+ import { bottomSheetVariants } from "../bottom-sheet/bottom-sheet.variants";
3
4
  import { INPUT_SIZES, INPUT_VARIANTS, inputVariants, resolveInputGroupClass } from "../input/input.variants";
4
5
  import {
5
6
  resolveSelectSheetMaxHeight,
@@ -43,6 +44,7 @@ const SLOT_NAMES = [
43
44
  "createRow",
44
45
  "createLabel",
45
46
  "header",
47
+ "headerClose",
46
48
  "results",
47
49
  "empty",
48
50
  "sheetBody",
@@ -72,6 +74,34 @@ function everyCell() {
72
74
  );
73
75
  }
74
76
 
77
+ describe("comboboxVariants header", () => {
78
+ test("is opaque in the sheet's colour, so pinned it hides the rows scrolling under it", () => {
79
+ for (const variant of INPUT_VARIANTS) {
80
+ for (const size of INPUT_SIZES) {
81
+ expect(comboboxVariants({ size, variant }).header().split(" ")).toContain("bg-popover");
82
+ }
83
+ }
84
+ });
85
+
86
+ test("carries the list's top padding, so it pins where it rests instead of riding up 8pt", () => {
87
+ for (const size of INPUT_SIZES) {
88
+ const slots = comboboxVariants({ size });
89
+ expect(slots.header().split(" ")).toContain("pt-2");
90
+ expect(bottomSheetVariants().scrollContent({ className: slots.sheetBody() }).split(" ")).toContain("pt-0");
91
+ }
92
+ });
93
+
94
+ test("the close keeps its place when the header takes the list's top padding", () => {
95
+ for (const size of INPUT_SIZES) {
96
+ const close = bottomSheetVariants()
97
+ .close({ className: comboboxVariants({ size }).headerClose() })
98
+ .split(" ");
99
+ expect(close).toContain("top-6");
100
+ expect(close).not.toContain("top-4");
101
+ }
102
+ });
103
+ });
104
+
75
105
  describe("resolveComboboxTriggerClass", () => {
76
106
  test("is Select's trigger exactly, at every cell, while it shows text", () => {
77
107
  for (const state of everyCell()) {
@@ -43,13 +43,23 @@ export const comboboxVariants = tv({
43
43
  clear: "items-center justify-center",
44
44
  createRow: "",
45
45
  createLabel: "",
46
- /** The sheet's title, chips, search field and result count, above the rows. */
47
- header: "gap-3 pb-3",
46
+ /**
47
+ * The sheet's title, chips, search field and result count, pinned above
48
+ * the rows. Opaque, so rows scroll under it unseen. It carries the list's
49
+ * top padding (`pt-2`, taken off `sheetBody`), so it pins where it rests.
50
+ */
51
+ header: "gap-3 bg-popover pb-3 pt-2",
52
+ /**
53
+ * The sheet's close, still absolute in the header's corner. `top-6` is the
54
+ * engine's `top-4` plus the `pt-2` the header now carries, so the close
55
+ * sits where it did when that padding was the list's.
56
+ */
57
+ headerClose: "top-6",
48
58
  /** The result count under the search field. */
49
59
  results: "text-muted-foreground",
50
60
  empty: "items-center justify-center py-8",
51
- /** Overrides the sheet's list gutter gap: rows touch, the way a list's do. */
52
- sheetBody: "gap-0",
61
+ /** Overrides the sheet's list gutter gap — rows touch, the way a list's do — and hands its top padding to `header`. */
62
+ sheetBody: "gap-0 pt-0",
53
63
  },
54
64
  variants: {
55
65
  variant: { primary: {}, secondary: {}, etched: {} },
@@ -62,8 +62,13 @@ The subpath imports `BottomSheet`, so an app using it installs the optional
62
62
  lag otherwise. Every tap cancels the last tap's pending close, so starting a new range inside
63
63
  that pause keeps the sheet open.
64
64
  - **A re-tap on the shown single day confirms it.** The calendar's `applySingleTap` reports it as
65
- `null`; the picker keeps the day, reports nothing and closes. A user who opens a date of birth to
65
+ `null`; the picker keeps the day, reports no change and closes. A user who opens a date of birth to
66
66
  check it and taps it must not clear it. Clear (`isClearable`) is the way to empty a single day.
67
+ - **`onConfirm` says a single pick happened, changed or not.** It fires on every completed single
68
+ pick — the re-tap above included, inline too — after `onValueChange`, and never on Clear or a
69
+ dismiss. Without it a re-tap and a dismiss look the same (`onOpenChange(false)`, then `onClose`),
70
+ so a form that moves on after a pick stalls on a prefilled day. `range` and `multiple` type it as
71
+ `never`, so it is a type error outside single mode and the root can pull it out of the `View` props.
67
72
  - **A half-picked range is never reported.** The first tap is held in `rangeDraft` inside the
68
73
  root; `onValueChange` fires once the range is complete, and on Clear. Dismissing the sheet —
69
74
  swipe, scrim, close, Done, or a controlled `isOpen={false}` — drops the draft and any pending
@@ -194,6 +194,41 @@ describe("DatePicker single mode", () => {
194
194
  expect(trigger()).toHaveAccessibilityValue({ text: "12 October 2026" });
195
195
  });
196
196
 
197
+ test("onConfirm fires after onValueChange for a new day, and alone for the shown day tapped again", async () => {
198
+ const calls: string[] = [];
199
+ const onValueChange = jest.fn((_value: unknown) => void calls.push("change"));
200
+ const onConfirm = jest.fn((_value: unknown) => void calls.push("confirm"));
201
+ await renderWithProviders(
202
+ <Picker defaultOpen defaultValue={OCT_12} onConfirm={onConfirm} onValueChange={onValueChange} />,
203
+ { wrapper: Providers }
204
+ );
205
+
206
+ await tap(day("2026-10-12"));
207
+ expect(onConfirm).toHaveBeenLastCalledWith(OCT_12);
208
+ expect(onValueChange).not.toHaveBeenCalled();
209
+ await settle();
210
+
211
+ await tap(trigger());
212
+ await tap(day("2026-10-14"));
213
+ expect(onConfirm).toHaveBeenLastCalledWith(OCT_14);
214
+ expect(onConfirm).toHaveBeenCalledTimes(2);
215
+ expect(calls).toEqual(["confirm", "change", "confirm"]);
216
+ });
217
+
218
+ test("onConfirm never fires on Clear or a dismiss", async () => {
219
+ const onConfirm = jest.fn();
220
+ const onValueChange = jest.fn();
221
+ await renderWithProviders(
222
+ <Picker defaultOpen defaultValue={OCT_12} isClearable onConfirm={onConfirm} onValueChange={onValueChange} />,
223
+ { wrapper: Providers }
224
+ );
225
+ await tap(screen.getByRole("button", { name: "Clear" }));
226
+ expect(onValueChange).toHaveBeenCalledWith(null);
227
+ await tap(screen.getByTestId("stay-close"));
228
+ await settle();
229
+ expect(onConfirm).not.toHaveBeenCalled();
230
+ });
231
+
197
232
  test("the picked day is announced as selected", async () => {
198
233
  await renderWithProviders(<Picker defaultOpen defaultValue={OCT_12} />, { wrapper: Providers });
199
234
  expect(day("2026-10-12")).toBeSelected();
@@ -379,6 +414,13 @@ describe("DatePicker inline", () => {
379
414
  await settle();
380
415
  expect(onOpenChange).not.toHaveBeenCalled();
381
416
  });
417
+
418
+ test("onConfirm fires for an inline pick too", async () => {
419
+ const onConfirm = jest.fn();
420
+ await renderWithProviders(<Picker onConfirm={onConfirm} presentation="inline" />, { wrapper: Providers });
421
+ await tap(day("2026-10-12"));
422
+ expect(onConfirm).toHaveBeenCalledWith(OCT_12);
423
+ });
382
424
  });
383
425
 
384
426
  describe("DatePicker parts", () => {
@@ -116,6 +116,7 @@ function DatePickerRoot(props: DatePickerProps): ReactElement {
116
116
  value: _value,
117
117
  defaultValue: _defaultValue,
118
118
  onValueChange: _onValueChange,
119
+ onConfirm,
119
120
  ...viewProps
120
121
  } = props;
121
122
 
@@ -212,10 +213,12 @@ function DatePickerRoot(props: DatePickerProps): ReactElement {
212
213
  // when this selection is complete, so a new range start keeps the sheet open.
213
214
  // A single day tapped again is a confirmation, not a clear: the calendar reports it as `null`,
214
215
  // but the picker keeps the day and closes. Clearing a single day is Clear's job.
216
+ // `onConfirm` fires for both, after `onValueChange`, so a caller can tell a pick from a dismiss.
215
217
  const select = useCallback(
216
218
  (next: CalendarSelectionState) => {
217
219
  cancelPendingClose();
218
220
  if (next.mode === "single" && next.value === null && value.mode === "single" && value.value !== null) {
221
+ onConfirm?.(value.value);
219
222
  finish(value);
220
223
  return;
221
224
  }
@@ -225,9 +228,10 @@ function DatePickerRoot(props: DatePickerProps): ReactElement {
225
228
  }
226
229
  setRangeDraft(null);
227
230
  setValue(next);
231
+ if (next.mode === "single" && next.value !== null) onConfirm?.(next.value);
228
232
  if (resolveShouldClose(next)) finish(next);
229
233
  },
230
- [cancelPendingClose, finish, setValue, value]
234
+ [cancelPendingClose, finish, onConfirm, setValue, value]
231
235
  );
232
236
 
233
237
  const clear = useCallback(() => {
@@ -24,6 +24,12 @@ export type DatePickerSelectionProps =
24
24
  defaultValue?: CalendarDate | null;
25
25
  /** Fires when a day is picked, and with `null` on Clear. */
26
26
  onValueChange?: (value: CalendarDate | null) => void;
27
+ /**
28
+ * Fires on every pick, after `onValueChange`, including a re-tap of the shown day, which
29
+ * closes the sheet without `onValueChange`. Never on Clear or a dismiss. Lets a form move on
30
+ * after the user confirms the day it already holds.
31
+ */
32
+ onConfirm?: (value: CalendarDate) => void;
27
33
  }
28
34
  | {
29
35
  mode: "range";
@@ -34,6 +40,8 @@ export type DatePickerSelectionProps =
34
40
  * held inside the sheet and never reported.
35
41
  */
36
42
  onValueChange?: (value: CalendarDateRange) => void;
43
+ /** Single mode only. */
44
+ onConfirm?: never;
37
45
  }
38
46
  | {
39
47
  mode: "multiple";
@@ -41,6 +49,8 @@ export type DatePickerSelectionProps =
41
49
  defaultValue?: readonly CalendarDate[];
42
50
  /** Fires on every toggle, sorted earliest first. */
43
51
  onValueChange?: (value: readonly CalendarDate[]) => void;
52
+ /** Single mode only. */
53
+ onConfirm?: never;
44
54
  };
45
55
 
46
56
  export type DatePickerProps = Omit<ViewProps, "children"> &
@@ -25,7 +25,7 @@ engine. An app that imports no picker still never resolves it.
25
25
  | `select.context.tsx` | `SelectProvider`, `useSelect()`, `useSelectContext()`, `useSelectPart()` |
26
26
  | `select.types.ts` | `SelectOption`, `SelectOptionGroup`, `SelectRowOption`, `SelectEntry`, `SelectListRow`, `SelectHighlightRange` |
27
27
  | `select.variants.ts` | Pure `tv()` slots + every resolver, no RN imports — the sheet cap, the searchable list's floor and the list's virtualisation window among them |
28
- | `select.render.test.tsx` | Mounted under Jest inside `BottomSheetProvider` — trigger role, expanded and value, single and multiple picks, controlled and uncontrolled, limit, search, long-list virtualisation, `Field` inheritance, parts outside a root |
28
+ | `select.render.test.tsx` | Mounted under Jest inside `BottomSheetProvider` — trigger role, expanded and value, the pinned header, single and multiple picks, controlled and uncontrolled, limit, search, long-list virtualisation, `Field` inheritance, parts outside a root |
29
29
  | `select.variants.test.ts` | |
30
30
  | `select.collect.test.ts` | |
31
31
 
@@ -72,7 +72,7 @@ engine. An app that imports no picker still never resolves it.
72
72
  disables a chosen row for `maxSelected`, or the selection could not be undone.
73
73
  A row disabled by the limit with no description of its own says "Limit
74
74
  reached" (`limitReachedText`).
75
- - **`onClose` is the sheet's, not the state's.** It is passed straight to `BottomSheet` and runs once the sheet has finished sliding down, later than `onValueChange` or the open state turning false. Move focus from here, never from the pick.
75
+ - **`onClose` is the sheet's, not the state's.** It is passed straight to `BottomSheet` and runs once the sheet has finished sliding down, later than `onValueChange` or the open state turning false. Move focus from here, never from the pick. `onConfirm` (single only) says a close came from a pick — a press on the chosen row of a non-clearable select included — and not from a clear or a dismiss. It fires after `onValueChange`, and never for a clearable deselect, which empties the selection.
76
76
  - **Multiple never closes on a pick.** A sticky `Done` footer closes it; every
77
77
  close path — a pick, Done, a swipe, the overlay, the close button, or a
78
78
  controlled `isOpen` set to false — clears the query, because the clear reads
@@ -83,6 +83,16 @@ engine. An app that imports no picker still never resolves it.
83
83
  it raises is the sheet's to lift for. The close sits in a row of its own with
84
84
  the title (`headerBar`), not in the sheet's absolute corner, so with no title
85
85
  it still never covers the search field or the first row.
86
+ - **The header is pinned while the rows scroll.** The list passes
87
+ `stickyHeaderIndices={[0]}` — FlatList puts `ListHeaderComponent` at child 0
88
+ and offsets the rows past it, and always mounts it whatever the window — so
89
+ the title, the close and the search stay at the top of a long list instead of
90
+ scrolling off with it. The `header` slot is `bg-popover`, the sheet's own
91
+ colour, so the rows pass under it unseen. It carries the list's `pt-2` (`sheetBody` sets `pt-0`), so it
92
+ rests at the list's top edge and pins where it rests; with the padding on the
93
+ content container it rode up 8pt before it stuck. It stays in the list rather than
94
+ above it, or dynamic sizing would stop counting it. Group headings are not
95
+ sticky.
86
96
  - **A sheet sized to its rows is capped.** `resolveSelectSheetMaxHeight` hands
87
97
  the sheet `maxDynamicContentSize` — the lower of 85% of the window and the room
88
98
  below the top inset less a 24pt gap — and the list scrolls inside it. Without
@@ -163,3 +173,16 @@ engine. An app that imports no picker still never resolves it.
163
173
  - **`presentation` is a union of one.** `"sheet"` today; an anchored member is
164
174
  added once the library has a popover. There is no platform-native picker mode
165
175
  — it would need a new native peer.
176
+
177
+ ## Test IDs
178
+
179
+ `testID` goes on the trigger, and the sheet's parts derive from it:
180
+
181
+ | Part | testID |
182
+ | --- | --- |
183
+ | A row | `${testID}-option-${value}` |
184
+ | The pinned header (title, close, search) | `${testID}-header` |
185
+ | The list | `${testID}-list` |
186
+ | The search field | `${testID}-search` |
187
+ | The close | `${testID}-close` |
188
+ | Done, in multiple mode | `${testID}-done` |
@@ -95,6 +95,13 @@ describe("Select trigger", () => {
95
95
  expect(screen.getByRole("radio", { name: "Designer" })).toBeOnTheScreen();
96
96
  });
97
97
 
98
+ test("the title and search stay pinned while the rows scroll", async () => {
99
+ await renderSelect({ isSearchable: true, title: "Your role" });
100
+ await openSheet("Your role");
101
+ expect(screen.getByTestId("select-list")).toHaveProp("stickyHeaderIndices", [0]);
102
+ expect(screen.getByTestId("select-header")).toBeOnTheScreen();
103
+ });
104
+
98
105
  test("a disabled select is disabled and never opens", async () => {
99
106
  await renderSelect({ isDisabled: true });
100
107
  expect(trigger()).toBeDisabled();
@@ -209,6 +216,34 @@ describe("Select single", () => {
209
216
  await waitFor(() => expect(screen.queryByRole("radio", { name: "Engineer" })).not.toBeOnTheScreen());
210
217
  });
211
218
 
219
+ test("onConfirm fires alone for the chosen row pressed again, and after onValueChange for a new pick", async () => {
220
+ const calls: string[] = [];
221
+ const onValueChange = jest.fn((_value: unknown) => void calls.push("change"));
222
+ const onConfirm = jest.fn((_value: unknown) => void calls.push("confirm"));
223
+ await renderSelect({ defaultValue: "designer", onConfirm, onValueChange });
224
+ await openSheet();
225
+ await tap(screen.getByRole("radio", { name: "Designer" }));
226
+ expect(onConfirm).toHaveBeenLastCalledWith("designer");
227
+ expect(onValueChange).not.toHaveBeenCalled();
228
+ await waitFor(() => expect(screen.queryByRole("radio", { name: "Engineer" })).not.toBeOnTheScreen());
229
+
230
+ await openSheet();
231
+ await tap(screen.getByRole("radio", { name: "Engineer" }));
232
+ expect(onConfirm).toHaveBeenLastCalledWith("engineer");
233
+ expect(onConfirm).toHaveBeenCalledTimes(2);
234
+ expect(calls).toEqual(["confirm", "change", "confirm"]);
235
+ });
236
+
237
+ test("isClearable: clearing the chosen row does not confirm", async () => {
238
+ const onConfirm = jest.fn();
239
+ const onValueChange = jest.fn();
240
+ await renderSelect({ defaultValue: "designer", isClearable: true, onConfirm, onValueChange });
241
+ await openSheet();
242
+ await tap(screen.getByRole("radio", { name: "Designer" }));
243
+ expect(onValueChange).toHaveBeenCalledWith(null);
244
+ expect(onConfirm).not.toHaveBeenCalled();
245
+ });
246
+
212
247
  test("isClearable: pressing the chosen row clears it and reports null", async () => {
213
248
  const onValueChange = jest.fn();
214
249
  await renderSelect({ defaultValue: "designer", isClearable: true, onValueChange });
@@ -80,7 +80,7 @@ type SelectBaseProps = {
80
80
  formatSelectedCount?: (count: number) => string;
81
81
  /** Classes for the trigger. */
82
82
  className?: string;
83
- /** On the trigger; rows take `${testID}-option-${value}`, search `-search`, close `-close`, Done `-done`. */
83
+ /** On the trigger; rows take `${testID}-option-${value}`, search `-search`, close `-close`, Done `-done`, header `-header`, list `-list`. */
84
84
  testID?: string;
85
85
  /** `Select.Item`, `Select.Group`, and optionally a `Select.Trigger` to replace the default one. */
86
86
  children?: ReactNode;
@@ -93,6 +93,12 @@ export type SelectSingleProps = SelectBaseProps & {
93
93
  onValueChange?: (value: string | null) => void;
94
94
  /** A second press on the chosen row clears it. @default false */
95
95
  isClearable?: boolean;
96
+ /**
97
+ * Fires on every pick, after `onValueChange`, including a press on the chosen row, which closes
98
+ * the sheet without `onValueChange`. Never on a clear or a dismiss. Lets a form move on after the
99
+ * user confirms the option it already holds.
100
+ */
101
+ onConfirm?: (value: string) => void;
96
102
  };
97
103
 
98
104
  export type SelectMultipleProps = SelectBaseProps & {
@@ -111,6 +117,8 @@ export type SelectMultipleProps = SelectBaseProps & {
111
117
  export type SelectProps = SelectSingleProps | SelectMultipleProps;
112
118
 
113
119
  const NO_VALUES: readonly string[] = [];
120
+ /** FlatList puts `ListHeaderComponent` at child 0, so this pins the header. Module scope keeps one reference across renders. */
121
+ const STICKY_HEADER = [0];
114
122
 
115
123
  function SelectRoot(props: SelectProps): ReactElement {
116
124
  const {
@@ -198,7 +206,10 @@ function SelectRoot(props: SelectProps): ReactElement {
198
206
  const result = toggleSelection(selected, value, toggleOptions);
199
207
  if (result.change === "blocked" || result.change === "limit-reached") playHaptic("warning");
200
208
  if (result.change !== "unchanged" && result.change !== "blocked") setSelected(result.selected);
201
- if (mode === "single") close();
209
+ if (mode !== "single") return;
210
+ const confirmed = result.selected[0];
211
+ if (confirmed !== undefined) single?.onConfirm?.(confirmed);
212
+ close();
202
213
  };
203
214
 
204
215
  // Offered to an enclosing `Field`, so tapping its label opens the sheet the
@@ -284,12 +295,14 @@ function SelectRoot(props: SelectProps): ReactElement {
284
295
  };
285
296
 
286
297
  // The title and the search field ride at the head of the list rather than
287
- // above it, so they count towards the height the sheet sizes itself to. The
288
- // close sits in the title's row, so it covers nothing when there is no title.
298
+ // above it, so they count towards the height the sheet sizes itself to, and
299
+ // the list pins them (`stickyHeaderIndices`) so they stay put while the rows
300
+ // scroll under them. The close sits in the title's row, so it covers nothing
301
+ // when there is no title.
289
302
  // The search group opts out of the enclosing Field's state: the sheet only
290
303
  // opens when the select is enabled, and a query is never the invalid value.
291
304
  const header = (
292
- <View className={slots.header()}>
305
+ <View className={slots.header()} testID={testID ? `${testID}-header` : undefined}>
293
306
  <View className={slots.headerBar()}>
294
307
  {sheetTitle ? <BottomSheet.Title className={slots.headerTitle()}>{sheetTitle}</BottomSheet.Title> : null}
295
308
  <BottomSheet.Close className={slots.headerClose()} testID={testID ? `${testID}-close` : undefined} />
@@ -355,6 +368,8 @@ function SelectRoot(props: SelectProps): ReactElement {
355
368
  ListHeaderComponent={header}
356
369
  maxToRenderPerBatch={listWindow.maxToRenderPerBatch}
357
370
  renderItem={renderRow}
371
+ stickyHeaderIndices={STICKY_HEADER}
372
+ testID={testID ? `${testID}-list` : undefined}
358
373
  windowSize={listWindow.windowSize}
359
374
  />
360
375
  {multiple ? (
@@ -1,5 +1,6 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import { declaredTokens } from "../../styles/theme-tokens.test";
3
+ import { bottomSheetVariants } from "../bottom-sheet/bottom-sheet.variants";
3
4
  import { INPUT_SIZES, INPUT_VARIANTS, inputVariants } from "../input/input.variants";
4
5
  import { listGroupVariants } from "../list-group/list-group.variants";
5
6
  import type { SelectEntry, SelectOptionInput } from "./select.types";
@@ -90,6 +91,26 @@ function everySlotClass(): string[] {
90
91
  return out;
91
92
  }
92
93
 
94
+ describe("selectVariants header", () => {
95
+ test("is opaque in the sheet's colour, so pinned it hides the rows scrolling under it", () => {
96
+ for (const variant of INPUT_VARIANTS) {
97
+ for (const size of INPUT_SIZES) {
98
+ expect(selectVariants({ size, variant }).header().split(" ")).toContain("bg-popover");
99
+ }
100
+ }
101
+ });
102
+
103
+ test("carries the list's top padding, so it pins where it rests instead of riding up 8pt", () => {
104
+ for (const variant of INPUT_VARIANTS) {
105
+ for (const size of INPUT_SIZES) {
106
+ const slots = selectVariants({ size, variant });
107
+ expect(slots.header().split(" ")).toContain("pt-2");
108
+ expect(bottomSheetVariants().scrollContent({ className: slots.sheetBody() }).split(" ")).toContain("pt-0");
109
+ }
110
+ }
111
+ });
112
+ });
113
+
93
114
  const FRUIT: SelectOptionInput[] = [
94
115
  { label: "Apple", value: "apple" },
95
116
  { label: "Banana", value: "banana" },
@@ -164,8 +164,13 @@ export const selectVariants = tv({
164
164
  rowCheckbox: "items-center justify-center overflow-hidden border border-input bg-card",
165
165
  /** Layout only — the heading is a `Text.Overline`, which owns its type. */
166
166
  groupHeading: "pb-1.5 pt-4",
167
- /** The sheet's title and search field, above the rows. */
168
- header: "gap-3 pb-3",
167
+ /**
168
+ * The sheet's title and search field, pinned above the rows. Opaque, so
169
+ * rows scroll under it unseen. It carries the list's top padding (`pt-2`,
170
+ * taken off `sheetBody`), so it rests at the list's top edge and pins
171
+ * exactly where it rests rather than riding up the padding first.
172
+ */
173
+ header: "gap-3 bg-popover pb-3 pt-2",
169
174
  /**
170
175
  * The close and the optional title, in one row above the search.
171
176
  *
@@ -178,8 +183,8 @@ export const selectVariants = tv({
178
183
  /** The bar already clears the close, so the title needs no gutter. */
179
184
  headerTitle: "flex-1 pr-0",
180
185
  empty: "items-center justify-center py-8",
181
- /** Overrides the sheet's list gutter gap: rows touch, the way a list's do. */
182
- sheetBody: "gap-0",
186
+ /** Overrides the sheet's list gutter gap — rows touch, the way a list's do — and hands its top padding to `header`. */
187
+ sheetBody: "gap-0 pt-0",
183
188
  },
184
189
  variants: {
185
190
  variant: {