@react-native-ama/core 1.0.1-alpha.1 → 1.0.1
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/dist/hooks/useButtonChecks.js +1 -1
- package/dist/hooks/useFocus.js +25 -10
- package/package.json +3 -3
- package/src/hooks/useButtonChecks.ts +1 -1
- package/src/hooks/useFocus.ts +33 -12
|
@@ -30,7 +30,7 @@ exports.useButtonChecks = __DEV__
|
|
|
30
30
|
});
|
|
31
31
|
checkCompatibleAccessibilityState({
|
|
32
32
|
accessibilityStates: props === null || props === void 0 ? void 0 : props.accessibilityState,
|
|
33
|
-
accessibilityRole: props === null || props === void 0 ? void 0 : props.
|
|
33
|
+
accessibilityRole: props === null || props === void 0 ? void 0 : props.accessibilityRole,
|
|
34
34
|
});
|
|
35
35
|
checkAccessibilityRole(props.accessibilityRole);
|
|
36
36
|
const contrastCheckerCallback = shouldPerformContrastCheck
|
package/dist/hooks/useFocus.js
CHANGED
|
@@ -29,17 +29,32 @@ const React = __importStar(require("react"));
|
|
|
29
29
|
const react_native_1 = require("react-native");
|
|
30
30
|
const useFocus = (refComponent) => {
|
|
31
31
|
const setFocus = React.useCallback((component) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (elementId) {
|
|
35
|
-
react_native_1.AccessibilityInfo.setAccessibilityFocus(elementId);
|
|
36
|
-
react_native_1.AccessibilityInfo.setAccessibilityFocus(elementId);
|
|
37
|
-
}
|
|
38
|
-
else if (__DEV__) {
|
|
39
|
-
console.warn(
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
`${internal_1.SHELL_COLORS.BG_RED}AMA.${internal_1.SHELL_COLORS.RESET} ${internal_1.SHELL_COLORS.BLUE}useFocus${internal_1.SHELL_COLORS.RESET}: ${internal_1.SHELL_COLORS.YELLOW}Ref element not found${internal_1.SHELL_COLORS.RESET}`);
|
|
32
|
+
if (!component) {
|
|
33
|
+
return;
|
|
42
34
|
}
|
|
35
|
+
react_native_1.InteractionManager.runAfterInteractions(() => {
|
|
36
|
+
try {
|
|
37
|
+
const elementId = (0, react_native_1.findNodeHandle)(component);
|
|
38
|
+
if (elementId) {
|
|
39
|
+
react_native_1.AccessibilityInfo.setAccessibilityFocus(elementId);
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
react_native_1.AccessibilityInfo.setAccessibilityFocus(elementId); //ISSUE: https://github.com/facebook/react-native/issues/30097
|
|
42
|
+
}, 100);
|
|
43
|
+
}
|
|
44
|
+
else if (__DEV__) {
|
|
45
|
+
console.warn(
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
`${internal_1.SHELL_COLORS.BG_RED}AMA.${internal_1.SHELL_COLORS.RESET} ${internal_1.SHELL_COLORS.BLUE}useFocus${internal_1.SHELL_COLORS.RESET}: ${internal_1.SHELL_COLORS.YELLOW}Ref element not found${internal_1.SHELL_COLORS.RESET}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (__DEV__) {
|
|
52
|
+
console.warn(
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
`${internal_1.SHELL_COLORS.BG_RED}AMA.${internal_1.SHELL_COLORS.RESET} ${internal_1.SHELL_COLORS.BLUE}useFocus${internal_1.SHELL_COLORS.RESET}: ${internal_1.SHELL_COLORS.YELLOW}Error finding node handle${internal_1.SHELL_COLORS.RESET} \n`, error);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
43
58
|
}, []);
|
|
44
59
|
React.useEffect(() => {
|
|
45
60
|
if (!refComponent) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-ama/core",
|
|
3
|
-
"version": "1.0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Accessible Mobile App Library for React Native",
|
|
5
5
|
"private": false,
|
|
6
6
|
"react-native": "src/index",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"test": "jest"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@react-native-ama/internal": "
|
|
28
|
+
"@react-native-ama/internal": "~1.0.1"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": "*",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://github.com/FormidableLabs/react-native-ama#readme",
|
|
48
48
|
"publishConfig": {
|
|
49
|
-
"provenance":
|
|
49
|
+
"provenance": true
|
|
50
50
|
},
|
|
51
51
|
"author": "",
|
|
52
52
|
"license": "MIT",
|
|
@@ -49,7 +49,7 @@ export const useButtonChecks = __DEV__
|
|
|
49
49
|
});
|
|
50
50
|
checkCompatibleAccessibilityState({
|
|
51
51
|
accessibilityStates: props?.accessibilityState,
|
|
52
|
-
accessibilityRole: props?.
|
|
52
|
+
accessibilityRole: props?.accessibilityRole,
|
|
53
53
|
});
|
|
54
54
|
checkAccessibilityRole(props.accessibilityRole);
|
|
55
55
|
|
package/src/hooks/useFocus.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { SHELL_COLORS } from '@react-native-ama/internal';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
AccessibilityInfo,
|
|
5
|
+
InteractionManager,
|
|
6
|
+
findNodeHandle,
|
|
7
|
+
} from 'react-native';
|
|
4
8
|
|
|
5
9
|
export const useFocus = (refComponent?: React.RefObject<any>) => {
|
|
6
10
|
const setFocus = React.useCallback(
|
|
@@ -11,18 +15,35 @@ export const useFocus = (refComponent?: React.RefObject<any>) => {
|
|
|
11
15
|
| React.Component<any, any>
|
|
12
16
|
| React.ComponentClass<any>,
|
|
13
17
|
) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (elementId) {
|
|
18
|
-
AccessibilityInfo.setAccessibilityFocus(elementId);
|
|
19
|
-
AccessibilityInfo.setAccessibilityFocus(elementId);
|
|
20
|
-
} else if (__DEV__) {
|
|
21
|
-
console.warn(
|
|
22
|
-
// @ts-ignore
|
|
23
|
-
`${SHELL_COLORS.BG_RED}AMA.${SHELL_COLORS.RESET} ${SHELL_COLORS.BLUE}useFocus${SHELL_COLORS.RESET}: ${SHELL_COLORS.YELLOW}Ref element not found${SHELL_COLORS.RESET}`,
|
|
24
|
-
);
|
|
18
|
+
if (!component) {
|
|
19
|
+
return;
|
|
25
20
|
}
|
|
21
|
+
|
|
22
|
+
InteractionManager.runAfterInteractions(() => {
|
|
23
|
+
try {
|
|
24
|
+
const elementId = findNodeHandle(component);
|
|
25
|
+
|
|
26
|
+
if (elementId) {
|
|
27
|
+
AccessibilityInfo.setAccessibilityFocus(elementId);
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
AccessibilityInfo.setAccessibilityFocus(elementId); //ISSUE: https://github.com/facebook/react-native/issues/30097
|
|
30
|
+
}, 100);
|
|
31
|
+
} else if (__DEV__) {
|
|
32
|
+
console.warn(
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
`${SHELL_COLORS.BG_RED}AMA.${SHELL_COLORS.RESET} ${SHELL_COLORS.BLUE}useFocus${SHELL_COLORS.RESET}: ${SHELL_COLORS.YELLOW}Ref element not found${SHELL_COLORS.RESET}`,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (__DEV__) {
|
|
39
|
+
console.warn(
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
`${SHELL_COLORS.BG_RED}AMA.${SHELL_COLORS.RESET} ${SHELL_COLORS.BLUE}useFocus${SHELL_COLORS.RESET}: ${SHELL_COLORS.YELLOW}Error finding node handle${SHELL_COLORS.RESET} \n`,
|
|
42
|
+
error,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
26
47
|
},
|
|
27
48
|
[],
|
|
28
49
|
);
|