@testing-library/react-native 12.6.1 → 12.7.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 (99) hide show
  1. package/build/cleanup.d.ts +1 -2
  2. package/build/cleanup.js +1 -1
  3. package/build/cleanup.js.map +1 -1
  4. package/build/config.d.ts +1 -0
  5. package/build/config.js.map +1 -1
  6. package/build/fire-event.js +31 -0
  7. package/build/fire-event.js.map +1 -1
  8. package/build/helpers/accessibility.d.ts +23 -14
  9. package/build/helpers/accessibility.js +104 -78
  10. package/build/helpers/accessibility.js.map +1 -1
  11. package/build/helpers/format-default.js +1 -1
  12. package/build/helpers/format-default.js.map +1 -1
  13. package/build/helpers/host-component-names.d.ts +14 -4
  14. package/build/helpers/host-component-names.js +25 -4
  15. package/build/helpers/host-component-names.js.map +1 -1
  16. package/build/helpers/matchers/match-accessibility-state.js +16 -18
  17. package/build/helpers/matchers/match-accessibility-state.js.map +1 -1
  18. package/build/helpers/matchers/match-accessibility-value.js +1 -1
  19. package/build/helpers/matchers/match-accessibility-value.js.map +1 -1
  20. package/build/helpers/matchers/match-label-text.js +3 -3
  21. package/build/helpers/matchers/match-label-text.js.map +1 -1
  22. package/build/helpers/text-input.js +2 -1
  23. package/build/helpers/text-input.js.map +1 -1
  24. package/build/matchers/extend-expect.js +1 -2
  25. package/build/matchers/extend-expect.js.map +1 -1
  26. package/build/matchers/index.d.ts +1 -2
  27. package/build/matchers/index.js +1 -2
  28. package/build/matchers/index.js.map +1 -1
  29. package/build/matchers/to-be-busy.d.ts +1 -1
  30. package/build/matchers/to-be-busy.js +1 -1
  31. package/build/matchers/to-be-busy.js.map +1 -1
  32. package/build/matchers/to-be-checked.js +7 -6
  33. package/build/matchers/to-be-checked.js.map +1 -1
  34. package/build/matchers/to-be-disabled.d.ts +1 -1
  35. package/build/matchers/to-be-disabled.js +4 -15
  36. package/build/matchers/to-be-disabled.js.map +1 -1
  37. package/build/matchers/to-be-expanded.d.ts +5 -1
  38. package/build/matchers/to-be-expanded.js +12 -1
  39. package/build/matchers/to-be-expanded.js.map +1 -1
  40. package/build/matchers/to-be-partially-checked.js +2 -2
  41. package/build/matchers/to-be-partially-checked.js.map +1 -1
  42. package/build/matchers/to-be-selected.d.ts +1 -1
  43. package/build/matchers/to-be-selected.js +1 -1
  44. package/build/matchers/to-be-selected.js.map +1 -1
  45. package/build/matchers/to-have-accessibility-value.js +1 -1
  46. package/build/matchers/to-have-accessibility-value.js.map +1 -1
  47. package/build/matchers/to-have-accessible-name.js +1 -1
  48. package/build/matchers/to-have-accessible-name.js.map +1 -1
  49. package/build/matchers/utils.js +1 -1
  50. package/build/matchers/utils.js.map +1 -1
  51. package/build/native-state.d.ts +12 -0
  52. package/build/native-state.js +17 -0
  53. package/build/native-state.js.map +1 -0
  54. package/build/queries/hint-text.js +2 -2
  55. package/build/queries/hint-text.js.map +1 -1
  56. package/build/queries/role.js +4 -3
  57. package/build/queries/role.js.map +1 -1
  58. package/build/queries/unsafe-props.js +1 -1
  59. package/build/queries/unsafe-props.js.map +1 -1
  60. package/build/queries/unsafe-type.js +1 -1
  61. package/build/queries/unsafe-type.js.map +1 -1
  62. package/build/render.js.map +1 -1
  63. package/build/types.d.ts +14 -0
  64. package/build/types.js.map +1 -1
  65. package/build/user-event/event-builder/index.d.ts +2 -2
  66. package/build/user-event/event-builder/scroll-view.d.ts +4 -16
  67. package/build/user-event/event-builder/scroll-view.js +0 -4
  68. package/build/user-event/event-builder/scroll-view.js.map +1 -1
  69. package/build/user-event/event-builder/text-input.d.ts +2 -2
  70. package/build/user-event/event-builder/text-input.js.map +1 -1
  71. package/build/user-event/paste.js +2 -0
  72. package/build/user-event/paste.js.map +1 -1
  73. package/build/user-event/press/press.js +0 -1
  74. package/build/user-event/press/press.js.map +1 -1
  75. package/build/user-event/scroll/scroll-to.d.ts +3 -8
  76. package/build/user-event/scroll/scroll-to.js +9 -6
  77. package/build/user-event/scroll/scroll-to.js.map +1 -1
  78. package/build/user-event/scroll/utils.d.ts +2 -2
  79. package/build/user-event/scroll/utils.js.map +1 -1
  80. package/build/user-event/type/type.js +2 -0
  81. package/build/user-event/type/type.js.map +1 -1
  82. package/build/user-event/utils/content-size.d.ts +2 -5
  83. package/build/user-event/utils/content-size.js +0 -1
  84. package/build/user-event/utils/content-size.js.map +1 -1
  85. package/build/user-event/utils/index.d.ts +0 -1
  86. package/build/user-event/utils/index.js +0 -11
  87. package/build/user-event/utils/index.js.map +1 -1
  88. package/build/wait-for-element-to-be-removed.js +1 -1
  89. package/build/wait-for-element-to-be-removed.js.map +1 -1
  90. package/package.json +3 -4
  91. package/build/matchers/to-be-collapsed.d.ts +0 -5
  92. package/build/matchers/to-be-collapsed.js +0 -20
  93. package/build/matchers/to-be-collapsed.js.map +0 -1
  94. package/build/user-event/scroll/state.d.ts +0 -4
  95. package/build/user-event/scroll/state.js +0 -18
  96. package/build/user-event/scroll/state.js.map +0 -1
  97. package/build/user-event/utils/warn-about-real-timers.d.ts +0 -1
  98. package/build/user-event/utils/warn-about-real-timers.js +0 -23
  99. package/build/user-event/utils/warn-about-real-timers.js.map +0 -1
@@ -1,5 +1,4 @@
1
- import * as React from 'react';
2
- type CleanUpFunction = (nextElement?: React.ReactElement<any>) => void;
1
+ type CleanUpFunction = () => void;
3
2
  export default function cleanup(): void;
4
3
  export declare function addToCleanupQueue(fn: CleanUpFunction): void;
5
4
  export {};
package/build/cleanup.js CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.addToCleanupQueue = addToCleanupQueue;
7
7
  exports.default = cleanup;
8
8
  var _screen = require("./screen");
9
- let cleanupQueue = new Set();
9
+ const cleanupQueue = new Set();
10
10
  function cleanup() {
11
11
  (0, _screen.clearRenderResult)();
12
12
  cleanupQueue.forEach(fn => fn());
@@ -1 +1 @@
1
- {"version":3,"file":"cleanup.js","names":["_screen","require","cleanupQueue","Set","cleanup","clearRenderResult","forEach","fn","clear","addToCleanupQueue","add"],"sources":["../src/cleanup.ts"],"sourcesContent":["import * as React from 'react';\nimport { clearRenderResult } from './screen';\n\ntype CleanUpFunction = (nextElement?: React.ReactElement<any>) => void;\nlet cleanupQueue = new Set<CleanUpFunction>();\n\nexport default function cleanup() {\n clearRenderResult();\n cleanupQueue.forEach((fn) => fn());\n cleanupQueue.clear();\n}\n\nexport function addToCleanupQueue(fn: CleanUpFunction) {\n cleanupQueue.add(fn);\n}\n"],"mappings":";;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAGA,IAAIC,YAAY,GAAG,IAAIC,GAAG,CAAkB,CAAC;AAE9B,SAASC,OAAOA,CAAA,EAAG;EAChC,IAAAC,yBAAiB,EAAC,CAAC;EACnBH,YAAY,CAACI,OAAO,CAAEC,EAAE,IAAKA,EAAE,CAAC,CAAC,CAAC;EAClCL,YAAY,CAACM,KAAK,CAAC,CAAC;AACtB;AAEO,SAASC,iBAAiBA,CAACF,EAAmB,EAAE;EACrDL,YAAY,CAACQ,GAAG,CAACH,EAAE,CAAC;AACtB","ignoreList":[]}
1
+ {"version":3,"file":"cleanup.js","names":["_screen","require","cleanupQueue","Set","cleanup","clearRenderResult","forEach","fn","clear","addToCleanupQueue","add"],"sources":["../src/cleanup.ts"],"sourcesContent":["import { clearRenderResult } from './screen';\n\ntype CleanUpFunction = () => void;\n\nconst cleanupQueue = new Set<CleanUpFunction>();\n\nexport default function cleanup() {\n clearRenderResult();\n\n cleanupQueue.forEach((fn) => fn());\n cleanupQueue.clear();\n}\n\nexport function addToCleanupQueue(fn: CleanUpFunction) {\n cleanupQueue.add(fn);\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAIA,MAAMC,YAAY,GAAG,IAAIC,GAAG,CAAkB,CAAC;AAEhC,SAASC,OAAOA,CAAA,EAAG;EAChC,IAAAC,yBAAiB,EAAC,CAAC;EAEnBH,YAAY,CAACI,OAAO,CAAEC,EAAE,IAAKA,EAAE,CAAC,CAAC,CAAC;EAClCL,YAAY,CAACM,KAAK,CAAC,CAAC;AACtB;AAEO,SAASC,iBAAiBA,CAACF,EAAmB,EAAE;EACrDL,YAAY,CAACQ,GAAG,CAACH,EAAE,CAAC;AACtB","ignoreList":[]}
package/build/config.d.ts CHANGED
@@ -17,6 +17,7 @@ export type ConfigAliasOptions = {
17
17
  export type HostComponentNames = {
18
18
  text: string;
19
19
  textInput: string;
20
+ image: string;
20
21
  switch: string;
21
22
  scrollView: string;
22
23
  modal: string;
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":["defaultConfig","asyncUtilTimeout","defaultIncludeHiddenElements","config","configure","options","defaultHidden","restOptions","configureInternal","option","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["import { DebugOptions } from './helpers/debug-deep';\n\n/**\n * Global configuration options for React Native Testing Library.\n */\n\nexport type Config = {\n /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */\n asyncUtilTimeout: number;\n\n /** Default value for `includeHiddenElements` query option. */\n defaultIncludeHiddenElements: boolean;\n\n /** Default options for `debug` helper. */\n defaultDebugOptions?: Partial<DebugOptions>;\n};\n\nexport type ConfigAliasOptions = {\n /** RTL-compatibility alias to `defaultIncludeHiddenElements` */\n defaultHidden: boolean;\n};\n\nexport type HostComponentNames = {\n text: string;\n textInput: string;\n switch: string;\n scrollView: string;\n modal: string;\n};\n\nexport type InternalConfig = Config & {\n /** Names for key React Native host components. */\n hostComponentNames?: HostComponentNames;\n};\n\nconst defaultConfig: InternalConfig = {\n asyncUtilTimeout: 1000,\n defaultIncludeHiddenElements: false,\n};\n\nlet config = { ...defaultConfig };\n\n/**\n * Configure global options for React Native Testing Library.\n */\nexport function configure(options: Partial<Config & ConfigAliasOptions>) {\n const { defaultHidden, ...restOptions } = options;\n\n const defaultIncludeHiddenElements =\n restOptions.defaultIncludeHiddenElements ??\n defaultHidden ??\n config.defaultIncludeHiddenElements;\n\n config = {\n ...config,\n ...restOptions,\n defaultIncludeHiddenElements,\n };\n}\n\nexport function configureInternal(option: Partial<InternalConfig>) {\n config = {\n ...config,\n ...option,\n };\n}\n\nexport function resetToDefaults() {\n config = { ...defaultConfig };\n}\n\nexport function getConfig() {\n return config;\n}\n"],"mappings":";;;;;;;;;AAEA;AACA;AACA;;AA+BA,MAAMA,aAA6B,GAAG;EACpCC,gBAAgB,EAAE,IAAI;EACtBC,4BAA4B,EAAE;AAChC,CAAC;AAED,IAAIC,MAAM,GAAG;EAAE,GAAGH;AAAc,CAAC;;AAEjC;AACA;AACA;AACO,SAASI,SAASA,CAACC,OAA6C,EAAE;EACvE,MAAM;IAAEC,aAAa;IAAE,GAAGC;EAAY,CAAC,GAAGF,OAAO;EAEjD,MAAMH,4BAA4B,GAChCK,WAAW,CAACL,4BAA4B,IACxCI,aAAa,IACbH,MAAM,CAACD,4BAA4B;EAErCC,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGI,WAAW;IACdL;EACF,CAAC;AACH;AAEO,SAASM,iBAAiBA,CAACC,MAA+B,EAAE;EACjEN,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGM;EACL,CAAC;AACH;AAEO,SAASC,eAAeA,CAAA,EAAG;EAChCP,MAAM,GAAG;IAAE,GAAGH;EAAc,CAAC;AAC/B;AAEO,SAASW,SAASA,CAAA,EAAG;EAC1B,OAAOR,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"file":"config.js","names":["defaultConfig","asyncUtilTimeout","defaultIncludeHiddenElements","config","configure","options","defaultHidden","restOptions","configureInternal","option","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["import { DebugOptions } from './helpers/debug-deep';\n\n/**\n * Global configuration options for React Native Testing Library.\n */\n\nexport type Config = {\n /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */\n asyncUtilTimeout: number;\n\n /** Default value for `includeHiddenElements` query option. */\n defaultIncludeHiddenElements: boolean;\n\n /** Default options for `debug` helper. */\n defaultDebugOptions?: Partial<DebugOptions>;\n};\n\nexport type ConfigAliasOptions = {\n /** RTL-compatibility alias to `defaultIncludeHiddenElements` */\n defaultHidden: boolean;\n};\n\nexport type HostComponentNames = {\n text: string;\n textInput: string;\n image: string;\n switch: string;\n scrollView: string;\n modal: string;\n};\n\nexport type InternalConfig = Config & {\n /** Names for key React Native host components. */\n hostComponentNames?: HostComponentNames;\n};\n\nconst defaultConfig: InternalConfig = {\n asyncUtilTimeout: 1000,\n defaultIncludeHiddenElements: false,\n};\n\nlet config = { ...defaultConfig };\n\n/**\n * Configure global options for React Native Testing Library.\n */\nexport function configure(options: Partial<Config & ConfigAliasOptions>) {\n const { defaultHidden, ...restOptions } = options;\n\n const defaultIncludeHiddenElements =\n restOptions.defaultIncludeHiddenElements ??\n defaultHidden ??\n config.defaultIncludeHiddenElements;\n\n config = {\n ...config,\n ...restOptions,\n defaultIncludeHiddenElements,\n };\n}\n\nexport function configureInternal(option: Partial<InternalConfig>) {\n config = {\n ...config,\n ...option,\n };\n}\n\nexport function resetToDefaults() {\n config = { ...defaultConfig };\n}\n\nexport function getConfig() {\n return config;\n}\n"],"mappings":";;;;;;;;;AAEA;AACA;AACA;;AAgCA,MAAMA,aAA6B,GAAG;EACpCC,gBAAgB,EAAE,IAAI;EACtBC,4BAA4B,EAAE;AAChC,CAAC;AAED,IAAIC,MAAM,GAAG;EAAE,GAAGH;AAAc,CAAC;;AAEjC;AACA;AACA;AACO,SAASI,SAASA,CAACC,OAA6C,EAAE;EACvE,MAAM;IAAEC,aAAa;IAAE,GAAGC;EAAY,CAAC,GAAGF,OAAO;EAEjD,MAAMH,4BAA4B,GAChCK,WAAW,CAACL,4BAA4B,IACxCI,aAAa,IACbH,MAAM,CAACD,4BAA4B;EAErCC,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGI,WAAW;IACdL;EACF,CAAC;AACH;AAEO,SAASM,iBAAiBA,CAACC,MAA+B,EAAE;EACjEN,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGM;EACL,CAAC;AACH;AAEO,SAASC,eAAeA,CAAA,EAAG;EAChCP,MAAM,GAAG;IAAE,GAAGH;EAAc,CAAC;AAC/B;AAEO,SAASW,SAASA,CAAA,EAAG;EAC1B,OAAOR,MAAM;AACf","ignoreList":[]}
@@ -11,6 +11,7 @@ var _componentTree = require("./helpers/component-tree");
11
11
  var _hostComponentNames = require("./helpers/host-component-names");
12
12
  var _pointerEvents = require("./helpers/pointer-events");
13
13
  var _textInput = require("./helpers/text-input");
14
+ var _nativeState = require("./native-state");
14
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
16
  function isTouchResponder(element) {
16
17
  if (!(0, _componentTree.isHostElement)(element)) {
@@ -76,6 +77,7 @@ function getEventHandlerName(eventName) {
76
77
  // String union type of keys of T that start with on, stripped of 'on'
77
78
 
78
79
  function fireEvent(element, eventName, ...data) {
80
+ setNativeStateIfNeeded(element, eventName, data[0]);
79
81
  const handler = findEventHandler(element, eventName);
80
82
  if (!handler) {
81
83
  return;
@@ -90,4 +92,33 @@ fireEvent.press = (element, ...data) => fireEvent(element, 'press', ...data);
90
92
  fireEvent.changeText = (element, ...data) => fireEvent(element, 'changeText', ...data);
91
93
  fireEvent.scroll = (element, ...data) => fireEvent(element, 'scroll', ...data);
92
94
  var _default = exports.default = fireEvent;
95
+ const scrollEventNames = new Set(['scroll', 'scrollBeginDrag', 'scrollEndDrag', 'momentumScrollBegin', 'momentumScrollEnd']);
96
+ function setNativeStateIfNeeded(element, eventName, value) {
97
+ if (eventName === 'changeText' && typeof value === 'string' && (0, _hostComponentNames.isHostTextInput)(element) && (0, _textInput.isTextInputEditable)(element)) {
98
+ _nativeState.nativeState.valueForElement.set(element, value);
99
+ }
100
+ if (scrollEventNames.has(eventName) && (0, _hostComponentNames.isHostScrollView)(element)) {
101
+ const contentOffset = tryGetContentOffset(value);
102
+ if (contentOffset) {
103
+ _nativeState.nativeState.contentOffsetForElement.set(element, contentOffset);
104
+ }
105
+ }
106
+ }
107
+ function tryGetContentOffset(value) {
108
+ try {
109
+ // @ts-expect-error: try to extract contentOffset from the event value
110
+ const contentOffset = value?.nativeEvent?.contentOffset;
111
+ const x = contentOffset?.x;
112
+ const y = contentOffset?.y;
113
+ if (typeof x === 'number' || typeof y === 'number') {
114
+ return {
115
+ x: Number.isFinite(x) ? x : 0,
116
+ y: Number.isFinite(y) ? y : 0
117
+ };
118
+ }
119
+ } catch {
120
+ // Do nothing
121
+ }
122
+ return null;
123
+ }
93
124
  //# sourceMappingURL=fire-event.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fire-event.js","names":["_act","_interopRequireDefault","require","_componentTree","_hostComponentNames","_pointerEvents","_textInput","e","__esModule","default","isTouchResponder","element","isHostElement","Boolean","props","onStartShouldSetResponder","isHostTextInput","eventsAffectedByPointerEventsProp","Set","textInputEventsIgnoringEditableProp","isEventEnabled","eventName","nearestTouchResponder","isTextInputEditable","has","isPointerEventEnabled","touchStart","touchMove","onMoveShouldSetResponder","undefined","findEventHandler","touchResponder","handler","getEventHandler","parent","eventHandlerName","getEventHandlerName","charAt","toUpperCase","slice","fireEvent","data","returnValue","act","press","changeText","scroll","_default","exports"],"sources":["../src/fire-event.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport {\n ViewProps,\n TextProps,\n TextInputProps,\n PressableProps,\n ScrollViewProps,\n} from 'react-native';\nimport act from './act';\nimport { isHostElement } from './helpers/component-tree';\nimport { isHostTextInput } from './helpers/host-component-names';\nimport { isPointerEventEnabled } from './helpers/pointer-events';\nimport { isTextInputEditable } from './helpers/text-input';\nimport { StringWithAutocomplete } from './types';\n\ntype EventHandler = (...args: unknown[]) => unknown;\n\nexport function isTouchResponder(element: ReactTestInstance) {\n if (!isHostElement(element)) {\n return false;\n }\n\n return Boolean(element.props.onStartShouldSetResponder) || isHostTextInput(element);\n}\n\n/**\n * List of events affected by `pointerEvents` prop.\n *\n * Note: `fireEvent` is accepting both `press` and `onPress` for event names,\n * so we need cover both forms.\n */\nconst eventsAffectedByPointerEventsProp = new Set(['press', 'onPress']);\n\n/**\n * List of `TextInput` events not affected by `editable` prop.\n *\n * Note: `fireEvent` is accepting both `press` and `onPress` for event names,\n * so we need cover both forms.\n */\nconst textInputEventsIgnoringEditableProp = new Set([\n 'contentSizeChange',\n 'onContentSizeChange',\n 'layout',\n 'onLayout',\n 'scroll',\n 'onScroll',\n]);\n\nexport function isEventEnabled(\n element: ReactTestInstance,\n eventName: string,\n nearestTouchResponder?: ReactTestInstance,\n) {\n if (isHostTextInput(nearestTouchResponder)) {\n return (\n isTextInputEditable(nearestTouchResponder) ||\n textInputEventsIgnoringEditableProp.has(eventName)\n );\n }\n\n if (eventsAffectedByPointerEventsProp.has(eventName) && !isPointerEventEnabled(element)) {\n return false;\n }\n\n const touchStart = nearestTouchResponder?.props.onStartShouldSetResponder?.();\n const touchMove = nearestTouchResponder?.props.onMoveShouldSetResponder?.();\n if (touchStart || touchMove) {\n return true;\n }\n\n return touchStart === undefined && touchMove === undefined;\n}\n\nfunction findEventHandler(\n element: ReactTestInstance,\n eventName: string,\n nearestTouchResponder?: ReactTestInstance,\n): EventHandler | null {\n const touchResponder = isTouchResponder(element) ? element : nearestTouchResponder;\n\n const handler = getEventHandler(element, eventName);\n if (handler && isEventEnabled(element, eventName, touchResponder)) return handler;\n\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (element.parent === null || element.parent.parent === null) {\n return null;\n }\n\n return findEventHandler(element.parent, eventName, touchResponder);\n}\n\nfunction getEventHandler(element: ReactTestInstance, eventName: string) {\n const eventHandlerName = getEventHandlerName(eventName);\n if (typeof element.props[eventHandlerName] === 'function') {\n return element.props[eventHandlerName];\n }\n\n if (typeof element.props[eventName] === 'function') {\n return element.props[eventName];\n }\n\n return undefined;\n}\n\nfunction getEventHandlerName(eventName: string) {\n return `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;\n}\n\n// String union type of keys of T that start with on, stripped of 'on'\ntype EventNameExtractor<T> = keyof {\n [K in keyof T as K extends `on${infer Rest}` ? Uncapitalize<Rest> : never]: T[K];\n};\n\ntype EventName = StringWithAutocomplete<\n | EventNameExtractor<ViewProps>\n | EventNameExtractor<TextProps>\n | EventNameExtractor<TextInputProps>\n | EventNameExtractor<PressableProps>\n | EventNameExtractor<ScrollViewProps>\n>;\n\nfunction fireEvent(element: ReactTestInstance, eventName: EventName, ...data: unknown[]) {\n const handler = findEventHandler(element, eventName);\n if (!handler) {\n return;\n }\n\n let returnValue;\n void act(() => {\n returnValue = handler(...data);\n });\n\n return returnValue;\n}\n\nfireEvent.press = (element: ReactTestInstance, ...data: unknown[]) =>\n fireEvent(element, 'press', ...data);\n\nfireEvent.changeText = (element: ReactTestInstance, ...data: unknown[]) =>\n fireEvent(element, 'changeText', ...data);\n\nfireEvent.scroll = (element: ReactTestInstance, ...data: unknown[]) =>\n fireEvent(element, 'scroll', ...data);\n\nexport default fireEvent;\n"],"mappings":";;;;;;;;AAQA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAA2D,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAKpD,SAASG,gBAAgBA,CAACC,OAA0B,EAAE;EAC3D,IAAI,CAAC,IAAAC,4BAAa,EAACD,OAAO,CAAC,EAAE;IAC3B,OAAO,KAAK;EACd;EAEA,OAAOE,OAAO,CAACF,OAAO,CAACG,KAAK,CAACC,yBAAyB,CAAC,IAAI,IAAAC,mCAAe,EAACL,OAAO,CAAC;AACrF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMM,iCAAiC,GAAG,IAAIC,GAAG,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;;AAEvE;AACA;AACA;AACA;AACA;AACA;AACA,MA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AAE,GAAG8B,IAAI,CAAC;AAE3CD,SAAS,CAACM,MAAM,GAAG,CAACnC,OAA0B,EAAE,GAAG8B,IAAe,KAChED,SAAS,CAAC7B,OAAO,EAAE,QAAQ,EAAE,GAAG8B,IAAI,CAAC;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAvC,OAAA,GAEzB+B,SAAS","ignoreList":[]}
1
+ {"version":3,"file":"fire-event.js","names":["_act","_interopRequireDefault","require","_componentTree","_hostComponentNames","_pointerEvents","_textInput","_nativeState","e","__esModule","default","isTouchResponder","element","isHostElement","Boolean","props","onStartShouldSetResponder","isHostTextInput","eventsAffectedByPointerEventsProp","Set","textInputEventsIgnoringEditableProp","isEventEnabled","eventName","nearestTouchResponder","isTextInputEditable","has","isPointerEventEnabled","touchStart","touchMove","onMoveShouldSetResponder","undefined","findEventHandler","touchResponder","handler","getEventHandler","parent","eventHandlerName","getEventHandlerName","charAt","toUpperCase","slice","fireEvent","data","setNativeStateIfNeeded","returnValue","act","press","changeText","scroll","_default","exports","scrollEventNames","value","nativeState","valueForElement","set","isHostScrollView","contentOffset","tryGetContentOffset","contentOffsetForElement","nativeEvent","x","y","Number","isFinite"],"sources":["../src/fire-event.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport {\n ViewProps,\n TextProps,\n TextInputProps,\n PressableProps,\n ScrollViewProps,\n} from 'react-native';\nimport act from './act';\nimport { isHostElement } from './helpers/component-tree';\nimport { isHostScrollView, isHostTextInput } from './helpers/host-component-names';\nimport { isPointerEventEnabled } from './helpers/pointer-events';\nimport { isTextInputEditable } from './helpers/text-input';\nimport { Point, StringWithAutocomplete } from './types';\nimport { nativeState } from './native-state';\n\ntype EventHandler = (...args: unknown[]) => unknown;\n\nexport function isTouchResponder(element: ReactTestInstance) {\n if (!isHostElement(element)) {\n return false;\n }\n\n return Boolean(element.props.onStartShouldSetResponder) || isHostTextInput(element);\n}\n\n/**\n * List of events affected by `pointerEvents` prop.\n *\n * Note: `fireEvent` is accepting both `press` and `onPress` for event names,\n * so we need cover both forms.\n */\nconst eventsAffectedByPointerEventsProp = new Set(['press', 'onPress']);\n\n/**\n * List of `TextInput` events not affected by `editable` prop.\n *\n * Note: `fireEvent` is accepting both `press` and `onPress` for event names,\n * so we need cover both forms.\n */\nconst textInputEventsIgnoringEditableProp = new Set([\n 'contentSizeChange',\n 'onContentSizeChange',\n 'layout',\n 'onLayout',\n 'scroll',\n 'onScroll',\n]);\n\nexport function isEventEnabled(\n element: ReactTestInstance,\n eventName: string,\n nearestTouchResponder?: ReactTestInstance,\n) {\n if (isHostTextInput(nearestTouchResponder)) {\n return (\n isTextInputEditable(nearestTouchResponder) ||\n textInputEventsIgnoringEditableProp.has(eventName)\n );\n }\n\n if (eventsAffectedByPointerEventsProp.has(eventName) && !isPointerEventEnabled(element)) {\n return false;\n }\n\n const touchStart = nearestTouchResponder?.props.onStartShouldSetResponder?.();\n const touchMove = nearestTouchResponder?.props.onMoveShouldSetResponder?.();\n if (touchStart || touchMove) {\n return true;\n }\n\n return touchStart === undefined && touchMove === undefined;\n}\n\nfunction findEventHandler(\n element: ReactTestInstance,\n eventName: string,\n nearestTouchResponder?: ReactTestInstance,\n): EventHandler | null {\n const touchResponder = isTouchResponder(element) ? element : nearestTouchResponder;\n\n const handler = getEventHandler(element, eventName);\n if (handler && isEventEnabled(element, eventName, touchResponder)) return handler;\n\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (element.parent === null || element.parent.parent === null) {\n return null;\n }\n\n return findEventHandler(element.parent, eventName, touchResponder);\n}\n\nfunction getEventHandler(element: ReactTestInstance, eventName: string) {\n const eventHandlerName = getEventHandlerName(eventName);\n if (typeof element.props[eventHandlerName] === 'function') {\n return element.props[eventHandlerName];\n }\n\n if (typeof element.props[eventName] === 'function') {\n return element.props[eventName];\n }\n\n return undefined;\n}\n\nfunction getEventHandlerName(eventName: string) {\n return `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;\n}\n\n// String union type of keys of T that start with on, stripped of 'on'\ntype EventNameExtractor<T> = keyof {\n [K in keyof T as K extends `on${infer Rest}` ? Uncapitalize<Rest> : never]: T[K];\n};\n\ntype EventName = StringWithAutocomplete<\n | EventNameExtractor<ViewProps>\n | EventNameExtractor<TextProps>\n | EventNameExtractor<TextInputProps>\n | EventNameExtractor<PressableProps>\n | EventNameExtractor<ScrollViewProps>\n>;\n\nfunction fireEvent(element: ReactTestInstance, eventName: EventName, ...data: unknown[]) {\n setNativeStateIfNeeded(element, eventName, data[0]);\n\n const handler = findEventHandler(element, eventName);\n if (!handler) {\n return;\n }\n\n let returnValue;\n void act(() => {\n returnValue = handler(...data);\n });\n\n return returnValue;\n}\n\nfireEvent.press = (element: ReactTestInstance, ...data: unknown[]) =>\n fireEvent(element, 'press', ...data);\n\nfireEvent.changeText = (element: ReactTestInstance, ...data: unknown[]) =>\n fireEvent(element, 'changeText', ...data);\n\nfireEvent.scroll = (element: ReactTestInstance, ...data: unknown[]) =>\n fireEvent(element, 'scroll', ...data);\n\nexport default fireEvent;\n\nconst scrollEventNames = new Set([\n 'scroll',\n 'scrollBeginDrag',\n 'scrollEndDrag',\n 'momentumScrollBegin',\n 'momentumScrollEnd',\n]);\n\nfunction setNativeStateIfNeeded(element: ReactTestInstance, eventName: string, value: unknown) {\n if (\n eventName === 'changeText' &&\n typeof value === 'string' &&\n isHostTextInput(element) &&\n isTextInputEditable(element)\n ) {\n nativeState.valueForElement.set(element, value);\n }\n\n if (scrollEventNames.has(eventName) && isHostScrollView(element)) {\n const contentOffset = tryGetContentOffset(value);\n if (contentOffset) {\n nativeState.contentOffsetForElement.set(element, contentOffset);\n }\n }\n}\n\nfunction tryGetContentOffset(value: unknown): Point | null {\n try {\n // @ts-expect-error: try to extract contentOffset from the event value\n const contentOffset = value?.nativeEvent?.contentOffset;\n const x = contentOffset?.x;\n const y = contentOffset?.y;\n if (typeof x === 'number' || typeof y === 'number') {\n return {\n x: Number.isFinite(x) ? x : 0,\n y: Number.isFinite(y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OAA0B,EAAEU,SAAiB,EAAE8B,KAAc,EAAE;EAC7F,IACE9B,SAAS,KAAK,YAAY,IAC1B,OAAO8B,KAAK,KAAK,QAAQ,IACzB,IAAAnC,mCAAe,EAACL,OAAO,CAAC,IACxB,IAAAY,8BAAmB,EAACZ,OAAO,CAAC,EAC5B;IACAyC,wBAAW,CAACC,eAAe,CAACC,GAAG,CAAC3C,OAAO,EAAEwC,KAAK,CAAC;EACjD;EAEA,IAAID,gBAAgB,CAAC1B,GAAG,CAACH,SAAS,CAAC,IAAI,IAAAkC,oCAAgB,EAAC5C,OAAO,CAAC,EAAE;IAChE,MAAM6C,aAAa,GAAGC,mBAAmB,CAACN,KAAK,CAAC;IAChD,IAAIK,aAAa,EAAE;MACjBJ,wBAAW,CAACM,uBAAuB,CAACJ,GAAG,CAAC3C,OAAO,EAAE6C,aAAa,CAAC;IACjE;EACF;AACF;AAEA,SAASC,mBAAmBA,CAACN,KAAc,EAAgB;EACzD,IAAI;IACF;IACA,MAAMK,aAAa,GAAGL,KAAK,EAAEQ,WAAW,EAAEH,aAAa;IACvD,MAAMI,CAAC,GAAGJ,aAAa,EAAEI,CAAC;IAC1B,MAAMC,CAAC,GAAGL,aAAa,EAAEK,CAAC;IAC1B,IAAI,OAAOD,CAAC,KAAK,QAAQ,IAAI,OAAOC,CAAC,KAAK,QAAQ,EAAE;MAClD,OAAO;QACLD,CAAC,EAAEE,MAAM,CAACC,QAAQ,CAACH,CAAC,CAAC,GAAGA,CAAC,GAAG,CAAC;QAC7BC,CAAC,EAAEC,MAAM,CAACC,QAAQ,CAACF,CAAC,CAAC,GAAGA,CAAC,GAAG;MAC9B,CAAC;IACH;EACF,CAAC,CAAC,MAAM;IACN;EAAA;EAGF,OAAO,IAAI;AACb","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { AccessibilityState, AccessibilityValue } from 'react-native';
1
+ import { AccessibilityRole, AccessibilityState, AccessibilityValue, Role } from 'react-native';
2
2
  import { ReactTestInstance } from 'react-test-renderer';
3
3
  type IsInaccessibleOptions = {
4
4
  cache?: WeakMap<ReactTestInstance, boolean>;
@@ -6,7 +6,7 @@ type IsInaccessibleOptions = {
6
6
  export declare const accessibilityStateKeys: (keyof AccessibilityState)[];
7
7
  export declare const accessibilityValueKeys: (keyof AccessibilityValue)[];
8
8
  export declare function isHiddenFromAccessibility(element: ReactTestInstance | null, { cache }?: IsInaccessibleOptions): boolean;
9
- /** RTL-compatitibility alias for `isHiddenFromAccessibility` */
9
+ /** RTL-compatibility alias for `isHiddenFromAccessibility` */
10
10
  export declare const isInaccessible: typeof isHiddenFromAccessibility;
11
11
  export declare function isAccessibilityElement(element: ReactTestInstance | null): boolean;
12
12
  /**
@@ -22,16 +22,25 @@ export declare function isAccessibilityElement(element: ReactTestInstance | null
22
22
  * @param element
23
23
  * @returns
24
24
  */
25
- export declare function getAccessibilityRole(element: ReactTestInstance): any;
26
- export declare function getAccessibilityViewIsModal(element: ReactTestInstance): any;
27
- export declare function getAccessibilityLabel(element: ReactTestInstance): string | undefined;
28
- export declare function getAccessibilityLabelledBy(element: ReactTestInstance): string | undefined;
29
- export declare function getAccessibilityState(element: ReactTestInstance): AccessibilityState | undefined;
30
- export declare function getAccessibilityCheckedState(element: ReactTestInstance): AccessibilityState['checked'];
31
- export declare function getAccessibilityValue(element: ReactTestInstance): AccessibilityValue | undefined;
32
- export declare function isElementBusy(element: ReactTestInstance): NonNullable<AccessibilityState['busy']>;
33
- export declare function isElementCollapsed(element: ReactTestInstance): NonNullable<AccessibilityState['expanded']>;
34
- export declare function isElementExpanded(element: ReactTestInstance): NonNullable<AccessibilityState['expanded']>;
35
- export declare function isElementSelected(element: ReactTestInstance): NonNullable<AccessibilityState['selected']>;
36
- export declare function getAccessibleName(element: ReactTestInstance): string | undefined;
25
+ export declare function getRole(element: ReactTestInstance): Role | AccessibilityRole;
26
+ /**
27
+ * There are some duplications between (ARIA) `Role` and `AccessibilityRole` types.
28
+ * Resolve them by using ARIA `Role` type where possible.
29
+ *
30
+ * @param role Role to normalize
31
+ * @returns Normalized role
32
+ */
33
+ export declare function normalizeRole(role: string): Role | AccessibilityRole;
34
+ export declare function computeAriaModal(element: ReactTestInstance): boolean | undefined;
35
+ export declare function computeAriaLabel(element: ReactTestInstance): string | undefined;
36
+ export declare function computeAriaLabelledBy(element: ReactTestInstance): string | undefined;
37
+ export declare function computeAriaBusy({ props }: ReactTestInstance): boolean;
38
+ export declare function computeAriaChecked(element: ReactTestInstance): AccessibilityState['checked'];
39
+ export declare function computeAriaDisabled(element: ReactTestInstance): boolean;
40
+ export declare function computeAriaExpanded({ props }: ReactTestInstance): boolean | undefined;
41
+ export declare function computeAriaSelected({ props }: ReactTestInstance): boolean;
42
+ export declare function computeAriaValue(element: ReactTestInstance): AccessibilityValue;
43
+ export declare function computeAccessibleName(element: ReactTestInstance): string | undefined;
44
+ type RoleSupportMap = Partial<Record<Role | AccessibilityRole, true>>;
45
+ export declare const rolesSupportingCheckedState: RoleSupportMap;
37
46
  export {};
@@ -4,25 +4,27 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.accessibilityValueKeys = exports.accessibilityStateKeys = void 0;
7
- exports.getAccessibilityCheckedState = getAccessibilityCheckedState;
8
- exports.getAccessibilityLabel = getAccessibilityLabel;
9
- exports.getAccessibilityLabelledBy = getAccessibilityLabelledBy;
10
- exports.getAccessibilityRole = getAccessibilityRole;
11
- exports.getAccessibilityState = getAccessibilityState;
12
- exports.getAccessibilityValue = getAccessibilityValue;
13
- exports.getAccessibilityViewIsModal = getAccessibilityViewIsModal;
14
- exports.getAccessibleName = getAccessibleName;
7
+ exports.computeAccessibleName = computeAccessibleName;
8
+ exports.computeAriaBusy = computeAriaBusy;
9
+ exports.computeAriaChecked = computeAriaChecked;
10
+ exports.computeAriaDisabled = computeAriaDisabled;
11
+ exports.computeAriaExpanded = computeAriaExpanded;
12
+ exports.computeAriaLabel = computeAriaLabel;
13
+ exports.computeAriaLabelledBy = computeAriaLabelledBy;
14
+ exports.computeAriaModal = computeAriaModal;
15
+ exports.computeAriaSelected = computeAriaSelected;
16
+ exports.computeAriaValue = computeAriaValue;
17
+ exports.getRole = getRole;
15
18
  exports.isAccessibilityElement = isAccessibilityElement;
16
- exports.isElementBusy = isElementBusy;
17
- exports.isElementCollapsed = isElementCollapsed;
18
- exports.isElementExpanded = isElementExpanded;
19
- exports.isElementSelected = isElementSelected;
20
19
  exports.isHiddenFromAccessibility = isHiddenFromAccessibility;
21
20
  exports.isInaccessible = void 0;
21
+ exports.normalizeRole = normalizeRole;
22
+ exports.rolesSupportingCheckedState = void 0;
22
23
  var _reactNative = require("react-native");
23
24
  var _componentTree = require("./component-tree");
24
25
  var _hostComponentNames = require("./host-component-names");
25
26
  var _textContent = require("./text-content");
27
+ var _textInput = require("./text-input");
26
28
  const accessibilityStateKeys = exports.accessibilityStateKeys = ['disabled', 'selected', 'checked', 'busy', 'expanded'];
27
29
  const accessibilityValueKeys = exports.accessibilityValueKeys = ['min', 'max', 'now', 'text'];
28
30
  function isHiddenFromAccessibility(element, {
@@ -46,7 +48,7 @@ function isHiddenFromAccessibility(element, {
46
48
  return false;
47
49
  }
48
50
 
49
- /** RTL-compatitibility alias for `isHiddenFromAccessibility` */
51
+ /** RTL-compatibility alias for `isHiddenFromAccessibility` */
50
52
  const isInaccessible = exports.isInaccessible = isHiddenFromAccessibility;
51
53
  function isSubtreeInaccessible(element) {
52
54
  // Null props can happen for React.Fragments
@@ -78,7 +80,7 @@ function isSubtreeInaccessible(element) {
78
80
  // iOS: accessibilityViewIsModal or aria-modal
79
81
  // See: https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios
80
82
  const hostSiblings = (0, _componentTree.getHostSiblings)(element);
81
- if (hostSiblings.some(sibling => getAccessibilityViewIsModal(sibling))) {
83
+ if (hostSiblings.some(sibling => computeAriaModal(sibling))) {
82
84
  return true;
83
85
  }
84
86
  return false;
@@ -87,6 +89,11 @@ function isAccessibilityElement(element) {
87
89
  if (element == null) {
88
90
  return false;
89
91
  }
92
+
93
+ // https://github.com/facebook/react-native/blob/8dabed60f456e76a9e53273b601446f34de41fb5/packages/react-native/Libraries/Image/Image.ios.js#L172
94
+ if ((0, _hostComponentNames.isHostImage)(element) && element.props.alt !== undefined) {
95
+ return true;
96
+ }
90
97
  if (element.props.accessible !== undefined) {
91
98
  return element.props.accessible;
92
99
  }
@@ -107,54 +114,100 @@ function isAccessibilityElement(element) {
107
114
  * @param element
108
115
  * @returns
109
116
  */
110
- function getAccessibilityRole(element) {
117
+ function getRole(element) {
111
118
  const explicitRole = element.props.role ?? element.props.accessibilityRole;
112
119
  if (explicitRole) {
113
- return explicitRole;
120
+ return normalizeRole(explicitRole);
114
121
  }
115
122
  if ((0, _hostComponentNames.isHostText)(element)) {
116
123
  return 'text';
117
124
  }
125
+
126
+ // Note: host Image elements report "image" role in screen reader only on Android, but not on iOS.
127
+ // It's better to require explicit role for Image elements.
128
+
118
129
  return 'none';
119
130
  }
120
- function getAccessibilityViewIsModal(element) {
131
+
132
+ /**
133
+ * There are some duplications between (ARIA) `Role` and `AccessibilityRole` types.
134
+ * Resolve them by using ARIA `Role` type where possible.
135
+ *
136
+ * @param role Role to normalize
137
+ * @returns Normalized role
138
+ */
139
+ function normalizeRole(role) {
140
+ if (role === 'image') {
141
+ return 'img';
142
+ }
143
+ return role;
144
+ }
145
+ function computeAriaModal(element) {
121
146
  return element.props['aria-modal'] ?? element.props.accessibilityViewIsModal;
122
147
  }
123
- function getAccessibilityLabel(element) {
124
- return element.props['aria-label'] ?? element.props.accessibilityLabel;
148
+ function computeAriaLabel(element) {
149
+ const explicitLabel = element.props['aria-label'] ?? element.props.accessibilityLabel;
150
+ if (explicitLabel) {
151
+ return explicitLabel;
152
+ }
153
+
154
+ //https://github.com/facebook/react-native/blob/8dabed60f456e76a9e53273b601446f34de41fb5/packages/react-native/Libraries/Image/Image.ios.js#L173
155
+ if ((0, _hostComponentNames.isHostImage)(element) && element.props.alt) {
156
+ return element.props.alt;
157
+ }
158
+ return undefined;
125
159
  }
126
- function getAccessibilityLabelledBy(element) {
160
+ function computeAriaLabelledBy(element) {
127
161
  return element.props['aria-labelledby'] ?? element.props.accessibilityLabelledBy;
128
162
  }
129
- function getAccessibilityState(element) {
163
+
164
+ // See: https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State#busy-state
165
+ function computeAriaBusy({
166
+ props
167
+ }) {
168
+ return props['aria-busy'] ?? props.accessibilityState?.busy ?? false;
169
+ }
170
+
171
+ // See: https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State#checked-state
172
+ function computeAriaChecked(element) {
130
173
  const {
131
- accessibilityState,
132
- 'aria-busy': ariaBusy,
133
- 'aria-checked': ariaChecked,
134
- 'aria-disabled': ariaDisabled,
135
- 'aria-expanded': ariaExpanded,
136
- 'aria-selected': ariaSelected
137
- } = element.props;
138
- const hasAnyAccessibilityStateProps = accessibilityState != null || ariaBusy != null || ariaChecked != null || ariaDisabled != null || ariaExpanded != null || ariaSelected != null;
139
- if (!hasAnyAccessibilityStateProps) {
174
+ props
175
+ } = element;
176
+ if ((0, _hostComponentNames.isHostSwitch)(element)) {
177
+ return props.value;
178
+ }
179
+ const role = getRole(element);
180
+ if (!rolesSupportingCheckedState[role]) {
140
181
  return undefined;
141
182
  }
142
- return {
143
- busy: ariaBusy ?? accessibilityState?.busy,
144
- checked: ariaChecked ?? accessibilityState?.checked,
145
- disabled: ariaDisabled ?? accessibilityState?.disabled,
146
- expanded: ariaExpanded ?? accessibilityState?.expanded,
147
- selected: ariaSelected ?? accessibilityState?.selected
148
- };
183
+ return props['aria-checked'] ?? props.accessibilityState?.checked;
149
184
  }
150
- function getAccessibilityCheckedState(element) {
185
+
186
+ // See: https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State#disabled-state
187
+ function computeAriaDisabled(element) {
188
+ if ((0, _hostComponentNames.isHostTextInput)(element) && !(0, _textInput.isTextInputEditable)(element)) {
189
+ return true;
190
+ }
151
191
  const {
152
- accessibilityState,
153
- 'aria-checked': ariaChecked
154
- } = element.props;
155
- return ariaChecked ?? accessibilityState?.checked;
192
+ props
193
+ } = element;
194
+ return props['aria-disabled'] ?? props.accessibilityState?.disabled ?? false;
156
195
  }
157
- function getAccessibilityValue(element) {
196
+
197
+ // See: https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State#expanded-state
198
+ function computeAriaExpanded({
199
+ props
200
+ }) {
201
+ return props['aria-expanded'] ?? props.accessibilityState?.expanded;
202
+ }
203
+
204
+ // See: https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State#selected-state
205
+ function computeAriaSelected({
206
+ props
207
+ }) {
208
+ return props['aria-selected'] ?? props.accessibilityState?.selected ?? false;
209
+ }
210
+ function computeAriaValue(element) {
158
211
  const {
159
212
  accessibilityValue,
160
213
  'aria-valuemax': ariaValueMax,
@@ -162,10 +215,6 @@ function getAccessibilityValue(element) {
162
215
  'aria-valuenow': ariaValueNow,
163
216
  'aria-valuetext': ariaValueText
164
217
  } = element.props;
165
- const hasAnyAccessibilityValueProps = accessibilityValue != null || ariaValueMax != null || ariaValueMin != null || ariaValueNow != null || ariaValueText != null;
166
- if (!hasAnyAccessibilityValueProps) {
167
- return undefined;
168
- }
169
218
  return {
170
219
  max: ariaValueMax ?? accessibilityValue?.max,
171
220
  min: ariaValueMin ?? accessibilityValue?.min,
@@ -173,40 +222,12 @@ function getAccessibilityValue(element) {
173
222
  text: ariaValueText ?? accessibilityValue?.text
174
223
  };
175
224
  }
176
- function isElementBusy(element) {
177
- const {
178
- accessibilityState,
179
- 'aria-busy': ariaBusy
180
- } = element.props;
181
- return ariaBusy ?? accessibilityState?.busy ?? false;
182
- }
183
- function isElementCollapsed(element) {
184
- const {
185
- accessibilityState,
186
- 'aria-expanded': ariaExpanded
187
- } = element.props;
188
- return (ariaExpanded ?? accessibilityState?.expanded) === false;
189
- }
190
- function isElementExpanded(element) {
191
- const {
192
- accessibilityState,
193
- 'aria-expanded': ariaExpanded
194
- } = element.props;
195
- return ariaExpanded ?? accessibilityState?.expanded ?? false;
196
- }
197
- function isElementSelected(element) {
198
- const {
199
- accessibilityState,
200
- 'aria-selected': ariaSelected
201
- } = element.props;
202
- return ariaSelected ?? accessibilityState?.selected ?? false;
203
- }
204
- function getAccessibleName(element) {
205
- const label = getAccessibilityLabel(element);
225
+ function computeAccessibleName(element) {
226
+ const label = computeAriaLabel(element);
206
227
  if (label) {
207
228
  return label;
208
229
  }
209
- const labelElementId = getAccessibilityLabelledBy(element);
230
+ const labelElementId = computeAriaLabelledBy(element);
210
231
  if (labelElementId) {
211
232
  const rootElement = (0, _componentTree.getUnsafeRootElement)(element);
212
233
  const labelElement = rootElement?.findByProps({
@@ -218,4 +239,9 @@ function getAccessibleName(element) {
218
239
  }
219
240
  return (0, _textContent.getTextContent)(element);
220
241
  }
242
+ const rolesSupportingCheckedState = exports.rolesSupportingCheckedState = {
243
+ checkbox: true,
244
+ radio: true,
245
+ switch: true
246
+ };
221
247
  //# sourceMappingURL=accessibility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"accessibility.js","names":["_reactNative","require","_componentTree","_hostComponentNames","_textContent","accessibilityStateKeys","exports","accessibilityValueKeys","isHiddenFromAccessibility","element","cache","current","isCurrentSubtreeInaccessible","get","undefined","isSubtreeInaccessible","set","parent","isInaccessible","props","accessibilityElementsHidden","importantForAccessibility","flatStyle","StyleSheet","flatten","style","display","hostSiblings","getHostSiblings","some","sibling","getAccessibilityViewIsModal","isAccessibilityElement","accessible","hostComponentNames","getHostComponentNames","type","text","textInput","switch","getAccessibilityRole","explicitRole","role","accessibilityRole","isHostText","accessibilityViewIsModal","getAccessibilityLabel","accessibilityLabel","getAccessibilityLabelledBy","accessibilityLabelledBy","getAccessibilityState","accessibilityState","ariaBusy","ariaChecked","ariaDisabled","ariaExpanded","ariaSelected","hasAnyAccessibilityStateProps","busy","checked","disabled","expanded","selected","getAccessibilityCheckedState","getAccessibilityValue","accessibilityValue","ariaValueMax","ariaValueMin","ariaValueNow","ariaValueText","hasAnyAccessibilityValueProps","max","min","now","isElementBusy","isElementCollapsed","isElementExpanded","isElementSelected","getAccessibleName","label","labelElementId","rootElement","getUnsafeRootElement","labelElement","findByProps","nativeID","getTextContent"],"sources":["../../src/helpers/accessibility.ts"],"sourcesContent":["import { AccessibilityState, AccessibilityValue, StyleSheet } from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { getHostSiblings, getUnsafeRootElement } from './component-tree';\nimport { getHostComponentNames, isHostText } from './host-component-names';\nimport { getTextContent } from './text-content';\n\ntype IsInaccessibleOptions = {\n cache?: WeakMap<ReactTestInstance, boolean>;\n};\n\nexport const accessibilityStateKeys: (keyof AccessibilityState)[] = [\n 'disabled',\n 'selected',\n 'checked',\n 'busy',\n 'expanded',\n];\n\nexport const accessibilityValueKeys: (keyof AccessibilityValue)[] = ['min', 'max', 'now', 'text'];\n\nexport function isHiddenFromAccessibility(\n element: ReactTestInstance | null,\n { cache }: IsInaccessibleOptions = {},\n): boolean {\n if (element == null) {\n return true;\n }\n\n let current: ReactTestInstance | null = element;\n while (current) {\n let isCurrentSubtreeInaccessible = cache?.get(current);\n\n if (isCurrentSubtreeInaccessible === undefined) {\n isCurrentSubtreeInaccessible = isSubtreeInaccessible(current);\n cache?.set(current, isCurrentSubtreeInaccessible);\n }\n\n if (isCurrentSubtreeInaccessible) {\n return true;\n }\n\n current = current.parent;\n }\n\n return false;\n}\n\n/** RTL-compatitibility alias for `isHiddenFromAccessibility` */\nexport const isInaccessible = isHiddenFromAccessibility;\n\nfunction isSubtreeInaccessible(element: ReactTestInstance): boolean {\n // Null props can happen for React.Fragments\n if (element.props == null) {\n return false;\n }\n\n // See: https://reactnative.dev/docs/accessibility#aria-hidden\n if (element.props['aria-hidden']) {\n return true;\n }\n\n // iOS: accessibilityElementsHidden\n // See: https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios\n if (element.props.accessibilityElementsHidden) {\n return true;\n }\n\n // Android: importantForAccessibility\n // See: https://reactnative.dev/docs/accessibility#importantforaccessibility-android\n if (element.props.importantForAccessibility === 'no-hide-descendants') {\n return true;\n }\n\n // Note that `opacity: 0` is not treated as inaccessible on iOS\n const flatStyle = StyleSheet.flatten(element.props.style) ?? {};\n if (flatStyle.display === 'none') return true;\n\n // iOS: accessibilityViewIsModal or aria-modal\n // See: https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios\n const hostSiblings = getHostSiblings(element);\n if (hostSiblings.some((sibling) => getAccessibilityViewIsModal(sibling))) {\n return true;\n }\n\n return false;\n}\n\nexport function isAccessibilityElement(element: ReactTestInstance | null): boolean {\n if (element == null) {\n return false;\n }\n\n if (element.props.accessible !== undefined) {\n return element.props.accessible;\n }\n\n const hostComponentNames = getHostComponentNames();\n return (\n element?.type === hostComponentNames?.text ||\n element?.type === hostComponentNames?.textInput ||\n element?.type === hostComponentNames?.switch\n );\n}\n\n/**\n * Returns the accessibility role for given element. It will return explicit\n * role from either `role` or `accessibilityRole` props if set.\n *\n * If explicit role is not available, it would try to return default element\n * role:\n * - `text` for `Text` elements\n *\n * In all other cases this functions returns `none`.\n *\n * @param element\n * @returns\n */\nexport function getAccessibilityRole(element: ReactTestInstance) {\n const explicitRole = element.props.role ?? element.props.accessibilityRole;\n if (explicitRole) {\n return explicitRole;\n }\n\n if (isHostText(element)) {\n return 'text';\n }\n\n return 'none';\n}\n\nexport function getAccessibilityViewIsModal(element: ReactTestInstance) {\n return element.props['aria-modal'] ?? element.props.accessibilityViewIsModal;\n}\n\nexport function getAccessibilityLabel(element: ReactTestInstance): string | undefined {\n return element.props['aria-label'] ?? element.props.accessibilityLabel;\n}\n\nexport function getAccessibilityLabelledBy(element: ReactTestInstance): string | undefined {\n return element.props['aria-labelledby'] ?? element.props.accessibilityLabelledBy;\n}\n\nexport function getAccessibilityState(element: ReactTestInstance): AccessibilityState | undefined {\n const {\n accessibilityState,\n 'aria-busy': ariaBusy,\n 'aria-checked': ariaChecked,\n 'aria-disabled': ariaDisabled,\n 'aria-expanded': ariaExpanded,\n 'aria-selected': ariaSelected,\n } = element.props;\n\n const hasAnyAccessibilityStateProps =\n accessibilityState != null ||\n ariaBusy != null ||\n ariaChecked != null ||\n ariaDisabled != null ||\n ariaExpanded != null ||\n ariaSelected != null;\n\n if (!hasAnyAccessibilityStateProps) {\n return undefined;\n }\n\n return {\n busy: ariaBusy ?? accessibilityState?.busy,\n checked: ariaChecked ?? accessibilityState?.checked,\n disabled: ariaDisabled ?? accessibilityState?.disabled,\n expanded: ariaExpanded ?? accessibilityState?.expanded,\n selected: ariaSelected ?? accessibilityState?.selected,\n };\n}\n\nexport function getAccessibilityCheckedState(\n element: ReactTestInstance,\n): AccessibilityState['checked'] {\n const { accessibilityState, 'aria-checked': ariaChecked } = element.props;\n return ariaChecked ?? accessibilityState?.checked;\n}\n\nexport function getAccessibilityValue(element: ReactTestInstance): AccessibilityValue | undefined {\n const {\n accessibilityValue,\n 'aria-valuemax': ariaValueMax,\n 'aria-valuemin': ariaValueMin,\n 'aria-valuenow': ariaValueNow,\n 'aria-valuetext': ariaValueText,\n } = element.props;\n\n const hasAnyAccessibilityValueProps =\n accessibilityValue != null ||\n ariaValueMax != null ||\n ariaValueMin != null ||\n ariaValueNow != null ||\n ariaValueText != null;\n\n if (!hasAnyAccessibilityValueProps) {\n return undefined;\n }\n\n return {\n max: ariaValueMax ?? accessibilityValue?.max,\n min: ariaValueMin ?? accessibilityValue?.min,\n now: ariaValueNow ?? accessibilityValue?.now,\n text: ariaValueText ?? accessibilityValue?.text,\n };\n}\n\nexport function isElementBusy(element: ReactTestInstance): NonNullable<AccessibilityState['busy']> {\n const { accessibilityState, 'aria-busy': ariaBusy } = element.props;\n return ariaBusy ?? accessibilityState?.busy ?? false;\n}\n\nexport function isElementCollapsed(\n element: ReactTestInstance,\n): NonNullable<AccessibilityState['expanded']> {\n const { accessibilityState, 'aria-expanded': ariaExpanded } = element.props;\n return (ariaExpanded ?? accessibilityState?.expanded) === false;\n}\n\nexport function isElementExpanded(\n element: ReactTestInstance,\n): NonNullable<AccessibilityState['expanded']> {\n const { accessibilityState, 'aria-expanded': ariaExpanded } = element.props;\n return ariaExpanded ?? accessibilityState?.expanded ?? false;\n}\n\nexport function isElementSelected(\n element: ReactTestInstance,\n): NonNullable<AccessibilityState['selected']> {\n const { accessibilityState, 'aria-selected': ariaSelected } = element.props;\n return ariaSelected ?? accessibilityState?.selected ?? false;\n}\n\nexport function getAccessibleName(element: ReactTestInstance): string | undefined {\n const label = getAccessibilityLabel(element);\n if (label) {\n return label;\n }\n\n const labelElementId = getAccessibilityLabelledBy(element);\n if (labelElementId) {\n const rootElement = getUnsafeRootElement(element);\n const labelElement = rootElement?.findByProps({ nativeID: labelElementId });\n if (labelElement) {\n return getTextContent(labelElement);\n }\n }\n\n return getTextContent(element);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAMO,MAAMI,sBAAoD,GAAAC,OAAA,CAAAD,sBAAA,GAAG,CAClE,UAAU,EACV,UAAU,EACV,SAAS,EACT,MAAM,EACN,UAAU,CACX;AAEM,MAAME,sBAAoD,GAAAD,OAAA,CAAAC,sBAAA,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;AAE1F,SAASC,yBAAyBA,CACvCC,OAAiC,EACjC;EAAEC;AAA6B,CAAC,GAAG,CAAC,CAAC,EAC5B;EACT,IAAID,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,IAAI;EACb;EAEA,IAAIE,OAAiC,GAAGF,OAAO;EAC/C,OAAOE,OAAO,EAAE;IACd,IAAIC,4BAA4B,GAAGF,KAAK,EAAEG,GAAG,CAACF,OAAO,CAAC;IAEtD,IAAIC,4BAA4B,KAAKE,SAAS,EAAE;MAC9CF,4BAA4B,GAAGG,qBAAqB,CAACJ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C,0BAA0B,CAACvC,OAAO,CAAC;EAC1D,IAAIuE,cAAc,EAAE;IAClB,MAAMC,WAAW,GAAG,IAAAC,mCAAoB,EAACzE,OAAO,CAAC;IACjD,MAAM0E,YAAY,GAAGF,WAAW,EAAEG,WAAW,CAAC;MAAEC,QAAQ,EAAEL;IAAe,CAAC,CAAC;IAC3E,IAAIG,YAAY,EAAE;MAChB,OAAO,IAAAG,2BAAc,EAACH,YAAY,CAAC;IACrC;EACF;EAEA,OAAO,IAAAG,2BAAc,EAAC7E,OAAO,CAAC;AAChC","ignoreList":[]}
1
+ {"version":3,"file":"accessibility.js","names":["_reactNative","require","_componentTree","_hostComponentNames","_textContent","_textInput","accessibilityStateKeys","exports","accessibilityValueKeys","isHiddenFromAccessibility","element","cache","current","isCurrentSubtreeInaccessible","get","undefined","isSubtreeInaccessible","set","parent","isInaccessible","props","accessibilityElementsHidden","importantForAccessibility","flatStyle","StyleSheet","flatten","style","display","hostSiblings","getHostSiblings","some","sibling","computeAriaModal","isAccessibilityElement","isHostImage","alt","accessible","hostComponentNames","getHostComponentNames","type","text","textInput","switch","getRole","explicitRole","role","accessibilityRole","normalizeRole","isHostText","accessibilityViewIsModal","computeAriaLabel","explicitLabel","accessibilityLabel","computeAriaLabelledBy","accessibilityLabelledBy","computeAriaBusy","accessibilityState","busy","computeAriaChecked","isHostSwitch","value","rolesSupportingCheckedState","checked","computeAriaDisabled","isHostTextInput","isTextInputEditable","disabled","computeAriaExpanded","expanded","computeAriaSelected","selected","computeAriaValue","accessibilityValue","ariaValueMax","ariaValueMin","ariaValueNow","ariaValueText","max","min","now","computeAccessibleName","label","labelElementId","rootElement","getUnsafeRootElement","labelElement","findByProps","nativeID","getTextContent","checkbox","radio"],"sources":["../../src/helpers/accessibility.ts"],"sourcesContent":["import {\n AccessibilityRole,\n AccessibilityState,\n AccessibilityValue,\n Role,\n StyleSheet,\n} from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { getHostSiblings, getUnsafeRootElement } from './component-tree';\nimport {\n getHostComponentNames,\n isHostImage,\n isHostSwitch,\n isHostText,\n isHostTextInput,\n} from './host-component-names';\nimport { getTextContent } from './text-content';\nimport { isTextInputEditable } from './text-input';\n\ntype IsInaccessibleOptions = {\n cache?: WeakMap<ReactTestInstance, boolean>;\n};\n\nexport const accessibilityStateKeys: (keyof AccessibilityState)[] = [\n 'disabled',\n 'selected',\n 'checked',\n 'busy',\n 'expanded',\n];\n\nexport const accessibilityValueKeys: (keyof AccessibilityValue)[] = ['min', 'max', 'now', 'text'];\n\nexport function isHiddenFromAccessibility(\n element: ReactTestInstance | null,\n { cache }: IsInaccessibleOptions = {},\n): boolean {\n if (element == null) {\n return true;\n }\n\n let current: ReactTestInstance | null = element;\n while (current) {\n let isCurrentSubtreeInaccessible = cache?.get(current);\n\n if (isCurrentSubtreeInaccessible === undefined) {\n isCurrentSubtreeInaccessible = isSubtreeInaccessible(current);\n cache?.set(current, isCurrentSubtreeInaccessible);\n }\n\n if (isCurrentSubtreeInaccessible) {\n return true;\n }\n\n current = current.parent;\n }\n\n return false;\n}\n\n/** RTL-compatibility alias for `isHiddenFromAccessibility` */\nexport const isInaccessible = isHiddenFromAccessibility;\n\nfunction isSubtreeInaccessible(element: ReactTestInstance): boolean {\n // Null props can happen for React.Fragments\n if (element.props == null) {\n return false;\n }\n\n // See: https://reactnative.dev/docs/accessibility#aria-hidden\n if (element.props['aria-hidden']) {\n return true;\n }\n\n // iOS: accessibilityElementsHidden\n // See: https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios\n if (element.props.accessibilityElementsHidden) {\n return true;\n }\n\n // Android: importantForAccessibility\n // See: https://reactnative.dev/docs/accessibility#importantforaccessibility-android\n if (element.props.importantForAccessibility === 'no-hide-descendants') {\n return true;\n }\n\n // Note that `opacity: 0` is not treated as inaccessible on iOS\n const flatStyle = StyleSheet.flatten(element.props.style) ?? {};\n if (flatStyle.display === 'none') return true;\n\n // iOS: accessibilityViewIsModal or aria-modal\n // See: https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios\n const hostSiblings = getHostSiblings(element);\n if (hostSiblings.some((sibling) => computeAriaModal(sibling))) {\n return true;\n }\n\n return false;\n}\n\nexport function isAccessibilityElement(element: ReactTestInstance | null): boolean {\n if (element == null) {\n return false;\n }\n\n // https://github.com/facebook/react-native/blob/8dabed60f456e76a9e53273b601446f34de41fb5/packages/react-native/Libraries/Image/Image.ios.js#L172\n if (isHostImage(element) && element.props.alt !== undefined) {\n return true;\n }\n\n if (element.props.accessible !== undefined) {\n return element.props.accessible;\n }\n\n const hostComponentNames = getHostComponentNames();\n return (\n element?.type === hostComponentNames?.text ||\n element?.type === hostComponentNames?.textInput ||\n element?.type === hostComponentNames?.switch\n );\n}\n\n/**\n * Returns the accessibility role for given element. It will return explicit\n * role from either `role` or `accessibilityRole` props if set.\n *\n * If explicit role is not available, it would try to return default element\n * role:\n * - `text` for `Text` elements\n *\n * In all other cases this functions returns `none`.\n *\n * @param element\n * @returns\n */\nexport function getRole(element: ReactTestInstance): Role | AccessibilityRole {\n const explicitRole = element.props.role ?? element.props.accessibilityRole;\n if (explicitRole) {\n return normalizeRole(explicitRole);\n }\n\n if (isHostText(element)) {\n return 'text';\n }\n\n // Note: host Image elements report \"image\" role in screen reader only on Android, but not on iOS.\n // It's better to require explicit role for Image elements.\n\n return 'none';\n}\n\n/**\n * There are some duplications between (ARIA) `Role` and `AccessibilityRole` types.\n * Resolve them by using ARIA `Role` type where possible.\n *\n * @param role Role to normalize\n * @returns Normalized role\n */\nexport function normalizeRole(role: string): Role | AccessibilityRole {\n if (role === 'image') {\n return 'img';\n }\n\n return role as Role | AccessibilityRole;\n}\n\nexport function computeAriaModal(element: ReactTestInstance): boolean | undefined {\n return element.props['aria-modal'] ?? element.props.accessibilityViewIsModal;\n}\n\nexport function computeAriaLabel(element: ReactTestInstance): string | undefined {\n const explicitLabel = element.props['aria-label'] ?? element.props.accessibilityLabel;\n if (explicitLabel) {\n return explicitLabel;\n }\n\n //https://github.com/facebook/react-native/blob/8dabed60f456e76a9e53273b601446f34de41fb5/packages/react-native/Libraries/Image/Image.ios.js#L173\n if (isHostImage(element) && element.props.alt) {\n return element.props.alt;\n }\n\n return undefined;\n}\n\nexport function computeAriaLabelledBy(element: ReactTestInstance): string | undefined {\n return element.props['aria-labelledby'] ?? element.props.accessibilityLabelledBy;\n}\n\n// See: https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State#busy-state\nexport function computeAriaBusy({ props }: ReactTestInstance): boolean {\n return props['aria-busy'] ?? props.accessibilityState?.busy ?? false;\n}\n\n// See: https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State#checked-state\nexport function computeAriaChecked(element: ReactTestInstance): AccessibilityState['checked'] {\n const { props } = element;\n\n if (isHostSwitch(element)) {\n return props.value;\n }\n\n const role = getRole(element);\n if (!rolesSupportingCheckedState[role]) {\n return undefined;\n }\n\n return props['aria-checked'] ?? props.accessibilityState?.checked;\n}\n\n// See: https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State#disabled-state\nexport function computeAriaDisabled(element: ReactTestInstance): boolean {\n if (isHostTextInput(element) && !isTextInputEditable(element)) {\n return true;\n }\n\n const { props } = element;\n return props['aria-disabled'] ?? props.accessibilityState?.disabled ?? false;\n}\n\n// See: https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State#expanded-state\nexport function computeAriaExpanded({ props }: ReactTestInstance): boolean | undefined {\n return props['aria-expanded'] ?? props.accessibilityState?.expanded;\n}\n\n// See: https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State#selected-state\nexport function computeAriaSelected({ props }: ReactTestInstance): boolean {\n return props['aria-selected'] ?? props.accessibilityState?.selected ?? false;\n}\n\nexport function computeAriaValue(element: ReactTestInstance): AccessibilityValue {\n const {\n accessibilityValue,\n 'aria-valuemax': ariaValueMax,\n 'aria-valuemin': ariaValueMin,\n 'aria-valuenow': ariaValueNow,\n 'aria-valuetext': ariaValueText,\n } = element.props;\n\n return {\n max: ariaValueMax ?? accessibilityValue?.max,\n min: ariaValueMin ?? accessibilityValue?.min,\n now: ariaValueNow ?? accessibilityValue?.now,\n text: ariaValueText ?? accessibilityValue?.text,\n };\n}\n\nexport function computeAccessibleName(element: ReactTestInstance): string | undefined {\n const label = computeAriaLabel(element);\n if (label) {\n return label;\n }\n\n const labelElementId = computeAriaLabelledBy(element);\n if (labelElementId) {\n const rootElement = getUnsafeRootElement(element);\n const labelElement = rootElement?.findByProps({ nativeID: labelElementId });\n if (labelElement) {\n return getTextContent(labelElement);\n }\n }\n\n return getTextContent(element);\n}\n\ntype RoleSupportMap = Partial<Record<Role | AccessibilityRole, true>>;\n\nexport const rolesSupportingCheckedState: RoleSupportMap = {\n checkbox: true,\n radio: true,\n switch: true,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAQA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAOA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAMO,MAAMK,sBAAoD,GAAAC,OAAA,CAAAD,sBAAA,GAAG,CAClE,UAAU,EACV,UAAU,EACV,SAAS,EACT,MAAM,EACN,UAAU,CACX;AAEM,MAAME,sBAAoD,GAAAD,OAAA,CAAAC,sBAAA,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;AAE1F,SAASC,yBAAyBA,CACvCC,OAAiC,EACjC;EAAEC;AAA6B,CAAC,GAAG,CAAC,CAAC,EAC5B;EACT,IAAID,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,IAAI;EACb;EAEA,IAAIE,OAAiC,GAAGF,OAAO;EAC/C,OAAOE,OAAO,EAAE;IACd,IAAIC,4BAA4B,GAAGF,KAAK,EAAEG,GAAG,CAACF,OAAO,CAAC;IAEtD,IAAIC,4BAA4B,KAAKE,SAAS,EAAE;MAC9CF,4BAA4B,GAAGG,qB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Y,EAAE;MAChB,OAAO,IAAAG,2BAAc,EAACH,YAAY,CAAC;IACrC;EACF;EAEA,OAAO,IAAAG,2BAAc,EAAC9E,OAAO,CAAC;AAChC;AAIO,MAAMmD,2BAA2C,GAAAtD,OAAA,CAAAsD,2BAAA,GAAG;EACzD4B,QAAQ,EAAE,IAAI;EACdC,KAAK,EAAE,IAAI;EACXhD,MAAM,EAAE;AACV,CAAC","ignoreList":[]}
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.defaultMapProps = defaultMapProps;
7
7
  var _reactNative = require("react-native");
8
8
  var _object = require("./object");
9
- const propsToDisplay = ['accessible', 'accessibilityElementsHidden', 'accessibilityHint', 'accessibilityLabel', 'accessibilityLabelledBy', 'accessibilityRole', 'accessibilityViewIsModal', 'aria-busy', 'aria-checked', 'aria-disabled', 'aria-expanded', 'aria-hidden', 'aria-label', 'aria-labelledby', 'aria-modal', 'aria-selected', 'aria-valuemax', 'aria-valuemin', 'aria-valuenow', 'aria-valuetext', 'defaultValue', 'importantForAccessibility', 'nativeID', 'placeholder', 'role', 'testID', 'title', 'value'];
9
+ const propsToDisplay = ['accessible', 'accessibilityElementsHidden', 'accessibilityHint', 'accessibilityLabel', 'accessibilityLabelledBy', 'accessibilityRole', 'accessibilityViewIsModal', 'alt', 'aria-busy', 'aria-checked', 'aria-disabled', 'aria-expanded', 'aria-hidden', 'aria-label', 'aria-labelledby', 'aria-modal', 'aria-selected', 'aria-valuemax', 'aria-valuemin', 'aria-valuenow', 'aria-valuetext', 'defaultValue', 'importantForAccessibility', 'nativeID', 'placeholder', 'role', 'testID', 'title', 'value'];
10
10
 
11
11
  /**
12
12
  * Preserve props that are helpful in diagnosing test failures, while stripping rest
@@ -1 +1 @@
1
- {"version":3,"file":"format-default.js","names":["_reactNative","require","_object","propsToDisplay","defaultMapProps","props","result","styles","StyleSheet","flatten","style","styleToDisplay","extractStyle","undefined","accessibilityState","removeUndefinedKeys","accessibilityValue","forEach","propName","display","opacity","hasAnyKeys","Object","keys","length"],"sources":["../../src/helpers/format-default.ts"],"sourcesContent":["import { StyleSheet, ViewStyle } from 'react-native';\nimport { removeUndefinedKeys } from './object';\n\nconst propsToDisplay = [\n 'accessible',\n 'accessibilityElementsHidden',\n 'accessibilityHint',\n 'accessibilityLabel',\n 'accessibilityLabelledBy',\n 'accessibilityRole',\n 'accessibilityViewIsModal',\n 'aria-busy',\n 'aria-checked',\n 'aria-disabled',\n 'aria-expanded',\n 'aria-hidden',\n 'aria-label',\n 'aria-labelledby',\n 'aria-modal',\n 'aria-selected',\n 'aria-valuemax',\n 'aria-valuemin',\n 'aria-valuenow',\n 'aria-valuetext',\n 'defaultValue',\n 'importantForAccessibility',\n 'nativeID',\n 'placeholder',\n 'role',\n 'testID',\n 'title',\n 'value',\n] as const;\n\n/**\n * Preserve props that are helpful in diagnosing test failures, while stripping rest\n */\nexport function defaultMapProps(props: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n const styles = StyleSheet.flatten(props.style as ViewStyle);\n const styleToDisplay = extractStyle(styles);\n if (styleToDisplay !== undefined) {\n result.style = styleToDisplay;\n }\n\n const accessibilityState = removeUndefinedKeys(props.accessibilityState);\n if (accessibilityState !== undefined) {\n result.accessibilityState = accessibilityState;\n }\n\n const accessibilityValue = removeUndefinedKeys(props.accessibilityValue);\n if (accessibilityValue !== undefined) {\n result.accessibilityValue = accessibilityValue;\n }\n\n propsToDisplay.forEach((propName) => {\n if (propName in props) {\n result[propName] = props[propName];\n }\n });\n\n return result;\n}\n\nfunction extractStyle(style: ViewStyle | undefined) {\n if (style == null) {\n return undefined;\n }\n\n const result: Record<string, unknown> = {};\n if (style.display === 'none') {\n result.display = 'none';\n }\n\n if (style.opacity === 0) {\n result.opacity = 0;\n }\n\n const hasAnyKeys = Object.keys(result).length > 0;\n return hasAnyKeys ? result : undefined;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,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,SAASM,YAAYA,CAACF,KAA4B,EAAE;EAClD,IAAIA,KAAK,IAAI,IAAI,EAAE;IACjB,OAAOG,SAAS;EAClB;EAEA,MAAMP,MAA+B,GAAG,CAAC,CAAC;EAC1C,IAAII,KAAK,CAACS,OAAO,KAAK,MAAM,EAAE;IAC5Bb,MAAM,CAACa,OAAO,GAAG,MAAM;EACzB;EAEA,IAAIT,KAAK,CAACU,OAAO,KAAK,CAAC,EAAE;IACvBd,MAAM,CAACc,OAAO,GAAG,CAAC;EACpB;EAEA,MAAMC,UAAU,GAAGC,MAAM,CAACC,IAAI,CAACjB,MAAM,CAAC,CAACkB,MAAM,GAAG,CAAC;EACjD,OAAOH,UAAU,GAAGf,MAAM,GAAGO,SAAS;AACxC","ignoreList":[]}
1
+ {"version":3,"file":"format-default.js","names":["_reactNative","require","_object","propsToDisplay","defaultMapProps","props","result","styles","StyleSheet","flatten","style","styleToDisplay","extractStyle","undefined","accessibilityState","removeUndefinedKeys","accessibilityValue","forEach","propName","display","opacity","hasAnyKeys","Object","keys","length"],"sources":["../../src/helpers/format-default.ts"],"sourcesContent":["import { StyleSheet, ViewStyle } from 'react-native';\nimport { removeUndefinedKeys } from './object';\n\nconst propsToDisplay = [\n 'accessible',\n 'accessibilityElementsHidden',\n 'accessibilityHint',\n 'accessibilityLabel',\n 'accessibilityLabelledBy',\n 'accessibilityRole',\n 'accessibilityViewIsModal',\n 'alt',\n 'aria-busy',\n 'aria-checked',\n 'aria-disabled',\n 'aria-expanded',\n 'aria-hidden',\n 'aria-label',\n 'aria-labelledby',\n 'aria-modal',\n 'aria-selected',\n 'aria-valuemax',\n 'aria-valuemin',\n 'aria-valuenow',\n 'aria-valuetext',\n 'defaultValue',\n 'importantForAccessibility',\n 'nativeID',\n 'placeholder',\n 'role',\n 'testID',\n 'title',\n 'value',\n] as const;\n\n/**\n * Preserve props that are helpful in diagnosing test failures, while stripping rest\n */\nexport function defaultMapProps(props: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n const styles = StyleSheet.flatten(props.style as ViewStyle);\n const styleToDisplay = extractStyle(styles);\n if (styleToDisplay !== undefined) {\n result.style = styleToDisplay;\n }\n\n const accessibilityState = removeUndefinedKeys(props.accessibilityState);\n if (accessibilityState !== undefined) {\n result.accessibilityState = accessibilityState;\n }\n\n const accessibilityValue = removeUndefinedKeys(props.accessibilityValue);\n if (accessibilityValue !== undefined) {\n result.accessibilityValue = accessibilityValue;\n }\n\n propsToDisplay.forEach((propName) => {\n if (propName in props) {\n result[propName] = props[propName];\n }\n });\n\n return result;\n}\n\nfunction extractStyle(style: ViewStyle | undefined) {\n if (style == null) {\n return undefined;\n }\n\n const result: Record<string, unknown> = {};\n if (style.display === 'none') {\n result.display = 'none';\n }\n\n if (style.opacity === 0) {\n result.opacity = 0;\n }\n\n const hasAnyKeys = Object.keys(result).length > 0;\n return hasAnyKeys ? result : undefined;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,cAAc,GAAG,CACrB,YAAY,EACZ,6BAA6B,EAC7B,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,0BAA0B,EAC1B,KAAK,EACL,WAAW,EACX,cAAc,EACd,eAAe,EACf,eAAe,EACf,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,2BAA2B,EAC3B,UAAU,EACV,aAAa,EACb,MAAM,EACN,QAAQ,EACR,OAAO,EACP,OAAO,CACC;;AAEV;AACA;AACA;AACO,SAASC,eAAeA,CAACC,KAA8B,EAA2B;EACvF,MAAMC,MAA+B,GAAG,CAAC,CAAC;EAE1C,MAAMC,MAAM,GAAGC,uBAAU,CAACC,OAAO,CAACJ,KAAK,CAACK,KAAkB,CAAC;EAC3D,MAAMC,cAAc,GAAGC,YAAY,CAACL,MAAM,CAAC;EAC3C,IAAII,cAAc,KAAKE,SAAS,EAAE;IAChCP,MAAM,CAACI,KAAK,GAAGC,cAAc;EAC/B;EAEA,MAAMG,kBAAkB,GAAG,IAAAC,2BAAmB,EAACV,KAAK,CAACS,kBAAkB,CAAC;EACxE,IAAIA,kBAAkB,KAAKD,SAAS,EAAE;IACpCP,MAAM,CAACQ,kBAAkB,GAAGA,kBAAkB;EAChD;EAEA,MAAME,kBAAkB,GAAG,IAAAD,2BAAmB,EAACV,KAAK,CAACW,kBAAkB,CAAC;EACxE,IAAIA,kBAAkB,KAAKH,SAAS,EAAE;IACpCP,MAAM,CAACU,kBAAkB,GAAGA,kBAAkB;EAChD;EAEAb,cAAc,CAACc,OAAO,CAAEC,QAAQ,IAAK;IACnC,IAAIA,QAAQ,IAAIb,KAAK,EAAE;MACrBC,MAAM,CAACY,QAAQ,CAAC,GAAGb,KAAK,CAACa,QAAQ,CAAC;IACpC;EACF,CAAC,CAAC;EAEF,OAAOZ,MAAM;AACf;AAEA,SAASM,YAAYA,CAACF,KAA4B,EAAE;EAClD,IAAIA,KAAK,IAAI,IAAI,EAAE;IACjB,OAAOG,SAAS;EAClB;EAEA,MAAMP,MAA+B,GAAG,CAAC,CAAC;EAC1C,IAAII,KAAK,CAACS,OAAO,KAAK,MAAM,EAAE;IAC5Bb,MAAM,CAACa,OAAO,GAAG,MAAM;EACzB;EAEA,IAAIT,KAAK,CAACU,OAAO,KAAK,CAAC,EAAE;IACvBd,MAAM,CAACc,OAAO,GAAG,CAAC;EACpB;EAEA,MAAMC,UAAU,GAAGC,MAAM,CAACC,IAAI,CAACjB,MAAM,CAAC,CAACkB,MAAM,GAAG,CAAC;EACjD,OAAOH,UAAU,GAAGf,MAAM,GAAGO,SAAS;AACxC","ignoreList":[]}
@@ -4,22 +4,32 @@ import { HostTestInstance } from './component-tree';
4
4
  export declare function getHostComponentNames(): HostComponentNames;
5
5
  export declare function configureHostComponentNamesIfNeeded(): void;
6
6
  /**
7
- * Checks if the given element is a host Text.
7
+ * Checks if the given element is a host Text element.
8
8
  * @param element The element to check.
9
9
  */
10
10
  export declare function isHostText(element?: ReactTestInstance | null): element is HostTestInstance;
11
11
  /**
12
- * Checks if the given element is a host TextInput.
12
+ * Checks if the given element is a host TextInput element.
13
13
  * @param element The element to check.
14
14
  */
15
15
  export declare function isHostTextInput(element?: ReactTestInstance | null): element is HostTestInstance;
16
16
  /**
17
- * Checks if the given element is a host ScrollView.
17
+ * Checks if the given element is a host Image element.
18
+ * @param element The element to check.
19
+ */
20
+ export declare function isHostImage(element?: ReactTestInstance | null): element is HostTestInstance;
21
+ /**
22
+ * Checks if the given element is a host Switch element.
23
+ * @param element The element to check.
24
+ */
25
+ export declare function isHostSwitch(element?: ReactTestInstance | null): element is HostTestInstance;
26
+ /**
27
+ * Checks if the given element is a host ScrollView element.
18
28
  * @param element The element to check.
19
29
  */
20
30
  export declare function isHostScrollView(element?: ReactTestInstance | null): element is HostTestInstance;
21
31
  /**
22
- * Checks if the given element is a host Modal.
32
+ * Checks if the given element is a host Modal element.
23
33
  * @param element The element to check.
24
34
  */
25
35
  export declare function isHostModal(element?: ReactTestInstance | null): element is HostTestInstance;