@testing-library/react-native 13.0.0-alpha.0 → 13.0.0-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.
- package/build/config.d.ts +0 -15
- package/build/config.js +0 -7
- package/build/config.js.map +1 -1
- package/build/fire-event.js +4 -1
- package/build/fire-event.js.map +1 -1
- package/build/helpers/accessibility.d.ts +1 -2
- package/build/helpers/accessibility.js +13 -21
- package/build/helpers/accessibility.js.map +1 -1
- package/build/helpers/component-tree.d.ts +2 -1
- package/build/helpers/component-tree.js +5 -3
- package/build/helpers/component-tree.js.map +1 -1
- package/build/helpers/host-component-names.d.ts +6 -9
- package/build/helpers/host-component-names.js +12 -71
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/matchers/match-label-text.d.ts +1 -1
- package/build/helpers/matchers/match-label-text.js +2 -13
- package/build/helpers/matchers/match-label-text.js.map +1 -1
- package/build/matchers/to-be-busy.js.map +1 -1
- package/build/matchers/to-be-checked.js.map +1 -1
- package/build/matchers/to-be-disabled.js.map +1 -1
- package/build/matchers/to-be-empty-element.js.map +1 -1
- package/build/matchers/to-be-expanded.js.map +1 -1
- package/build/matchers/to-be-on-the-screen.js.map +1 -1
- package/build/matchers/to-be-partially-checked.js.map +1 -1
- package/build/matchers/to-be-visible.js.map +1 -1
- package/build/matchers/to-contain-element.js.map +1 -1
- package/build/matchers/to-have-accessibility-value.js.map +1 -1
- package/build/matchers/to-have-accessible-name.js.map +1 -1
- package/build/matchers/to-have-display-value.js.map +1 -1
- package/build/matchers/to-have-style.js.map +1 -1
- package/build/matchers/to-have-text-content.js.map +1 -1
- package/build/matchers/types.js +4 -0
- package/build/matchers/utils.js.map +1 -1
- package/build/queries/label-text.js +1 -1
- package/build/queries/label-text.js.map +1 -1
- package/build/queries/options.js +4 -0
- package/build/render-hook.js +1 -2
- package/build/render-hook.js.map +1 -1
- package/build/render.d.ts +1 -4
- package/build/render.js +1 -6
- package/build/render.js.map +1 -1
- package/build/tsconfig.release.tsbuildinfo +1 -1
- package/build/user-event/press/press.d.ts +2 -0
- package/build/user-event/press/press.js +24 -10
- package/build/user-event/press/press.js.map +1 -1
- package/build/user-event/utils/dispatch-event.js +4 -0
- package/build/user-event/utils/dispatch-event.js.map +1 -1
- package/package.json +10 -9
- package/build/user-event/press/constants.d.ts +0 -2
- package/build/user-event/press/constants.js +0 -14
- package/build/user-event/press/constants.js.map +0 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.DEFAULT_MIN_PRESS_DURATION = exports.DEFAULT_LONG_PRESS_DELAY_MS = void 0;
|
|
6
7
|
exports.longPress = longPress;
|
|
7
8
|
exports.press = press;
|
|
8
9
|
var _act = _interopRequireDefault(require("../../act"));
|
|
@@ -12,18 +13,20 @@ var _pointerEvents = require("../../helpers/pointer-events");
|
|
|
12
13
|
var _hostComponentNames = require("../../helpers/host-component-names");
|
|
13
14
|
var _eventBuilder = require("../event-builder");
|
|
14
15
|
var _utils = require("../utils");
|
|
15
|
-
var _constants = require("./constants");
|
|
16
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
// These are constants defined in the React Native repo
|
|
18
|
+
// See: https://github.com/facebook/react-native/blob/50e38cc9f1e6713228a91ad50f426c4f65e65e1a/packages/react-native/Libraries/Pressability/Pressability.js#L264
|
|
19
|
+
const DEFAULT_MIN_PRESS_DURATION = exports.DEFAULT_MIN_PRESS_DURATION = 130;
|
|
20
|
+
const DEFAULT_LONG_PRESS_DELAY_MS = exports.DEFAULT_LONG_PRESS_DELAY_MS = 500;
|
|
17
21
|
async function press(element) {
|
|
18
22
|
await basePress(this.config, element, {
|
|
19
|
-
type: 'press'
|
|
20
|
-
duration: 0
|
|
23
|
+
type: 'press'
|
|
21
24
|
});
|
|
22
25
|
}
|
|
23
26
|
async function longPress(element, options) {
|
|
24
27
|
await basePress(this.config, element, {
|
|
25
28
|
type: 'longPress',
|
|
26
|
-
duration: options?.duration ??
|
|
29
|
+
duration: options?.duration ?? DEFAULT_LONG_PRESS_DELAY_MS
|
|
27
30
|
});
|
|
28
31
|
}
|
|
29
32
|
const basePress = async (config, element, options) => {
|
|
@@ -48,15 +51,16 @@ const basePress = async (config, element, options) => {
|
|
|
48
51
|
const emitPressablePressEvents = async (config, element, options) => {
|
|
49
52
|
await (0, _utils.wait)(config);
|
|
50
53
|
(0, _utils.dispatchEvent)(element, 'responderGrant', _eventBuilder.EventBuilder.Common.responderGrant());
|
|
51
|
-
|
|
54
|
+
const duration = options.duration ?? DEFAULT_MIN_PRESS_DURATION;
|
|
55
|
+
await (0, _utils.wait)(config, duration);
|
|
52
56
|
(0, _utils.dispatchEvent)(element, 'responderRelease', _eventBuilder.EventBuilder.Common.responderRelease());
|
|
53
57
|
|
|
54
58
|
// React Native will wait for minimal delay of DEFAULT_MIN_PRESS_DURATION
|
|
55
59
|
// before emitting the `pressOut` event. We need to wait here, so that
|
|
56
60
|
// `press()` function does not return before that.
|
|
57
|
-
if (
|
|
61
|
+
if (DEFAULT_MIN_PRESS_DURATION - duration > 0) {
|
|
58
62
|
await (0, _act.default)(async () => {
|
|
59
|
-
await (0, _utils.wait)(config,
|
|
63
|
+
await (0, _utils.wait)(config, DEFAULT_MIN_PRESS_DURATION - duration);
|
|
60
64
|
});
|
|
61
65
|
}
|
|
62
66
|
};
|
|
@@ -74,11 +78,21 @@ const isPressableText = element => {
|
|
|
74
78
|
async function emitTextPressEvents(config, element, options) {
|
|
75
79
|
await (0, _utils.wait)(config);
|
|
76
80
|
(0, _utils.dispatchEvent)(element, 'pressIn', _eventBuilder.EventBuilder.Common.touch());
|
|
77
|
-
|
|
78
|
-
// Emit either `press` or `longPress`.
|
|
79
|
-
(0, _utils.dispatchEvent)(element, options.type, _eventBuilder.EventBuilder.Common.touch());
|
|
80
81
|
await (0, _utils.wait)(config, options.duration);
|
|
82
|
+
|
|
83
|
+
// Long press events are emitted before `pressOut`.
|
|
84
|
+
if (options.type === 'longPress') {
|
|
85
|
+
(0, _utils.dispatchEvent)(element, 'longPress', _eventBuilder.EventBuilder.Common.touch());
|
|
86
|
+
}
|
|
81
87
|
(0, _utils.dispatchEvent)(element, 'pressOut', _eventBuilder.EventBuilder.Common.touch());
|
|
88
|
+
|
|
89
|
+
// Regular press events are emitted after `pressOut` according to the React Native docs.
|
|
90
|
+
// See: https://reactnative.dev/docs/pressable#onpress
|
|
91
|
+
// Experimentally for very short presses (< 130ms) `press` events are actually emitted before `onPressOut`, but
|
|
92
|
+
// we will ignore that as in reality most pressed would be above the 130ms threshold.
|
|
93
|
+
if (options.type === 'press') {
|
|
94
|
+
(0, _utils.dispatchEvent)(element, 'press', _eventBuilder.EventBuilder.Common.touch());
|
|
95
|
+
}
|
|
82
96
|
}
|
|
83
97
|
|
|
84
98
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"press.js","names":["_act","_interopRequireDefault","require","_componentTree","_textInput","_pointerEvents","_hostComponentNames","_eventBuilder","_utils","
|
|
1
|
+
{"version":3,"file":"press.js","names":["_act","_interopRequireDefault","require","_componentTree","_textInput","_pointerEvents","_hostComponentNames","_eventBuilder","_utils","e","__esModule","default","DEFAULT_MIN_PRESS_DURATION","exports","DEFAULT_LONG_PRESS_DELAY_MS","press","element","basePress","config","type","longPress","options","duration","isPressableText","emitTextPressEvents","isHostTextInput","isTextInputEditable","isPointerEventEnabled","emitTextInputPressEvents","isEnabledTouchResponder","emitPressablePressEvents","hostParentElement","getHostParent","wait","dispatchEvent","EventBuilder","Common","responderGrant","responderRelease","act","props","onStartShouldSetResponder","hasPressEventHandler","Boolean","onPress","onLongPress","onPressIn","onPressOut","isHostText","disabled","touch"],"sources":["../../../src/user-event/press/press.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport act from '../../act';\nimport { getHostParent } from '../../helpers/component-tree';\nimport { isTextInputEditable } from '../../helpers/text-input';\nimport { isPointerEventEnabled } from '../../helpers/pointer-events';\nimport { isHostText, isHostTextInput } from '../../helpers/host-component-names';\nimport { EventBuilder } from '../event-builder';\nimport { UserEventConfig, UserEventInstance } from '../setup';\nimport { dispatchEvent, wait } from '../utils';\n\n// These are constants defined in the React Native repo\n// See: https://github.com/facebook/react-native/blob/50e38cc9f1e6713228a91ad50f426c4f65e65e1a/packages/react-native/Libraries/Pressability/Pressability.js#L264\nexport const DEFAULT_MIN_PRESS_DURATION = 130;\nexport const DEFAULT_LONG_PRESS_DELAY_MS = 500;\n\nexport interface PressOptions {\n duration?: number;\n}\n\nexport async function press(this: UserEventInstance, element: ReactTestInstance): Promise<void> {\n await basePress(this.config, element, {\n type: 'press',\n });\n}\n\nexport async function longPress(\n this: UserEventInstance,\n element: ReactTestInstance,\n options?: PressOptions,\n): Promise<void> {\n await basePress(this.config, element, {\n type: 'longPress',\n duration: options?.duration ?? DEFAULT_LONG_PRESS_DELAY_MS,\n });\n}\n\ninterface BasePressOptions {\n type: 'press' | 'longPress';\n duration?: number;\n}\n\nconst basePress = async (\n config: UserEventConfig,\n element: ReactTestInstance,\n options: BasePressOptions,\n): Promise<void> => {\n if (isPressableText(element)) {\n await emitTextPressEvents(config, element, options);\n return;\n }\n\n if (isHostTextInput(element) && isTextInputEditable(element) && isPointerEventEnabled(element)) {\n await emitTextInputPressEvents(config, element, options);\n return;\n }\n\n if (isEnabledTouchResponder(element)) {\n await emitPressablePressEvents(config, element, options);\n return;\n }\n\n const hostParentElement = getHostParent(element);\n if (!hostParentElement) {\n return;\n }\n\n await basePress(config, hostParentElement, options);\n};\n\nconst emitPressablePressEvents = async (\n config: UserEventConfig,\n element: ReactTestInstance,\n options: BasePressOptions,\n) => {\n await wait(config);\n\n dispatchEvent(element, 'responderGrant', EventBuilder.Common.responderGrant());\n\n const duration = options.duration ?? DEFAULT_MIN_PRESS_DURATION;\n await wait(config, duration);\n\n dispatchEvent(element, 'responderRelease', EventBuilder.Common.responderRelease());\n\n // React Native will wait for minimal delay of DEFAULT_MIN_PRESS_DURATION\n // before emitting the `pressOut` event. We need to wait here, so that\n // `press()` function does not return before that.\n if (DEFAULT_MIN_PRESS_DURATION - duration > 0) {\n await act(async () => {\n await wait(config, DEFAULT_MIN_PRESS_DURATION - duration);\n });\n }\n};\n\nconst isEnabledTouchResponder = (element: ReactTestInstance) => {\n return isPointerEventEnabled(element) && element.props.onStartShouldSetResponder?.();\n};\n\nconst isPressableText = (element: ReactTestInstance) => {\n const hasPressEventHandler = Boolean(\n element.props.onPress ||\n element.props.onLongPress ||\n element.props.onPressIn ||\n element.props.onPressOut,\n );\n\n return (\n isHostText(element) &&\n isPointerEventEnabled(element) &&\n !element.props.disabled &&\n hasPressEventHandler\n );\n};\n\n/**\n * Dispatches a press event sequence for Text.\n */\nasync function emitTextPressEvents(\n config: UserEventConfig,\n element: ReactTestInstance,\n options: BasePressOptions,\n) {\n await wait(config);\n dispatchEvent(element, 'pressIn', EventBuilder.Common.touch());\n\n await wait(config, options.duration);\n\n // Long press events are emitted before `pressOut`.\n if (options.type === 'longPress') {\n dispatchEvent(element, 'longPress', EventBuilder.Common.touch());\n }\n\n dispatchEvent(element, 'pressOut', EventBuilder.Common.touch());\n\n // Regular press events are emitted after `pressOut` according to the React Native docs.\n // See: https://reactnative.dev/docs/pressable#onpress\n // Experimentally for very short presses (< 130ms) `press` events are actually emitted before `onPressOut`, but\n // we will ignore that as in reality most pressed would be above the 130ms threshold.\n if (options.type === 'press') {\n dispatchEvent(element, 'press', EventBuilder.Common.touch());\n }\n}\n\n/**\n * Dispatches a press event sequence for TextInput.\n */\nasync function emitTextInputPressEvents(\n config: UserEventConfig,\n element: ReactTestInstance,\n options: BasePressOptions,\n) {\n await wait(config);\n dispatchEvent(element, 'pressIn', EventBuilder.Common.touch());\n\n // Note: TextInput does not have `onPress`/`onLongPress` props.\n\n await wait(config, options.duration);\n dispatchEvent(element, 'pressOut', EventBuilder.Common.touch());\n}\n"],"mappings":";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f,MAAM,CAAC;EAClB,IAAAgB,oBAAa,EAAClB,OAAO,EAAE,SAAS,EAAEmB,0BAAY,CAACC,MAAM,CAACc,KAAK,CAAC,CAAC,CAAC;;EAE9D;;EAEA,MAAM,IAAAjB,WAAI,EAACf,MAAM,EAAEG,OAAO,CAACC,QAAQ,CAAC;EACpC,IAAAY,oBAAa,EAAClB,OAAO,EAAE,UAAU,EAAEmB,0BAAY,CAACC,MAAM,CAACc,KAAK,CAAC,CAAC,CAAC;AACjE","ignoreList":[]}
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.dispatchEvent = dispatchEvent;
|
|
7
7
|
var _act = _interopRequireDefault(require("../../act"));
|
|
8
|
+
var _componentTree = require("../../helpers/component-tree");
|
|
8
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
/**
|
|
10
11
|
* Basic dispatch event function used by User Event module.
|
|
@@ -14,6 +15,9 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
14
15
|
* @param event event payload(s)
|
|
15
16
|
*/
|
|
16
17
|
function dispatchEvent(element, eventName, ...event) {
|
|
18
|
+
if (!(0, _componentTree.isElementMounted)(element)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
17
21
|
const handler = getEventHandler(element, eventName);
|
|
18
22
|
if (!handler) {
|
|
19
23
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-event.js","names":["_act","_interopRequireDefault","require","e","__esModule","default","dispatchEvent","element","eventName","event","handler","getEventHandler","act","handleName","getEventHandlerName","handle","props","undefined","charAt","toUpperCase","slice"],"sources":["../../../src/user-event/utils/dispatch-event.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport act from '../../act';\n\n/**\n * Basic dispatch event function used by User Event module.\n *\n * @param element element trigger event on\n * @param eventName name of the event\n * @param event event payload(s)\n */\nexport function dispatchEvent(element: ReactTestInstance, eventName: string, ...event: unknown[]) {\n const handler = getEventHandler(element, eventName);\n if (!handler) {\n return;\n }\n\n // This will be called synchronously.\n void act(() => {\n handler(...event);\n });\n}\n\nfunction getEventHandler(element: ReactTestInstance, eventName: string) {\n const handleName = getEventHandlerName(eventName);\n const handle = element.props[handleName] as unknown;\n if (typeof handle !== 'function') {\n return undefined;\n }\n\n return handle;\n}\n\nfunction getEventHandlerName(eventName: string) {\n return `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;\n}\n"],"mappings":";;;;;;AACA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;
|
|
1
|
+
{"version":3,"file":"dispatch-event.js","names":["_act","_interopRequireDefault","require","_componentTree","e","__esModule","default","dispatchEvent","element","eventName","event","isElementMounted","handler","getEventHandler","act","handleName","getEventHandlerName","handle","props","undefined","charAt","toUpperCase","slice"],"sources":["../../../src/user-event/utils/dispatch-event.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport act from '../../act';\nimport { isElementMounted } from '../../helpers/component-tree';\n\n/**\n * Basic dispatch event function used by User Event module.\n *\n * @param element element trigger event on\n * @param eventName name of the event\n * @param event event payload(s)\n */\nexport function dispatchEvent(element: ReactTestInstance, eventName: string, ...event: unknown[]) {\n if (!isElementMounted(element)) {\n return;\n }\n\n const handler = getEventHandler(element, eventName);\n if (!handler) {\n return;\n }\n\n // This will be called synchronously.\n void act(() => {\n handler(...event);\n });\n}\n\nfunction getEventHandler(element: ReactTestInstance, eventName: string) {\n const handleName = getEventHandlerName(eventName);\n const handle = element.props[handleName] as unknown;\n if (typeof handle !== 'function') {\n return undefined;\n }\n\n return handle;\n}\n\nfunction getEventHandlerName(eventName: string) {\n return `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;\n}\n"],"mappings":";;;;;;AACA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAAgE,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,aAAaA,CAACC,OAA0B,EAAEC,SAAiB,EAAE,GAAGC,KAAgB,EAAE;EAChG,IAAI,CAAC,IAAAC,+BAAgB,EAACH,OAAO,CAAC,EAAE;IAC9B;EACF;EAEA,MAAMI,OAAO,GAAGC,eAAe,CAACL,OAAO,EAAEC,SAAS,CAAC;EACnD,IAAI,CAACG,OAAO,EAAE;IACZ;EACF;;EAEA;EACA,KAAK,IAAAE,YAAG,EAAC,MAAM;IACbF,OAAO,CAAC,GAAGF,KAAK,CAAC;EACnB,CAAC,CAAC;AACJ;AAEA,SAASG,eAAeA,CAACL,OAA0B,EAAEC,SAAiB,EAAE;EACtE,MAAMM,UAAU,GAAGC,mBAAmB,CAACP,SAAS,CAAC;EACjD,MAAMQ,MAAM,GAAGT,OAAO,CAACU,KAAK,CAACH,UAAU,CAAY;EACnD,IAAI,OAAOE,MAAM,KAAK,UAAU,EAAE;IAChC,OAAOE,SAAS;EAClB;EAEA,OAAOF,MAAM;AACf;AAEA,SAASD,mBAAmBA,CAACP,SAAiB,EAAE;EAC9C,OAAO,KAAKA,SAAS,CAACW,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAGZ,SAAS,CAACa,KAAK,CAAC,CAAC,CAAC,EAAE;AACtE","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/react-native",
|
|
3
|
-
"version": "13.0.0-alpha.
|
|
3
|
+
"version": "13.0.0-alpha.1",
|
|
4
4
|
"description": "Simple and complete React Native testing utilities that encourage good testing practices.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -65,32 +65,33 @@
|
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@babel/cli": "^7.25.9",
|
|
68
|
-
"@babel/core": "^7.
|
|
69
|
-
"@babel/plugin-transform-
|
|
70
|
-
"@babel/preset-env": "^7.
|
|
68
|
+
"@babel/core": "^7.26.0",
|
|
69
|
+
"@babel/plugin-transform-strict-mode": "^7.25.9",
|
|
70
|
+
"@babel/preset-env": "^7.26.0",
|
|
71
71
|
"@babel/preset-flow": "^7.25.9",
|
|
72
72
|
"@babel/preset-react": "^7.25.9",
|
|
73
|
-
"@babel/preset-typescript": "^7.
|
|
73
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
74
74
|
"@callstack/eslint-config": "^15.0.0",
|
|
75
|
-
"@
|
|
75
|
+
"@react-native/babel-preset": "^0.76.1",
|
|
76
|
+
"@release-it/conventional-changelog": "^9.0.2",
|
|
76
77
|
"@relmify/jest-serializer-strip-ansi": "^1.0.2",
|
|
77
78
|
"@types/jest": "^29.5.14",
|
|
78
79
|
"@types/react": "^18.3.12",
|
|
79
80
|
"@types/react-test-renderer": "^18.3.0",
|
|
80
81
|
"babel-jest": "^29.7.0",
|
|
82
|
+
"babel-plugin-module-resolver": "^5.0.2",
|
|
81
83
|
"del-cli": "^6.0.0",
|
|
82
84
|
"eslint": "^8.57.1",
|
|
83
|
-
"eslint-plugin-flowtype": "^8.0.3",
|
|
84
85
|
"eslint-plugin-prettier": "^4.2.1",
|
|
85
86
|
"flow-bin": "~0.170.0",
|
|
86
87
|
"jest": "^29.7.0",
|
|
87
88
|
"prettier": "^2.8.8",
|
|
88
89
|
"react": "18.3.1",
|
|
89
|
-
"react-native": "0.76.
|
|
90
|
+
"react-native": "0.76.1",
|
|
90
91
|
"react-test-renderer": "18.3.1",
|
|
91
92
|
"release-it": "^17.10.0",
|
|
92
93
|
"strip-ansi": "^6.0.1",
|
|
93
|
-
"typescript": "^5.
|
|
94
|
+
"typescript": "^5.6.3"
|
|
94
95
|
},
|
|
95
96
|
"publishConfig": {
|
|
96
97
|
"registry": "https://registry.npmjs.org"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DEFAULT_MIN_PRESS_DURATION = exports.DEFAULT_LONG_PRESS_DELAY_MS = void 0;
|
|
7
|
-
// These are constants defined in the React Native repo
|
|
8
|
-
|
|
9
|
-
// Used to define the delay before calling onPressOut after a press
|
|
10
|
-
const DEFAULT_MIN_PRESS_DURATION = exports.DEFAULT_MIN_PRESS_DURATION = 130;
|
|
11
|
-
|
|
12
|
-
// Default minimum press duration to trigger a long press
|
|
13
|
-
const DEFAULT_LONG_PRESS_DELAY_MS = exports.DEFAULT_LONG_PRESS_DELAY_MS = 500;
|
|
14
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["DEFAULT_MIN_PRESS_DURATION","exports","DEFAULT_LONG_PRESS_DELAY_MS"],"sources":["../../../src/user-event/press/constants.ts"],"sourcesContent":["// These are constants defined in the React Native repo\n\n// Used to define the delay before calling onPressOut after a press\nexport const DEFAULT_MIN_PRESS_DURATION = 130;\n\n// Default minimum press duration to trigger a long press\nexport const DEFAULT_LONG_PRESS_DELAY_MS = 500;\n"],"mappings":";;;;;;AAAA;;AAEA;AACO,MAAMA,0BAA0B,GAAAC,OAAA,CAAAD,0BAAA,GAAG,GAAG;;AAE7C;AACO,MAAME,2BAA2B,GAAAD,OAAA,CAAAC,2BAAA,GAAG,GAAG","ignoreList":[]}
|