@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,43 +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.interpolateAnimationStates = void 0;
15
- const constants_1 = require("./constants");
16
- const interpolateAnimationStates = (from, to, isReduceMotionEnabled, progressValue, reduceMotionProgressValue) => {
17
- return Object.keys(from).reduce((outputAnimation, key) => {
18
- const isMotionAnimation = constants_1.MOTION_ANIMATIONS.includes(key);
19
- const progressKey = isReduceMotionEnabled && isMotionAnimation
20
- ? reduceMotionProgressValue
21
- : progressValue;
22
- if (Array.isArray(from[key])) {
23
- outputAnimation[key] = from[key].map((animationObject, index) => {
24
- const _a = (0, exports.interpolateAnimationStates)(animationObject, to[key][index], isReduceMotionEnabled, progressValue, reduceMotionProgressValue), { __hasOnlyMotionAnimation } = _a, style = __rest(_a, ["__hasOnlyMotionAnimation"]);
25
- outputAnimation.__hasOnlyMotionAnimation =
26
- outputAnimation.__hasOnlyMotionAnimation &&
27
- __hasOnlyMotionAnimation;
28
- return style;
29
- });
30
- }
31
- else {
32
- outputAnimation[key] = progressKey.interpolate({
33
- inputRange: [0, 1],
34
- // @ts-ignore
35
- outputRange: [from[key], to[key]],
36
- });
37
- outputAnimation.__hasOnlyMotionAnimation =
38
- outputAnimation.__hasOnlyMotionAnimation && isMotionAnimation;
39
- }
40
- return outputAnimation;
41
- }, { __hasOnlyMotionAnimation: true });
42
- };
43
- exports.interpolateAnimationStates = interpolateAnimationStates;
@@ -1,2 +0,0 @@
1
- import type { TextInput } from 'react-native';
2
- export declare const isFocused: (input: TextInput | undefined | null) => boolean | undefined;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFocused = void 0;
4
- const isFocused = (input) => {
5
- return input === null || input === void 0 ? void 0 : input.isFocused();
6
- };
7
- exports.isFocused = isFocused;
@@ -1,16 +0,0 @@
1
- import { Rule, RuleAction } from './logger.rules';
2
- export type LogParams = {
3
- rule: Rule;
4
- message: string;
5
- extra?: any;
6
- };
7
- export declare const getRuleAction: ((rule: Rule) => RuleAction) | null;
8
- type LogFailure = LogParams & {
9
- action: RuleAction;
10
- };
11
- type CHECK_STATUS = 'ERROR' | 'WARNING';
12
- export declare const logFailure: (({ action, rule, message, extra }: LogFailure) => CHECK_STATUS) | null;
13
- export declare const getContrastCheckerMaxDepth: (() => RuleAction | 5) | null;
14
- export declare const shouldIgnoreContrastCheckForDisabledElement: (() => false | RuleAction) | null;
15
- export declare const isAccessibilityLabelAllowed: ((accessibilityLabel: string) => boolean) | null;
16
- export {};
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAccessibilityLabelAllowed = exports.shouldIgnoreContrastCheckForDisabledElement = exports.getContrastCheckerMaxDepth = exports.logFailure = exports.getRuleAction = void 0;
4
- const logger_rules_1 = require("./logger.rules");
5
- const logger_rules_2 = require("./logger.rules");
6
- const overrideRules = require('./../ama.rules.json');
7
- exports.getRuleAction = __DEV__
8
- ? (rule) => {
9
- var _a;
10
- const customRule = (logger_rules_1.canRuleBeOverridden === null || logger_rules_1.canRuleBeOverridden === void 0 ? void 0 : (0, logger_rules_1.canRuleBeOverridden)(rule))
11
- ? (_a = overrideRules === null || overrideRules === void 0 ? void 0 : overrideRules.rules) === null || _a === void 0 ? void 0 : _a[rule]
12
- : undefined;
13
- return customRule || logger_rules_2.LOGGER_RULES[rule];
14
- }
15
- : null;
16
- exports.logFailure = __DEV__
17
- ? ({ action, rule, message, extra = '' }) => {
18
- // @ts-ignore
19
- const formattedMessage = `❌ ${logger_rules_1.SHELL_COLORS.BG_RED}[ AMA ]${logger_rules_1.SHELL_COLORS.RESET}: ${logger_rules_1.SHELL_COLORS.BLUE}${rule}${logger_rules_1.SHELL_COLORS.RESET} - ${logger_rules_1.SHELL_COLORS.YELLOW}${message}${logger_rules_1.SHELL_COLORS.RESET}\n\n${logger_rules_2.RULES_HELP[rule]}\n\n`;
20
- switch (action) {
21
- case 'MUST_NOT':
22
- case 'MUST':
23
- console.info(formattedMessage, extra || '', '\n');
24
- return 'ERROR';
25
- case 'PLEASE_FORGIVE_ME':
26
- return 'WARNING';
27
- case 'SHOULD_NOT':
28
- default:
29
- console.warn(formattedMessage, extra || '', '\n');
30
- return 'WARNING';
31
- }
32
- }
33
- : null;
34
- exports.getContrastCheckerMaxDepth = __DEV__
35
- ? () => {
36
- var _a;
37
- return (((_a = overrideRules === null || overrideRules === void 0 ? void 0 : overrideRules.rules) === null || _a === void 0 ? void 0 : _a.CONTRAST_CHECKER_MAX_DEPTH) ||
38
- logger_rules_2.CONTRAST_CHECKER_MAX_DEPTH);
39
- }
40
- : null;
41
- exports.shouldIgnoreContrastCheckForDisabledElement = __DEV__
42
- ? () => {
43
- var _a;
44
- return (((_a = overrideRules === null || overrideRules === void 0 ? void 0 : overrideRules.rules) === null || _a === void 0 ? void 0 : _a.IGNORE_CONTRAST_FOR_DISABLED_ELEMENTS) ||
45
- logger_rules_1.IGNORE_CONTRAST_FOR_DISABLED_ELEMENTS);
46
- }
47
- : null;
48
- exports.isAccessibilityLabelAllowed = __DEV__
49
- ? (accessibilityLabel) => {
50
- var _a;
51
- return (_a = overrideRules === null || overrideRules === void 0 ? void 0 : overrideRules.accessibilityLabelExceptions) === null || _a === void 0 ? void 0 : _a.includes(accessibilityLabel);
52
- }
53
- : null;
@@ -1,15 +0,0 @@
1
- export type Rule = 'BOTTOM_SHEET_CLOSE_ACTION' | 'CONTRAST_FAILED' | 'CONTRAST_FAILED_AAA' | 'FLATLIST_NO_COUNT_IN_PLURAL_MESSAGE' | 'FLATLIST_NO_COUNT_IN_SINGULAR_MESSAGE' | 'MINIMUM_SIZE' | 'NO_ACCESSIBILITY_LABEL' | 'NO_ACCESSIBILITY_ROLE' | 'NO_FORM_ERROR' | 'NO_FORM_LABEL' | 'NO_KEYBOARD_TRAP' | 'NO_UNDEFINED' | 'NO_UPPERCASE_TEXT' | 'INCOMPATIBLE_ACCESSIBILITY_STATE' | 'INCOMPATIBLE_ACCESSIBILITY_ROLE' | 'NO_FORM_LABEL_ENDING_WITH_ASTERISK' | 'UPPERCASE_TEXT_NO_ACCESSIBILITY_LABEL';
2
- export type RuleAction = 'SHOULD_NOT' | 'MUST_NOT' | 'MUST' | 'SHOULD' | 'PLEASE_FORGIVE_ME';
3
- export declare const NON_OVERRIDABLE_RULES: string[] | undefined;
4
- export declare const LOGGER_RULES: Record<Rule, RuleAction> | null;
5
- export declare const CONTRAST_CHECKER_MAX_DEPTH = 5;
6
- export declare const IGNORE_CONTRAST_FOR_DISABLED_ELEMENTS = false;
7
- export declare const RULES_HELP: Record<Rule, string> | null;
8
- export declare const canRuleBeOverridden: ((rule: Rule) => boolean) | null;
9
- export declare const SHELL_COLORS: {
10
- RED: string;
11
- YELLOW: string;
12
- RESET: string;
13
- BLUE: string;
14
- BG_RED: string;
15
- } | undefined;
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SHELL_COLORS = exports.canRuleBeOverridden = exports.RULES_HELP = exports.IGNORE_CONTRAST_FOR_DISABLED_ELEMENTS = exports.CONTRAST_CHECKER_MAX_DEPTH = exports.LOGGER_RULES = exports.NON_OVERRIDABLE_RULES = void 0;
4
- exports.NON_OVERRIDABLE_RULES = __DEV__
5
- ? [
6
- 'NO_ACCESSIBILITY_ROLE',
7
- 'NO_ACCESSIBILITY_LABEL',
8
- 'NO_KEYBOARD_TRAP',
9
- 'NO_UNDEFINED',
10
- 'NO_FORM_LABEL',
11
- 'FLATLIST_NO_COUNT_IN_PLURAL_MESSAGE',
12
- 'BOTTOM_SHEET_CLOSE_ACTION',
13
- 'INCOMPATIBLE_ACCESSIBILITY_STATE',
14
- 'INCOMPATIBLE_ACCESSIBILITY_ROLE',
15
- ]
16
- : undefined;
17
- exports.LOGGER_RULES = __DEV__
18
- ? {
19
- CONTRAST_FAILED: 'MUST',
20
- CONTRAST_FAILED_AAA: 'SHOULD',
21
- FLATLIST_NO_COUNT_IN_SINGULAR_MESSAGE: 'SHOULD',
22
- FLATLIST_NO_COUNT_IN_PLURAL_MESSAGE: 'MUST',
23
- MINIMUM_SIZE: 'MUST',
24
- NO_ACCESSIBILITY_LABEL: 'MUST',
25
- NO_ACCESSIBILITY_ROLE: 'MUST',
26
- NO_FORM_LABEL: 'MUST',
27
- NO_FORM_ERROR: 'MUST',
28
- NO_KEYBOARD_TRAP: 'MUST_NOT',
29
- NO_UNDEFINED: 'MUST_NOT',
30
- UPPERCASE_TEXT_NO_ACCESSIBILITY_LABEL: 'MUST_NOT',
31
- NO_UPPERCASE_TEXT: 'MUST_NOT',
32
- BOTTOM_SHEET_CLOSE_ACTION: 'MUST',
33
- INCOMPATIBLE_ACCESSIBILITY_STATE: 'MUST',
34
- NO_FORM_LABEL_ENDING_WITH_ASTERISK: 'MUST_NOT',
35
- INCOMPATIBLE_ACCESSIBILITY_ROLE: 'MUST_NOT',
36
- }
37
- : null;
38
- exports.CONTRAST_CHECKER_MAX_DEPTH = 5;
39
- exports.IGNORE_CONTRAST_FOR_DISABLED_ELEMENTS = false;
40
- exports.RULES_HELP = __DEV__
41
- ? {
42
- NO_UNDEFINED: '',
43
- CONTRAST_FAILED: 'https://formidable.com/open-source/react-native-ama/guidelines/contrast',
44
- CONTRAST_FAILED_AAA: 'https://formidable.com/open-source/react-native-ama/guidelines/contrast',
45
- MINIMUM_SIZE: 'https://formidable.com/open-source/react-native-ama/guidelines/minimum-size',
46
- UPPERCASE_TEXT_NO_ACCESSIBILITY_LABEL: 'https://formidable.com/open-source/react-native-ama/guidelines/text',
47
- NO_UPPERCASE_TEXT: 'https://formidable.com/open-source/react-native-ama/guidelines/text',
48
- NO_ACCESSIBILITY_LABEL: 'https://formidable.com/open-source/react-native-ama/guidelines/accessibility-labels',
49
- NO_ACCESSIBILITY_ROLE: 'https://formidable.com/open-source/react-native-ama/guidelines/accessibility-role',
50
- NO_KEYBOARD_TRAP: 'https://formidable.com/open-source/react-native-ama/guidelines/forms',
51
- NO_FORM_LABEL: 'https://formidable.com/open-source/react-native-ama/guidelines/forms',
52
- NO_FORM_ERROR: 'https://formidable.com/open-source/react-native-ama/guidelines/forms',
53
- FLATLIST_NO_COUNT_IN_SINGULAR_MESSAGE: 'https://formidable.com/open-source/react-native-ama/guidelines/lists-grids#number-of-results',
54
- FLATLIST_NO_COUNT_IN_PLURAL_MESSAGE: 'https://formidable.com/open-source/react-native-ama/guidelines/lists-grids#number-of-results',
55
- BOTTOM_SHEET_CLOSE_ACTION: 'https://formidable.com/open-source/react-native-ama/guidelines/bottomsheet',
56
- INCOMPATIBLE_ACCESSIBILITY_STATE: 'https://formidable.com/open-source/react-native-ama/guidelines/accessibility-role',
57
- INCOMPATIBLE_ACCESSIBILITY_ROLE: 'https://formidable.com/open-source/react-native-ama/guidelines/accessibility-role',
58
- NO_FORM_LABEL_ENDING_WITH_ASTERISK: 'https://formidable.com/open-source/react-native-ama/guidelines/forms#labels',
59
- }
60
- : null;
61
- exports.canRuleBeOverridden = __DEV__
62
- ? (rule) => {
63
- return !exports.NON_OVERRIDABLE_RULES.includes(rule);
64
- }
65
- : null;
66
- exports.SHELL_COLORS = __DEV__
67
- ? {
68
- RED: '\x1b[31m',
69
- YELLOW: '\x1b[33m',
70
- RESET: '\x1b[0m',
71
- BLUE: '\x1b[36m',
72
- BG_RED: '\x1b[41m',
73
- }
74
- : undefined;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- /// <reference types="react" />
3
- export declare const maybeGenerateStringFromElement: (element?: JSX.Element, alternativeString?: string | null) => string;
@@ -1,3 +0,0 @@
1
- export declare const ANDROID_MINIMUM_TOUCHABLE_SIZE = 48;
2
- export declare const IOS_MINIMUM_TOUCHABLE_SIZE = 44;
3
- export declare const MINIMUM_TOUCHABLE_SIZE: number;
@@ -1,9 +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 = void 0;
4
- const react_native_1 = require("react-native");
5
- exports.ANDROID_MINIMUM_TOUCHABLE_SIZE = 48;
6
- exports.IOS_MINIMUM_TOUCHABLE_SIZE = 44;
7
- exports.MINIMUM_TOUCHABLE_SIZE = react_native_1.Platform.OS === 'android'
8
- ? exports.ANDROID_MINIMUM_TOUCHABLE_SIZE
9
- : exports.IOS_MINIMUM_TOUCHABLE_SIZE;
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  export { AutofocusContainer } from './components/AutofocusContainer';
2
- export { HideChildrenFromAccessibilityTree } from './components/HideChildrenFromAccessibilityTree';
3
2
  export { AMAProvider, useAMAContext, type AMAContextValue, type AMADevContextValue, type AMAProdContextValue, } from './components/AMAProvider';
3
+ export { HideChildrenFromAccessibilityTree } from './components/HideChildrenFromAccessibilityTree';
4
4
  export { useButtonChecks } from './hooks/useButtonChecks';
5
5
  export { useChecks } from './hooks/useChecks';
6
6
  export { useFocus } from './hooks/useFocus';
File without changes
File without changes