@tamagui/react-native-web-lite 1.130.8 → 1.131.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/cjs/ActivityIndicator/__tests__/index-test.cjs +1 -1
  2. package/dist/cjs/ActivityIndicator/index.cjs +1 -1
  3. package/dist/cjs/AppRegistry/AppContainer.cjs +1 -1
  4. package/dist/cjs/AppRegistry/__tests__/index-test.cjs +1 -1
  5. package/dist/cjs/AppRegistry/__tests__/index-test.node.cjs +2 -2
  6. package/dist/cjs/AppRegistry/index.cjs +1 -1
  7. package/dist/cjs/AppRegistry/renderApplication.cjs +2 -2
  8. package/dist/cjs/AppState/__tests__/index-test.cjs +1 -1
  9. package/dist/cjs/DeviceEmitter.cjs +1 -1
  10. package/dist/cjs/DeviceInfo/index.cjs +1 -1
  11. package/dist/cjs/Dimensions/__tests__/index-test.cjs +1 -1
  12. package/dist/cjs/FlatList.cjs +4 -4
  13. package/dist/cjs/Image/index.cjs +3 -3
  14. package/dist/cjs/ImageBackground/__tests__/index-test.cjs +2 -2
  15. package/dist/cjs/ImageBackground/index.cjs +2 -2
  16. package/dist/cjs/InteractionManager/index.cjs +3 -3
  17. package/dist/cjs/KeyboardAvoidingView/index.cjs +1 -1
  18. package/dist/cjs/Linking/__tests__/index-test.cjs +1 -1
  19. package/dist/cjs/Modal/ModalAnimation.cjs +1 -1
  20. package/dist/cjs/Modal/ModalContent.cjs +1 -1
  21. package/dist/cjs/PanResponder/index.cjs +1 -1
  22. package/dist/cjs/PixelRatio/index.cjs +1 -1
  23. package/dist/cjs/Pressable/index.cjs +1 -1
  24. package/dist/cjs/RefreshControl/index.cjs +1 -1
  25. package/dist/cjs/SafeAreaView/index.cjs +1 -1
  26. package/dist/cjs/ScrollView/ScrollViewBase.cjs +1 -1
  27. package/dist/cjs/ScrollView/index.cjs +3 -3
  28. package/dist/cjs/SectionList.cjs +1 -1
  29. package/dist/cjs/Text/index.cjs +1 -1
  30. package/dist/cjs/TextInput/index.cjs +1 -1
  31. package/dist/cjs/TouchableNativeFeedback.cjs +1 -1
  32. package/dist/cjs/TouchableOpacity.cjs +1 -1
  33. package/dist/cjs/UnimplementedView.cjs +1 -1
  34. package/dist/cjs/View/index.cjs +1 -1
  35. package/dist/cjs/VirtualizedList.cjs +1 -1
  36. package/dist/cjs/createElement/__tests__/index-test.cjs +1 -1
  37. package/dist/cjs/index.cjs +47 -47
  38. package/dist/cjs/useColorScheme/index.cjs +1 -1
  39. package/dist/cjs/useWindowDimensions/index.cjs +1 -3
  40. package/dist/cjs/useWindowDimensions/index.js +0 -1
  41. package/dist/cjs/useWindowDimensions/index.js.map +1 -1
  42. package/dist/cjs/useWindowDimensions/index.native.js.map +1 -1
  43. package/dist/cjs/vendor/react-native/Animated/Animated.cjs +8 -8
  44. package/dist/cjs/vendor/react-native/Animated/AnimatedEvent.cjs +3 -4
  45. package/dist/cjs/vendor/react-native/Animated/AnimatedEvent.js +0 -1
  46. package/dist/cjs/vendor/react-native/Animated/AnimatedEvent.js.map +1 -1
  47. package/dist/cjs/vendor/react-native/Animated/AnimatedEvent.native.js +1 -1
  48. package/dist/cjs/vendor/react-native/Animated/AnimatedEvent.native.js.map +2 -2
  49. package/dist/cjs/vendor/react-native/Animated/AnimatedImplementation.cjs +19 -19
  50. package/dist/cjs/vendor/react-native/Animated/AnimatedMock.cjs +8 -8
  51. package/dist/cjs/vendor/react-native/Animated/Easing.cjs +1 -1
  52. package/dist/cjs/vendor/react-native/Animated/NativeAnimatedHelper.cjs +6 -6
  53. package/dist/cjs/vendor/react-native/Animated/NativeAnimatedModule.cjs +1 -1
  54. package/dist/cjs/vendor/react-native/Animated/NativeAnimatedTurboModule.cjs +1 -1
  55. package/dist/cjs/vendor/react-native/Animated/animations/Animation.cjs +1 -1
  56. package/dist/cjs/vendor/react-native/Animated/animations/DecayAnimation.cjs +2 -2
  57. package/dist/cjs/vendor/react-native/Animated/animations/SpringAnimation.cjs +3 -3
  58. package/dist/cjs/vendor/react-native/Animated/animations/TimingAnimation.cjs +3 -3
  59. package/dist/cjs/vendor/react-native/Animated/components/AnimatedFlatList.cjs +2 -2
  60. package/dist/cjs/vendor/react-native/Animated/components/AnimatedImage.cjs +2 -2
  61. package/dist/cjs/vendor/react-native/Animated/components/AnimatedScrollView.cjs +2 -2
  62. package/dist/cjs/vendor/react-native/Animated/components/AnimatedSectionList.cjs +2 -2
  63. package/dist/cjs/vendor/react-native/Animated/components/AnimatedText.cjs +2 -2
  64. package/dist/cjs/vendor/react-native/Animated/components/AnimatedView.cjs +2 -2
  65. package/dist/cjs/vendor/react-native/Animated/createAnimatedComponent.cjs +2 -2
  66. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedAddition.cjs +3 -3
  67. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedColor.cjs +3 -3
  68. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedDiffClamp.cjs +2 -2
  69. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedDivision.cjs +4 -4
  70. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedInterpolation.cjs +2 -2
  71. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedModulo.cjs +2 -2
  72. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedMultiplication.cjs +3 -3
  73. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedNode.cjs +1 -1
  74. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedProps.cjs +4 -4
  75. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedStyle.cjs +4 -4
  76. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedSubtraction.cjs +3 -3
  77. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedTracking.cjs +3 -3
  78. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedTransform.cjs +3 -3
  79. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedValue.cjs +3 -3
  80. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedValueXY.cjs +2 -2
  81. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedWithChildren.cjs +2 -2
  82. package/dist/cjs/vendor/react-native/Animated/useAnimatedProps.cjs +4 -4
  83. package/dist/cjs/vendor/react-native/EventEmitter/NativeEventEmitter.cjs +1 -1
  84. package/dist/cjs/vendor/react-native/EventEmitter/RCTDeviceEventEmitter.cjs +1 -1
  85. package/dist/cjs/vendor/react-native/FlatList/index.cjs +4 -4
  86. package/dist/cjs/vendor/react-native/JSEventLoopWatchdog/index.cjs +1 -1
  87. package/dist/cjs/vendor/react-native/SectionList/index.cjs +1 -1
  88. package/dist/cjs/vendor/react-native/VirtualizedList/VirtualizedListCellRenderer.cjs +2 -2
  89. package/dist/cjs/vendor/react-native/VirtualizedList/VirtualizedListContext.cjs +1 -1
  90. package/dist/cjs/vendor/react-native/VirtualizedList/index.cjs +9 -9
  91. package/dist/cjs/vendor/react-native/VirtualizedSectionList/index.cjs +1 -1
  92. package/dist/cjs/vendor/react-native/emitter/EventEmitter.cjs +1 -1
  93. package/dist/cjs/vendor/react-native/emitter/_EmitterSubscription.cjs +1 -1
  94. package/dist/cjs/vendor/react-native/emitter/_EventEmitter.cjs +2 -2
  95. package/dist/cjs/without-animated.cjs +48 -48
  96. package/dist/esm/useWindowDimensions/index.js.map +1 -1
  97. package/dist/esm/useWindowDimensions/index.mjs.map +1 -1
  98. package/dist/esm/useWindowDimensions/index.native.js.map +1 -1
  99. package/dist/esm/vendor/react-native/Animated/AnimatedEvent.js +0 -1
  100. package/dist/esm/vendor/react-native/Animated/AnimatedEvent.js.map +1 -1
  101. package/dist/esm/vendor/react-native/Animated/AnimatedEvent.mjs +0 -1
  102. package/dist/esm/vendor/react-native/Animated/AnimatedEvent.mjs.map +1 -1
  103. package/dist/esm/vendor/react-native/Animated/AnimatedEvent.native.js +1 -1
  104. package/dist/esm/vendor/react-native/Animated/AnimatedEvent.native.js.map +1 -1
  105. package/package.json +7 -7
  106. package/src/useWindowDimensions/index.tsx +12 -14
  107. package/src/vendor/react-native/Animated/AnimatedEvent.js +0 -1
  108. package/dist/cjs/TextInput/__tests__/index-test.cjs +0 -709
  109. package/dist/cjs/TextInput/__tests__/index-test.js +0 -422
  110. package/dist/cjs/TextInput/__tests__/index-test.js.map +0 -6
  111. package/dist/cjs/TextInput/__tests__/index-test.native.js +0 -532
  112. package/dist/cjs/TextInput/__tests__/index-test.native.js.map +0 -6
  113. package/dist/esm/TextInput/__tests__/index-test.js +0 -408
  114. package/dist/esm/TextInput/__tests__/index-test.js.map +0 -6
  115. package/dist/esm/TextInput/__tests__/index-test.mjs +0 -688
  116. package/dist/esm/TextInput/__tests__/index-test.mjs.map +0 -1
  117. package/dist/esm/TextInput/__tests__/index-test.native.js +0 -703
  118. package/dist/esm/TextInput/__tests__/index-test.native.js.map +0 -1
@@ -1,709 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
9
- get: () => from[key],
10
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
- });
12
- return to;
13
- };
14
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
15
- // If the importer is in node compatibility mode or this is not an ESM
16
- // file that has been converted to a CommonJS file using a Babel-
17
- // compatible transform (i.e. "__esModule" has not been set), then set
18
- // "default" to the CommonJS "module.exports" for node compatibility.
19
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
- value: mod,
21
- enumerable: !0
22
- }) : target, mod));
23
- var import_react = require("@testing-library/react"),
24
- import_dom_event_testing_library = require("dom-event-testing-library"),
25
- import_react2 = __toESM(require("react")),
26
- import_test_utils = require("react-dom/test-utils"),
27
- import__ = __toESM(require("../index.cjs")),
28
- import_jsx_runtime = require("react/jsx-runtime");
29
- function findInput(container) {
30
- return container.querySelector("input");
31
- }
32
- function findTextArea(container) {
33
- return container.querySelector("textarea");
34
- }
35
- const testIfDocumentIsFocused = (message, fn) => {
36
- document.hasFocus && document.hasFocus() ? test(message, fn) : test.skip(`${message} \u2013 document is not focused`, () => {});
37
- };
38
- function createEvent(type, data = {}) {
39
- const event = document.createEvent("CustomEvent");
40
- return event.initCustomEvent(type, !0, !0), data != null && Object.keys(data).forEach(key => {
41
- const value = data[key];
42
- key === "timeStamp" && !value || Object.defineProperty(event, key, {
43
- value
44
- });
45
- }), event;
46
- }
47
- function createKeyboardEvent(type, {
48
- altKey = !1,
49
- ctrlKey = !1,
50
- isComposing = !1,
51
- key = "",
52
- keyCode = 0,
53
- metaKey = !1,
54
- preventDefault = () => {},
55
- shiftKey = !1
56
- } = {}) {
57
- return createEvent(type, {
58
- altKey,
59
- ctrlKey,
60
- isComposing,
61
- key,
62
- keyCode,
63
- metaKey,
64
- preventDefault,
65
- shiftKey
66
- });
67
- }
68
- function keydown(payload) {
69
- return createKeyboardEvent("keydown", payload);
70
- }
71
- describe("components/TextInput", () => {
72
- describe('prop "autoComplete"', () => {
73
- test('value "on"', () => {
74
- const {
75
- container
76
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {})),
77
- input = findInput(container);
78
- expect(input.getAttribute("autoComplete")).toEqual("on");
79
- }), test('value "off"', () => {
80
- const {
81
- container
82
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
83
- autoComplete: "off"
84
- })),
85
- input = findInput(container);
86
- expect(input.getAttribute("autoComplete")).toEqual("off");
87
- }), test("autoCompleteType fallback", () => {
88
- const {
89
- container
90
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
91
- autoCompleteType: "off"
92
- })),
93
- input = findInput(container);
94
- expect(input.getAttribute("autoComplete")).toEqual("off");
95
- });
96
- }), describe('prop "autoFocus"', () => {
97
- test('value "false"', () => {
98
- const {
99
- container
100
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {})),
101
- input = findInput(container);
102
- expect(document.activeElement).not.toBe(input);
103
- }), test('value "true"', () => {
104
- const {
105
- container
106
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
107
- autoFocus: !0
108
- })),
109
- input = findInput(container);
110
- expect(document.activeElement).toBe(input);
111
- });
112
- }), describe('prop "clearTextOnFocus"', () => {
113
- const defaultValue = "defaultValue";
114
- testIfDocumentIsFocused('value "false"', () => {
115
- const {
116
- container
117
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
118
- defaultValue
119
- })),
120
- input = findInput(container);
121
- input.focus(), expect(input.node.value).toEqual(defaultValue);
122
- }), testIfDocumentIsFocused('value "true"', () => {
123
- const {
124
- container
125
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
126
- clearTextOnFocus: !0,
127
- defaultValue
128
- })),
129
- input = findInput(container);
130
- input.focus(), expect(input.node.value).toEqual("");
131
- });
132
- }), test('prop "defaultValue"', () => {
133
- const defaultValue = "defaultValue",
134
- {
135
- container
136
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
137
- defaultValue
138
- })),
139
- input = findInput(container);
140
- expect(input.value).toEqual(defaultValue);
141
- }), describe('prop "disabled"', () => {
142
- test('value "false"', () => {
143
- const {
144
- container
145
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {})),
146
- input = findInput(container);
147
- expect(input.disabled).toEqual(!1);
148
- }), test('value "true"', () => {
149
- const {
150
- container
151
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
152
- disabled: !0
153
- })),
154
- input = findInput(container);
155
- expect(input.disabled).toEqual(!0);
156
- });
157
- }), describe('prop "editable"', () => {
158
- test('value "true"', () => {
159
- const {
160
- container
161
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {})),
162
- input = findInput(container);
163
- expect(input.readOnly).toEqual(!1);
164
- }), test('value "false"', () => {
165
- const {
166
- container
167
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
168
- editable: !1
169
- })),
170
- input = findInput(container);
171
- expect(input.readOnly).toEqual(!0);
172
- });
173
- }), describe('prop "keyboardType"', () => {
174
- test("default value", () => {
175
- const {
176
- container
177
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
178
- keyboardType: "default"
179
- })),
180
- input = findInput(container);
181
- expect(input.type).toEqual("text");
182
- }), test('value "email-address"', () => {
183
- const {
184
- container
185
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
186
- keyboardType: "email-address"
187
- })),
188
- input = findInput(container);
189
- expect(input.type).toEqual("email");
190
- }), test('value "decimal-pad"', () => {
191
- const {
192
- container
193
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
194
- keyboardType: "decimal-pad"
195
- })),
196
- input = findInput(container);
197
- expect(input.inputMode).toEqual("decimal");
198
- }), test('value "number-pad"', () => {
199
- const {
200
- container
201
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
202
- keyboardType: "number-pad"
203
- })),
204
- input = findInput(container);
205
- expect(input.inputMode).toEqual("numeric");
206
- }), test('value "numeric"', () => {
207
- const {
208
- container
209
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
210
- keyboardType: "numeric"
211
- })),
212
- input = findInput(container);
213
- expect(input.inputMode).toEqual("numeric");
214
- }), test('value "phone-pad"', () => {
215
- const {
216
- container
217
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
218
- keyboardType: "phone-pad"
219
- })),
220
- input = findInput(container);
221
- expect(input.type).toEqual("tel");
222
- }), test('value "url"', () => {
223
- const {
224
- container
225
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
226
- keyboardType: "url"
227
- })),
228
- input = findInput(container);
229
- expect(input.type).toEqual("url");
230
- });
231
- }), test('prop "maxLength"', () => {
232
- let {
233
- container
234
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {})),
235
- input = findInput(container);
236
- expect(input.getAttribute("maxLength")).toEqual(null), {
237
- container
238
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
239
- maxLength: 10
240
- })), input = findInput(container), expect(input.getAttribute("maxLength")).toEqual("10");
241
- }), describe('prop "multiline"', () => {
242
- test('value "false"', () => {
243
- const {
244
- container
245
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {})),
246
- input = findInput(container);
247
- expect(input).toBeDefined();
248
- }), test('value "true"', () => {
249
- const {
250
- container
251
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
252
- multiline: !0
253
- })),
254
- textarea = findTextArea(container);
255
- expect(textarea).toBeDefined();
256
- });
257
- }), describe('prop "numberOfLines"', () => {
258
- test('without "multiline"', () => {
259
- const {
260
- container
261
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
262
- numberOfLines: 2
263
- })),
264
- input = findInput(container),
265
- textarea = findTextArea(container);
266
- expect(input).toBeDefined(), expect(textarea).toBeNull();
267
- }), test('with "multiline"', () => {
268
- const {
269
- container
270
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
271
- multiline: !0,
272
- numberOfLines: 3
273
- })),
274
- textarea = findTextArea(container);
275
- expect(textarea.getAttribute("rows")).toEqual("3");
276
- });
277
- }), test('prop "onBlur"', () => {
278
- const onBlur = jest.fn(),
279
- ref = import_react2.default.createRef();
280
- (0, import_test_utils.act)(() => {
281
- (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
282
- onBlur,
283
- ref
284
- }));
285
- });
286
- const target = (0, import_dom_event_testing_library.createEventTarget)(ref.current),
287
- body = (0, import_dom_event_testing_library.createEventTarget)(document.body);
288
- (0, import_test_utils.act)(() => {
289
- target.focus(), body.focus({
290
- relatedTarget: target.node
291
- });
292
- }), expect(onBlur).toHaveBeenCalledTimes(1), expect(import__.default.State.currentlyFocusedField()).toBe(null);
293
- }), test.skip('prop "onChange"', () => {
294
- const onChange = jest.fn(),
295
- {
296
- container
297
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
298
- onChange
299
- }));
300
- findInput(container).dispatchEvent(new window.Event("change", {
301
- bubbles: !0
302
- })), expect(onChange).toHaveBeenCalledTimes(1);
303
- }), test.skip('prop "onChangeText"', () => {
304
- const onChangeText = jest.fn(),
305
- {
306
- container
307
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
308
- onChangeText
309
- })),
310
- input = findInput(container);
311
- input.dispatchEvent(keydown({
312
- key: "a"
313
- })), input.dispatchEvent(new window.Event("change", {
314
- bubbles: !0
315
- })), expect(onChangeText).toHaveBeenCalledTimes(1), expect(onChangeText).toBeCalledWith("a");
316
- }), test('prop "onFocus"', () => {
317
- const onFocus = jest.fn(),
318
- ref = import_react2.default.createRef();
319
- (0, import_test_utils.act)(() => {
320
- (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
321
- onFocus,
322
- ref
323
- }));
324
- });
325
- const target = (0, import_dom_event_testing_library.createEventTarget)(ref.current);
326
- (0, import_test_utils.act)(() => {
327
- target.focus();
328
- }), expect(onFocus).toHaveBeenCalledTimes(1), target.node.focus(), expect(import__.default.State.currentlyFocusedField()).toBe(target.node);
329
- }), describe('prop "onKeyPress"', () => {
330
- test("arrow key", () => {
331
- const onKeyPress = jest.fn(e => {
332
- e.persist();
333
- }),
334
- {
335
- container
336
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
337
- onKeyPress
338
- }));
339
- findInput(container).dispatchEvent(keydown({
340
- key: "ArrowLeft"
341
- })), expect(onKeyPress).toHaveBeenCalledTimes(1), expect(onKeyPress).toBeCalledWith(expect.objectContaining({
342
- nativeEvent: expect.objectContaining({
343
- altKey: !1,
344
- ctrlKey: !1,
345
- key: "ArrowLeft",
346
- metaKey: !1,
347
- shiftKey: !1,
348
- target: expect.anything()
349
- })
350
- }));
351
- }), test("backspace key", () => {
352
- const onKeyPress = jest.fn(e => {
353
- e.persist();
354
- }),
355
- {
356
- container
357
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
358
- onKeyPress
359
- }));
360
- findInput(container).dispatchEvent(keydown({
361
- key: "Backspace"
362
- })), expect(onKeyPress).toHaveBeenCalledTimes(1), expect(onKeyPress).toBeCalledWith(expect.objectContaining({
363
- nativeEvent: expect.objectContaining({
364
- altKey: !1,
365
- ctrlKey: !1,
366
- key: "Backspace",
367
- metaKey: !1,
368
- shiftKey: !1,
369
- target: expect.anything()
370
- })
371
- }));
372
- }), test("enter key", () => {
373
- const onKeyPress = jest.fn(e => {
374
- e.persist();
375
- }),
376
- {
377
- container
378
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
379
- onKeyPress
380
- }));
381
- findInput(container).dispatchEvent(keydown({
382
- key: "Enter"
383
- })), expect(onKeyPress).toHaveBeenCalledTimes(1), expect(onKeyPress).toBeCalledWith(expect.objectContaining({
384
- nativeEvent: expect.objectContaining({
385
- altKey: !1,
386
- ctrlKey: !1,
387
- key: "Enter",
388
- metaKey: !1,
389
- shiftKey: !1,
390
- target: expect.anything()
391
- })
392
- }));
393
- }), test("escape key", () => {
394
- const onKeyPress = jest.fn(e => {
395
- e.persist();
396
- }),
397
- {
398
- container
399
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
400
- onKeyPress
401
- }));
402
- findInput(container).dispatchEvent(keydown({
403
- key: "Escape"
404
- })), expect(onKeyPress).toHaveBeenCalledTimes(1), expect(onKeyPress).toBeCalledWith(expect.objectContaining({
405
- nativeEvent: expect.objectContaining({
406
- altKey: !1,
407
- ctrlKey: !1,
408
- key: "Escape",
409
- metaKey: !1,
410
- shiftKey: !1,
411
- target: expect.anything()
412
- })
413
- }));
414
- }), test("space key", () => {
415
- const onKeyPress = jest.fn(e => {
416
- e.persist();
417
- }),
418
- {
419
- container
420
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
421
- onKeyPress
422
- }));
423
- findInput(container).dispatchEvent(keydown({
424
- key: " "
425
- })), expect(onKeyPress).toHaveBeenCalledTimes(1), expect(onKeyPress).toBeCalledWith(expect.objectContaining({
426
- nativeEvent: expect.objectContaining({
427
- altKey: !1,
428
- ctrlKey: !1,
429
- key: " ",
430
- metaKey: !1,
431
- shiftKey: !1,
432
- target: expect.anything()
433
- })
434
- }));
435
- }), test("tab key", () => {
436
- const onKeyPress = jest.fn(e => {
437
- e.persist();
438
- }),
439
- {
440
- container
441
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
442
- onKeyPress
443
- }));
444
- findInput(container).dispatchEvent(keydown({
445
- key: "Tab"
446
- })), expect(onKeyPress).toHaveBeenCalledTimes(1), expect(onKeyPress).toBeCalledWith(expect.objectContaining({
447
- nativeEvent: expect.objectContaining({
448
- altKey: !1,
449
- ctrlKey: !1,
450
- key: "Tab",
451
- metaKey: !1,
452
- shiftKey: !1,
453
- target: expect.anything()
454
- })
455
- }));
456
- }), test("text key", () => {
457
- const onKeyPress = jest.fn(e => {
458
- e.persist();
459
- }),
460
- {
461
- container
462
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
463
- onKeyPress
464
- }));
465
- findInput(container).dispatchEvent(keydown({
466
- key: "a"
467
- })), expect(onKeyPress).toHaveBeenCalledTimes(1), expect(onKeyPress).toBeCalledWith(expect.objectContaining({
468
- nativeEvent: expect.objectContaining({
469
- altKey: !1,
470
- ctrlKey: !1,
471
- key: "a",
472
- metaKey: !1,
473
- shiftKey: !1,
474
- target: expect.anything()
475
- })
476
- }));
477
- }), test("modifier keys are included", () => {
478
- const onKeyPress = jest.fn(e => {
479
- e.persist();
480
- }),
481
- {
482
- container
483
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
484
- onKeyPress
485
- }));
486
- findInput(container).dispatchEvent(keydown({
487
- altKey: !0,
488
- ctrlKey: !0,
489
- metaKey: !0,
490
- shiftKey: !0,
491
- key: " "
492
- })), expect(onKeyPress).toHaveBeenCalledTimes(1), expect(onKeyPress).toBeCalledWith(expect.objectContaining({
493
- nativeEvent: expect.objectContaining({
494
- altKey: !0,
495
- ctrlKey: !0,
496
- key: " ",
497
- metaKey: !0,
498
- shiftKey: !0,
499
- target: expect.anything()
500
- })
501
- }));
502
- }), test('meta key + Enter calls "onKeyPress"', () => {
503
- const onKeyPress = jest.fn(e => {
504
- e.persist();
505
- }),
506
- {
507
- container
508
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
509
- onKeyPress
510
- }));
511
- findInput(container).dispatchEvent(keydown({
512
- metaKey: !0,
513
- key: "Enter"
514
- })), expect(onKeyPress).toHaveBeenCalledTimes(1);
515
- });
516
- }), describe('prop "onSelectionChange"', () => {
517
- test("is called on select", () => {
518
- const {
519
- container
520
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
521
- defaultValue: "12345",
522
- onSelectionChange
523
- })),
524
- input = findInput(container);
525
- input.selectionStart = 0, input.selectionEnd = 3, input.dispatchEvent(new window.Event("select", {}));
526
- function onSelectionChange(e) {
527
- expect(e.nativeEvent.selection.end).toEqual(3), expect(e.nativeEvent.selection.start).toEqual(0);
528
- }
529
- }), test.skip("is called on change", () => {
530
- const onSelectionChange = jest.fn(),
531
- {
532
- container
533
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
534
- onSelectionChange
535
- }));
536
- findInput(container).dispatchEvent(new window.Event("input", {
537
- bubbles: !0
538
- })), expect(onSelectionChange).toHaveBeenCalledTimes(1);
539
- });
540
- }), describe('prop "onSubmitEditing"', () => {
541
- test("single-line input", done => {
542
- const {
543
- container
544
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
545
- defaultValue: "12345",
546
- onSubmitEditing
547
- }));
548
- findInput(container).dispatchEvent(keydown({
549
- key: "Enter"
550
- }));
551
- function onSubmitEditing(e) {
552
- expect(e.nativeEvent.target).toBeDefined(), expect(e.nativeEvent.text).toBe("12345"), done();
553
- }
554
- }), test("single-line input while composing", () => {
555
- const onSubmitEditing = jest.fn(),
556
- {
557
- container
558
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
559
- defaultValue: "12345",
560
- onSubmitEditing
561
- })),
562
- input = findInput(container);
563
- input.dispatchEvent(keydown({
564
- key: "Enter",
565
- isComposing: !0,
566
- keyCode: 13
567
- })), input.dispatchEvent(keydown({
568
- key: "Enter",
569
- isComposing: !1,
570
- keyCode: 229
571
- })), expect(onSubmitEditing).not.toHaveBeenCalled();
572
- }), test("multi-line input", () => {
573
- const onSubmitEditing = jest.fn(),
574
- {
575
- container
576
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
577
- defaultValue: "12345",
578
- multiline: !0,
579
- onSubmitEditing
580
- }));
581
- findTextArea(container).dispatchEvent(keydown({
582
- key: "Enter"
583
- })), expect(onSubmitEditing).not.toHaveBeenCalled();
584
- }), test('multi-line input with "blurOnSubmit" triggers "onSubmitEditing"', () => {
585
- const onSubmitEditing = jest.fn(),
586
- preventDefault = jest.fn(),
587
- {
588
- container
589
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
590
- blurOnSubmit: !0,
591
- defaultValue: "12345",
592
- multiline: !0,
593
- onSubmitEditing
594
- })),
595
- textarea = findTextArea(container);
596
- textarea.dispatchEvent(keydown({
597
- key: "Enter",
598
- preventDefault,
599
- shiftKey: !0
600
- })), expect(onSubmitEditing).not.toHaveBeenCalledWith(expect.objectContaining({
601
- shiftKey: !0
602
- })), expect(preventDefault).not.toHaveBeenCalled(), textarea.dispatchEvent(keydown({
603
- key: "Enter",
604
- preventDefault
605
- })), expect(onSubmitEditing).toHaveBeenCalledTimes(1), expect(preventDefault).toHaveBeenCalledTimes(1);
606
- });
607
- }), test('prop "returnKeyType"', () => {
608
- const returnKeyType = "previous",
609
- {
610
- container
611
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
612
- returnKeyType
613
- })),
614
- input = findInput(container);
615
- expect(input.getAttribute("enterkeyhint")).toEqual(returnKeyType);
616
- }), test('prop "secureTextEntry"', () => {
617
- let {
618
- container
619
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
620
- secureTextEntry: !0
621
- }));
622
- const input = findInput(container);
623
- expect(input.getAttribute("type")).toEqual("password"), {
624
- container
625
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
626
- multiline: !0,
627
- secureTextEntry: !0
628
- }));
629
- const textarea = findTextArea(container);
630
- expect(textarea.getAttribute("type")).toEqual(null);
631
- }), describe('prop "selectTextOnFocus"', () => {
632
- testIfDocumentIsFocused('value "false"', () => {
633
- const {
634
- container
635
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
636
- defaultValue: "text"
637
- })),
638
- input = findInput(container);
639
- input.focus(), expect(input.selectionEnd).toEqual(4), expect(input.selectionStart).toEqual(4);
640
- });
641
- }), describe('prop "selection"', () => {
642
- test("set cursor location", () => {
643
- const cursorLocation = {
644
- start: 3,
645
- end: 3
646
- },
647
- {
648
- container: defaultContainer
649
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
650
- defaultValue: "12345"
651
- })),
652
- inputDefaultSelection = findInput(defaultContainer);
653
- expect(inputDefaultSelection.selectionStart).toEqual(5), expect(inputDefaultSelection.selectionEnd).toEqual(5);
654
- const {
655
- container: customContainer
656
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
657
- defaultValue: "12345",
658
- selection: cursorLocation
659
- })),
660
- inputCustomSelection = findInput(customContainer);
661
- expect(inputCustomSelection.selectionStart).toEqual(cursorLocation.start), expect(inputCustomSelection.selectionEnd).toEqual(cursorLocation.end);
662
- });
663
- }), describe('prop "spellCheck"', () => {
664
- test("default value", () => {
665
- const {
666
- container
667
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {})),
668
- input = findInput(container);
669
- expect(input.getAttribute("spellCheck")).toEqual("true");
670
- }), test('inherit from "autoCorrect"', () => {
671
- const {
672
- container
673
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
674
- autoCorrect: !1
675
- })),
676
- input = findInput(container);
677
- expect(input.getAttribute("spellCheck")).toEqual("false");
678
- }), test('value "false"', () => {
679
- const {
680
- container
681
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
682
- spellCheck: !1
683
- })),
684
- input = findInput(container);
685
- expect(input.getAttribute("spellCheck")).toEqual("false");
686
- });
687
- }), test('prop "value"', () => {
688
- const value = "value",
689
- {
690
- container
691
- } = (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
692
- value
693
- })),
694
- input = findInput(container);
695
- expect(input.value).toEqual(value);
696
- }), describe("imperative methods", () => {
697
- test("node.clear()", () => {
698
- const ref = import_react2.default.createRef();
699
- (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
700
- ref
701
- })), expect(typeof ref.current.clear).toBe("function");
702
- }), test("node.isFocused()", () => {
703
- const ref = import_react2.default.createRef();
704
- (0, import_react.render)(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import__.default, {
705
- ref
706
- })), expect(typeof ref.current.isFocused).toBe("function");
707
- });
708
- });
709
- });