@react-native-ama/core 0.0.1 → 1.0.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.
Files changed (94) hide show
  1. package/dist/{core/src/components → components}/AMAProvider.js +1 -2
  2. package/dist/{core/src/index.js → index.js} +3 -3
  3. package/package.json +31 -6
  4. package/src/components/AMAProvider.d.ts +26 -0
  5. package/src/components/AMAProvider.integration.test.tsx +145 -0
  6. package/src/components/AMAProvider.js +147 -0
  7. package/src/components/AMAProvider.test.tsx +199 -0
  8. package/src/components/AMAProvider.tsx +229 -0
  9. package/src/components/AutofocusContainer.d.ts +9 -0
  10. package/src/components/AutofocusContainer.js +58 -0
  11. package/src/components/AutofocusContainer.test.tsx +69 -0
  12. package/src/components/AutofocusContainer.tsx +43 -0
  13. package/src/components/HideChildrenFromAccessibilityTree.d.ts +6 -0
  14. package/src/components/HideChildrenFromAccessibilityTree.js +40 -0
  15. package/src/components/HideChildrenFromAccessibilityTree.test.tsx +129 -0
  16. package/src/components/HideChildrenFromAccessibilityTree.tsx +55 -0
  17. package/src/hooks/useButtonChecks.d.ts +8 -0
  18. package/src/hooks/useButtonChecks.js +51 -0
  19. package/src/hooks/useButtonChecks.ts +73 -0
  20. package/src/hooks/useChecks.d.ts +15 -0
  21. package/src/hooks/useChecks.js +152 -0
  22. package/src/hooks/useChecks.test.ts +214 -0
  23. package/src/hooks/useChecks.ts +207 -0
  24. package/src/hooks/useFocus.d.ts +4 -0
  25. package/{dist/internal/src/utils/maybeGenerateStringFromElement.js → src/hooks/useFocus.js} +26 -22
  26. package/src/hooks/useFocus.test.ts +99 -0
  27. package/src/hooks/useFocus.ts +42 -0
  28. package/src/hooks/useTimedAction.android.test.ts +39 -0
  29. package/src/hooks/useTimedAction.d.ts +3 -0
  30. package/src/hooks/useTimedAction.ios.test.ts +46 -0
  31. package/src/hooks/useTimedAction.js +63 -0
  32. package/src/hooks/useTimedAction.ts +40 -0
  33. package/src/index.d.ts +7 -0
  34. package/src/index.js +20 -0
  35. package/src/index.ts +16 -0
  36. package/src/utils/numerify.test.ts +11 -0
  37. package/src/utils/numerify.ts +3 -0
  38. package/dist/internal/src/checks/checkAccessibilityRole.d.ts +0 -3
  39. package/dist/internal/src/checks/checkAccessibilityRole.js +0 -32
  40. package/dist/internal/src/checks/checkFocusTrap.d.ts +0 -8
  41. package/dist/internal/src/checks/checkFocusTrap.js +0 -34
  42. package/dist/internal/src/checks/checkForAccessibilityState.d.ts +0 -7
  43. package/dist/internal/src/checks/checkForAccessibilityState.js +0 -48
  44. package/dist/internal/src/checks/checkMinimumSize.d.ts +0 -3
  45. package/dist/internal/src/checks/checkMinimumSize.js +0 -29
  46. package/dist/internal/src/checks/contrastChecker.d.ts +0 -8
  47. package/dist/internal/src/checks/contrastChecker.js +0 -77
  48. package/dist/internal/src/checks/noUndefinedProperty.d.ts +0 -8
  49. package/dist/internal/src/checks/noUndefinedProperty.js +0 -14
  50. package/dist/internal/src/checks/uppercaseChecker.d.ts +0 -9
  51. package/dist/internal/src/checks/uppercaseChecker.js +0 -18
  52. package/dist/internal/src/checks/uppercaseStringChecker.d.ts +0 -8
  53. package/dist/internal/src/checks/uppercaseStringChecker.js +0 -29
  54. package/dist/internal/src/index.d.ts +0 -20
  55. package/dist/internal/src/index.js +0 -56
  56. package/dist/internal/src/types.d.ts +0 -17
  57. package/dist/internal/src/types.js +0 -2
  58. package/dist/internal/src/utils/applyStyle.d.ts +0 -10
  59. package/dist/internal/src/utils/applyStyle.js +0 -33
  60. package/dist/internal/src/utils/constants.d.ts +0 -3
  61. package/dist/internal/src/utils/constants.js +0 -32
  62. package/dist/internal/src/utils/error.style.d.ts +0 -6
  63. package/dist/internal/src/utils/error.style.js +0 -11
  64. package/dist/internal/src/utils/generateAccessibilityStateFromProp.d.ts +0 -9
  65. package/dist/internal/src/utils/generateAccessibilityStateFromProp.js +0 -35
  66. package/dist/internal/src/utils/getPropertyFromStyle.d.ts +0 -2
  67. package/dist/internal/src/utils/getPropertyFromStyle.js +0 -10
  68. package/dist/internal/src/utils/interpolateAnimationStates.d.ts +0 -2
  69. package/dist/internal/src/utils/interpolateAnimationStates.js +0 -43
  70. package/dist/internal/src/utils/isFocused.d.ts +0 -2
  71. package/dist/internal/src/utils/isFocused.js +0 -7
  72. package/dist/internal/src/utils/logger.d.ts +0 -16
  73. package/dist/internal/src/utils/logger.js +0 -53
  74. package/dist/internal/src/utils/logger.rules.d.ts +0 -15
  75. package/dist/internal/src/utils/logger.rules.js +0 -74
  76. package/dist/internal/src/utils/maybeGenerateStringFromElement.d.ts +0 -3
  77. package/dist/internal/src/utils/minimumTouchableSize.d.ts +0 -3
  78. package/dist/internal/src/utils/minimumTouchableSize.js +0 -9
  79. package/dist/{core/src/components → components}/AMAProvider.d.ts +0 -0
  80. package/dist/{core/src/components → components}/AutofocusContainer.d.ts +0 -0
  81. package/dist/{core/src/components → components}/AutofocusContainer.js +0 -0
  82. package/dist/{core/src/components → components}/HideChildrenFromAccessibilityTree.d.ts +0 -0
  83. package/dist/{core/src/components → components}/HideChildrenFromAccessibilityTree.js +0 -0
  84. package/dist/{core/src/hooks → hooks}/useButtonChecks.d.ts +0 -0
  85. package/dist/{core/src/hooks → hooks}/useButtonChecks.js +0 -0
  86. package/dist/{core/src/hooks → hooks}/useChecks.d.ts +0 -0
  87. package/dist/{core/src/hooks → hooks}/useChecks.js +0 -0
  88. package/dist/{core/src/hooks → hooks}/useFocus.d.ts +0 -0
  89. package/dist/{core/src/hooks → hooks}/useFocus.js +0 -0
  90. package/dist/{core/src/hooks → hooks}/useTimedAction.d.ts +0 -0
  91. package/dist/{core/src/hooks → hooks}/useTimedAction.js +0 -0
  92. package/dist/{core/src/index.d.ts → index.d.ts} +1 -1
  93. /package/dist/{core/src/utils → utils}/numerify.d.ts +0 -0
  94. /package/dist/{core/src/utils → utils}/numerify.js +0 -0
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkAccessibilityRole = void 0;
4
- const react_native_1 = require("react-native");
5
- const checkAccessibilityRole = (accessibilityRole) => {
6
- if (!checkPlatformSupportsRole(accessibilityRole, react_native_1.Platform.OS)) {
7
- return {
8
- message: `"${accessibilityRole}" is not a native element for "${react_native_1.Platform.OS}"`,
9
- rule: 'INCOMPATIBLE_ACCESSIBILITY_ROLE',
10
- };
11
- }
12
- return null;
13
- };
14
- exports.checkAccessibilityRole = checkAccessibilityRole;
15
- const checkPlatformSupportsRole = (role, platform) => {
16
- const supportedPlatforms = MAPPED_ROLE_CHECKS[role] || [];
17
- return supportedPlatforms.includes(platform);
18
- };
19
- // @ts-ignore
20
- const MAPPED_ROLE_CHECKS = {
21
- none: ['ios', 'android'],
22
- button: ['ios', 'android'],
23
- switch: ['ios', 'android'],
24
- checkbox: ['android'],
25
- tab: ['android', 'ios'],
26
- togglebutton: ['android'],
27
- radio: ['android'],
28
- adjustable: ['ios'],
29
- link: ['ios', 'android'],
30
- search: ['ios', 'android'],
31
- header: ['ios', 'android'],
32
- };
@@ -1,8 +0,0 @@
1
- import type React from 'react';
2
- import type { TextInput } from 'react-native';
3
- import type { LogParams } from '../utils/logger';
4
- export type CheckFocusTrap = {
5
- ref: React.RefObject<TextInput>;
6
- shouldHaveFocus: boolean;
7
- };
8
- export declare const checkFocusTrap: ({ ref, shouldHaveFocus, }: CheckFocusTrap) => Promise<LogParams | null>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.checkFocusTrap = void 0;
13
- const isFocused_1 = require("../utils/isFocused");
14
- const checkFocusTrap = ({ ref, shouldHaveFocus, }) => __awaiter(void 0, void 0, void 0, function* () {
15
- return new Promise(resolve => {
16
- setTimeout(() => {
17
- var _a, _b;
18
- const hasFocus = (0, isFocused_1.isFocused)(ref === null || ref === void 0 ? void 0 : ref.current) === shouldHaveFocus;
19
- if (!hasFocus) {
20
- const message = shouldHaveFocus
21
- ? 'The component did not receive the focus'
22
- : 'The component did trap the focus';
23
- resolve({
24
- rule: 'NO_KEYBOARD_TRAP',
25
- message,
26
- // @ts-ignore
27
- extra: (_b = (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a._internalFiberInstanceHandleDEV) === null || _b === void 0 ? void 0 : _b.memoizedProps,
28
- });
29
- }
30
- resolve(null);
31
- }, 100);
32
- });
33
- });
34
- exports.checkFocusTrap = checkFocusTrap;
@@ -1,7 +0,0 @@
1
- import type { AccessibilityState } from 'react-native';
2
- import type { AMAAccessibilityState, AccessibilityRoles } from '../types';
3
- import type { LogParams } from '../utils/logger';
4
- export type CheckForAccessibilityState = AMAAccessibilityState & {
5
- accessibilityState?: AccessibilityState;
6
- } & AccessibilityRoles;
7
- export declare const checkForAccessibilityState: ({ accessibilityState, accessibilityRole, ...rest }: CheckForAccessibilityState) => LogParams | null;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.checkForAccessibilityState = void 0;
15
- const checkForAccessibilityState = (_a) => {
16
- var { accessibilityState, accessibilityRole } = _a, rest = __rest(_a, ["accessibilityState", "accessibilityRole"]);
17
- const expectedState = MAPPED_ROLE_CHECKS[accessibilityRole] || {
18
- accessibilityStates: [],
19
- };
20
- const allStates = [
21
- ...Object.keys(rest || {}),
22
- ...Object.keys(accessibilityState || {}),
23
- ].filter(state => state !== 'busy' && state !== 'disabled');
24
- for (const state of allStates) {
25
- // @ts-ignore
26
- const stateValue = rest === null || rest === void 0 ? void 0 : rest[state];
27
- if (allStates.length > 1 && stateValue === undefined) {
28
- continue;
29
- }
30
- if (!expectedState.accessibilityStates.includes(state)) {
31
- return {
32
- message: `The accessibilityState "${state} = ${stateValue}" and the role "${accessibilityRole}" are not compatible.\nCompatible states are: [${expectedState.accessibilityStates.join(', ')}]\nReceived: [${allStates.join(', ')}]`,
33
- rule: 'INCOMPATIBLE_ACCESSIBILITY_STATE',
34
- };
35
- }
36
- }
37
- return null;
38
- };
39
- exports.checkForAccessibilityState = checkForAccessibilityState;
40
- // @ts-ignore
41
- const MAPPED_ROLE_CHECKS = {
42
- button: { accessibilityStates: ['expanded', 'selected'], required: false },
43
- togglebutton: { accessibilityStates: ['checked'], required: true },
44
- switch: { accessibilityStates: ['checked'], required: true },
45
- checkbox: { accessibilityStates: ['checked'], required: true },
46
- tab: { accessibilityStates: ['selected'], required: true },
47
- radio: { accessibilityStates: ['selected'], required: true },
48
- };
@@ -1,3 +0,0 @@
1
- import type { LayoutChangeEvent } from 'react-native';
2
- import type { LogParams } from '../utils/logger';
3
- export declare const checkMinimumSize: (event: LayoutChangeEvent) => LogParams | null;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkMinimumSize = void 0;
4
- const react_native_1 = require("react-native");
5
- const minimumTouchableSize_1 = require("../utils/minimumTouchableSize");
6
- const logger_1 = require("../utils/logger");
7
- const checkMinimumSize = (event) => {
8
- const width = Math.ceil(event.nativeEvent.layout.width);
9
- const height = Math.ceil(event.nativeEvent.layout.height);
10
- const shouldForgive = (logger_1.getRuleAction === null || logger_1.getRuleAction === void 0 ? void 0 : (0, logger_1.getRuleAction)('MINIMUM_SIZE')) === 'PLEASE_FORGIVE_ME';
11
- if (react_native_1.Platform.OS === 'ios' &&
12
- width < minimumTouchableSize_1.ANDROID_MINIMUM_TOUCHABLE_SIZE &&
13
- height < minimumTouchableSize_1.ANDROID_MINIMUM_TOUCHABLE_SIZE) {
14
- if (shouldForgive) {
15
- console.info('The minimum size might be too small for Android');
16
- }
17
- else {
18
- console.warn('The minimum size might be too small for Android');
19
- }
20
- }
21
- if (width < minimumTouchableSize_1.MINIMUM_TOUCHABLE_SIZE || height < minimumTouchableSize_1.MINIMUM_TOUCHABLE_SIZE) {
22
- return {
23
- rule: 'MINIMUM_SIZE',
24
- message: `The touchable area must have a minimum size of ${minimumTouchableSize_1.MINIMUM_TOUCHABLE_SIZE}x${minimumTouchableSize_1.MINIMUM_TOUCHABLE_SIZE} found instead: ${width.toFixed(0)}x${height.toFixed(0)}`,
25
- };
26
- }
27
- return null;
28
- };
29
- exports.checkMinimumSize = checkMinimumSize;
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import type { StyleProp } from 'react-native';
3
- import { LogParams } from '../utils/logger';
4
- export type ContrastChecker = {
5
- style: StyleProp<any> | undefined | StyleProp<any>[];
6
- children: React.ReactNode;
7
- };
8
- export declare const contrastChecker: ({ style, children, }: ContrastChecker) => LogParams[] | null;
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.contrastChecker = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const wcag_color_1 = require("wcag-color");
9
- const getPropertyFromStyle_1 = require("../utils/getPropertyFromStyle");
10
- const logger_1 = require("../utils/logger");
11
- const MAX_DEPTH_LEVEL = logger_1.getContrastCheckerMaxDepth === null || logger_1.getContrastCheckerMaxDepth === void 0 ? void 0 : (0, logger_1.getContrastCheckerMaxDepth)();
12
- const contrastChecker = ({ style, children, }) => {
13
- const backgroundColor = (0, getPropertyFromStyle_1.getPropertyFromStyle)(style, 'backgroundColor');
14
- if (backgroundColor === undefined) {
15
- return null;
16
- }
17
- const failed = checkContrastInChildren(backgroundColor, children, 1);
18
- return failed.length > 0 ? failed : null;
19
- };
20
- exports.contrastChecker = contrastChecker;
21
- const checkContrastInChildren = (backgroundColor, children, depthLevel, contrastFailed = []) => {
22
- react_1.default.Children.forEach(children, (child) => {
23
- var _a, _b, _c;
24
- const childStyle = ((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.style) || {};
25
- const color = (0, getPropertyFromStyle_1.getPropertyFromStyle)(childStyle, 'color') || ((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.stroke);
26
- if (color) {
27
- const result = performContrastCheck(backgroundColor, color, child, childStyle);
28
- if (result) {
29
- contrastFailed.push(result);
30
- }
31
- }
32
- // @ts-ignore
33
- if (depthLevel < MAX_DEPTH_LEVEL && ((_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.children)) {
34
- checkContrastInChildren(backgroundColor, child.props.children, depthLevel + 1, contrastFailed);
35
- }
36
- });
37
- return contrastFailed;
38
- };
39
- const performContrastCheck = (backgroundColor, color, child, childStyle) => {
40
- const testFailed = `background: ${backgroundColor} with foreground: ${color}: `;
41
- const result = getContrastScore(backgroundColor, color);
42
- switch (result) {
43
- case 'Fail':
44
- return {
45
- rule: 'CONTRAST_FAILED',
46
- message: `"${testFailed}" fails all the contrast check`,
47
- extra: child,
48
- };
49
- case 'AA Large':
50
- if (isFontSizeLarge(childStyle.fontSize, childStyle.fontWeight === 'bold')) {
51
- return null;
52
- }
53
- return {
54
- rule: 'CONTRAST_FAILED',
55
- message: `"${testFailed}" fails AA Normal Text, but ✅ passes AA Large Text`,
56
- extra: child,
57
- };
58
- case 'AA':
59
- return {
60
- rule: 'CONTRAST_FAILED_AAA',
61
- message: `"${testFailed}" fails the AAA Level`,
62
- extra: child,
63
- };
64
- }
65
- return null;
66
- };
67
- const getContrastScore = (c1, c2) => {
68
- try {
69
- return (0, wcag_color_1.score)(c1, c2);
70
- }
71
- catch (_a) {
72
- return null;
73
- }
74
- };
75
- const isFontSizeLarge = (fontSize, isBold) => {
76
- return fontSize && (fontSize >= 18 || (fontSize >= 14 && isBold));
77
- };
@@ -1,8 +0,0 @@
1
- import type { LogParams } from '../utils/logger';
2
- import type { Rule } from '../utils/logger.rules';
3
- export type NoUndefinedProperty<T> = {
4
- properties: T;
5
- property: keyof T;
6
- rule?: Rule;
7
- };
8
- export declare const noUndefinedProperty: <T>({ property, properties, rule, }: NoUndefinedProperty<T>) => LogParams | null;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noUndefinedProperty = void 0;
4
- const noUndefinedProperty = ({ property, properties, rule = 'NO_UNDEFINED', }) => {
5
- if ((properties === null || properties === void 0 ? void 0 : properties[property]) == null) {
6
- return {
7
- rule,
8
- message: `The property "${property}" cannot be UNDEFINED`,
9
- extra: properties,
10
- };
11
- }
12
- return null;
13
- };
14
- exports.noUndefinedProperty = noUndefinedProperty;
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import type { StyleProp } from 'react-native';
3
- import type { LogParams } from '../utils/logger';
4
- export type UppercaseChecker = {
5
- style: StyleProp<Text> | undefined;
6
- accessibilityLabel?: string;
7
- extra?: any;
8
- };
9
- export declare const uppercaseChecker: ({ style, extra, accessibilityLabel, }: UppercaseChecker) => LogParams | null;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uppercaseChecker = void 0;
4
- const getPropertyFromStyle_1 = require("../utils/getPropertyFromStyle");
5
- const uppercaseChecker = ({ style, extra, accessibilityLabel, }) => {
6
- const textTransform = (0, getPropertyFromStyle_1.getPropertyFromStyle)(style, 'textTransform');
7
- const isAccessibilityLabelEmpty = !(accessibilityLabel === null || accessibilityLabel === void 0 ? void 0 : accessibilityLabel.trim());
8
- const fails = textTransform === 'uppercase' && isAccessibilityLabelEmpty;
9
- if (fails) {
10
- return {
11
- rule: 'UPPERCASE_TEXT_NO_ACCESSIBILITY_LABEL',
12
- message: 'accessibilityLabel cannot be empty when using `textTransform = uppercase`',
13
- extra: extra,
14
- };
15
- }
16
- return null;
17
- };
18
- exports.uppercaseChecker = uppercaseChecker;
@@ -1,8 +0,0 @@
1
- import { LogParams } from '../utils/logger';
2
- import type { Rule } from '../utils/logger.rules';
3
- export type UppercaseStringChecker = {
4
- text?: string;
5
- canBeEmpty?: boolean;
6
- rule?: Rule;
7
- };
8
- export declare const uppercaseStringChecker: ({ text, canBeEmpty, rule, }?: UppercaseStringChecker) => LogParams | null;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uppercaseStringChecker = void 0;
4
- const logger_1 = require("../utils/logger");
5
- const uppercaseStringChecker = ({ text, canBeEmpty = true, rule = 'NO_UPPERCASE_TEXT', } = {}) => {
6
- var _a;
7
- const isEmpty = !text || ((_a = text === null || text === void 0 ? void 0 : text.trim()) === null || _a === void 0 ? void 0 : _a.length) === 0;
8
- if (isEmpty && canBeEmpty) {
9
- return null;
10
- }
11
- if (isEmpty && !canBeEmpty) {
12
- return {
13
- rule: 'NO_ACCESSIBILITY_LABEL',
14
- message: 'The accessibilityLabel cannot be empty',
15
- extra: text,
16
- };
17
- }
18
- const isAllowed = logger_1.isAccessibilityLabelAllowed === null || logger_1.isAccessibilityLabelAllowed === void 0 ? void 0 : (0, logger_1.isAccessibilityLabelAllowed)(text);
19
- if (!isAllowed && isUpperCase(text)) {
20
- return {
21
- rule,
22
- message: 'The accessibilityLabel cannot be all CAPS',
23
- extra: text,
24
- };
25
- }
26
- return null;
27
- };
28
- exports.uppercaseStringChecker = uppercaseStringChecker;
29
- const isUpperCase = (string) => string.replace(/\d/, '').toUpperCase() === string;
@@ -1,20 +0,0 @@
1
- export { checkAccessibilityRole } from './checks/checkAccessibilityRole';
2
- export { checkFocusTrap, type CheckFocusTrap } from './checks/checkFocusTrap';
3
- export { checkForAccessibilityState, type CheckForAccessibilityState, } from './checks/checkForAccessibilityState';
4
- export { checkMinimumSize } from './checks/checkMinimumSize';
5
- export { contrastChecker, type ContrastChecker, } from './checks/contrastChecker';
6
- export { noUndefinedProperty, type NoUndefinedProperty, } from './checks/noUndefinedProperty';
7
- export { uppercaseChecker, type UppercaseChecker, } from './checks/uppercaseChecker';
8
- export { uppercaseStringChecker, type UppercaseStringChecker, } from './checks/uppercaseStringChecker';
9
- export { applyStyle } from './utils/applyStyle';
10
- export { MOTION_ANIMATIONS, type MotionAnimationKey } from './utils/constants';
11
- export { ERROR_STYLE, RED } from './utils/error.style';
12
- export { generateAccessibilityStateFromProp } from './utils/generateAccessibilityStateFromProp';
13
- export { getPropertyFromStyle } from './utils/getPropertyFromStyle';
14
- export { interpolateAnimationStates } from './utils/interpolateAnimationStates';
15
- export { isFocused } from './utils/isFocused';
16
- export { CONTRAST_CHECKER_MAX_DEPTH, IGNORE_CONTRAST_FOR_DISABLED_ELEMENTS, LOGGER_RULES, NON_OVERRIDABLE_RULES, RULES_HELP, SHELL_COLORS, canRuleBeOverridden, type Rule, type RuleAction, } from './utils/logger.rules';
17
- export { logFailure, type LogParams, getContrastCheckerMaxDepth, getRuleAction, isAccessibilityLabelAllowed, shouldIgnoreContrastCheckForDisabledElement, } from './utils/logger';
18
- export { maybeGenerateStringFromElement } from './utils/maybeGenerateStringFromElement';
19
- export { ANDROID_MINIMUM_TOUCHABLE_SIZE, IOS_MINIMUM_TOUCHABLE_SIZE, MINIMUM_TOUCHABLE_SIZE, } from './utils/minimumTouchableSize';
20
- export { type AMAAccessibilityState, type AccessibilityRoles } from './types';
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MINIMUM_TOUCHABLE_SIZE = exports.IOS_MINIMUM_TOUCHABLE_SIZE = exports.ANDROID_MINIMUM_TOUCHABLE_SIZE = exports.maybeGenerateStringFromElement = exports.shouldIgnoreContrastCheckForDisabledElement = exports.isAccessibilityLabelAllowed = exports.getRuleAction = exports.getContrastCheckerMaxDepth = exports.logFailure = exports.canRuleBeOverridden = exports.SHELL_COLORS = exports.RULES_HELP = exports.NON_OVERRIDABLE_RULES = exports.LOGGER_RULES = exports.IGNORE_CONTRAST_FOR_DISABLED_ELEMENTS = exports.CONTRAST_CHECKER_MAX_DEPTH = exports.isFocused = exports.interpolateAnimationStates = exports.getPropertyFromStyle = exports.generateAccessibilityStateFromProp = exports.RED = exports.ERROR_STYLE = exports.MOTION_ANIMATIONS = exports.applyStyle = exports.uppercaseStringChecker = exports.uppercaseChecker = exports.noUndefinedProperty = exports.contrastChecker = exports.checkMinimumSize = exports.checkForAccessibilityState = exports.checkFocusTrap = exports.checkAccessibilityRole = void 0;
4
- // Checks
5
- var checkAccessibilityRole_1 = require("./checks/checkAccessibilityRole");
6
- Object.defineProperty(exports, "checkAccessibilityRole", { enumerable: true, get: function () { return checkAccessibilityRole_1.checkAccessibilityRole; } });
7
- var checkFocusTrap_1 = require("./checks/checkFocusTrap");
8
- Object.defineProperty(exports, "checkFocusTrap", { enumerable: true, get: function () { return checkFocusTrap_1.checkFocusTrap; } });
9
- var checkForAccessibilityState_1 = require("./checks/checkForAccessibilityState");
10
- Object.defineProperty(exports, "checkForAccessibilityState", { enumerable: true, get: function () { return checkForAccessibilityState_1.checkForAccessibilityState; } });
11
- var checkMinimumSize_1 = require("./checks/checkMinimumSize");
12
- Object.defineProperty(exports, "checkMinimumSize", { enumerable: true, get: function () { return checkMinimumSize_1.checkMinimumSize; } });
13
- var contrastChecker_1 = require("./checks/contrastChecker");
14
- Object.defineProperty(exports, "contrastChecker", { enumerable: true, get: function () { return contrastChecker_1.contrastChecker; } });
15
- var noUndefinedProperty_1 = require("./checks/noUndefinedProperty");
16
- Object.defineProperty(exports, "noUndefinedProperty", { enumerable: true, get: function () { return noUndefinedProperty_1.noUndefinedProperty; } });
17
- var uppercaseChecker_1 = require("./checks/uppercaseChecker");
18
- Object.defineProperty(exports, "uppercaseChecker", { enumerable: true, get: function () { return uppercaseChecker_1.uppercaseChecker; } });
19
- var uppercaseStringChecker_1 = require("./checks/uppercaseStringChecker");
20
- Object.defineProperty(exports, "uppercaseStringChecker", { enumerable: true, get: function () { return uppercaseStringChecker_1.uppercaseStringChecker; } });
21
- // Utilities
22
- var applyStyle_1 = require("./utils/applyStyle");
23
- Object.defineProperty(exports, "applyStyle", { enumerable: true, get: function () { return applyStyle_1.applyStyle; } });
24
- var constants_1 = require("./utils/constants");
25
- Object.defineProperty(exports, "MOTION_ANIMATIONS", { enumerable: true, get: function () { return constants_1.MOTION_ANIMATIONS; } });
26
- var error_style_1 = require("./utils/error.style");
27
- Object.defineProperty(exports, "ERROR_STYLE", { enumerable: true, get: function () { return error_style_1.ERROR_STYLE; } });
28
- Object.defineProperty(exports, "RED", { enumerable: true, get: function () { return error_style_1.RED; } });
29
- var generateAccessibilityStateFromProp_1 = require("./utils/generateAccessibilityStateFromProp");
30
- Object.defineProperty(exports, "generateAccessibilityStateFromProp", { enumerable: true, get: function () { return generateAccessibilityStateFromProp_1.generateAccessibilityStateFromProp; } });
31
- var getPropertyFromStyle_1 = require("./utils/getPropertyFromStyle");
32
- Object.defineProperty(exports, "getPropertyFromStyle", { enumerable: true, get: function () { return getPropertyFromStyle_1.getPropertyFromStyle; } });
33
- var interpolateAnimationStates_1 = require("./utils/interpolateAnimationStates");
34
- Object.defineProperty(exports, "interpolateAnimationStates", { enumerable: true, get: function () { return interpolateAnimationStates_1.interpolateAnimationStates; } });
35
- var isFocused_1 = require("./utils/isFocused");
36
- Object.defineProperty(exports, "isFocused", { enumerable: true, get: function () { return isFocused_1.isFocused; } });
37
- var logger_rules_1 = require("./utils/logger.rules");
38
- Object.defineProperty(exports, "CONTRAST_CHECKER_MAX_DEPTH", { enumerable: true, get: function () { return logger_rules_1.CONTRAST_CHECKER_MAX_DEPTH; } });
39
- Object.defineProperty(exports, "IGNORE_CONTRAST_FOR_DISABLED_ELEMENTS", { enumerable: true, get: function () { return logger_rules_1.IGNORE_CONTRAST_FOR_DISABLED_ELEMENTS; } });
40
- Object.defineProperty(exports, "LOGGER_RULES", { enumerable: true, get: function () { return logger_rules_1.LOGGER_RULES; } });
41
- Object.defineProperty(exports, "NON_OVERRIDABLE_RULES", { enumerable: true, get: function () { return logger_rules_1.NON_OVERRIDABLE_RULES; } });
42
- Object.defineProperty(exports, "RULES_HELP", { enumerable: true, get: function () { return logger_rules_1.RULES_HELP; } });
43
- Object.defineProperty(exports, "SHELL_COLORS", { enumerable: true, get: function () { return logger_rules_1.SHELL_COLORS; } });
44
- Object.defineProperty(exports, "canRuleBeOverridden", { enumerable: true, get: function () { return logger_rules_1.canRuleBeOverridden; } });
45
- var logger_1 = require("./utils/logger");
46
- Object.defineProperty(exports, "logFailure", { enumerable: true, get: function () { return logger_1.logFailure; } });
47
- Object.defineProperty(exports, "getContrastCheckerMaxDepth", { enumerable: true, get: function () { return logger_1.getContrastCheckerMaxDepth; } });
48
- Object.defineProperty(exports, "getRuleAction", { enumerable: true, get: function () { return logger_1.getRuleAction; } });
49
- Object.defineProperty(exports, "isAccessibilityLabelAllowed", { enumerable: true, get: function () { return logger_1.isAccessibilityLabelAllowed; } });
50
- Object.defineProperty(exports, "shouldIgnoreContrastCheckForDisabledElement", { enumerable: true, get: function () { return logger_1.shouldIgnoreContrastCheckForDisabledElement; } });
51
- var maybeGenerateStringFromElement_1 = require("./utils/maybeGenerateStringFromElement");
52
- Object.defineProperty(exports, "maybeGenerateStringFromElement", { enumerable: true, get: function () { return maybeGenerateStringFromElement_1.maybeGenerateStringFromElement; } });
53
- var minimumTouchableSize_1 = require("./utils/minimumTouchableSize");
54
- Object.defineProperty(exports, "ANDROID_MINIMUM_TOUCHABLE_SIZE", { enumerable: true, get: function () { return minimumTouchableSize_1.ANDROID_MINIMUM_TOUCHABLE_SIZE; } });
55
- Object.defineProperty(exports, "IOS_MINIMUM_TOUCHABLE_SIZE", { enumerable: true, get: function () { return minimumTouchableSize_1.IOS_MINIMUM_TOUCHABLE_SIZE; } });
56
- Object.defineProperty(exports, "MINIMUM_TOUCHABLE_SIZE", { enumerable: true, get: function () { return minimumTouchableSize_1.MINIMUM_TOUCHABLE_SIZE; } });
@@ -1,17 +0,0 @@
1
- import type { AccessibilityState } from 'react-native';
2
- export type AMAAccessibilityState = Pick<AccessibilityState, 'busy'>;
3
- export type AccessibilityRoles = {
4
- accessibilityRole: 'none' | 'link' | 'search' | 'image' | 'keyboardkey' | 'text' | 'imagebutton' | 'header' | 'summary' | 'alert' | 'combobox' | 'menu' | 'menubar' | 'menuitem' | 'progressbar' | 'radiogroup' | 'scrollbar' | 'spinbutton' | 'tabbar' | 'tablist' | 'timer' | 'list' | 'toolbar';
5
- } | {
6
- accessibilityRole: 'button';
7
- expanded?: AccessibilityState['expanded'];
8
- } | {
9
- accessibilityRole: 'switch';
10
- checked: AccessibilityState['checked'];
11
- } | {
12
- accessibilityRole: 'tab' | 'radio';
13
- selected: AccessibilityState['selected'];
14
- } | {
15
- accessibilityRole: 'togglebutton' | 'switch' | 'checkbox';
16
- checked: AccessibilityState['checked'];
17
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- import type { ContrastChecker } from '../checks/contrastChecker';
3
- export declare const applyStyle: (({ style, debugStyle, children, contrastCheckerCallback, }: {
4
- style: Record<string, any> | Function;
5
- debugStyle: Record<any, any>;
6
- children?: ReactNode;
7
- contrastCheckerCallback?: ((_: ContrastChecker) => Record<string, any>) | undefined;
8
- }) => any[] | ((...params: any) => any) | {
9
- [x: string]: any;
10
- } | undefined) | null;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applyStyle = void 0;
4
- const applyStyleFunction = __DEV__
5
- ? (style, debugStyle, children, contrastCheckerCallback) => {
6
- return (...params) => {
7
- const s = style(...params);
8
- const contrastStyle = contrastCheckerCallback
9
- ? contrastCheckerCallback({ style: s, children })
10
- : {};
11
- if (Array.isArray(s)) {
12
- return [...s, debugStyle, contrastStyle];
13
- }
14
- return Object.assign(Object.assign(Object.assign({}, s), debugStyle), contrastStyle);
15
- };
16
- }
17
- : null;
18
- exports.applyStyle = __DEV__
19
- ? ({ style, debugStyle, children, contrastCheckerCallback, }) => {
20
- if (typeof style === 'function') {
21
- return applyStyleFunction === null || applyStyleFunction === void 0 ? void 0 : applyStyleFunction(style, debugStyle, children, contrastCheckerCallback);
22
- }
23
- const contrastCheckerStyle = contrastCheckerCallback
24
- ? contrastCheckerCallback({ style, children })
25
- : {};
26
- if (Array.isArray(style)) {
27
- return [...style, debugStyle, contrastCheckerStyle].filter(Boolean);
28
- }
29
- else {
30
- return Object.assign(Object.assign(Object.assign({}, style), debugStyle), contrastCheckerStyle);
31
- }
32
- }
33
- : null;
@@ -1,3 +0,0 @@
1
- import type { ViewStyle } from 'react-native';
2
- export type MotionAnimationKey = Partial<keyof ViewStyle> | 'scale';
3
- export declare const MOTION_ANIMATIONS: MotionAnimationKey[];
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MOTION_ANIMATIONS = void 0;
4
- exports.MOTION_ANIMATIONS = [
5
- 'left',
6
- 'bottom',
7
- 'top',
8
- 'right',
9
- 'transform',
10
- 'translateX',
11
- 'translateY',
12
- 'scaleX',
13
- 'scaleY',
14
- 'scale',
15
- 'width',
16
- 'height',
17
- 'padding',
18
- 'paddingBottom',
19
- 'paddingLeft',
20
- 'paddingRight',
21
- 'paddingTop',
22
- 'paddingVertical',
23
- 'paddingHorizontal',
24
- 'margin',
25
- 'marginBottom',
26
- 'marginLeft',
27
- 'marginRight',
28
- 'marginTop',
29
- 'marginHorizontal',
30
- 'marginVertical',
31
- 'rotation',
32
- ];
@@ -1,6 +0,0 @@
1
- export declare const RED = "#A31420";
2
- export declare const ERROR_STYLE: {
3
- borderColor: string;
4
- backgroundColor: string;
5
- borderWidth: number;
6
- } | null;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ERROR_STYLE = exports.RED = void 0;
4
- exports.RED = '#A31420';
5
- exports.ERROR_STYLE = __DEV__
6
- ? {
7
- borderColor: exports.RED,
8
- backgroundColor: 'rgba(163, 20, 32, 0.4)',
9
- borderWidth: 4,
10
- }
11
- : null;
@@ -1,9 +0,0 @@
1
- import type { AccessibilityRole, AccessibilityState } from 'react-native';
2
- export declare const generateAccessibilityStateFromProp: ({ accessibilityRole, ...props }: StateKeyValue) => AccessibilityState;
3
- type StateKeyValue = {
4
- [key in keyof AccessibilityState]: AccessibilityState[key];
5
- } & {
6
- accessibilityState?: AccessibilityState;
7
- accessibilityRole?: AccessibilityRole;
8
- };
9
- export {};
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.generateAccessibilityStateFromProp = void 0;
15
- const react_native_1 = require("react-native");
16
- const generateAccessibilityStateFromProp = (_a) => {
17
- var { accessibilityRole } = _a, props = __rest(_a, ["accessibilityRole"]);
18
- const state = Object.assign({ disabled: props.disabled, selected: props.selected, checked: props.checked, busy: props.busy, expanded: props.expanded }, (props.accessibilityState || {}));
19
- if (accessibilityRole === 'button' && react_native_1.Platform.OS === 'ios') {
20
- /**
21
- * Accessibility roles like
22
- * - checkbox
23
- * - radio
24
- * - togglebutton
25
- *
26
- * need to set the "selected" state for iOS
27
- */
28
- if (typeof state.checked !== 'undefined') {
29
- state.selected = state.checked;
30
- state.checked = undefined;
31
- }
32
- }
33
- return Object.fromEntries(Object.entries(state).filter(([, value]) => value !== undefined));
34
- };
35
- exports.generateAccessibilityStateFromProp = generateAccessibilityStateFromProp;
@@ -1,2 +0,0 @@
1
- import type { StyleProp } from 'react-native';
2
- export declare const getPropertyFromStyle: (style: StyleProp<any> | StyleProp<any>[] | null, key: keyof StyleProp<any>) => any;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPropertyFromStyle = void 0;
4
- const getPropertyFromStyle = (style, key) => {
5
- var _a, _b, _c;
6
- return Array.isArray(style)
7
- ? (_c = (_b = (_a = style.filter(theStyle => theStyle === null || theStyle === void 0 ? void 0 : theStyle[key])) === null || _a === void 0 ? void 0 : _a.slice(-1)) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c[key]
8
- : style === null || style === void 0 ? void 0 : style[key];
9
- };
10
- exports.getPropertyFromStyle = getPropertyFromStyle;
@@ -1,2 +0,0 @@
1
- import type { Animated } from 'react-native';
2
- export declare const interpolateAnimationStates: (from: Record<string, any>, to: Record<string, any>, isReduceMotionEnabled: boolean, progressValue: Animated.Value, reduceMotionProgressValue: Animated.Value) => Record<string, any>;