@delacour/react-native-ui 0.6.0-alpha.20261103164139 → 0.6.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/package.json +13 -7
- package/src/components/accordion/AGENTS.md +1 -0
- package/src/components/accordion/accordion.render.test.tsx +330 -0
- package/src/components/alert/AGENTS.md +1 -0
- package/src/components/alert/alert.render.test.tsx +162 -0
- package/src/components/animated-badge/AGENTS.md +1 -0
- package/src/components/animated-badge/animated-badge.render.test.tsx +136 -0
- package/src/components/attachment/AGENTS.md +1 -0
- package/src/components/attachment/attachment.render.test.tsx +422 -0
- package/src/components/avatar/AGENTS.md +1 -0
- package/src/components/avatar/avatar.render.test.tsx +353 -0
- package/src/components/badge/AGENTS.md +1 -0
- package/src/components/badge/badge.render.test.tsx +216 -0
- package/src/components/bottom-sheet/AGENTS.md +1 -0
- package/src/components/bottom-sheet/bottom-sheet.render.test.tsx +190 -0
- package/src/components/breadcrumb/AGENTS.md +1 -0
- package/src/components/breadcrumb/breadcrumb.render.test.tsx +324 -0
- package/src/components/button/AGENTS.md +1 -0
- package/src/components/button/button.render.test.tsx +67 -0
- package/src/components/calendar/AGENTS.md +1 -0
- package/src/components/calendar/calendar.render.test.tsx +388 -0
- package/src/components/card/AGENTS.md +1 -0
- package/src/components/card/card.render.test.tsx +287 -0
- package/src/components/carousel/AGENTS.md +3 -0
- package/src/components/carousel/carousel-content.tsx +3 -1
- package/src/components/carousel/carousel.render.test.tsx +356 -0
- package/src/components/chart/AGENTS.md +1 -0
- package/src/components/chart/chart.render.test.tsx +443 -0
- package/src/components/checkbox/AGENTS.md +2 -0
- package/src/components/checkbox/checkbox.render.test.tsx +250 -0
- package/src/components/checkbox/checkbox.tsx +2 -1
- package/src/components/chip/chip.render.test.tsx +277 -0
- package/src/components/circular-text/AGENTS.md +1 -0
- package/src/components/circular-text/circular-text.render.test.tsx +154 -0
- package/src/components/collapsible/AGENTS.md +1 -0
- package/src/components/collapsible/collapsible.render.test.tsx +243 -0
- package/src/components/color-picker/AGENTS.md +1 -0
- package/src/components/color-picker/color-picker.render.test.tsx +347 -0
- package/src/components/combobox/AGENTS.md +1 -0
- package/src/components/combobox/combobox.render.test.tsx +464 -0
- package/src/components/compare/AGENTS.md +1 -0
- package/src/components/compare/compare.render.test.tsx +265 -0
- package/src/components/context-menu/AGENTS.md +1 -0
- package/src/components/context-menu/context-menu.render.test.tsx +183 -0
- package/src/components/countdown/AGENTS.md +1 -0
- package/src/components/countdown/countdown.render.test.tsx +194 -0
- package/src/components/date-picker/AGENTS.md +1 -0
- package/src/components/date-picker/date-picker.render.test.tsx +378 -0
- package/src/components/date-time-picker/AGENTS.md +1 -0
- package/src/components/date-time-picker/date-time-picker.render.test.tsx +356 -0
- package/src/components/dialog/AGENTS.md +1 -0
- package/src/components/dialog/dialog.render.test.tsx +67 -0
- package/src/components/direction/AGENTS.md +1 -0
- package/src/components/direction/direction.render.test.tsx +150 -0
- package/src/components/drawer/AGENTS.md +1 -0
- package/src/components/drawer/drawer.render.test.tsx +340 -0
- package/src/components/empty-state/AGENTS.md +1 -0
- package/src/components/empty-state/empty-state.render.test.tsx +134 -0
- package/src/components/fab/AGENTS.md +1 -0
- package/src/components/fab/fab.render.test.tsx +278 -0
- package/src/components/feedback/AGENTS.md +1 -0
- package/src/components/feedback/feedback.render.test.tsx +257 -0
- package/src/components/field/AGENTS.md +1 -0
- package/src/components/field/field.render.test.tsx +361 -0
- package/src/components/flip-card/AGENTS.md +1 -0
- package/src/components/flip-card/flip-card.render.test.tsx +259 -0
- package/src/components/flow/AGENTS.md +1 -0
- package/src/components/flow/flow.render.test.tsx +354 -0
- package/src/components/frame/AGENTS.md +1 -0
- package/src/components/frame/frame.render.test.tsx +273 -0
- package/src/components/grid-item/AGENTS.md +1 -0
- package/src/components/grid-item/grid-item.render.test.tsx +326 -0
- package/src/components/icon/AGENTS.md +1 -0
- package/src/components/icon/icon.render.test.tsx +110 -0
- package/src/components/image-viewer/AGENTS.md +5 -0
- package/src/components/image-viewer/image-viewer.render.test.tsx +244 -0
- package/src/components/image-viewer/image-viewer.tsx +6 -3
- package/src/components/input/AGENTS.md +1 -0
- package/src/components/input/input.render.test.tsx +246 -0
- package/src/components/item/AGENTS.md +1 -0
- package/src/components/item/item.render.test.tsx +276 -0
- package/src/components/kpi/AGENTS.md +1 -0
- package/src/components/kpi/kpi.render.test.tsx +232 -0
- package/src/components/label/AGENTS.md +1 -0
- package/src/components/label/label.render.test.tsx +81 -0
- package/src/components/leaderboard/AGENTS.md +1 -0
- package/src/components/leaderboard/leaderboard.render.test.tsx +198 -0
- package/src/components/list-group/AGENTS.md +1 -0
- package/src/components/list-group/list-group.render.test.tsx +279 -0
- package/src/components/map/AGENTS.md +1 -0
- package/src/components/map/map.render.test.tsx +460 -0
- package/src/components/markdown-editor/AGENTS.md +1 -0
- package/src/components/markdown-editor/markdown-editor.render.test.tsx +461 -0
- package/src/components/marker/AGENTS.md +1 -0
- package/src/components/marker/marker.render.test.tsx +232 -0
- package/src/components/marquee/AGENTS.md +1 -0
- package/src/components/marquee/marquee.render.test.tsx +145 -0
- package/src/components/menu/AGENTS.md +2 -0
- package/src/components/menu/menu-item.tsx +40 -1
- package/src/components/menu/menu.render.test.tsx +449 -0
- package/src/components/message/AGENTS.md +1 -0
- package/src/components/message/message.render.test.tsx +401 -0
- package/src/components/message-scroller/AGENTS.md +1 -0
- package/src/components/message-scroller/message-scroller.render.test.tsx +295 -0
- package/src/components/meter/AGENTS.md +1 -0
- package/src/components/meter/meter.render.test.tsx +249 -0
- package/src/components/number-input/AGENTS.md +2 -0
- package/src/components/number-input/number-input-field.tsx +3 -2
- package/src/components/number-input/number-input.render.test.tsx +426 -0
- package/src/components/otp-input/AGENTS.md +3 -0
- package/src/components/otp-input/otp-input.render.test.tsx +405 -0
- package/src/components/otp-input/otp-input.tsx +9 -2
- package/src/components/overlay/AGENTS.md +7 -1
- package/src/components/overlay/overlay-teleport.ts +21 -0
- package/src/components/overlay/overlay.render.test.tsx +367 -0
- package/src/components/overlay/overlay.tsx +5 -2
- package/src/components/page-header/AGENTS.md +1 -0
- package/src/components/page-header/page-header.render.test.tsx +217 -0
- package/src/components/pagination/AGENTS.md +1 -0
- package/src/components/pagination/pagination.render.test.tsx +293 -0
- package/src/components/planner/AGENTS.md +1 -0
- package/src/components/planner/planner.render.test.tsx +429 -0
- package/src/components/popover/AGENTS.md +1 -0
- package/src/components/popover/popover.render.test.tsx +206 -0
- package/src/components/post/AGENTS.md +4 -0
- package/src/components/post/post-author.tsx +8 -1
- package/src/components/post/post-community.tsx +7 -1
- package/src/components/post/post.render.test.tsx +456 -0
- package/src/components/pressable/AGENTS.md +7 -0
- package/src/components/pressable/pressable.render.test.tsx +183 -0
- package/src/components/pressable/pressable.tsx +1 -1
- package/src/components/progress/AGENTS.md +1 -0
- package/src/components/progress/progress.render.test.tsx +192 -0
- package/src/components/progress-button/AGENTS.md +1 -0
- package/src/components/progress-button/progress-button.render.test.tsx +251 -0
- package/src/components/provider/AGENTS.md +1 -0
- package/src/components/provider/provider.render.test.tsx +101 -0
- package/src/components/qr-code/AGENTS.md +1 -0
- package/src/components/qr-code/qr-code.render.test.tsx +117 -0
- package/src/components/questionnaire/AGENTS.md +1 -0
- package/src/components/questionnaire/questionnaire.render.test.tsx +549 -0
- package/src/components/radio/AGENTS.md +1 -0
- package/src/components/radio/radio.render.test.tsx +334 -0
- package/src/components/rating/AGENTS.md +5 -0
- package/src/components/rating/rating-stars.tsx +4 -0
- package/src/components/rating/rating.render.test.tsx +402 -0
- package/src/components/screen/AGENTS.md +9 -0
- package/src/components/screen/screen-error.tsx +3 -1
- package/src/components/screen/screen-navbar-title.tsx +6 -1
- package/src/components/screen/screen.render.test.tsx +309 -0
- package/src/components/scroll-blur/AGENTS.md +1 -0
- package/src/components/scroll-blur/scroll-blur.render.test.tsx +197 -0
- package/src/components/scroll-canvas/AGENTS.md +1 -0
- package/src/components/scroll-canvas/scroll-canvas.render.test.tsx +184 -0
- package/src/components/scroll-fade/AGENTS.md +1 -0
- package/src/components/scroll-fade/scroll-fade-edge.tsx +1 -0
- package/src/components/scroll-fade/scroll-fade.render.test.tsx +122 -0
- package/src/components/scroll-header/AGENTS.md +1 -0
- package/src/components/scroll-header/scroll-header.render.test.tsx +168 -0
- package/src/components/scroll-text/AGENTS.md +1 -0
- package/src/components/scroll-text/scroll-text.render.test.tsx +191 -0
- package/src/components/search-bar/AGENTS.md +1 -0
- package/src/components/search-bar/search-bar.render.test.tsx +377 -0
- package/src/components/section-progress/AGENTS.md +1 -0
- package/src/components/section-progress/section-progress.render.test.tsx +186 -0
- package/src/components/section-rail/AGENTS.md +1 -0
- package/src/components/section-rail/section-rail.render.test.tsx +341 -0
- package/src/components/select/AGENTS.md +1 -0
- package/src/components/select/select.render.test.tsx +466 -0
- package/src/components/selection-mode/AGENTS.md +1 -0
- package/src/components/selection-mode/selection-mode.render.test.tsx +487 -0
- package/src/components/separator/AGENTS.md +1 -0
- package/src/components/separator/separator.render.test.tsx +43 -0
- package/src/components/signature/AGENTS.md +4 -0
- package/src/components/signature/signature-pad.tsx +4 -0
- package/src/components/signature/signature.render.test.tsx +257 -0
- package/src/components/skeleton/AGENTS.md +2 -1
- package/src/components/skeleton/skeleton.render.test.tsx +222 -0
- package/src/components/sketch/AGENTS.md +2 -0
- package/src/components/sketch/sketch-canvas.tsx +4 -0
- package/src/components/sketch/sketch.render.test.tsx +527 -0
- package/src/components/slide-button/AGENTS.md +2 -0
- package/src/components/slide-button/slide-button.render.test.tsx +354 -0
- package/src/components/slide-button/slide-button.tsx +4 -0
- package/src/components/slider/AGENTS.md +12 -0
- package/src/components/slider/slider-thumb.tsx +2 -1
- package/src/components/slider/slider-track.tsx +4 -1
- package/src/components/slider/slider.render.test.tsx +254 -0
- package/src/components/slider/slider.tsx +11 -0
- package/src/components/sortable/AGENTS.md +2 -0
- package/src/components/sortable/sortable-item.tsx +2 -1
- package/src/components/sortable/sortable.render.test.tsx +204 -0
- package/src/components/spinner/AGENTS.md +3 -0
- package/src/components/spinner/spinner.render.test.tsx +88 -0
- package/src/components/spinner/spinner.tsx +1 -0
- package/src/components/split-view/AGENTS.md +1 -0
- package/src/components/split-view/split-view-drag-area.tsx +2 -0
- package/src/components/split-view/split-view.render.test.tsx +423 -0
- package/src/components/splitter/AGENTS.md +7 -0
- package/src/components/splitter/splitter-handle.tsx +2 -0
- package/src/components/splitter/splitter.render.test.tsx +307 -0
- package/src/components/stack-card/AGENTS.md +3 -0
- package/src/components/stack-card/stack-card.render.test.tsx +309 -0
- package/src/components/stack-card/stack-card.tsx +1 -1
- package/src/components/steps/AGENTS.md +1 -0
- package/src/components/steps/steps.render.test.tsx +318 -0
- package/src/components/support/AGENTS.md +1 -0
- package/src/components/support/support.render.test.tsx +331 -0
- package/src/components/surface/AGENTS.md +1 -0
- package/src/components/surface/surface.render.test.tsx +129 -0
- package/src/components/swipe/AGENTS.md +3 -0
- package/src/components/swipe/swipe.render.test.tsx +280 -0
- package/src/components/swipe/swipe.tsx +7 -4
- package/src/components/switch/AGENTS.md +5 -0
- package/src/components/switch/switch.render.test.tsx +46 -0
- package/src/components/switch/switch.tsx +5 -1
- package/src/components/table/AGENTS.md +1 -0
- package/src/components/table/table.render.test.tsx +294 -0
- package/src/components/tabs/AGENTS.md +6 -0
- package/src/components/tabs/tabs.render.test.tsx +325 -0
- package/src/components/tabs/tabs.tsx +12 -1
- package/src/components/tag-input/AGENTS.md +1 -0
- package/src/components/tag-input/tag-input.render.test.tsx +655 -0
- package/src/components/text/AGENTS.md +1 -0
- package/src/components/text/text.render.test.tsx +197 -0
- package/src/components/text-animation/AGENTS.md +1 -0
- package/src/components/text-animation/text-animation.render.test.tsx +283 -0
- package/src/components/textarea/AGENTS.md +1 -0
- package/src/components/textarea/textarea.render.test.tsx +192 -0
- package/src/components/theme-selector/AGENTS.md +1 -0
- package/src/components/theme-selector/theme-selector.render.test.tsx +196 -0
- package/src/components/time-picker/AGENTS.md +1 -0
- package/src/components/time-picker/time-picker.render.test.tsx +466 -0
- package/src/components/timeline/AGENTS.md +1 -0
- package/src/components/timeline/timeline.render.test.tsx +316 -0
- package/src/components/toast/AGENTS.md +1 -0
- package/src/components/toast/toast.render.test.tsx +245 -0
- package/src/components/toggle-button/AGENTS.md +1 -0
- package/src/components/toggle-button/toggle-button.render.test.tsx +392 -0
- package/src/components/tooltip/AGENTS.md +1 -0
- package/src/components/tooltip/tooltip.render.test.tsx +231 -0
- package/src/components/tour/AGENTS.md +1 -0
- package/src/components/tour/tour.render.test.tsx +217 -0
- package/src/components/tree/AGENTS.md +1 -0
- package/src/components/tree/tree.render.test.tsx +395 -0
- package/src/display-name.test.ts +9 -3
- package/src/render-tests.test.ts +27 -0
- package/src/test/AGENTS.md +121 -0
- package/src/test/render.tsx +22 -0
- package/src/test/setup.ts +142 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { describe, expect, jest, test } from "@jest/globals";
|
|
2
|
+
import { Platform, Text } from "react-native";
|
|
3
|
+
import { fireEvent, renderWithProviders, screen } from "../../test/render";
|
|
4
|
+
import { Marker } from "./marker";
|
|
5
|
+
import { useMarker } from "./marker.context";
|
|
6
|
+
|
|
7
|
+
function Probe() {
|
|
8
|
+
const { variant, isDisabled, isBusy } = useMarker();
|
|
9
|
+
return <Text testID="probe">{`${variant}|${isDisabled}|${isBusy}`}</Text>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function activateAndroid(element: Parameters<typeof fireEvent>[0], actionName: string) {
|
|
13
|
+
return fireEvent(element, "accessibilityAction", { nativeEvent: { actionName } });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* VoiceOver reaches a long press through a held touch, which Jest cannot send;
|
|
18
|
+
* TalkBack lists a `longpress` action, which it can. So the long press runs on Android.
|
|
19
|
+
*/
|
|
20
|
+
async function renderOnAndroid(ui: React.ReactElement) {
|
|
21
|
+
const platform = Platform.OS;
|
|
22
|
+
Platform.OS = "android";
|
|
23
|
+
try {
|
|
24
|
+
return await renderWithProviders(ui);
|
|
25
|
+
} finally {
|
|
26
|
+
Platform.OS = platform;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe("Marker", () => {
|
|
31
|
+
test("a static marker is one text element holding its words", async () => {
|
|
32
|
+
await renderWithProviders(<Marker testID="root">Yesterday</Marker>);
|
|
33
|
+
const root = screen.getByTestId("root");
|
|
34
|
+
expect(root).toHaveProp("accessibilityRole", "text");
|
|
35
|
+
expect(root).toHaveProp("accessible", true);
|
|
36
|
+
expect(root).toHaveTextContent("Yesterday");
|
|
37
|
+
expect(screen.queryByRole("button")).not.toBeOnTheScreen();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("an accessibilityLabel overrides the words", async () => {
|
|
41
|
+
await renderWithProviders(<Marker accessibilityLabel="Searched files">Searched 128 files</Marker>);
|
|
42
|
+
expect(screen.getByLabelText("Searched files")).toBeOnTheScreen();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("consecutive string and number children collapse into one Marker.Content", async () => {
|
|
46
|
+
await renderWithProviders(<Marker>{128} files</Marker>);
|
|
47
|
+
expect(screen.getByText("128 files")).toBeOnTheScreen();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("explicit parts render", async () => {
|
|
51
|
+
await renderWithProviders(
|
|
52
|
+
<Marker>
|
|
53
|
+
<Marker.Icon testID="glyph">
|
|
54
|
+
<Text>*</Text>
|
|
55
|
+
</Marker.Icon>
|
|
56
|
+
<Marker.Content>Read config.ts</Marker.Content>
|
|
57
|
+
</Marker>
|
|
58
|
+
);
|
|
59
|
+
expect(screen.getByText("Read config.ts")).toBeOnTheScreen();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("Marker.Icon is hidden from assistive technology", async () => {
|
|
63
|
+
await renderWithProviders(
|
|
64
|
+
<Marker>
|
|
65
|
+
<Marker.Icon testID="glyph">
|
|
66
|
+
<Text>glyph</Text>
|
|
67
|
+
</Marker.Icon>
|
|
68
|
+
<Marker.Content>Read config.ts</Marker.Content>
|
|
69
|
+
</Marker>
|
|
70
|
+
);
|
|
71
|
+
expect(screen.queryByTestId("glyph")).not.toBeOnTheScreen();
|
|
72
|
+
expect(screen.getByTestId("glyph", { includeHiddenElements: true })).toBeOnTheScreen();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("the separator variant renders its label between two hidden rules", async () => {
|
|
76
|
+
await renderWithProviders(
|
|
77
|
+
<Marker testID="root" variant="separator">
|
|
78
|
+
Yesterday
|
|
79
|
+
</Marker>
|
|
80
|
+
);
|
|
81
|
+
expect(screen.getByText("Yesterday")).toBeOnTheScreen();
|
|
82
|
+
expect(screen.getByTestId("root")).toBeOnTheScreen();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test.each(["default", "border", "separator"] as const)(
|
|
86
|
+
"the %s variant stays a static text element",
|
|
87
|
+
async (variant) => {
|
|
88
|
+
await renderWithProviders(
|
|
89
|
+
<Marker testID="root" variant={variant}>
|
|
90
|
+
Done
|
|
91
|
+
</Marker>
|
|
92
|
+
);
|
|
93
|
+
expect(screen.getByTestId("root")).toBeOnTheScreen();
|
|
94
|
+
expect(screen.queryByRole("button")).not.toBeOnTheScreen();
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
test("a static marker is not busy by default", async () => {
|
|
99
|
+
await renderWithProviders(<Marker testID="root">Done</Marker>);
|
|
100
|
+
expect(screen.getByTestId("root")).not.toBeBusy();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("a shimmering Marker.Content announces the static marker busy", async () => {
|
|
104
|
+
await renderWithProviders(
|
|
105
|
+
<Marker testID="root">
|
|
106
|
+
<Marker.Content shimmer>Searching files</Marker.Content>
|
|
107
|
+
</Marker>
|
|
108
|
+
);
|
|
109
|
+
expect(screen.getByTestId("root")).toBeBusy();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test("dropping shimmer clears busy", async () => {
|
|
113
|
+
const tree = (shimmer: boolean) => (
|
|
114
|
+
<Marker testID="root">
|
|
115
|
+
<Marker.Content shimmer={shimmer}>Searching files</Marker.Content>
|
|
116
|
+
</Marker>
|
|
117
|
+
);
|
|
118
|
+
const view = await renderWithProviders(tree(true));
|
|
119
|
+
expect(screen.getByTestId("root")).toBeBusy();
|
|
120
|
+
await view.rerender(tree(false));
|
|
121
|
+
expect(screen.getByTestId("root")).not.toBeBusy();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("useMarker hands a custom child the variant and state", async () => {
|
|
125
|
+
await renderWithProviders(
|
|
126
|
+
<Marker isDisabled variant="border">
|
|
127
|
+
<Probe />
|
|
128
|
+
<Marker.Content shimmer>Running</Marker.Content>
|
|
129
|
+
</Marker>
|
|
130
|
+
);
|
|
131
|
+
expect(screen.getByTestId("probe")).toHaveTextContent("border|true|true");
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test("a marker with onPress is a button and fires on an assistive tap", async () => {
|
|
135
|
+
const onPress = jest.fn();
|
|
136
|
+
await renderWithProviders(
|
|
137
|
+
<Marker accessibilityHint="Shows the files" onPress={onPress}>
|
|
138
|
+
Searched files
|
|
139
|
+
</Marker>
|
|
140
|
+
);
|
|
141
|
+
const button = screen.getByRole("button", { name: "Searched files" });
|
|
142
|
+
expect(button.props.accessibilityHint).toBe("Shows the files");
|
|
143
|
+
await fireEvent(button, "accessibilityTap");
|
|
144
|
+
expect(onPress).toHaveBeenCalledTimes(1);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test("on Android a marker with only onLongPress is a button and fires on the longpress action", async () => {
|
|
148
|
+
const onLongPress = jest.fn();
|
|
149
|
+
await renderOnAndroid(<Marker onLongPress={onLongPress}>Searched files</Marker>);
|
|
150
|
+
const button = screen.getByRole("button", { name: "Searched files" });
|
|
151
|
+
await activateAndroid(button, "longpress");
|
|
152
|
+
expect(onLongPress).toHaveBeenCalledTimes(1);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test("on Android the activate action calls onPress", async () => {
|
|
156
|
+
const onPress = jest.fn();
|
|
157
|
+
await renderOnAndroid(<Marker onPress={onPress}>Searched files</Marker>);
|
|
158
|
+
await activateAndroid(screen.getByRole("button", { name: "Searched files" }), "activate");
|
|
159
|
+
expect(onPress).toHaveBeenCalledTimes(1);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test("a disabled interactive marker is announced disabled and does not fire", async () => {
|
|
163
|
+
const onPress = jest.fn();
|
|
164
|
+
const onLongPress = jest.fn();
|
|
165
|
+
await renderOnAndroid(
|
|
166
|
+
<Marker isDisabled onLongPress={onLongPress} onPress={onPress}>
|
|
167
|
+
Searched files
|
|
168
|
+
</Marker>
|
|
169
|
+
);
|
|
170
|
+
const button = screen.getByRole("button", { name: "Searched files" });
|
|
171
|
+
expect(button).toBeDisabled();
|
|
172
|
+
await fireEvent(button, "accessibilityTap");
|
|
173
|
+
await activateAndroid(button, "activate");
|
|
174
|
+
await activateAndroid(button, "longpress");
|
|
175
|
+
expect(onPress).not.toHaveBeenCalled();
|
|
176
|
+
expect(onLongPress).not.toHaveBeenCalled();
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test("a running interactive marker is announced busy and still takes its press", async () => {
|
|
180
|
+
const onPress = jest.fn();
|
|
181
|
+
await renderWithProviders(
|
|
182
|
+
<Marker onPress={onPress}>
|
|
183
|
+
<Marker.Content shimmer>Searching files</Marker.Content>
|
|
184
|
+
</Marker>
|
|
185
|
+
);
|
|
186
|
+
const button = screen.getByRole("button", { name: "Searching files" });
|
|
187
|
+
expect(button).toBeBusy();
|
|
188
|
+
expect(button).not.toBeDisabled();
|
|
189
|
+
await fireEvent(button, "accessibilityTap");
|
|
190
|
+
expect(onPress).toHaveBeenCalledTimes(1);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
test("a disabled static marker stays a text element", async () => {
|
|
194
|
+
await renderWithProviders(
|
|
195
|
+
<Marker isDisabled testID="root">
|
|
196
|
+
Done
|
|
197
|
+
</Marker>
|
|
198
|
+
);
|
|
199
|
+
expect(screen.getByTestId("root")).toBeOnTheScreen();
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
test("Marker.Icon outside a Marker throws its documented error", async () => {
|
|
203
|
+
const spy = jest.spyOn(console, "error").mockImplementation(() => {});
|
|
204
|
+
try {
|
|
205
|
+
await expect(renderWithProviders(<Marker.Icon />)).rejects.toThrow(
|
|
206
|
+
"Marker.Icon must be rendered inside a <Marker>."
|
|
207
|
+
);
|
|
208
|
+
} finally {
|
|
209
|
+
spy.mockRestore();
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test("Marker.Content outside a Marker throws its documented error", async () => {
|
|
214
|
+
const spy = jest.spyOn(console, "error").mockImplementation(() => {});
|
|
215
|
+
try {
|
|
216
|
+
await expect(renderWithProviders(<Marker.Content>x</Marker.Content>)).rejects.toThrow(
|
|
217
|
+
"Marker.Content must be rendered inside a <Marker>."
|
|
218
|
+
);
|
|
219
|
+
} finally {
|
|
220
|
+
spy.mockRestore();
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
test("useMarker outside a Marker throws", async () => {
|
|
225
|
+
const spy = jest.spyOn(console, "error").mockImplementation(() => {});
|
|
226
|
+
try {
|
|
227
|
+
await expect(renderWithProviders(<Probe />)).rejects.toThrow("useMarker must be called inside a <Marker>.");
|
|
228
|
+
} finally {
|
|
229
|
+
spy.mockRestore();
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
});
|
|
@@ -21,6 +21,7 @@ root plus `Marquee.Group`, which keeps the strips inside it in step.
|
|
|
21
21
|
| `marquee.types.ts` | `MarqueeStripProps`, shared by the track and the scroller |
|
|
22
22
|
| `marquee.variants.ts` | Slotted `tv()` + every pure resolver and worklet, no RN imports |
|
|
23
23
|
| `marquee.variants.test.ts` | |
|
|
24
|
+
| `marquee.render.test.tsx` | Mounted under Jest — copies mount only after layout, duplicates hidden from assistive tech, `accessibilityLabel` collapses the strip, calm motion swaps in one still copy, `Marquee.Group` renders |
|
|
24
25
|
|
|
25
26
|
Display names: `DelacourUI.Marquee`, `.Group`, `.Group.Provider`, `.Track`, `.Scroller`, `.Fade`.
|
|
26
27
|
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { describe, expect, jest, test } from "@jest/globals";
|
|
2
|
+
import { Text } from "react-native";
|
|
3
|
+
import { fireEvent, renderWithProviders, screen } from "../../test/render";
|
|
4
|
+
import { DelacourProvider } from "../provider";
|
|
5
|
+
import { Marquee } from "./marquee";
|
|
6
|
+
|
|
7
|
+
const WORDS = ["Alpha", "Beta"] as const;
|
|
8
|
+
|
|
9
|
+
function Words() {
|
|
10
|
+
return (
|
|
11
|
+
<>
|
|
12
|
+
{WORDS.map((word) => (
|
|
13
|
+
<Text key={word}>{word}</Text>
|
|
14
|
+
))}
|
|
15
|
+
</>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Reports a root width, then a copy length, the way the native layout pass would. */
|
|
20
|
+
async function measure(root: number, copy: number): Promise<void> {
|
|
21
|
+
await fireEvent(screen.getByTestId("strip"), "layout", { nativeEvent: { layout: { width: root, height: 40 } } });
|
|
22
|
+
const [first] = screen.getAllByText("Alpha", { includeHiddenElements: true });
|
|
23
|
+
const copyView = first?.parent;
|
|
24
|
+
if (!copyView) throw new Error("copy view not found");
|
|
25
|
+
await fireEvent(copyView, "layout", { nativeEvent: { layout: { width: copy, height: 40 } } });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe("Marquee", () => {
|
|
29
|
+
test("renders its content once before it is measured", async () => {
|
|
30
|
+
await renderWithProviders(
|
|
31
|
+
<Marquee testID="strip">
|
|
32
|
+
<Words />
|
|
33
|
+
</Marquee>
|
|
34
|
+
);
|
|
35
|
+
expect(screen.getAllByText("Alpha", { includeHiddenElements: true })).toHaveLength(1);
|
|
36
|
+
expect(screen.getByText("Alpha")).toBeOnTheScreen();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("forwards onLayout from the root", async () => {
|
|
40
|
+
const onLayout = jest.fn();
|
|
41
|
+
await renderWithProviders(
|
|
42
|
+
<Marquee onLayout={onLayout} testID="strip">
|
|
43
|
+
<Words />
|
|
44
|
+
</Marquee>
|
|
45
|
+
);
|
|
46
|
+
await fireEvent(screen.getByTestId("strip"), "layout", { nativeEvent: { layout: { width: 200, height: 40 } } });
|
|
47
|
+
expect(onLayout).toHaveBeenCalledTimes(1);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("once measured, duplicate copies mount and only the first is reachable by assistive tech", async () => {
|
|
51
|
+
await renderWithProviders(
|
|
52
|
+
<Marquee testID="strip">
|
|
53
|
+
<Words />
|
|
54
|
+
</Marquee>
|
|
55
|
+
);
|
|
56
|
+
await measure(300, 100);
|
|
57
|
+
|
|
58
|
+
const all = screen.getAllByText("Alpha", { includeHiddenElements: true });
|
|
59
|
+
expect(all.length).toBeGreaterThan(1);
|
|
60
|
+
expect(screen.getAllByText("Alpha")).toHaveLength(1);
|
|
61
|
+
expect(screen.getAllByText("Beta")).toHaveLength(1);
|
|
62
|
+
expect(all[0]?.parent).toHaveProp("importantForAccessibility", "auto");
|
|
63
|
+
for (const duplicate of all.slice(1)) {
|
|
64
|
+
expect(duplicate.parent).toHaveProp("accessibilityElementsHidden", true);
|
|
65
|
+
expect(duplicate.parent).toHaveProp("importantForAccessibility", "no-hide-descendants");
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("an accessibilityLabel makes the strip one element and hides every copy", async () => {
|
|
70
|
+
await renderWithProviders(
|
|
71
|
+
<Marquee accessibilityLabel="Our partners" testID="strip">
|
|
72
|
+
<Words />
|
|
73
|
+
</Marquee>
|
|
74
|
+
);
|
|
75
|
+
await measure(300, 100);
|
|
76
|
+
|
|
77
|
+
expect(screen.getByLabelText("Our partners")).toBeOnTheScreen();
|
|
78
|
+
expect(screen.getByTestId("strip")).toHaveProp("accessible", true);
|
|
79
|
+
expect(screen.queryByText("Alpha")).not.toBeOnTheScreen();
|
|
80
|
+
for (const copy of screen.getAllByText("Alpha", { includeHiddenElements: true })) {
|
|
81
|
+
expect(copy.parent).toHaveProp("importantForAccessibility", "no-hide-descendants");
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("without a label the root is not itself an accessible element", async () => {
|
|
86
|
+
await renderWithProviders(
|
|
87
|
+
<Marquee testID="strip">
|
|
88
|
+
<Words />
|
|
89
|
+
</Marquee>
|
|
90
|
+
);
|
|
91
|
+
expect(screen.getByTestId("strip")).not.toHaveProp("accessible", true);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test("a vertical direction also mounts duplicate copies and announces the content once", async () => {
|
|
95
|
+
await renderWithProviders(
|
|
96
|
+
<Marquee direction="up" testID="strip">
|
|
97
|
+
<Words />
|
|
98
|
+
</Marquee>
|
|
99
|
+
);
|
|
100
|
+
await measure(300, 100);
|
|
101
|
+
expect(screen.getAllByText("Beta")).toHaveLength(1);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test("calm motion swaps the moving track for one still, hand-scrollable copy", async () => {
|
|
105
|
+
await renderWithProviders(
|
|
106
|
+
<DelacourProvider isMotionCalm>
|
|
107
|
+
<Marquee testID="strip">
|
|
108
|
+
<Words />
|
|
109
|
+
</Marquee>
|
|
110
|
+
</DelacourProvider>
|
|
111
|
+
);
|
|
112
|
+
await fireEvent(screen.getByTestId("strip"), "layout", { nativeEvent: { layout: { width: 300, height: 40 } } });
|
|
113
|
+
expect(screen.getAllByText("Alpha", { includeHiddenElements: true })).toHaveLength(1);
|
|
114
|
+
expect(screen.getByText("Alpha")).toBeOnTheScreen();
|
|
115
|
+
expect(screen.getByText("Beta")).toBeOnTheScreen();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test("calm motion with a label still hides the content behind it", async () => {
|
|
119
|
+
await renderWithProviders(
|
|
120
|
+
<DelacourProvider isMotionCalm>
|
|
121
|
+
<Marquee accessibilityLabel="Our partners" testID="strip">
|
|
122
|
+
<Words />
|
|
123
|
+
</Marquee>
|
|
124
|
+
</DelacourProvider>
|
|
125
|
+
);
|
|
126
|
+
expect(screen.getByLabelText("Our partners")).toBeOnTheScreen();
|
|
127
|
+
expect(screen.queryByText("Alpha")).not.toBeOnTheScreen();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("a Group renders every strip inside it, each announced once", async () => {
|
|
131
|
+
await renderWithProviders(
|
|
132
|
+
<Marquee.Group speed={30} testID="group">
|
|
133
|
+
<Marquee direction="left">
|
|
134
|
+
<Text>Left</Text>
|
|
135
|
+
</Marquee>
|
|
136
|
+
<Marquee direction="right">
|
|
137
|
+
<Text>Right</Text>
|
|
138
|
+
</Marquee>
|
|
139
|
+
</Marquee.Group>
|
|
140
|
+
);
|
|
141
|
+
expect(screen.getByTestId("group")).toBeOnTheScreen();
|
|
142
|
+
expect(screen.getByText("Left")).toBeOnTheScreen();
|
|
143
|
+
expect(screen.getByText("Right")).toBeOnTheScreen();
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -30,6 +30,7 @@ rows run actions, they never become the trigger's value. Compound root plus
|
|
|
30
30
|
| `menu.context.tsx` | The menu, submenu and radio-group contexts; `useMenu`, `useMenuRootValue`, `MenuRootProvider` |
|
|
31
31
|
| `menu.types.ts` | `MenuItemProps`, shared by every row |
|
|
32
32
|
| `menu.variants.ts` | The slotted `tv()`, the constants and the pure resolvers — no RN imports |
|
|
33
|
+
| `menu.render.test.tsx` | Mounted under Jest — open/close, items, disabled rows, checkbox and radio state, submenus, outside-part errors, Android `activate` |
|
|
33
34
|
| `menu.variants.test.ts` | Placement (flip, cap, clamp, RTL, the zero-size anchor), width, close rules, accessibility, tokens |
|
|
34
35
|
|
|
35
36
|
## The panel
|
|
@@ -141,6 +142,7 @@ rows run actions, they never become the trigger's value. Compound root plus
|
|
|
141
142
|
|
|
142
143
|
## Accessibility
|
|
143
144
|
|
|
145
|
+
- Rows are activated by a screen reader too: `MenuRow` wires `onAccessibilityTap` (iOS) and an `activate` action (Android) to the same select as the tap gesture, behind the disabled guard, via `resolvePressableActivation`.
|
|
144
146
|
- Content: `accessibilityRole="menu"`, `accessibilityViewIsModal`.
|
|
145
147
|
- Rows: `accessibilityRole="menuitem"`; checkbox → `checked`, radio →
|
|
146
148
|
`selected`, sub-trigger → `expanded`, all → `disabled`. One source:
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type ReactElement, type ReactNode, useCallback, useMemo, useRef } from "react";
|
|
2
|
-
import { type AccessibilityState, View } from "react-native";
|
|
2
|
+
import { type AccessibilityActionEvent, type AccessibilityState, Platform, View } from "react-native";
|
|
3
3
|
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
4
4
|
import Animated, { useAnimatedStyle, useReducedMotion, useSharedValue, withTiming } from "react-native-reanimated";
|
|
5
5
|
import { scheduleOnRN } from "react-native-worklets";
|
|
6
6
|
import { Icon } from "../icon";
|
|
7
7
|
import { playHaptic } from "../pressable/pressable";
|
|
8
|
+
import { dispatchPressableAccessibilityAction, resolvePressableActivation } from "../pressable/pressable.variants";
|
|
8
9
|
import { Text } from "../text";
|
|
9
10
|
import { useMenuPart } from "./menu.context";
|
|
10
11
|
import type { MenuItemProps } from "./menu.types";
|
|
@@ -28,6 +29,36 @@ export type MenuRowProps = MenuItemProps & {
|
|
|
28
29
|
accessibilityState?: AccessibilityState;
|
|
29
30
|
};
|
|
30
31
|
|
|
32
|
+
/**
|
|
33
|
+
* A gesture only sees touches, so a screen reader's activation is wired to the
|
|
34
|
+
* same select: `onAccessibilityTap` on iOS, an `activate` action on Android.
|
|
35
|
+
* A disabled row consumes the activation and does nothing.
|
|
36
|
+
*/
|
|
37
|
+
function useRowActivation(isDisabled: boolean, select: () => void) {
|
|
38
|
+
const activation = resolvePressableActivation({
|
|
39
|
+
hasAccessibilityTap: false,
|
|
40
|
+
hasPress: true,
|
|
41
|
+
platform: Platform.OS,
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
accessibilityActions: activation.accessibilityActions,
|
|
45
|
+
onAccessibilityAction: (event: AccessibilityActionEvent) => {
|
|
46
|
+
dispatchPressableAccessibilityAction({
|
|
47
|
+
actionName: event.nativeEvent.actionName,
|
|
48
|
+
activation,
|
|
49
|
+
busy: false,
|
|
50
|
+
disabled: isDisabled,
|
|
51
|
+
onPress: select,
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
onAccessibilityTap: activation.wiresAccessibilityTap
|
|
55
|
+
? () => {
|
|
56
|
+
if (!isDisabled) select();
|
|
57
|
+
}
|
|
58
|
+
: undefined,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
31
62
|
/**
|
|
32
63
|
* The row every menu row is built on: the press fill, the scale, the label
|
|
33
64
|
* column, the icon, the shortcut and the trailing slot.
|
|
@@ -100,6 +131,11 @@ export function MenuRow({
|
|
|
100
131
|
[handleSelect, haptic, inMs, isDisabled, outMs, pressed]
|
|
101
132
|
);
|
|
102
133
|
|
|
134
|
+
const { accessibilityActions, onAccessibilityAction, onAccessibilityTap } = useRowActivation(
|
|
135
|
+
isDisabled,
|
|
136
|
+
handleSelect
|
|
137
|
+
);
|
|
138
|
+
|
|
103
139
|
const rowStyle = useAnimatedStyle(() => ({
|
|
104
140
|
transform: [{ scale: 1 - pressed.value * (1 - pressedScale) }],
|
|
105
141
|
}));
|
|
@@ -123,8 +159,11 @@ export function MenuRow({
|
|
|
123
159
|
<Animated.View
|
|
124
160
|
accessibilityRole="menuitem"
|
|
125
161
|
accessibilityState={accessibilityState ?? resolveMenuItemAccessibility({ isDisabled, kind: "item" })}
|
|
162
|
+
accessibilityActions={accessibilityActions}
|
|
126
163
|
accessible
|
|
127
164
|
className={slots.item({ className })}
|
|
165
|
+
onAccessibilityAction={onAccessibilityAction}
|
|
166
|
+
onAccessibilityTap={onAccessibilityTap}
|
|
128
167
|
style={rowStyle}
|
|
129
168
|
{...props}
|
|
130
169
|
>
|