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