Skip to content

Commit 15e5b72

Browse files
authored
fixes to get AMA playground running. (#325)
* fixes to get AMA playground running. still WIP * fix build
1 parent e64f279 commit 15e5b72

28 files changed

+382
-260
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
4141
"@testing-library/react-native": "^12.3.0",
4242
"@types/jest": "^29.5.10",
43+
"@types/node": "^24.0.15",
4344
"@types/react": "~19.0.0",
4445
"eslint": "^8.19.0",
4546
"eslint-plugin-import": "^2.26.0",
@@ -51,6 +52,8 @@
5152
"jest": "^29.6.3",
5253
"prettier": "^3.6.2",
5354
"react-native": "0.79.1",
55+
"react-native-gesture-handler": "~2.24.0",
56+
"react-native-reanimated": "~3.17.4",
5457
"ts-jest": "^29.1.1",
5558
"typescript": "^5.1.3"
5659
},

packages/animations/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
},
2828
"peerDependencies": {
2929
"react": "*",
30-
"react-native": "*"
30+
"react-native": "*",
31+
"react-native-reanimated": ">=2.0.0"
3132
},
3233
"keywords": [
3334
"react-native",

packages/core/ios/A11yChecker.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public class A11yChecker {
8383
issues.removeAll()
8484

8585
traverseAndCheck(view: root)
86-
var shouldSendEvent = clearFixedIssues(oldIssues)
86+
let shouldSendEvent = clearFixedIssues(oldIssues)
8787

8888
let newIssuesToSend = issues.filter { !$0.sent }
8989

@@ -306,9 +306,12 @@ public class A11yChecker {
306306

307307
issues.append(
308308
A11yIssue(
309-
type: action, rule: rule, label: label, issue: issue,
309+
type: action,
310+
rule: rule,
311+
label: label,
312+
issue: issue,
310313
viewId: viewId,
311-
sent: false,
314+
sent: false
312315
))
313316
}
314317
}

packages/core/src/ReactNativeAmaModule.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { NativeModule, requireNativeModule } from 'expo';
2+
import { ReactNativeAmaModuleEvents } from './ReactNativeAma.types';
23

3-
declare class ReactNativeAmaModule extends NativeModule {
4+
declare class ReactNativeAmaModule extends NativeModule<ReactNativeAmaModuleEvents> {
45
start(config?: any): void;
56
stop(): void;
67
}

packages/core/src/ReactNativeAmaModule.web.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { NativeModule, registerWebModule } from 'expo';
22
import { ReactNativeAmaModuleEvents } from './ReactNativeAma.types';
3+
import type { A11yIssue } from './internals/types';
34

45
class ReactNativeAmaModule extends NativeModule<ReactNativeAmaModuleEvents> {
56
PI = Math.PI;
6-
async setValueAsync(value: string): Promise<void> {
7-
this.emit('onChange', { value });
7+
async setValueAsync(issues: A11yIssue[]): Promise<void> {
8+
this.emit('onA11yIssues', issues);
89
}
910
hello() {
1011
return 'Hello world! 👋';

packages/core/src/ReactNativeAmaView.web.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default function ReactNativeAmaView(props: ReactNativeAmaViewProps) {
55
return (
66
<div>
77
<iframe
8+
// eslint-disable-next-line react-native/no-inline-styles
89
style={{ flex: 1 }}
910
src={props.url}
1011
onLoad={() => props.onLoad({ nativeEvent: { url: props.url } })}

packages/core/src/components/AMAProvider.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable react-native/no-inline-styles */
12
import * as React from 'react';
23
import {
34
AccessibilityChangeEventName,
@@ -20,6 +21,8 @@ type SharedContextValue = {
2021
isInvertColorsEnabled: boolean;
2122
isReduceMotionEnabled: boolean;
2223
isReduceTransparencyEnabled: boolean;
24+
isHighTextContrastEnabled: boolean;
25+
isDarkerSystemColorsEnabled: boolean;
2326
reactNavigationScreenOptions: {
2427
animationEnabled: boolean;
2528
animation: 'default' | 'fade';
@@ -56,6 +59,8 @@ const eventsMapping: AccessibilityInfoEvents = {
5659
boldTextChanged: 'isBoldTextEnabled',
5760
invertColorsChanged: 'isInvertColorsEnabled',
5861
screenReaderChanged: 'isScreenReaderEnabled',
62+
highTextContrastChanged: 'isHighTextContrastEnabled',
63+
darkerSystemColorsChanged: 'isDarkerSystemColorsEnabled',
5964
};
6065

6166
export const isDevContextValue = (
@@ -70,6 +75,8 @@ const DEFAULT_VALUES = {
7075
isInvertColorsEnabled: false,
7176
isReduceMotionEnabled: false,
7277
isScreenReaderEnabled: false,
78+
isHighTextContrastEnabled: false,
79+
isDarkerSystemColorsEnabled: false,
7380
reactNavigationScreenOptions: {
7481
animationEnabled: true,
7582
animation: 'default',
@@ -153,7 +160,7 @@ export const AMAProvider: React.FC<AMAProviderProps> = ({ children }) => {
153160
<View style={{ flex: 1 }}>
154161
<>
155162
{children}
156-
<AMAError issues={issues} />
163+
{AMAError && <AMAError issues={issues} />}
157164
</>
158165
</View>
159166
</AMAContext.Provider>

packages/core/src/components/AutofocusContainer.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ beforeEach(() => {
88
});
99

1010
describe('AutofocusContainer', () => {
11-
it('it call setFocus when gets rendered', async () => {
11+
it('call setFocus when gets rendered', async () => {
1212
const setFocus = jest.fn();
1313
jest.spyOn(UseFocus, 'useFocus').mockReturnValue({
1414
setFocus,
@@ -20,7 +20,7 @@ describe('AutofocusContainer', () => {
2020
</AutofocusContainer>,
2121
);
2222

23-
await waitFor(() => expect(setFocus).toBeCalled());
23+
await waitFor(() => expect(setFocus).toHaveBeenCalled());
2424
});
2525

2626
it.each([undefined, true])(
@@ -37,7 +37,7 @@ describe('AutofocusContainer', () => {
3737
</AutofocusContainer>,
3838
);
3939

40-
await waitFor(() => expect(setFocus).toBeCalled());
40+
await waitFor(() => expect(setFocus).toHaveBeenCalled());
4141

4242
expect(
4343
renderAPI.getByTestId('autofocusContainer.accessibleView'),
@@ -57,7 +57,7 @@ describe('AutofocusContainer', () => {
5757
</AutofocusContainer>,
5858
);
5959

60-
await waitFor(() => expect(setFocus).toBeCalled());
60+
await waitFor(() => expect(setFocus).toHaveBeenCalled());
6161

6262
expect(
6363
renderAPI.queryByTestId('autofocusContainer.accessibleView'),

packages/core/src/components/HideChildrenFromAccessibilityTree.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { PropsWithChildren } from 'react';
1+
import React, { PropsWithChildren, type JSX } from 'react';
22
import { Platform, View } from 'react-native';
33
import { useAMAContext } from './AMAProvider';
44

@@ -38,17 +38,19 @@ const HideChildrenFromAccessibilityTreeIOS = ({
3838
return hideChildrenFromAccessibilityTree(children);
3939
};
4040

41-
const hideChildrenFromAccessibilityTree = (component: React.ReactNode): any => {
41+
const hideChildrenFromAccessibilityTree = (component: React.ReactNode): React.ReactNode => {
4242
return (
4343
React.Children.map(component, child => {
44-
return React.isValidElement(child)
45-
? React.cloneElement(child, {
46-
// @ts-ignore
47-
importantForAccessibility: 'no',
48-
accessibilityElementsHidden: true,
49-
children: hideChildrenFromAccessibilityTree(child.props.children),
50-
})
51-
: child;
44+
if (React.isValidElement(child)) {
45+
const element = child as React.ReactElement<{ children?: React.ReactNode }>;
46+
return React.cloneElement(element, {
47+
// @ts-ignore
48+
importantForAccessibility: 'no',
49+
accessibilityElementsHidden: true,
50+
children: hideChildrenFromAccessibilityTree(element.props.children),
51+
});
52+
}
53+
return child;
5254
}) || null
5355
);
5456
};

packages/core/src/hooks/useChecks.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const useChecks = () => {
4141
const hasErrors = React.useRef(false);
4242
const failedTests = React.useRef<string[]>([]);
4343
const shouldCheckLayout = React.useRef(true);
44-
const layoutCheckTimeout = React.useRef<NodeJS.Timeout>();
44+
const layoutCheckTimeout = React.useRef<ReturnType<typeof setTimeout> | null>(null);
4545
const [minimumSizeFailed, setMinimumSizeFailed] = React.useState(false);
4646
const [debugStyle, setDebugStyle] = React.useState<any>({});
4747

@@ -178,8 +178,9 @@ export const useChecks = () => {
178178

179179
shouldCheckLayout.current = false;
180180

181-
// @ts-ignore
182-
clearTimeout(layoutCheckTimeout.current);
181+
if (layoutCheckTimeout.current) {
182+
clearTimeout(layoutCheckTimeout.current);
183+
}
183184

184185
layoutCheckTimeout.current = setTimeout(() => {
185186
shouldCheckLayout.current = true;

0 commit comments

Comments
 (0)