@delacour/react-native-ui 0.8.0 → 0.8.1-alpha.20261109114648
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/input/AGENTS.md +4 -1
- package/src/components/input/input-group.tsx +5 -2
- package/src/components/input/input.render.test.tsx +34 -0
- package/src/components/select/AGENTS.md +3 -0
- package/src/components/select/select.render.test.tsx +15 -0
- package/src/components/select/select.tsx +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delacour/react-native-ui",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1-alpha.20261109114648",
|
|
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": "
|
|
190
|
-
"@delacour/react-native-charts": "
|
|
189
|
+
"@delacour/react-native-bottom-sheet": "0.8.1-alpha.20261109114648",
|
|
190
|
+
"@delacour/react-native-charts": "0.8.1-alpha.20261109114648",
|
|
191
191
|
"@legendapp/list": ">=3.3",
|
|
192
192
|
"react-native-skia": ">=3.9.0",
|
|
193
193
|
"expo-linear-gradient": ">=15",
|
|
@@ -134,7 +134,10 @@ or drops its focus.
|
|
|
134
134
|
`Separator` bleeds through the horizontal inset, so its own padding is all
|
|
135
135
|
there is on either side. Only the outermost block takes it — the first `start`
|
|
136
136
|
block and the last `end` block, picked by the pure `resolveOuterBlocks`. A
|
|
137
|
-
second block in a section would be pulled over its separator.
|
|
137
|
+
second block in a section would be pulled over its separator. Every block is
|
|
138
|
+
wrapped in `InputGroupOuterBlockProvider`, outermost or not, and only its
|
|
139
|
+
boolean changes: a block that stops being outermost when another is appended
|
|
140
|
+
keeps its subtree mounted, so its controls keep their state and focus.
|
|
138
141
|
- **A `Block` draws no border.** Divide it from the row with a `Separator`, or
|
|
139
142
|
leave it flush. Bare text and `Icon`s in it take the decorator treatment.
|
|
140
143
|
- **`Separator` has no `orientation` prop.** `InputGroupPlacementProvider` tells
|
|
@@ -153,10 +153,13 @@ function sortIntoSections(children: ReactNode): Record<InputGroupSegment, ReactN
|
|
|
153
153
|
const outer = resolveOuterBlocks(kinds);
|
|
154
154
|
const sections: Record<InputGroupSegment, ReactNode[]> = { end: [], row: [], start: [] };
|
|
155
155
|
|
|
156
|
+
// Every block gets the provider, outermost or not. Only its value changes,
|
|
157
|
+
// so a block that stops being outermost keeps its subtree mounted.
|
|
156
158
|
for (const [index, child] of items.entries()) {
|
|
159
|
+
const isBlock = kinds[index] === "block-start" || kinds[index] === "block-end";
|
|
157
160
|
const placed =
|
|
158
|
-
|
|
159
|
-
<InputGroupOuterBlockProvider key={child.key} value>
|
|
161
|
+
isBlock && isValidElement(child) ? (
|
|
162
|
+
<InputGroupOuterBlockProvider key={child.key} value={outer[index] ?? false}>
|
|
160
163
|
{child}
|
|
161
164
|
</InputGroupOuterBlockProvider>
|
|
162
165
|
) : (
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, jest, test } from "@jest/globals";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
+
import { TextInput } from "react-native";
|
|
3
4
|
import { fireEvent, renderWithProviders, screen, userEvent } from "../../test/render";
|
|
4
5
|
import { Field } from "../field";
|
|
5
6
|
import { Input } from "./input";
|
|
@@ -18,6 +19,12 @@ function ControlledInput({ onChangeText }: { onChangeText: (text: string) => voi
|
|
|
18
19
|
);
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
/** Holds its text in local state, so a remount shows up as an empty field. */
|
|
23
|
+
function StatefulInput() {
|
|
24
|
+
const [value, setValue] = useState("");
|
|
25
|
+
return <TextInput accessibilityLabel="Note" onChangeText={setValue} value={value} />;
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
describe("Input", () => {
|
|
22
29
|
test("is a text field named by its accessibilityLabel", async () => {
|
|
23
30
|
await renderWithProviders(<Input accessibilityLabel="Email" placeholder="you@example.com" />);
|
|
@@ -214,6 +221,33 @@ describe("Input", () => {
|
|
|
214
221
|
expect(onBlur).toHaveBeenCalledTimes(1);
|
|
215
222
|
});
|
|
216
223
|
|
|
224
|
+
// A block stops being the outermost one when another is appended after
|
|
225
|
+
// it. Its subtree must stay mounted, or its controls lose their state.
|
|
226
|
+
test("a block keeps its state when it stops being the outermost", async () => {
|
|
227
|
+
const view = await renderWithProviders(
|
|
228
|
+
<Input.Group>
|
|
229
|
+
<Input accessibilityLabel="Message" />
|
|
230
|
+
<Input.Group.Block key="first" position="end">
|
|
231
|
+
<StatefulInput />
|
|
232
|
+
</Input.Group.Block>
|
|
233
|
+
</Input.Group>
|
|
234
|
+
);
|
|
235
|
+
await fireEvent.changeText(screen.getByLabelText("Note"), "kept");
|
|
236
|
+
|
|
237
|
+
await view.rerender(
|
|
238
|
+
<Input.Group>
|
|
239
|
+
<Input accessibilityLabel="Message" />
|
|
240
|
+
<Input.Group.Block key="first" position="end">
|
|
241
|
+
<StatefulInput />
|
|
242
|
+
</Input.Group.Block>
|
|
243
|
+
<Input.Group.Block key="second" position="end">
|
|
244
|
+
<Input.Group.Suffix>Last</Input.Group.Suffix>
|
|
245
|
+
</Input.Group.Block>
|
|
246
|
+
</Input.Group>
|
|
247
|
+
);
|
|
248
|
+
expect(screen.getByLabelText("Note")).toHaveDisplayValue("kept");
|
|
249
|
+
});
|
|
250
|
+
|
|
217
251
|
describe("parts outside a group", () => {
|
|
218
252
|
let original: typeof console.error;
|
|
219
253
|
beforeEach(() => {
|
|
@@ -142,6 +142,9 @@ engine. An app that imports no picker still never resolves it.
|
|
|
142
142
|
- **Read-only looks normal and never opens.** The trigger stays enabled for a
|
|
143
143
|
screen reader — it is not disabled, it is fixed — with no press feedback, and
|
|
144
144
|
`open` refuses.
|
|
145
|
+
- **An open sheet locks with the select.** Turn the select disabled or read-only
|
|
146
|
+
while its sheet is open and every row is announced disabled, and a press that
|
|
147
|
+
still lands changes nothing — the value and `onValueChange` stay put.
|
|
145
148
|
- **The trigger is a button.** React Native has no combobox role that works on
|
|
146
149
|
both platforms, so it is `button` with the choice as its `accessibilityValue`,
|
|
147
150
|
`expanded` in its state, and a hint. Rows are `radio` or `checkbox` with
|
|
@@ -156,6 +156,21 @@ describe("Select single", () => {
|
|
|
156
156
|
expect(screen.getByRole("radio", { name: "Designer" })).toBeOnTheScreen();
|
|
157
157
|
});
|
|
158
158
|
|
|
159
|
+
test.each([
|
|
160
|
+
["disabled", { isDisabled: true }],
|
|
161
|
+
["read-only", { isReadOnly: true }],
|
|
162
|
+
] as const)("an open sheet locks its options once the select turns %s", async (_, lock) => {
|
|
163
|
+
const onValueChange = jest.fn();
|
|
164
|
+
const view = await renderSelect({ isOpen: true, onValueChange });
|
|
165
|
+
await view.rerender(
|
|
166
|
+
<Select isOpen onValueChange={onValueChange} options={OPTIONS} placeholder="Choose" testID="select" {...lock} />
|
|
167
|
+
);
|
|
168
|
+
const designer = screen.getByRole("radio", { name: "Designer" });
|
|
169
|
+
expect(designer).toBeDisabled();
|
|
170
|
+
await tap(designer);
|
|
171
|
+
expect(onValueChange).not.toHaveBeenCalled();
|
|
172
|
+
});
|
|
173
|
+
|
|
159
174
|
test("pressing the chosen row again keeps it and closes, without reporting", async () => {
|
|
160
175
|
const onValueChange = jest.fn();
|
|
161
176
|
await renderSelect({ defaultValue: "designer", onValueChange });
|
|
@@ -190,7 +190,10 @@ function SelectRoot(props: SelectProps): ReactElement {
|
|
|
190
190
|
const toggleOptions: SelectToggleOptions =
|
|
191
191
|
mode === "multiple" ? { max: maxSelected, mode: "multiple" } : { isClearable, mode: "single" };
|
|
192
192
|
|
|
193
|
+
// The sheet can stay open while the select turns disabled or read-only, so
|
|
194
|
+
// the rows lock with it and a press that slips through changes nothing.
|
|
193
195
|
const toggle = (value: string) => {
|
|
196
|
+
if (!canOpen) return;
|
|
194
197
|
const result = toggleSelection(selected, value, toggleOptions);
|
|
195
198
|
if (result.change === "blocked" || result.change === "limit-reached") playHaptic("warning");
|
|
196
199
|
if (result.change !== "unchanged" && result.change !== "blocked") setSelected(result.selected);
|
|
@@ -266,7 +269,7 @@ function SelectRoot(props: SelectProps): ReactElement {
|
|
|
266
269
|
return (
|
|
267
270
|
<SelectOptionRow
|
|
268
271
|
description={limitDescription}
|
|
269
|
-
isDisabled={state.isDisabled}
|
|
272
|
+
isDisabled={state.isDisabled || !canOpen}
|
|
270
273
|
isSelected={isSelected}
|
|
271
274
|
mode={mode}
|
|
272
275
|
onPress={toggle}
|