@terreno/ui 0.31.0 → 56.0.0-beta.2

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 (126) hide show
  1. package/dist/ActionSheet.d.ts +1 -1
  2. package/dist/Avatar.js +1 -4
  3. package/dist/Avatar.js.map +1 -1
  4. package/dist/Box.js +45 -9
  5. package/dist/Box.js.map +1 -1
  6. package/dist/Common.d.ts +21 -0
  7. package/dist/Common.js.map +1 -1
  8. package/dist/ConflictSheet.d.ts +53 -0
  9. package/dist/ConflictSheet.js +132 -0
  10. package/dist/ConflictSheet.js.map +1 -0
  11. package/dist/DateTimeActionSheet.d.ts +2 -1
  12. package/dist/DateTimeField.js +5 -21
  13. package/dist/DateTimeField.js.map +1 -1
  14. package/dist/DecimalRangeActionSheet.d.ts +1 -1
  15. package/dist/EmojiSelector.d.ts +1 -1
  16. package/dist/ErrorPage.d.ts +1 -1
  17. package/dist/HeightActionSheet.d.ts +1 -1
  18. package/dist/Hyperlink.d.ts +2 -1
  19. package/dist/Hyperlink.js +2 -1
  20. package/dist/Hyperlink.js.map +1 -1
  21. package/dist/Image.d.ts +1 -1
  22. package/dist/ImageBackground.d.ts +1 -1
  23. package/dist/MobileAddressAutoComplete.d.ts +1 -1
  24. package/dist/NumberPickerActionSheet.d.ts +1 -1
  25. package/dist/Page.d.ts +5 -4
  26. package/dist/Page.js +0 -2
  27. package/dist/Page.js.map +1 -1
  28. package/dist/PickerSelect.d.ts +1 -1
  29. package/dist/SidebarNavigation.js +1 -1
  30. package/dist/SidebarNavigation.js.map +1 -1
  31. package/dist/SidebarNavigation.native.js +1 -1
  32. package/dist/SidebarNavigation.native.js.map +1 -1
  33. package/dist/SplitPage.d.ts +1 -1
  34. package/dist/SplitPage.js +1 -4
  35. package/dist/SplitPage.js.map +1 -1
  36. package/dist/SplitPage.native.d.ts +1 -1
  37. package/dist/SyncStatusBanner.d.ts +46 -0
  38. package/dist/SyncStatusBanner.js +29 -0
  39. package/dist/SyncStatusBanner.js.map +1 -0
  40. package/dist/Theme.d.ts +1 -1
  41. package/dist/Toast.d.ts +9 -1
  42. package/dist/Toast.js +20 -7
  43. package/dist/Toast.js.map +1 -1
  44. package/dist/ToastNotifications.js +23 -1
  45. package/dist/ToastNotifications.js.map +1 -1
  46. package/dist/UnifiedAddressAutoComplete.d.ts +1 -1
  47. package/dist/Unifier.js +1 -1
  48. package/dist/Unifier.js.map +1 -1
  49. package/dist/conflictFieldDiff.d.ts +14 -0
  50. package/dist/conflictFieldDiff.js +62 -0
  51. package/dist/conflictFieldDiff.js.map +1 -0
  52. package/dist/icons/OfflineIcon.d.ts +1 -1
  53. package/dist/icons/OnlineIcon.d.ts +1 -1
  54. package/dist/icons/OutOfficeIcon.d.ts +1 -1
  55. package/dist/index.d.ts +5 -2
  56. package/dist/index.js +5 -2
  57. package/dist/index.js.map +1 -1
  58. package/dist/pdfHtmlTemplate.d.ts +30 -0
  59. package/dist/pdfHtmlTemplate.js +170 -0
  60. package/dist/pdfHtmlTemplate.js.map +1 -0
  61. package/dist/table/TableTitle.js +1 -3
  62. package/dist/table/TableTitle.js.map +1 -1
  63. package/dist/useAppLaunchOrForeground.d.ts +9 -0
  64. package/dist/useAppLaunchOrForeground.js +27 -0
  65. package/dist/useAppLaunchOrForeground.js.map +1 -0
  66. package/package.json +44 -37
  67. package/src/ActionSheet.test.tsx +123 -136
  68. package/src/Box.test.tsx +68 -30
  69. package/src/Box.tsx +46 -7
  70. package/src/Common.ts +21 -3
  71. package/src/ConflictSheet.test.tsx +461 -0
  72. package/src/ConflictSheet.tsx +399 -0
  73. package/src/ConsentFormScreen.test.tsx +22 -0
  74. package/src/DateTimeField.test.tsx +14 -0
  75. package/src/DateTimeField.tsx +5 -19
  76. package/src/Hyperlink.tsx +1 -1
  77. package/src/Page.tsx +2 -3
  78. package/src/SidebarNavigation.native.tsx +1 -1
  79. package/src/SidebarNavigation.tsx +1 -1
  80. package/src/SyncStatusBanner.test.tsx +204 -0
  81. package/src/SyncStatusBanner.tsx +148 -0
  82. package/src/TerrenoProvider.test.tsx +3 -4
  83. package/src/Toast.test.tsx +60 -0
  84. package/src/Toast.tsx +46 -1
  85. package/src/ToastNotifications.test.tsx +82 -0
  86. package/src/ToastNotifications.tsx +25 -1
  87. package/src/Unifier.ts +1 -1
  88. package/src/WebDropdownMenu.test.tsx +128 -0
  89. package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +0 -3
  90. package/src/__snapshots__/Body.test.tsx.snap +0 -16
  91. package/src/__snapshots__/Box.test.tsx.snap +4 -13
  92. package/src/__snapshots__/Page.test.tsx.snap +0 -84
  93. package/src/__snapshots__/SplitPage.test.tsx.snap +24 -120
  94. package/src/__snapshots__/TapToEdit.test.tsx.snap +5 -16
  95. package/src/__snapshots__/Toast.test.tsx.snap +4 -2
  96. package/src/bunSetup.ts +19 -0
  97. package/src/conflictFieldDiff.test.ts +26 -0
  98. package/src/conflictFieldDiff.ts +78 -0
  99. package/src/index.tsx +5 -2
  100. package/src/login/__snapshots__/LoginScreen.test.tsx.snap +0 -9
  101. package/src/pdfHtmlTemplate.ts +219 -0
  102. package/src/signUp/__snapshots__/OAuthButtons.test.tsx.snap +0 -1
  103. package/src/signUp/__snapshots__/PasswordRequirements.test.tsx.snap +2 -16
  104. package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +1 -17
  105. package/src/signUp/__snapshots__/Swiper.test.tsx.snap +0 -1
  106. package/src/table/__snapshots__/Table.test.tsx.snap +22 -87
  107. package/src/table/__snapshots__/TableHeader.test.tsx.snap +10 -50
  108. package/src/table/__snapshots__/TableHeaderCell.test.tsx.snap +10 -84
  109. package/src/table/__snapshots__/TableRow.test.tsx.snap +12 -77
  110. package/src/useAppLaunchOrForeground.test.tsx +54 -0
  111. package/src/useAppLaunchOrForeground.ts +30 -0
  112. package/dist/ConsentHistory.d.ts +0 -9
  113. package/dist/ConsentHistory.js +0 -70
  114. package/dist/ConsentHistory.js.map +0 -1
  115. package/dist/generateConsentHistoryPdf.d.ts +0 -2
  116. package/dist/generateConsentHistoryPdf.js +0 -185
  117. package/dist/generateConsentHistoryPdf.js.map +0 -1
  118. package/dist/useConsentHistory.d.ts +0 -63
  119. package/dist/useConsentHistory.js +0 -40
  120. package/dist/useConsentHistory.js.map +0 -1
  121. package/src/ConsentHistory.test.tsx +0 -224
  122. package/src/ConsentHistory.tsx +0 -249
  123. package/src/generateConsentHistoryPdf.test.ts +0 -253
  124. package/src/generateConsentHistoryPdf.ts +0 -211
  125. package/src/useConsentHistory.test.ts +0 -106
  126. package/src/useConsentHistory.ts +0 -94
@@ -1,9 +1,15 @@
1
- // noExplicitAny: test mock typing
2
- // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
3
1
  import {afterAll, afterEach, beforeAll, describe, expect, it, type Mock, mock} from "bun:test";
4
2
  import {act, render} from "@testing-library/react-native";
5
3
  import {createRef, type RefObject} from "react";
6
- import {Animated, Dimensions, type KeyboardEvent, Text} from "react-native";
4
+ import {
5
+ Animated,
6
+ Dimensions,
7
+ type KeyboardEvent,
8
+ type LayoutChangeEvent,
9
+ type NativeScrollEvent,
10
+ type NativeSyntheticEvent,
11
+ Text,
12
+ } from "react-native";
7
13
 
8
14
  import {
9
15
  ActionSheet,
@@ -14,11 +20,32 @@ import {
14
20
  } from "./ActionSheet";
15
21
  import {ThemeProvider} from "./Theme";
16
22
 
23
+ const scrollEvent = (y: number): NativeSyntheticEvent<NativeScrollEvent> =>
24
+ ({nativeEvent: {contentOffset: {x: 0, y}}}) as NativeSyntheticEvent<NativeScrollEvent>;
25
+
26
+ const layoutEvent = (height: number, width: number): LayoutChangeEvent =>
27
+ ({nativeEvent: {layout: {height, width, x: 0, y: 0}}}) as LayoutChangeEvent;
28
+
29
+ /** Stands in for the SafeAreaView ref, whose measureInWindow reports `height`. */
30
+ const measuringSafeAreaRef = (
31
+ height: number
32
+ ): React.RefObject<{
33
+ measureInWindow: (
34
+ callback: (x: number, y: number, width: number, height: number) => void
35
+ ) => void;
36
+ }> => ({
37
+ current: {
38
+ measureInWindow: (callback) => {
39
+ callback(0, 0, 100, height);
40
+ },
41
+ },
42
+ });
43
+
17
44
  beforeAll(() => {
18
- (global as any).requestAnimationFrame = (callback: FrameRequestCallback) => {
45
+ globalThis.requestAnimationFrame = (callback: FrameRequestCallback) => {
19
46
  return setTimeout(() => callback(Date.now()), 0) as unknown as number;
20
47
  };
21
- (global as any).cancelAnimationFrame = (id: number) => {
48
+ globalThis.cancelAnimationFrame = (id: number) => {
22
49
  clearTimeout(id);
23
50
  };
24
51
  });
@@ -232,7 +259,7 @@ describe("ActionSheet", () => {
232
259
  act(() => {
233
260
  ref.current?.show();
234
261
  });
235
- expect(() => (ref.current as any)._onRequestClose()).not.toThrow();
262
+ expect(() => ref.current!._onRequestClose()).not.toThrow();
236
263
  });
237
264
 
238
265
  it("_onTouchBackdrop hides modal when closeOnTouchBackdrop is true", () => {
@@ -247,7 +274,7 @@ describe("ActionSheet", () => {
247
274
  act(() => {
248
275
  ref.current?.show();
249
276
  });
250
- expect(() => (ref.current as any)._onTouchBackdrop()).not.toThrow();
277
+ expect(() => ref.current!._onTouchBackdrop()).not.toThrow();
251
278
  });
252
279
 
253
280
  it("_onRequestClose does not hide when closeOnPressBack is false", () => {
@@ -262,7 +289,7 @@ describe("ActionSheet", () => {
262
289
  act(() => {
263
290
  ref.current?.show();
264
291
  });
265
- (ref.current as any)._onRequestClose();
292
+ ref.current!._onRequestClose();
266
293
  expect(ref.current?.state.modalVisible).toBe(true);
267
294
  });
268
295
 
@@ -278,7 +305,7 @@ describe("ActionSheet", () => {
278
305
  act(() => {
279
306
  ref.current?.show();
280
307
  });
281
- (ref.current as any)._onTouchBackdrop();
308
+ ref.current!._onTouchBackdrop();
282
309
  expect(ref.current?.state.modalVisible).toBe(true);
283
310
  });
284
311
 
@@ -291,11 +318,7 @@ describe("ActionSheet", () => {
291
318
  </ActionSheet>
292
319
  </ThemeProvider>
293
320
  );
294
- expect(() =>
295
- (ref.current as any)._onScroll({
296
- nativeEvent: {contentOffset: {x: 0, y: 10}},
297
- })
298
- ).not.toThrow();
321
+ expect(() => ref.current!._onScroll(scrollEvent(10))).not.toThrow();
299
322
  });
300
323
 
301
324
  it("_onTouchStart and _onTouchMove do not throw", () => {
@@ -307,9 +330,9 @@ describe("ActionSheet", () => {
307
330
  </ActionSheet>
308
331
  </ThemeProvider>
309
332
  );
310
- expect(() => (ref.current as any)._onTouchStart()).not.toThrow();
311
- expect(() => (ref.current as any)._onTouchMove()).not.toThrow();
312
- expect(() => (ref.current as any)._onTouchEnd()).not.toThrow();
333
+ expect(() => ref.current!._onTouchStart()).not.toThrow();
334
+ expect(() => ref.current!._onTouchMove()).not.toThrow();
335
+ expect(() => ref.current!._onTouchEnd()).not.toThrow();
313
336
  });
314
337
 
315
338
  describe("getDeviceHeight", () => {
@@ -356,7 +379,7 @@ describe("ActionSheet", () => {
356
379
  </ActionSheet>
357
380
  </ThemeProvider>
358
381
  );
359
- const result = await (ref.current as any).measure();
382
+ const result = await ref.current!.measure();
360
383
  expect(result).toBe(20);
361
384
  });
362
385
 
@@ -369,14 +392,8 @@ describe("ActionSheet", () => {
369
392
  </ActionSheet>
370
393
  </ThemeProvider>
371
394
  );
372
- (ref.current as any).safeAreaViewRef = {
373
- current: {
374
- measureInWindow: (_cb: any) => {
375
- _cb(0, 0, 100, 44);
376
- },
377
- },
378
- };
379
- const result = await (ref.current as any).measure();
395
+ ref.current!.safeAreaViewRef = measuringSafeAreaRef(44);
396
+ const result = await ref.current!.measure();
380
397
  expect(result).toBe(44);
381
398
  });
382
399
 
@@ -389,14 +406,8 @@ describe("ActionSheet", () => {
389
406
  </ActionSheet>
390
407
  </ThemeProvider>
391
408
  );
392
- (ref.current as any).safeAreaViewRef = {
393
- current: {
394
- measureInWindow: (_cb: any) => {
395
- _cb(0, 0, 100, 0);
396
- },
397
- },
398
- };
399
- const result = await (ref.current as any).measure();
409
+ ref.current!.safeAreaViewRef = measuringSafeAreaRef(0);
410
+ const result = await ref.current!.measure();
400
411
  expect(result).toBe(20);
401
412
  });
402
413
  });
@@ -411,7 +422,7 @@ describe("ActionSheet", () => {
411
422
  </ActionSheet>
412
423
  </ThemeProvider>
413
424
  );
414
- await (ref.current as any)._showModal({});
425
+ await ref.current!._showModal({} as LayoutChangeEvent);
415
426
  expect(ref.current).toBeTruthy();
416
427
  });
417
428
 
@@ -425,10 +436,8 @@ describe("ActionSheet", () => {
425
436
  </ThemeProvider>
426
437
  );
427
438
  ref.current!.layoutHasCalled = false;
428
- await (ref.current as any)._showModal({
429
- nativeEvent: {layout: {height: 500, width: 400}},
430
- });
431
- expect((ref.current as any).actionSheetHeight).toBe(500);
439
+ await ref.current!._showModal(layoutEvent(500, 400));
440
+ expect(ref.current!.actionSheetHeight).toBe(500);
432
441
  expect(ref.current!.layoutHasCalled).toBe(true);
433
442
  });
434
443
 
@@ -442,11 +451,9 @@ describe("ActionSheet", () => {
442
451
  </ThemeProvider>
443
452
  );
444
453
  ref.current!.layoutHasCalled = true;
445
- (ref.current as any).actionSheetHeight = 400;
446
- await (ref.current as any)._showModal({
447
- nativeEvent: {layout: {height: 600, width: 400}},
448
- });
449
- expect((ref.current as any).actionSheetHeight).toBe(600);
454
+ ref.current!.actionSheetHeight = 400;
455
+ await ref.current!._showModal(layoutEvent(600, 400));
456
+ expect(ref.current!.actionSheetHeight).toBe(600);
450
457
  });
451
458
  });
452
459
 
@@ -460,7 +467,7 @@ describe("ActionSheet", () => {
460
467
  </ActionSheet>
461
468
  </ThemeProvider>
462
469
  );
463
- expect(() => (ref.current as any)._openAnimation(100)).not.toThrow();
470
+ expect(() => ref.current!._openAnimation(100)).not.toThrow();
464
471
  });
465
472
 
466
473
  it("sets opacity directly when animated is false", () => {
@@ -472,7 +479,7 @@ describe("ActionSheet", () => {
472
479
  </ActionSheet>
473
480
  </ThemeProvider>
474
481
  );
475
- expect(() => (ref.current as any)._openAnimation(100)).not.toThrow();
482
+ expect(() => ref.current!._openAnimation(100)).not.toThrow();
476
483
  });
477
484
  });
478
485
 
@@ -486,10 +493,8 @@ describe("ActionSheet", () => {
486
493
  </ActionSheet>
487
494
  </ThemeProvider>
488
495
  );
489
- await (ref.current as any)._onScrollBeginDrag({
490
- nativeEvent: {contentOffset: {y: 42}},
491
- });
492
- expect((ref.current as any).prevScroll).toBe(42);
496
+ await ref.current!._onScrollBeginDrag(scrollEvent(42));
497
+ expect(ref.current!.prevScroll).toBe(42);
493
498
  });
494
499
  });
495
500
 
@@ -503,11 +508,9 @@ describe("ActionSheet", () => {
503
508
  </ActionSheet>
504
509
  </ThemeProvider>
505
510
  );
506
- (ref.current as any).actionSheetHeight = 99999;
507
- (ref.current as any)._applyHeightLimiter();
508
- expect((ref.current as any).actionSheetHeight).toBeLessThanOrEqual(
509
- ref.current!.state.deviceHeight
510
- );
511
+ ref.current!.actionSheetHeight = 99999;
512
+ ref.current!._applyHeightLimiter();
513
+ expect(ref.current!.actionSheetHeight).toBeLessThanOrEqual(ref.current!.state.deviceHeight);
511
514
  });
512
515
 
513
516
  it("does not change actionSheetHeight when smaller than deviceHeight", () => {
@@ -519,9 +522,9 @@ describe("ActionSheet", () => {
519
522
  </ActionSheet>
520
523
  </ThemeProvider>
521
524
  );
522
- (ref.current as any).actionSheetHeight = 100;
523
- (ref.current as any)._applyHeightLimiter();
524
- expect((ref.current as any).actionSheetHeight).toBe(100);
525
+ ref.current!.actionSheetHeight = 100;
526
+ ref.current!._applyHeightLimiter();
527
+ expect(ref.current!.actionSheetHeight).toBe(100);
525
528
  });
526
529
  });
527
530
 
@@ -535,12 +538,10 @@ describe("ActionSheet", () => {
535
538
  </ActionSheet>
536
539
  </ThemeProvider>
537
540
  );
538
- (ref.current as any).prevScroll = 100;
539
- (ref.current as any).actionSheetHeight = 500;
540
- (ref.current as any).isRecoiling = false;
541
- await (ref.current as any)._onScrollEnd({
542
- nativeEvent: {contentOffset: {y: 200}},
543
- });
541
+ ref.current!.prevScroll = 100;
542
+ ref.current!.actionSheetHeight = 500;
543
+ ref.current!.isRecoiling = false;
544
+ await ref.current!._onScrollEnd(scrollEvent(200));
544
545
  expect(ref.current).toBeTruthy();
545
546
  });
546
547
 
@@ -553,10 +554,8 @@ describe("ActionSheet", () => {
553
554
  </ActionSheet>
554
555
  </ThemeProvider>
555
556
  );
556
- (ref.current as any).isRecoiling = true;
557
- await (ref.current as any)._onScrollEnd({
558
- nativeEvent: {contentOffset: {y: 50}},
559
- });
557
+ ref.current!.isRecoiling = true;
558
+ await ref.current!._onScrollEnd(scrollEvent(50));
560
559
  expect(ref.current).toBeTruthy();
561
560
  });
562
561
 
@@ -569,11 +568,9 @@ describe("ActionSheet", () => {
569
568
  </ActionSheet>
570
569
  </ThemeProvider>
571
570
  );
572
- (ref.current as any).prevScroll = 200;
573
- (ref.current as any).isRecoiling = false;
574
- await (ref.current as any)._onScrollEnd({
575
- nativeEvent: {contentOffset: {y: 50}},
576
- });
571
+ ref.current!.prevScroll = 200;
572
+ ref.current!.isRecoiling = false;
573
+ await ref.current!._onScrollEnd(scrollEvent(50));
577
574
  expect(ref.current).toBeTruthy();
578
575
  });
579
576
 
@@ -586,11 +583,9 @@ describe("ActionSheet", () => {
586
583
  </ActionSheet>
587
584
  </ThemeProvider>
588
585
  );
589
- (ref.current as any).prevScroll = 100;
590
- (ref.current as any).isRecoiling = false;
591
- await (ref.current as any)._onScrollEnd({
592
- nativeEvent: {contentOffset: {y: 95}},
593
- });
586
+ ref.current!.prevScroll = 100;
587
+ ref.current!.isRecoiling = false;
588
+ await ref.current!._onScrollEnd(scrollEvent(95));
594
589
  expect(ref.current).toBeTruthy();
595
590
  });
596
591
 
@@ -603,12 +598,10 @@ describe("ActionSheet", () => {
603
598
  </ActionSheet>
604
599
  </ThemeProvider>
605
600
  );
606
- (ref.current as any).prevScroll = 100;
607
- (ref.current as any).actionSheetHeight = 500;
608
- (ref.current as any).isRecoiling = false;
609
- await (ref.current as any)._onScrollEnd({
610
- nativeEvent: {contentOffset: {y: 110}},
611
- });
601
+ ref.current!.prevScroll = 100;
602
+ ref.current!.actionSheetHeight = 500;
603
+ ref.current!.isRecoiling = false;
604
+ await ref.current!._onScrollEnd(scrollEvent(110));
612
605
  expect(ref.current).toBeTruthy();
613
606
  });
614
607
  });
@@ -748,7 +741,7 @@ describe("ActionSheet", () => {
748
741
  </ThemeProvider>
749
742
  );
750
743
  act(() => {
751
- (ref.current as any)._onKeyboardHide();
744
+ ref.current!._onKeyboardHide();
752
745
  });
753
746
  expect(ref.current!.state.keyboard).toBe(false);
754
747
  });
@@ -764,9 +757,9 @@ describe("ActionSheet", () => {
764
757
  </ActionSheet>
765
758
  </ThemeProvider>
766
759
  );
767
- (ref.current as any).offsetY = 200;
768
- (ref.current as any).prevScroll = 100;
769
- await (ref.current as any).handleChildScrollEnd();
760
+ ref.current!.offsetY = 200;
761
+ ref.current!.prevScroll = 100;
762
+ await ref.current!.handleChildScrollEnd();
770
763
  expect(ref.current).toBeTruthy();
771
764
  });
772
765
 
@@ -779,10 +772,10 @@ describe("ActionSheet", () => {
779
772
  </ActionSheet>
780
773
  </ThemeProvider>
781
774
  );
782
- (ref.current as any).offsetY = 0;
783
- (ref.current as any).prevScroll = 200;
784
- (ref.current as any).actionSheetHeight = 500;
785
- await (ref.current as any).handleChildScrollEnd();
775
+ ref.current!.offsetY = 0;
776
+ ref.current!.prevScroll = 200;
777
+ ref.current!.actionSheetHeight = 500;
778
+ await ref.current!.handleChildScrollEnd();
786
779
  expect(ref.current).toBeTruthy();
787
780
  });
788
781
 
@@ -795,9 +788,9 @@ describe("ActionSheet", () => {
795
788
  </ActionSheet>
796
789
  </ThemeProvider>
797
790
  );
798
- (ref.current as any).offsetY = 90;
799
- (ref.current as any).prevScroll = 100;
800
- await (ref.current as any).handleChildScrollEnd();
791
+ ref.current!.offsetY = 90;
792
+ ref.current!.prevScroll = 100;
793
+ await ref.current!.handleChildScrollEnd();
801
794
  expect(ref.current).toBeTruthy();
802
795
  });
803
796
 
@@ -810,10 +803,10 @@ describe("ActionSheet", () => {
810
803
  </ActionSheet>
811
804
  </ThemeProvider>
812
805
  );
813
- (ref.current as any).offsetY = 50;
814
- (ref.current as any).prevScroll = 200;
815
- (ref.current as any).actionSheetHeight = 200;
816
- await (ref.current as any).handleChildScrollEnd();
806
+ ref.current!.offsetY = 50;
807
+ ref.current!.prevScroll = 200;
808
+ ref.current!.actionSheetHeight = 200;
809
+ await ref.current!.handleChildScrollEnd();
817
810
  expect(ref.current).toBeTruthy();
818
811
  });
819
812
  });
@@ -843,11 +836,9 @@ describe("ActionSheet", () => {
843
836
  </ThemeProvider>
844
837
  );
845
838
  const existingTimeout = setTimeout(() => {}, 1000);
846
- (ref.current as any).timeout = existingTimeout;
847
- (ref.current as any)._onDeviceLayout({
848
- nativeEvent: {layout: {height: 812, width: 375}},
849
- });
850
- const newTimeout = (ref.current as any).timeout;
839
+ ref.current!.timeout = existingTimeout;
840
+ ref.current!._onDeviceLayout(layoutEvent(812, 375));
841
+ const newTimeout = ref.current!.timeout;
851
842
  expect(newTimeout).not.toBe(existingTimeout);
852
843
  clearTimeout(newTimeout);
853
844
  });
@@ -863,8 +854,8 @@ describe("ActionSheet", () => {
863
854
  </ActionSheet>
864
855
  </ThemeProvider>
865
856
  );
866
- (ref.current as any).actionSheetHeight = 500;
867
- const pos = (ref.current as any).getInitialScrollPosition();
857
+ ref.current!.actionSheetHeight = 500;
858
+ const pos = ref.current!.getInitialScrollPosition();
868
859
  expect(typeof pos).toBe("number");
869
860
  });
870
861
 
@@ -877,8 +868,8 @@ describe("ActionSheet", () => {
877
868
  </ActionSheet>
878
869
  </ThemeProvider>
879
870
  );
880
- (ref.current as any).actionSheetHeight = 500;
881
- const pos = (ref.current as any).getInitialScrollPosition();
871
+ ref.current!.actionSheetHeight = 500;
872
+ const pos = ref.current!.getInitialScrollPosition();
882
873
  expect(typeof pos).toBe("number");
883
874
  });
884
875
  });
@@ -896,9 +887,9 @@ describe("ActionSheet", () => {
896
887
  act(() => {
897
888
  ref.current?.show();
898
889
  });
899
- (ref.current as any).isClosing = false;
890
+ ref.current!.isClosing = false;
900
891
  act(() => {
901
- (ref.current as any)._hideAnimation();
892
+ ref.current!._hideAnimation();
902
893
  });
903
894
  await act(async () => {
904
895
  await new Promise((r) => setTimeout(r, 50));
@@ -918,9 +909,9 @@ describe("ActionSheet", () => {
918
909
  act(() => {
919
910
  ref.current?.show();
920
911
  });
921
- (ref.current as any).isClosing = false;
912
+ ref.current!.isClosing = false;
922
913
  act(() => {
923
- (ref.current as any)._hideAnimation();
914
+ ref.current!._hideAnimation();
924
915
  });
925
916
  await act(async () => {
926
917
  await new Promise((r) => setTimeout(r, 50));
@@ -939,7 +930,7 @@ describe("ActionSheet", () => {
939
930
  </ActionSheet>
940
931
  </ThemeProvider>
941
932
  );
942
- await expect((ref.current as any)._onScrollBegin()).resolves.toBeUndefined();
933
+ await expect(ref.current!._onScrollBegin()).resolves.toBeUndefined();
943
934
  });
944
935
  });
945
936
 
@@ -953,19 +944,19 @@ describe("ActionSheet", () => {
953
944
  </ActionSheet>
954
945
  </ThemeProvider>
955
946
  );
956
- (ref.current as any).actionSheetHeight = 100;
947
+ ref.current!.actionSheetHeight = 100;
957
948
  // scrollOffset ≈ 100*0.5 + deviceHeight*0.15 ≈ 150
958
949
  // Need offsetY > scrollOffset - 100, so offsetY = 120 works
959
- (ref.current as any).offsetY = 120;
960
- (ref.current as any).prevScroll = 200;
950
+ ref.current!.offsetY = 120;
951
+ ref.current!.prevScroll = 200;
961
952
  await act(async () => {
962
- await (ref.current as any).handleChildScrollEnd();
953
+ await ref.current!.handleChildScrollEnd();
963
954
  });
964
- expect((ref.current as any).isRecoiling).toBe(true);
955
+ expect(ref.current!.isRecoiling).toBe(true);
965
956
  await act(async () => {
966
957
  await new Promise((r) => setTimeout(r, 600));
967
958
  });
968
- expect((ref.current as any).isRecoiling).toBe(false);
959
+ expect(ref.current!.isRecoiling).toBe(false);
969
960
  });
970
961
  });
971
962
 
@@ -979,16 +970,16 @@ describe("ActionSheet", () => {
979
970
  </ActionSheet>
980
971
  </ThemeProvider>
981
972
  );
982
- (ref.current as any).offsetY = 98;
983
- (ref.current as any).prevScroll = 100;
973
+ ref.current!.offsetY = 98;
974
+ ref.current!.prevScroll = 100;
984
975
  await act(async () => {
985
- await (ref.current as any).handleChildScrollEnd();
976
+ await ref.current!.handleChildScrollEnd();
986
977
  });
987
- expect((ref.current as any).isRecoiling).toBe(true);
978
+ expect(ref.current!.isRecoiling).toBe(true);
988
979
  await act(async () => {
989
980
  await new Promise((r) => setTimeout(r, 600));
990
981
  });
991
- expect((ref.current as any).isRecoiling).toBe(false);
982
+ expect(ref.current!.isRecoiling).toBe(false);
992
983
  });
993
984
 
994
985
  it("recoils when within scroll threshold of initial position", async () => {
@@ -1000,7 +991,7 @@ describe("ActionSheet", () => {
1000
991
  </ActionSheet>
1001
992
  </ThemeProvider>
1002
993
  );
1003
- const instance = ref.current as any;
994
+ const instance = ref.current!;
1004
995
  instance.actionSheetHeight = 500;
1005
996
  instance.prevScroll = 300;
1006
997
  instance.offsetY = 250;
@@ -1026,7 +1017,7 @@ describe("ActionSheet", () => {
1026
1017
  </ActionSheet>
1027
1018
  </ThemeProvider>
1028
1019
  );
1029
- const instance = ref.current as any;
1020
+ const instance = ref.current!;
1030
1021
  instance.actionSheetHeight = 500;
1031
1022
  instance.prevScroll = 300;
1032
1023
  instance.offsetY = 100;
@@ -1048,7 +1039,7 @@ describe("ActionSheet", () => {
1048
1039
  </ActionSheet>
1049
1040
  </ThemeProvider>
1050
1041
  );
1051
- const instance = ref.current as any;
1042
+ const instance = ref.current!;
1052
1043
  instance.actionSheetHeight = 500;
1053
1044
  instance.prevScroll = 300;
1054
1045
  instance.offsetY = 290;
@@ -1072,7 +1063,7 @@ describe("ActionSheet", () => {
1072
1063
  </ActionSheet>
1073
1064
  </ThemeProvider>
1074
1065
  );
1075
- const instance = ref.current as any;
1066
+ const instance = ref.current!;
1076
1067
  instance.prevScroll = 200;
1077
1068
  instance.offsetY = 195;
1078
1069
  instance._scrollTo = mock(() => {});
@@ -1100,14 +1091,12 @@ describe("ActionSheet", () => {
1100
1091
  </ThemeProvider>
1101
1092
  );
1102
1093
  await act(async () => {
1103
- (ref.current as any)._onDeviceLayout({
1104
- nativeEvent: {layout: {height: 800, width: 400}},
1105
- });
1094
+ ref.current!._onDeviceLayout(layoutEvent(800, 400));
1106
1095
  // measure() has a 100ms timeout on iOS; on android it uses StatusBar.currentHeight
1107
1096
  await new Promise((r) => setTimeout(r, 200));
1108
1097
  });
1109
1098
  // The callback should have run and set deviceLayoutCalled
1110
- expect((ref.current as any).deviceLayoutCalled).toBe(true);
1099
+ expect(ref.current!.deviceLayoutCalled).toBe(true);
1111
1100
  });
1112
1101
 
1113
1102
  it("updates state after layout timeout fires without drawUnderStatusBar on android", async () => {
@@ -1120,12 +1109,10 @@ describe("ActionSheet", () => {
1120
1109
  </ThemeProvider>
1121
1110
  );
1122
1111
  await act(async () => {
1123
- (ref.current as any)._onDeviceLayout({
1124
- nativeEvent: {layout: {height: 900, width: 400}},
1125
- });
1112
+ ref.current!._onDeviceLayout(layoutEvent(900, 400));
1126
1113
  await new Promise((r) => setTimeout(r, 200));
1127
1114
  });
1128
- expect((ref.current as any).deviceLayoutCalled).toBe(true);
1115
+ expect(ref.current!.deviceLayoutCalled).toBe(true);
1129
1116
  });
1130
1117
  });
1131
1118
  });