@delacour/react-native-ui 0.5.0-alpha.20261023135343 → 0.5.0-alpha.20261024103119
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.5.0-alpha.
|
|
3
|
+
"version": "0.5.0-alpha.20261024103119",
|
|
4
4
|
"description": "React Native UI components — Uniwind, Reanimated, Gesture Handler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -182,8 +182,8 @@
|
|
|
182
182
|
"expo-blur": ">=15",
|
|
183
183
|
"@maplibre/maplibre-react-native": "^11.5.0",
|
|
184
184
|
"@central-icons-react-native/round-outlined-radius-1-stroke-1.5": "^1.1",
|
|
185
|
-
"@delacour/react-native-bottom-sheet": "0.3.0-alpha.
|
|
186
|
-
"@delacour/react-native-charts": "0.2.0-alpha.
|
|
185
|
+
"@delacour/react-native-bottom-sheet": "0.3.0-alpha.20261024103119",
|
|
186
|
+
"@delacour/react-native-charts": "0.2.0-alpha.20261024103119",
|
|
187
187
|
"@legendapp/list": ">=3.3",
|
|
188
188
|
"react-native-skia": ">=3.7.3",
|
|
189
189
|
"expo-linear-gradient": ">=15",
|
|
@@ -32,7 +32,7 @@ typed text can become a value.
|
|
|
32
32
|
| `combobox.context.tsx` | `ComboboxProvider`, `useCombobox()`, `useComboboxContext()`, `useComboboxPart()` |
|
|
33
33
|
| `combobox.types.ts` | `ComboboxOption`, `ComboboxOptionGroup`, `ComboboxEntry`, `ComboboxFilter`, `ComboboxListRow`, … |
|
|
34
34
|
| `combobox.filter.ts` | Pure: normalise, match, filter, create row, highlight ranges, pending remove, query reset, announcement, remembered selection |
|
|
35
|
-
| `combobox.variants.ts` | Pure: the added slots, the trigger class, chip size / colour / cap, trigger text, the keyboard-aware sheet cap and the held
|
|
35
|
+
| `combobox.variants.ts` | Pure: the added slots, the trigger class, chip size / colour / cap, trigger text, the keyboard-aware sheet cap and the sheet's held height |
|
|
36
36
|
| `*.test.ts` | |
|
|
37
37
|
|
|
38
38
|
## Design
|
|
@@ -104,32 +104,24 @@ typed text can become a value.
|
|
|
104
104
|
sheet's chip row and multiple mode's rows sit in a view whose
|
|
105
105
|
`onStartShouldSetResponder` returns true. A single pick closes the sheet, so
|
|
106
106
|
its rows let the keyboard go.
|
|
107
|
-
- **The sheet
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
the
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
reported height, so it moved again as the keyboard arrived, was measured and
|
|
126
|
-
left. Now the cap is the sheet's one snap point, `dynamicSizing` is off, and
|
|
127
|
-
`resolveComboboxSheetHeight` sizes it for the keyboard expected when `open()`
|
|
128
|
-
ran, held until the next open. A live keyboard counts only when it is taller
|
|
129
|
-
than the one held — the engine's lift would otherwise carry the top under the
|
|
130
|
-
status bar — so a smaller one, or none, leaves the height alone. A short list
|
|
131
|
-
sits at the top of a full-height sheet; a caller who wants it shorter passes
|
|
132
|
-
`snapPoints`, which replaces the cap entirely.
|
|
107
|
+
- **The sheet opens at its full height and the keyboard never moves it.** It
|
|
108
|
+
used to size itself to its rows, so every keystroke resized it. Then it was
|
|
109
|
+
sized to the room above the keyboard and the engine lifted it by the
|
|
110
|
+
keyboard: it opened half-height, rode the keyboard up once the field
|
|
111
|
+
focused, and dropped back as the keyboard left on close — two moves per open
|
|
112
|
+
and one per close, all of it in the launch clip.
|
|
113
|
+
`resolveComboboxSheetHeight` is now Select's cap for an empty screen, the
|
|
114
|
+
sheet's one snap point, with `dynamicSizing` off and the engine's
|
|
115
|
+
`keyboardLiftLimit="highestSnapPoint"`: a sheet resting at its highest snap
|
|
116
|
+
point is not lifted, so the keyboard covers its bottom and the list's
|
|
117
|
+
viewport shrinks by it. Rows are top-aligned, so nothing visible moves but the
|
|
118
|
+
keyboard. Passing the engine a `topInset` was tried and rejected: it shrinks
|
|
119
|
+
the frame, and the scrim with it, leaving the status bar uncovered. A short
|
|
120
|
+
list sits at the top of a full-height sheet; a caller who wants it shorter
|
|
121
|
+
passes `snapPoints`, which replaces the cap, and the lift still stops at the
|
|
122
|
+
highest of them. `resolveComboboxSheetMaxHeight` and
|
|
123
|
+
`resolveExpectedKeyboardHeight` remain exported for callers sizing a sheet of
|
|
124
|
+
their own above a keyboard; the combobox no longer reads either.
|
|
133
125
|
- **Scrolling the list keeps the keyboard up.** The engine puts the keyboard
|
|
134
126
|
away the moment any pan starts on the sheet (`enableBlurKeyboardOnGesture`),
|
|
135
127
|
and its lists dismiss interactively, so scrolling the results to look past
|
|
@@ -7,9 +7,7 @@ import {
|
|
|
7
7
|
useWindowDimensions,
|
|
8
8
|
View,
|
|
9
9
|
} from "react-native";
|
|
10
|
-
import { useKeyboardHandler } from "react-native-keyboard-controller";
|
|
11
10
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
12
|
-
import { scheduleOnRN } from "react-native-worklets";
|
|
13
11
|
import { useControllableState } from "../../hooks/use-controllable-state";
|
|
14
12
|
import { IconCrossSmall, IconMagnifyingGlass } from "../../icons/central";
|
|
15
13
|
import { BottomSheet, type BottomSheetProps } from "../bottom-sheet";
|
|
@@ -53,12 +51,7 @@ import type {
|
|
|
53
51
|
ComboboxOptionInput,
|
|
54
52
|
ComboboxPresentation,
|
|
55
53
|
} from "./combobox.types";
|
|
56
|
-
import {
|
|
57
|
-
comboboxVariants,
|
|
58
|
-
resolveComboboxSheetHeight,
|
|
59
|
-
resolveComboboxTriggerText,
|
|
60
|
-
resolveExpectedKeyboardHeight,
|
|
61
|
-
} from "./combobox.variants";
|
|
54
|
+
import { comboboxVariants, resolveComboboxSheetHeight, resolveComboboxTriggerText } from "./combobox.variants";
|
|
62
55
|
import { ComboboxChipRow } from "./combobox-chip-row";
|
|
63
56
|
import { ComboboxCreateRow } from "./combobox-create-row";
|
|
64
57
|
import { ComboboxEmpty } from "./combobox-empty";
|
|
@@ -200,23 +193,6 @@ function ComboboxRoot(props: ComboboxProps): ReactElement {
|
|
|
200
193
|
const field = useFieldContext();
|
|
201
194
|
const { height: windowHeight } = useWindowDimensions();
|
|
202
195
|
const { top: topInset } = useSafeAreaInsets();
|
|
203
|
-
// The keyboard's target height, read as it starts to move, and the last one
|
|
204
|
-
// measured — see `resolveExpectedKeyboardHeight` for why both.
|
|
205
|
-
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
206
|
-
const [lastKeyboardHeight, setLastKeyboardHeight] = useState(0);
|
|
207
|
-
const handleKeyboardStart = (height: number) => {
|
|
208
|
-
setKeyboardHeight(height);
|
|
209
|
-
if (height > 0) setLastKeyboardHeight(height);
|
|
210
|
-
};
|
|
211
|
-
useKeyboardHandler(
|
|
212
|
-
{
|
|
213
|
-
onStart: (event) => {
|
|
214
|
-
"worklet";
|
|
215
|
-
scheduleOnRN(handleKeyboardStart, event.height);
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
[]
|
|
219
|
-
);
|
|
220
196
|
const resolvedIsInvalid = isInvalid ?? field?.isInvalid ?? false;
|
|
221
197
|
const resolvedIsDisabled = isDisabled ?? field?.isDisabled ?? false;
|
|
222
198
|
|
|
@@ -259,25 +235,13 @@ function ComboboxRoot(props: ComboboxProps): ReactElement {
|
|
|
259
235
|
};
|
|
260
236
|
|
|
261
237
|
const [isOpen, setOpen] = useState(false);
|
|
262
|
-
// The keyboard the sheet is sized for, fixed when it opens so the height
|
|
263
|
-
// holds while it is open — see `resolveComboboxSheetHeight`.
|
|
264
|
-
const [heldKeyboardHeight, setHeldKeyboardHeight] = useState(0);
|
|
265
238
|
const [pending, setPending] = useState<ComboboxPendingRemoveState>(IDLE);
|
|
266
239
|
const inputRef = useRef<TextInputInstance | null>(null);
|
|
267
240
|
const canOpen = !resolvedIsDisabled && !isReadOnly;
|
|
268
241
|
|
|
269
242
|
const open = useCallback(() => {
|
|
270
|
-
if (
|
|
271
|
-
|
|
272
|
-
resolveExpectedKeyboardHeight({
|
|
273
|
-
expectsKeyboard: openOnFocus,
|
|
274
|
-
keyboardHeight,
|
|
275
|
-
lastKnown: lastKeyboardHeight,
|
|
276
|
-
windowHeight,
|
|
277
|
-
})
|
|
278
|
-
);
|
|
279
|
-
setOpen(true);
|
|
280
|
-
}, [canOpen, openOnFocus, keyboardHeight, lastKeyboardHeight, windowHeight]);
|
|
243
|
+
if (canOpen) setOpen(true);
|
|
244
|
+
}, [canOpen]);
|
|
281
245
|
|
|
282
246
|
// One path for every close — Done, a swipe, the overlay, the close button —
|
|
283
247
|
// and each one empties the query, so the next open starts from the whole
|
|
@@ -292,7 +256,7 @@ function ComboboxRoot(props: ComboboxProps): ReactElement {
|
|
|
292
256
|
};
|
|
293
257
|
const close = () => handleOpenChange(false);
|
|
294
258
|
|
|
295
|
-
const sheetHeight = resolveComboboxSheetHeight({
|
|
259
|
+
const sheetHeight = resolveComboboxSheetHeight({ topInset, windowHeight });
|
|
296
260
|
const fixedSnapPoints = useMemo(() => [sheetHeight], [sheetHeight]);
|
|
297
261
|
|
|
298
262
|
// The field is focused once the sheet has settled, never with it: a
|
|
@@ -563,6 +527,7 @@ function ComboboxRoot(props: ComboboxProps): ReactElement {
|
|
|
563
527
|
dynamicSizing={false}
|
|
564
528
|
enableBlurKeyboardOnGesture={false}
|
|
565
529
|
isOpen={isOpen}
|
|
530
|
+
keyboardLiftLimit="highestSnapPoint"
|
|
566
531
|
onIndexChange={handleIndexChange}
|
|
567
532
|
onOpenChange={handleOpenChange}
|
|
568
533
|
snapPoints={snapPoints ?? fixedSnapPoints}
|
|
@@ -227,31 +227,13 @@ describe("resolveExpectedKeyboardHeight", () => {
|
|
|
227
227
|
describe("resolveComboboxSheetHeight", () => {
|
|
228
228
|
const room = { topInset: 62, windowHeight: 874 };
|
|
229
229
|
|
|
230
|
-
test("is
|
|
231
|
-
expect(resolveComboboxSheetHeight(
|
|
232
|
-
resolveComboboxSheetMaxHeight({ ...room, keyboardHeight: 358 })
|
|
233
|
-
);
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
test("does not move when a smaller keyboard than the one held arrives", () => {
|
|
237
|
-
const opened = resolveComboboxSheetHeight({ ...room, heldKeyboardHeight: 358, keyboardHeight: 0 });
|
|
238
|
-
expect(resolveComboboxSheetHeight({ ...room, heldKeyboardHeight: 358, keyboardHeight: 336 })).toBe(opened);
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
test("does not grow back when the keyboard leaves", () => {
|
|
242
|
-
const up = resolveComboboxSheetHeight({ ...room, heldKeyboardHeight: 336, keyboardHeight: 336 });
|
|
243
|
-
expect(resolveComboboxSheetHeight({ ...room, heldKeyboardHeight: 336, keyboardHeight: 0 })).toBe(up);
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
test("gives way to a keyboard taller than the one held", () => {
|
|
247
|
-
expect(resolveComboboxSheetHeight({ ...room, heldKeyboardHeight: 300, keyboardHeight: 380 })).toBe(
|
|
248
|
-
resolveComboboxSheetMaxHeight({ ...room, keyboardHeight: 380 })
|
|
249
|
-
);
|
|
230
|
+
test("is Select's cap for an empty screen — the keyboard covers the sheet's bottom rather than lifting it", () => {
|
|
231
|
+
expect(resolveComboboxSheetHeight(room)).toBe(resolveSelectSheetMaxHeight(room));
|
|
250
232
|
});
|
|
251
233
|
|
|
252
|
-
test("
|
|
253
|
-
expect(resolveComboboxSheetHeight(
|
|
254
|
-
|
|
234
|
+
test("is taller than the room above any keyboard, so a keyboard never moves it", () => {
|
|
235
|
+
expect(resolveComboboxSheetHeight(room)).toBeGreaterThan(
|
|
236
|
+
resolveComboboxSheetMaxHeight({ ...room, keyboardHeight: 336 })
|
|
255
237
|
);
|
|
256
238
|
});
|
|
257
239
|
});
|
|
@@ -197,30 +197,22 @@ export function resolveExpectedKeyboardHeight({
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
/**
|
|
200
|
-
* The sheet's one snap point
|
|
200
|
+
* The sheet's one snap point: Select's cap for an empty screen.
|
|
201
201
|
*
|
|
202
|
-
* The sheet opens
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
202
|
+
* The sheet opens there and holds it. Sized to its rows it shrank and grew on
|
|
203
|
+
* every keystroke; sized to the room above the keyboard it opened half-height,
|
|
204
|
+
* then rode the keyboard up once the field focused and dropped back as the
|
|
205
|
+
* keyboard left on close — two moves for every open and one for every close.
|
|
206
|
+
* At this height the engine's `keyboardLiftLimit="highestSnapPoint"` never
|
|
207
|
+
* lifts it: the keyboard covers the sheet's bottom and the list's viewport
|
|
208
|
+
* shrinks by it instead. The keyboard is not an input.
|
|
209
209
|
*/
|
|
210
210
|
export function resolveComboboxSheetHeight({
|
|
211
|
-
heldKeyboardHeight,
|
|
212
|
-
keyboardHeight,
|
|
213
211
|
topInset,
|
|
214
212
|
windowHeight,
|
|
215
213
|
}: {
|
|
216
|
-
heldKeyboardHeight: number;
|
|
217
|
-
keyboardHeight: number;
|
|
218
214
|
topInset: number;
|
|
219
215
|
windowHeight: number;
|
|
220
216
|
}): number {
|
|
221
|
-
return
|
|
222
|
-
keyboardHeight: Math.max(heldKeyboardHeight, keyboardHeight),
|
|
223
|
-
topInset,
|
|
224
|
-
windowHeight,
|
|
225
|
-
});
|
|
217
|
+
return resolveSelectSheetMaxHeight({ topInset, windowHeight });
|
|
226
218
|
}
|