@react-native-ama/forms 1.0.0 → 1.0.1-alpha.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.
Files changed (97) hide show
  1. package/dist/{forms/src/hooks → hooks}/useTextInput.d.ts +8 -8
  2. package/package.json +2 -2
  3. package/dist/core/src/components/AMAProvider.d.ts +0 -26
  4. package/dist/core/src/components/AMAProvider.js +0 -147
  5. package/dist/core/src/components/AutofocusContainer.d.ts +0 -9
  6. package/dist/core/src/components/AutofocusContainer.js +0 -58
  7. package/dist/core/src/components/HideChildrenFromAccessibilityTree.d.ts +0 -6
  8. package/dist/core/src/components/HideChildrenFromAccessibilityTree.js +0 -40
  9. package/dist/core/src/hooks/useButtonChecks.d.ts +0 -6
  10. package/dist/core/src/hooks/useButtonChecks.js +0 -51
  11. package/dist/core/src/hooks/useChecks.d.ts +0 -15
  12. package/dist/core/src/hooks/useChecks.js +0 -152
  13. package/dist/core/src/hooks/useFocus.d.ts +0 -4
  14. package/dist/core/src/hooks/useFocus.js +0 -55
  15. package/dist/core/src/hooks/useTimedAction.d.ts +0 -3
  16. package/dist/core/src/hooks/useTimedAction.js +0 -63
  17. package/dist/core/src/index.d.ts +0 -7
  18. package/dist/core/src/index.js +0 -20
  19. package/dist/internal/src/checks/checkAccessibilityRole.d.ts +0 -3
  20. package/dist/internal/src/checks/checkAccessibilityRole.js +0 -32
  21. package/dist/internal/src/checks/checkFocusTrap.d.ts +0 -8
  22. package/dist/internal/src/checks/checkFocusTrap.js +0 -34
  23. package/dist/internal/src/checks/checkForAccessibilityState.d.ts +0 -7
  24. package/dist/internal/src/checks/checkForAccessibilityState.js +0 -48
  25. package/dist/internal/src/checks/checkMinimumSize.d.ts +0 -3
  26. package/dist/internal/src/checks/checkMinimumSize.js +0 -29
  27. package/dist/internal/src/checks/contrastChecker.d.ts +0 -8
  28. package/dist/internal/src/checks/contrastChecker.js +0 -77
  29. package/dist/internal/src/checks/noUndefinedProperty.d.ts +0 -8
  30. package/dist/internal/src/checks/noUndefinedProperty.js +0 -14
  31. package/dist/internal/src/checks/uppercaseChecker.d.ts +0 -8
  32. package/dist/internal/src/checks/uppercaseChecker.js +0 -18
  33. package/dist/internal/src/checks/uppercaseStringChecker.d.ts +0 -8
  34. package/dist/internal/src/checks/uppercaseStringChecker.js +0 -29
  35. package/dist/internal/src/index.d.ts +0 -20
  36. package/dist/internal/src/index.js +0 -56
  37. package/dist/internal/src/types.d.ts +0 -17
  38. package/dist/internal/src/types.js +0 -2
  39. package/dist/internal/src/utils/applyStyle.d.ts +0 -9
  40. package/dist/internal/src/utils/applyStyle.js +0 -33
  41. package/dist/internal/src/utils/constants.d.ts +0 -3
  42. package/dist/internal/src/utils/constants.js +0 -32
  43. package/dist/internal/src/utils/error.style.d.ts +0 -6
  44. package/dist/internal/src/utils/error.style.js +0 -11
  45. package/dist/internal/src/utils/generateAccessibilityStateFromProp.d.ts +0 -9
  46. package/dist/internal/src/utils/generateAccessibilityStateFromProp.js +0 -35
  47. package/dist/internal/src/utils/getPropertyFromStyle.d.ts +0 -2
  48. package/dist/internal/src/utils/getPropertyFromStyle.js +0 -10
  49. package/dist/internal/src/utils/interpolateAnimationStates.d.ts +0 -2
  50. package/dist/internal/src/utils/interpolateAnimationStates.js +0 -43
  51. package/dist/internal/src/utils/isFocused.d.ts +0 -2
  52. package/dist/internal/src/utils/isFocused.js +0 -7
  53. package/dist/internal/src/utils/logger.d.ts +0 -16
  54. package/dist/internal/src/utils/logger.js +0 -53
  55. package/dist/internal/src/utils/logger.rules.d.ts +0 -15
  56. package/dist/internal/src/utils/logger.rules.js +0 -74
  57. package/dist/internal/src/utils/maybeGenerateStringFromElement.d.ts +0 -2
  58. package/dist/internal/src/utils/maybeGenerateStringFromElement.js +0 -51
  59. package/dist/internal/src/utils/minimumTouchableSize.d.ts +0 -3
  60. package/dist/internal/src/utils/minimumTouchableSize.js +0 -9
  61. package/dist/react-native/src/components/ExpandablePressable.d.ts +0 -6
  62. package/dist/react-native/src/components/ExpandablePressable.js +0 -26
  63. package/dist/react-native/src/components/Pressable.d.ts +0 -5
  64. package/dist/react-native/src/components/Pressable.js +0 -49
  65. package/dist/react-native/src/components/SwitchListItem.d.ts +0 -12
  66. package/dist/react-native/src/components/SwitchListItem.js +0 -44
  67. package/dist/react-native/src/components/SwitchWrapper.d.ts +0 -11
  68. package/dist/react-native/src/components/SwitchWrapper.js +0 -36
  69. package/dist/react-native/src/components/Text.d.ts +0 -6
  70. package/dist/react-native/src/components/Text.js +0 -77
  71. package/dist/react-native/src/components/TouchableOpacity.d.ts +0 -6
  72. package/dist/react-native/src/components/TouchableOpacity.js +0 -48
  73. package/dist/react-native/src/components/TouchableWithoutFeedback.d.ts +0 -5
  74. package/dist/react-native/src/components/TouchableWithoutFeedback.js +0 -48
  75. package/dist/react-native/src/hooks/useExpandable.d.ts +0 -13
  76. package/dist/react-native/src/hooks/useExpandable.js +0 -31
  77. package/dist/react-native/src/hooks/usePressable.d.ts +0 -16
  78. package/dist/react-native/src/hooks/usePressable.js +0 -44
  79. package/dist/react-native/src/hooks/useSwitch.d.ts +0 -10
  80. package/dist/react-native/src/hooks/useSwitch.js +0 -25
  81. package/dist/react-native/src/index.d.ts +0 -10
  82. package/dist/react-native/src/index.js +0 -25
  83. /package/dist/{forms/src/components → components}/Form.d.ts +0 -0
  84. /package/dist/{forms/src/components → components}/Form.js +0 -0
  85. /package/dist/{forms/src/components → components}/FormField.d.ts +0 -0
  86. /package/dist/{forms/src/components → components}/FormField.js +0 -0
  87. /package/dist/{forms/src/components → components}/FormSubmit.d.ts +0 -0
  88. /package/dist/{forms/src/components → components}/FormSubmit.js +0 -0
  89. /package/dist/{forms/src/components → components}/FormSwitch.d.ts +0 -0
  90. /package/dist/{forms/src/components → components}/FormSwitch.js +0 -0
  91. /package/dist/{forms/src/components → components}/TextInput.d.ts +0 -0
  92. /package/dist/{forms/src/components → components}/TextInput.js +0 -0
  93. /package/dist/{forms/src/hooks → hooks}/useFormField.d.ts +0 -0
  94. /package/dist/{forms/src/hooks → hooks}/useFormField.js +0 -0
  95. /package/dist/{forms/src/hooks → hooks}/useTextInput.js +0 -0
  96. /package/dist/{forms/src/index.d.ts → index.d.ts} +0 -0
  97. /package/dist/{forms/src/index.js → index.js} +0 -0
@@ -54,7 +54,7 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
54
54
  end?: number | undefined;
55
55
  } | undefined;
56
56
  selectionColor?: import("react-native").ColorValue | undefined;
57
- textAlign?: "left" | "right" | "center" | undefined;
57
+ textAlign?: "center" | "left" | "right" | undefined;
58
58
  testID?: string | undefined;
59
59
  inputAccessoryViewID?: string | undefined;
60
60
  value?: string | undefined;
@@ -63,7 +63,7 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
63
63
  hitSlop?: import("react-native").Insets | undefined;
64
64
  id?: string | undefined;
65
65
  onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
66
- pointerEvents?: "none" | "box-none" | "box-only" | "auto" | undefined;
66
+ pointerEvents?: "box-none" | "none" | "box-only" | "auto" | undefined;
67
67
  removeClippedSubviews?: boolean | undefined;
68
68
  nativeID?: string | undefined;
69
69
  collapsable?: boolean | undefined;
@@ -164,9 +164,9 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
164
164
  returnKeyLabel?: string | undefined;
165
165
  textBreakStrategy?: "simple" | "highQuality" | "balanced" | undefined;
166
166
  underlineColorAndroid?: import("react-native").ColorValue | undefined;
167
- textAlignVertical?: "bottom" | "top" | "auto" | "center" | undefined;
167
+ textAlignVertical?: "center" | "auto" | "top" | "bottom" | undefined;
168
168
  showSoftInputOnFocus?: boolean | undefined;
169
- verticalAlign?: "bottom" | "top" | "auto" | "middle" | undefined;
169
+ verticalAlign?: "auto" | "middle" | "top" | "bottom" | undefined;
170
170
  labelComponent?: JSX.Element | undefined;
171
171
  labelPosition?: "beforeInput" | "afterInput" | undefined;
172
172
  nextFormField?: React.RefObject<import("react-native").TextInput> | undefined;
@@ -220,7 +220,7 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
220
220
  } | undefined;
221
221
  selectionColor?: import("react-native").ColorValue | undefined;
222
222
  style?: false | ViewStyle | import("react-native").RegisteredStyle<TextStyle> | import("react-native").RecursiveArray<import("react-native").Falsy | TextStyle | import("react-native").RegisteredStyle<TextStyle>> | null | undefined;
223
- textAlign?: "left" | "right" | "center" | undefined;
223
+ textAlign?: "center" | "left" | "right" | undefined;
224
224
  testID?: string | undefined;
225
225
  inputAccessoryViewID?: string | undefined;
226
226
  value?: string | undefined;
@@ -229,7 +229,7 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
229
229
  hitSlop?: import("react-native").Insets | undefined;
230
230
  id?: string | undefined;
231
231
  onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
232
- pointerEvents?: "none" | "box-none" | "box-only" | "auto" | undefined;
232
+ pointerEvents?: "box-none" | "none" | "box-only" | "auto" | undefined;
233
233
  removeClippedSubviews?: boolean | undefined;
234
234
  nativeID?: string | undefined;
235
235
  collapsable?: boolean | undefined;
@@ -330,9 +330,9 @@ export declare const useTextInput: ({ onLayout, returnKeyType, onSubmitEditing,
330
330
  returnKeyLabel?: string | undefined;
331
331
  textBreakStrategy?: "simple" | "highQuality" | "balanced" | undefined;
332
332
  underlineColorAndroid?: import("react-native").ColorValue | undefined;
333
- textAlignVertical?: "bottom" | "top" | "auto" | "center" | undefined;
333
+ textAlignVertical?: "center" | "auto" | "top" | "bottom" | undefined;
334
334
  showSoftInputOnFocus?: boolean | undefined;
335
- verticalAlign?: "bottom" | "top" | "auto" | "middle" | undefined;
335
+ verticalAlign?: "auto" | "middle" | "top" | "bottom" | undefined;
336
336
  labelComponent?: JSX.Element | undefined;
337
337
  labelPosition?: "beforeInput" | "afterInput" | undefined;
338
338
  nextFormField?: React.RefObject<import("react-native").TextInput> | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-ama/forms",
3
- "version": "1.0.0",
3
+ "version": "1.0.1-alpha.1",
4
4
  "private": false,
5
5
  "react-native": "src/index",
6
6
  "types": "dist/index.d.ts",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "homepage": "https://github.com/FormidableLabs/react-native-ama#readme",
49
49
  "publishConfig": {
50
- "provenance": true
50
+ "provenance": false
51
51
  },
52
52
  "author": "",
53
53
  "license": "MIT",
@@ -1,26 +0,0 @@
1
- import * as React from 'react';
2
- type AMAProviderProps = {
3
- children: React.ReactNode;
4
- };
5
- type SharedContextValue = {
6
- isBoldTextEnabled: boolean;
7
- isScreenReaderEnabled: boolean;
8
- isGrayscaleEnabled: boolean;
9
- isInvertColorsEnabled: boolean;
10
- isReduceMotionEnabled: boolean;
11
- isReduceTransparencyEnabled: boolean;
12
- reactNavigationScreenOptions: {
13
- animationEnabled: boolean;
14
- animation: 'default' | 'fade';
15
- };
16
- };
17
- export type AMADevContextValue = SharedContextValue & {
18
- trackError: (id: string) => void;
19
- removeError: (id: string) => void;
20
- };
21
- export type AMAProdContextValue = SharedContextValue & {};
22
- export type AMAContextValue = AMADevContextValue | AMAProdContextValue;
23
- export declare const isDevContextValue: (value: AMAContextValue) => value is AMADevContextValue;
24
- export declare const AMAProvider: React.FC<AMAProviderProps>;
25
- export declare const useAMAContext: () => AMAContextValue;
26
- export {};
@@ -1,147 +0,0 @@
1
- "use strict";
2
- /* eslint-disable react-native/no-inline-styles */
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.useAMAContext = exports.AMAProvider = exports.isDevContextValue = void 0;
28
- const internal_1 = require("@react-native-ama/internal");
29
- const React = __importStar(require("react"));
30
- const react_native_1 = require("react-native");
31
- const eventsMapping = {
32
- reduceTransparencyChanged: 'isReduceTransparencyEnabled',
33
- reduceMotionChanged: 'isReduceMotionEnabled',
34
- grayscaleChanged: 'isGrayscaleEnabled',
35
- boldTextChanged: 'isBoldTextEnabled',
36
- invertColorsChanged: 'isInvertColorsEnabled',
37
- screenReaderChanged: 'isScreenReaderEnabled',
38
- };
39
- const isDevContextValue = (value) => value.trackError !== undefined;
40
- exports.isDevContextValue = isDevContextValue;
41
- const DEFAULT_VALUES = {
42
- isReduceTransparencyEnabled: false,
43
- isBoldTextEnabled: false,
44
- isGrayscaleEnabled: false,
45
- isInvertColorsEnabled: false,
46
- isReduceMotionEnabled: false,
47
- isScreenReaderEnabled: false,
48
- reactNavigationScreenOptions: {
49
- animationEnabled: true,
50
- animation: 'default',
51
- },
52
- };
53
- const AMAContext = React.createContext(null);
54
- const AMAProvider = ({ children }) => {
55
- const [values, setValues] = React.useState(DEFAULT_VALUES);
56
- const handleAccessibilityInfoChanged = (key) => {
57
- return (newValue) => {
58
- setValues(oldValues => {
59
- const newValues = Object.assign({}, oldValues);
60
- newValues[key] = newValue;
61
- if (key === 'isReduceMotionEnabled') {
62
- newValues.reactNavigationScreenOptions.animationEnabled = !newValue;
63
- newValues.reactNavigationScreenOptions.animation = newValue
64
- ? 'fade'
65
- : 'default';
66
- }
67
- return Object.assign(Object.assign({}, oldValues), newValues);
68
- });
69
- };
70
- };
71
- React.useEffect(() => {
72
- const allInitPromises = [];
73
- const subscriptions = Object.entries(eventsMapping).map(([eventName, contextKey]) => {
74
- allInitPromises.push(react_native_1.AccessibilityInfo[contextKey]());
75
- return react_native_1.AccessibilityInfo.addEventListener(eventName, handleAccessibilityInfoChanged(contextKey));
76
- });
77
- Promise.all(allInitPromises).then(promisesValues => {
78
- const newValues = Object.values(eventsMapping).reduce((list, key, index) => {
79
- list[key] = promisesValues[index];
80
- return list;
81
- }, {});
82
- setValues(oldValues => {
83
- return Object.assign(Object.assign({}, oldValues), newValues);
84
- });
85
- });
86
- return () => {
87
- subscriptions.forEach(subscription => subscription === null || subscription === void 0 ? void 0 : subscription.remove());
88
- };
89
- }, []);
90
- const [failedItems, setFailedItems] = React.useState([]);
91
- if (__DEV__) {
92
- const trackError = (id) => {
93
- if (failedItems.includes(id)) {
94
- return;
95
- }
96
- setFailedItems(items => [...items, id]);
97
- react_native_1.AccessibilityInfo.announceForAccessibility("One or more component didn't pass the accessibility check, please check the console for more info");
98
- };
99
- const removeError = (id) => {
100
- setFailedItems(items => {
101
- const index = items.indexOf(id);
102
- if (index >= 0) {
103
- items.splice(index);
104
- return [...items];
105
- }
106
- return items;
107
- });
108
- };
109
- return (<AMAContext.Provider value={Object.assign(Object.assign({}, values), { trackError,
110
- removeError })}>
111
- <react_native_1.View style={{ flex: 1 }}>
112
- <>
113
- {children}
114
- {failedItems.length > 0 ? (<AMAError count={failedItems.length}/>) : null}
115
- </>
116
- </react_native_1.View>
117
- </AMAContext.Provider>);
118
- }
119
- return <AMAContext.Provider value={values}>{children}</AMAContext.Provider>;
120
- };
121
- exports.AMAProvider = AMAProvider;
122
- const AMAError = ({ count }) => {
123
- const error = `${count} component(s) didn't pass the accessibility check(s)`;
124
- return (<react_native_1.View accessibilityLabel={error} accessibilityHint="Please check the console for more info..." style={{
125
- paddingHorizontal: 24,
126
- paddingTop: 24,
127
- paddingBottom: 48,
128
- backgroundColor: internal_1.RED,
129
- }} testID="amaError">
130
- <react_native_1.View accessible={true}>
131
- <react_native_1.Text style={{ color: 'white', fontSize: 16, lineHeight: 26 }} testID="amaError.message">
132
- {error}
133
- </react_native_1.Text>
134
- <react_native_1.Text style={{ color: 'white', fontSize: 16, lineHeight: 24 }}>
135
- Please check the console for more info...
136
- </react_native_1.Text>
137
- </react_native_1.View>
138
- </react_native_1.View>);
139
- };
140
- const useAMAContext = () => {
141
- const context = React.useContext(AMAContext);
142
- if (!context) {
143
- throw new Error('Please wrap your app with <AMAProvider />');
144
- }
145
- return context;
146
- };
147
- exports.useAMAContext = useAMAContext;
@@ -1,9 +0,0 @@
1
- import * as React from 'react';
2
- import { ViewProps } from 'react-native';
3
- type AutofocusContainerProps = React.PropsWithChildren<({
4
- wrapChildrenInAccessibleView?: true;
5
- } & ViewProps) | {
6
- wrapChildrenInAccessibleView: false;
7
- }>;
8
- export declare const AutofocusContainer: ({ children, wrapChildrenInAccessibleView, ...viewProps }: AutofocusContainerProps) => React.JSX.Element;
9
- export {};
@@ -1,58 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __rest = (this && this.__rest) || function (s, e) {
26
- var t = {};
27
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
- t[p] = s[p];
29
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
- t[p[i]] = s[p[i]];
33
- }
34
- return t;
35
- };
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.AutofocusContainer = void 0;
38
- const React = __importStar(require("react"));
39
- const react_native_1 = require("react-native");
40
- const useFocus_1 = require("../hooks/useFocus");
41
- const AutofocusContainer = (_a) => {
42
- var { children, wrapChildrenInAccessibleView = true } = _a, viewProps = __rest(_a, ["children", "wrapChildrenInAccessibleView"]);
43
- const containerRef = React.useRef(null);
44
- const { setFocus } = (0, useFocus_1.useFocus)();
45
- React.useEffect(() => {
46
- setTimeout(() => {
47
- setFocus(containerRef.current);
48
- }, 0);
49
- }, [setFocus]);
50
- return wrapChildrenInAccessibleView ? (<react_native_1.TouchableWithoutFeedback ref={containerRef}>
51
- <react_native_1.View accessible={true} testID="autofocusContainer.accessibleView" {...viewProps}>
52
- {children}
53
- </react_native_1.View>
54
- </react_native_1.TouchableWithoutFeedback>) : (<react_native_1.TouchableWithoutFeedback ref={containerRef}>
55
- {children}
56
- </react_native_1.TouchableWithoutFeedback>);
57
- };
58
- exports.AutofocusContainer = AutofocusContainer;
@@ -1,6 +0,0 @@
1
- import { PropsWithChildren } from 'react';
2
- type HideChildrenFromAccessibilityTreeProps = {
3
- testID?: string;
4
- };
5
- export declare const HideChildrenFromAccessibilityTree: (props: PropsWithChildren<HideChildrenFromAccessibilityTreeProps>) => JSX.Element;
6
- export {};
@@ -1,40 +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.HideChildrenFromAccessibilityTree = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const react_native_1 = require("react-native");
9
- const AMAProvider_1 = require("./AMAProvider");
10
- const HideChildrenFromAccessibilityTree = (props) => {
11
- const { isScreenReaderEnabled } = (0, AMAProvider_1.useAMAContext)();
12
- if (!isScreenReaderEnabled) {
13
- return <>{props.children}</>;
14
- }
15
- return react_native_1.Platform.select({
16
- default: <HideChildrenFromAccessibilityAndroid {...props}/>,
17
- ios: <HideChildrenFromAccessibilityTreeIOS {...props}/>,
18
- });
19
- };
20
- exports.HideChildrenFromAccessibilityTree = HideChildrenFromAccessibilityTree;
21
- const HideChildrenFromAccessibilityAndroid = ({ children, testID, }) => {
22
- return (<react_native_1.View importantForAccessibility="no-hide-descendants" testID={testID}>
23
- {children}
24
- </react_native_1.View>);
25
- };
26
- const HideChildrenFromAccessibilityTreeIOS = ({ children, }) => {
27
- return hideChildrenFromAccessibilityTree(children);
28
- };
29
- const hideChildrenFromAccessibilityTree = (component) => {
30
- return (react_1.default.Children.map(component, child => {
31
- return react_1.default.isValidElement(child)
32
- ? react_1.default.cloneElement(child, {
33
- // @ts-ignore
34
- importantForAccessibility: 'no',
35
- accessibilityElementsHidden: true,
36
- children: hideChildrenFromAccessibilityTree(child.props.children),
37
- })
38
- : child;
39
- }) || null);
40
- };
@@ -1,6 +0,0 @@
1
- import type React from 'react';
2
- import type { PressableStateCallbackType } from 'react-native';
3
- export declare const useButtonChecks: ((props: Record<string, any>, children?: React.ReactNode | ((state: PressableStateCallbackType) => React.ReactNode), shouldPerformContrastCheck?: boolean) => {
4
- onLayout: (event: import("react-native").LayoutChangeEvent) => void;
5
- debugStyle: any;
6
- } | null) | null;
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useButtonChecks = void 0;
4
- const internal_1 = require("@react-native-ama/internal");
5
- const useChecks_1 = require("./useChecks");
6
- exports.useButtonChecks = __DEV__
7
- ? (props, children, shouldPerformContrastCheck = true) => {
8
- const checks = (0, useChecks_1.useChecks)();
9
- if (checks === null) {
10
- return null;
11
- }
12
- const { noUndefinedProperty, contrastChecker, onLayout, noUppercaseStringChecker, checkCompatibleAccessibilityState, checkAccessibilityRole, debugStyle, } = checks;
13
- let style = props.style || {};
14
- const isAccessible = props.accessible !== false;
15
- isAccessible &&
16
- noUndefinedProperty({
17
- properties: props,
18
- property: 'accessibilityRole',
19
- rule: 'NO_ACCESSIBILITY_ROLE',
20
- });
21
- isAccessible &&
22
- noUndefinedProperty({
23
- properties: props,
24
- property: 'accessibilityLabel',
25
- rule: 'NO_ACCESSIBILITY_LABEL',
26
- });
27
- isAccessible &&
28
- noUppercaseStringChecker({
29
- text: props.accessibilityLabel,
30
- });
31
- checkCompatibleAccessibilityState({
32
- accessibilityStates: props === null || props === void 0 ? void 0 : props.accessibilityState,
33
- accessibilityRole: props === null || props === void 0 ? void 0 : props.accessiblityRole,
34
- });
35
- checkAccessibilityRole(props.accessibilityRole);
36
- const contrastCheckerCallback = shouldPerformContrastCheck
37
- ? contrastChecker
38
- : undefined;
39
- const theStyle = internal_1.applyStyle === null || internal_1.applyStyle === void 0 ? void 0 : (0, internal_1.applyStyle)({
40
- style,
41
- debugStyle,
42
- // @ts-ignore
43
- children,
44
- contrastCheckerCallback,
45
- });
46
- return {
47
- onLayout,
48
- debugStyle: theStyle,
49
- };
50
- }
51
- : null;
@@ -1,15 +0,0 @@
1
- import { LogParams, type CheckFocusTrap, type ContrastChecker, type NoUndefinedProperty, type UppercaseChecker, type UppercaseStringChecker } from '@react-native-ama/internal';
2
- import { AccessibilityRole, LayoutChangeEvent } from 'react-native';
3
- export declare const useChecks: () => {
4
- logResult: (name: string, result: LogParams | LogParams[] | null) => Record<string, any>;
5
- noUndefinedProperty: <T>(params: NoUndefinedProperty<T>) => Record<string, any>;
6
- contrastChecker: (params: ContrastChecker) => Record<string, any>;
7
- onLayout: (event: LayoutChangeEvent) => void;
8
- noUppercaseStringChecker: (params: UppercaseStringChecker) => Record<string, any>;
9
- uppercaseChecker: (params: UppercaseChecker) => Record<string, any>;
10
- checkFocusTrap: (params: CheckFocusTrap) => void;
11
- minimumSizeFailed: boolean;
12
- checkCompatibleAccessibilityState: (props: Record<string, any>) => void;
13
- checkAccessibilityRole: (param: AccessibilityRole) => void;
14
- debugStyle: any;
15
- } | null;
@@ -1,152 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.useChecks = void 0;
27
- const internal_1 = require("@react-native-ama/internal");
28
- const React = __importStar(require("react"));
29
- const react_native_1 = require("react-native");
30
- const AMAProvider_1 = require("../components/AMAProvider");
31
- const useChecks = () => {
32
- const context = (0, AMAProvider_1.useAMAContext)();
33
- if (!(0, AMAProvider_1.isDevContextValue)(context)) {
34
- return null;
35
- }
36
- /**
37
- * Because the AMA Error view cannot be removed by default, this hacky solution
38
- * allows the dev to hide it if all the issues have been solved.
39
- */
40
- const fakeRandom = React.useRef('' + Date.now() + Math.random() * 42);
41
- const hasErrors = React.useRef(false);
42
- const failedTests = React.useRef([]);
43
- const shouldCheckLayout = React.useRef(true);
44
- const layoutCheckTimeout = React.useRef();
45
- const [minimumSizeFailed, setMinimumSizeFailed] = React.useState(false);
46
- const [debugStyle, setDebugStyle] = React.useState({});
47
- const { trackError, removeError } = context;
48
- const logResult = (name, result) => {
49
- const index = failedTests.current.indexOf(name);
50
- if (result === null) {
51
- if (index >= 0 && hasErrors.current) {
52
- failedTests.current.splice(index);
53
- hasErrors.current = false;
54
- react_native_1.InteractionManager.runAfterInteractions(() => {
55
- removeError(fakeRandom.current);
56
- setTimeout(() => {
57
- setDebugStyle({});
58
- }, 100);
59
- });
60
- }
61
- }
62
- const results = Array.isArray(result) ? result : [result];
63
- results.forEach(logParam => {
64
- if (logParam === null) {
65
- return;
66
- }
67
- const action = internal_1.getRuleAction === null || internal_1.getRuleAction === void 0 ? void 0 : (0, internal_1.getRuleAction)(logParam.rule);
68
- const hasFailed = action === 'MUST_NOT' || action === 'MUST';
69
- if (index < 0) {
70
- // @ts-ignore
71
- internal_1.logFailure === null || internal_1.logFailure === void 0 ? void 0 : (0, internal_1.logFailure)(Object.assign({ action }, logParam));
72
- }
73
- if (!hasFailed) {
74
- return;
75
- }
76
- else if (index >= 0) {
77
- return;
78
- }
79
- failedTests.current.push(name);
80
- react_native_1.InteractionManager.runAfterInteractions(() => {
81
- trackError(fakeRandom.current);
82
- setDebugStyle(internal_1.ERROR_STYLE);
83
- });
84
- hasErrors.current = true;
85
- });
86
- // @ts-ignore
87
- return hasErrors.current ? internal_1.ERROR_STYLE : {};
88
- };
89
- const noUndefinedProperty = (params) => logResult(`noUndefinedProperty ${params.property}`, (0, internal_1.noUndefinedProperty)(params));
90
- const contrastChecker = (params) => logResult('contrastChecker', (0, internal_1.contrastChecker)(params));
91
- const checkMinimumSize = (params) => {
92
- return logResult('checkMinimumSize', (0, internal_1.checkMinimumSize)(params));
93
- };
94
- const noUppercaseStringChecker = (params) => logResult('accessibilityLabelChecker', (0, internal_1.uppercaseStringChecker)(params));
95
- const uppercaseChecker = (params) => logResult('uppercaseChecker', (0, internal_1.uppercaseChecker)(params));
96
- const checkFocusTrap = (params) => {
97
- (0, internal_1.checkFocusTrap)(params).then(result => {
98
- logResult('checkFocusTrap', result);
99
- });
100
- };
101
- const checkAccessibilityRole = (param) => {
102
- logResult('checkAccessibilityRole', (0, internal_1.checkAccessibilityRole)(param));
103
- };
104
- const checkCompatibleAccessibilityState = (props) => {
105
- const amaStates = ['checked', 'selected'];
106
- const params = {
107
- accessibilityRole: props.accessibilityRole,
108
- accessibilityState: props === null || props === void 0 ? void 0 : props.accessibilityState,
109
- };
110
- amaStates.forEach(amaState => {
111
- if (amaState in props) {
112
- // @ts-ignore
113
- params[amaState] = props[amaState];
114
- }
115
- });
116
- logResult('checkCompatibleAccessibilityState', (0, internal_1.checkForAccessibilityState)(params));
117
- };
118
- const onLayout = (event) => {
119
- /**
120
- * When the check fails there are situation when adding a border makes the
121
- * component meet the minimum size requirement, and this causes a loop as the
122
- * state is update continuously between true and false.
123
- * To "avoid" that we wait at least 100ms before checking the size again, as
124
- * this gives the dev time to hot-reload the changes.
125
- */
126
- if (!shouldCheckLayout.current) {
127
- return;
128
- }
129
- shouldCheckLayout.current = false;
130
- // @ts-ignore
131
- clearTimeout(layoutCheckTimeout.current);
132
- layoutCheckTimeout.current = setTimeout(() => {
133
- shouldCheckLayout.current = true;
134
- }, 1000);
135
- const result = checkMinimumSize(event);
136
- setMinimumSizeFailed(Object.keys(result).length > 0);
137
- };
138
- return {
139
- logResult,
140
- noUndefinedProperty,
141
- contrastChecker,
142
- onLayout,
143
- noUppercaseStringChecker,
144
- uppercaseChecker,
145
- checkFocusTrap,
146
- minimumSizeFailed,
147
- checkCompatibleAccessibilityState,
148
- checkAccessibilityRole,
149
- debugStyle,
150
- };
151
- };
152
- exports.useChecks = useChecks;
@@ -1,4 +0,0 @@
1
- import * as React from 'react';
2
- export declare const useFocus: (refComponent?: React.RefObject<any>) => {
3
- setFocus: (component: null | number | React.Component<any, any> | React.ComponentClass<any>) => void;
4
- };
@@ -1,55 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.useFocus = void 0;
27
- const internal_1 = require("@react-native-ama/internal");
28
- const React = __importStar(require("react"));
29
- const react_native_1 = require("react-native");
30
- const useFocus = (refComponent) => {
31
- const setFocus = React.useCallback((component) => {
32
- // @ts-ignore
33
- const elementId = (0, react_native_1.findNodeHandle)(component);
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}`);
42
- }
43
- }, []);
44
- React.useEffect(() => {
45
- if (!refComponent) {
46
- return;
47
- }
48
- setFocus(refComponent.current);
49
- // eslint-disable-next-line react-hooks/exhaustive-deps
50
- }, [refComponent]);
51
- return {
52
- setFocus,
53
- };
54
- };
55
- exports.useFocus = useFocus;
@@ -1,3 +0,0 @@
1
- export declare const useTimedAction: () => {
2
- onTimeout: (callback: () => void, milliseconds: number) => Promise<null | ReturnType<typeof setTimeout>>;
3
- };