@terreno/ui 0.24.0 → 0.25.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 (64) hide show
  1. package/dist/AIRequestExplorer.js +6 -1
  2. package/dist/AIRequestExplorer.js.map +1 -1
  3. package/dist/ActionSheet.d.ts +1 -0
  4. package/dist/ActionSheet.js +3 -0
  5. package/dist/ActionSheet.js.map +1 -1
  6. package/dist/Common.d.ts +16 -0
  7. package/dist/Common.js.map +1 -1
  8. package/dist/CustomSelectField.js +2 -2
  9. package/dist/CustomSelectField.js.map +1 -1
  10. package/dist/FilePickerButton.js +2 -1
  11. package/dist/FilePickerButton.js.map +1 -1
  12. package/dist/PickerSelect.d.ts +10 -2
  13. package/dist/PickerSelect.js +91 -17
  14. package/dist/PickerSelect.js.map +1 -1
  15. package/dist/SelectBadge.js +1 -1
  16. package/dist/SelectBadge.js.map +1 -1
  17. package/dist/SelectField.js +9 -9
  18. package/dist/SelectField.js.map +1 -1
  19. package/dist/WebDropdownMenu.d.ts +36 -5
  20. package/dist/WebDropdownMenu.js +211 -29
  21. package/dist/WebDropdownMenu.js.map +1 -1
  22. package/dist/createWebPortal.d.ts +7 -0
  23. package/dist/createWebPortal.js +3 -0
  24. package/dist/createWebPortal.js.map +1 -0
  25. package/dist/createWebPortal.native.d.ts +7 -0
  26. package/dist/createWebPortal.native.js +2 -0
  27. package/dist/createWebPortal.native.js.map +1 -0
  28. package/dist/fieldElements/FieldHelperText.js +1 -1
  29. package/dist/fieldElements/FieldHelperText.js.map +1 -1
  30. package/package.json +2 -2
  31. package/src/AIRequestExplorer.tsx +6 -1
  32. package/src/ActionSheet.test.tsx +103 -3
  33. package/src/ActionSheet.tsx +4 -0
  34. package/src/Common.ts +19 -0
  35. package/src/CustomSelectField.test.tsx +13 -3
  36. package/src/CustomSelectField.tsx +2 -0
  37. package/src/EmojiSelector.test.tsx +153 -0
  38. package/src/FilePickerButton.tsx +2 -1
  39. package/src/Modal.test.tsx +47 -0
  40. package/src/PickerSelect.test.tsx +253 -14
  41. package/src/PickerSelect.tsx +206 -49
  42. package/src/SelectBadge.tsx +1 -0
  43. package/src/SelectBadge.web.test.tsx +10 -0
  44. package/src/SelectField.tsx +19 -15
  45. package/src/WebDropdownMenu.test.tsx +449 -0
  46. package/src/WebDropdownMenu.tsx +405 -60
  47. package/src/__snapshots__/AddressField.test.tsx.snap +2088 -665
  48. package/src/__snapshots__/CustomSelectField.test.tsx.snap +2118 -1369
  49. package/src/__snapshots__/Field.test.tsx.snap +3787 -1806
  50. package/src/__snapshots__/HeightField.test.tsx.snap +3 -0
  51. package/src/__snapshots__/PickerSelect.test.tsx.snap +7 -7
  52. package/src/__snapshots__/SelectField.test.tsx.snap +1548 -1102
  53. package/src/__snapshots__/Slider.test.tsx.snap +3 -0
  54. package/src/__snapshots__/TextArea.test.tsx.snap +3 -0
  55. package/src/__snapshots__/TextField.test.tsx.snap +3 -0
  56. package/src/__snapshots__/TimezonePicker.test.tsx.snap +2499 -1353
  57. package/src/createWebPortal.native.ts +8 -0
  58. package/src/createWebPortal.test.tsx +13 -0
  59. package/src/createWebPortal.ts +10 -0
  60. package/src/fieldElements/FieldHelperText.tsx +4 -2
  61. package/src/fieldElements/__snapshots__/FieldHelperText.test.tsx.snap +3 -0
  62. package/src/table/TableBadge.test.tsx +19 -11
  63. package/src/table/__snapshots__/TableBadge.test.tsx.snap +226 -175
  64. package/src/types/react-dom.d.ts +5 -0
@@ -0,0 +1,8 @@
1
+ import type {ReactElement} from "react";
2
+
3
+ interface CreateWebPortalOptions {
4
+ children: ReactElement;
5
+ container: Element;
6
+ }
7
+
8
+ export const createWebPortal = ({children}: CreateWebPortalOptions): ReactElement => children;
@@ -0,0 +1,13 @@
1
+ import {describe, expect, it} from "bun:test";
2
+ import React from "react";
3
+
4
+ import {createWebPortal as createNativePortal} from "./createWebPortal.native";
5
+
6
+ describe("createWebPortal (native)", () => {
7
+ it("returns the children unchanged without creating a portal", () => {
8
+ const container = {nodeType: 1} as unknown as Element;
9
+ const children = React.createElement("div", null, "native-content");
10
+
11
+ expect(createNativePortal({children, container})).toBe(children);
12
+ });
13
+ });
@@ -0,0 +1,10 @@
1
+ import type {ReactElement} from "react";
2
+ import {createPortal} from "react-dom";
3
+
4
+ interface CreateWebPortalOptions {
5
+ children: ReactElement;
6
+ container: Element;
7
+ }
8
+
9
+ export const createWebPortal = ({children, container}: CreateWebPortalOptions): ReactElement =>
10
+ createPortal(children, container);
@@ -15,8 +15,10 @@ export const FieldHelperText: FC<FieldHelperTextProps> = ({text, testID}) => {
15
15
  const {theme} = useTheme();
16
16
 
17
17
  return (
18
- <View style={{marginTop: 2}} {...toTestProps(testID)}>
19
- <Text style={{color: theme.text.primary, fontSize: 12, lineHeight: 16}}>{text}</Text>
18
+ <View style={{alignSelf: "stretch", marginTop: 2, maxWidth: "100%"}} {...toTestProps(testID)}>
19
+ <Text style={{color: theme.text.primary, flexShrink: 1, fontSize: 12, lineHeight: 16}}>
20
+ {text}
21
+ </Text>
20
22
  </View>
21
23
  );
22
24
  };
@@ -12,6 +12,7 @@ exports[`FieldHelperText renders correctly 1`] = `
12
12
  "props": {
13
13
  "style": {
14
14
  "color": "#1C1C1C",
15
+ "flexShrink": 1,
15
16
  "fontSize": 12,
16
17
  "lineHeight": 16,
17
18
  },
@@ -21,7 +22,9 @@ exports[`FieldHelperText renders correctly 1`] = `
21
22
  ],
22
23
  "props": {
23
24
  "style": {
25
+ "alignSelf": "stretch",
24
26
  "marginTop": 2,
27
+ "maxWidth": "100%",
25
28
  },
26
29
  "testID": undefined,
27
30
  },
@@ -1,5 +1,5 @@
1
1
  import {describe, expect, it} from "bun:test";
2
- import {fireEvent} from "@testing-library/react-native";
2
+ import {act, fireEvent} from "@testing-library/react-native";
3
3
  import {renderWithTheme} from "../test-utils";
4
4
  import {TableBadge} from "./TableBadge";
5
5
 
@@ -55,10 +55,10 @@ describe("TableBadge", () => {
55
55
  it("renders badge when editing is enabled but options are missing", () => {
56
56
  const {getByText, queryByTestId} = renderWithTheme(<TableBadge isEditing value="Pending" />);
57
57
  expect(getByText("Pending")).toBeTruthy();
58
- expect(queryByTestId("ios_picker")).toBeNull();
58
+ expect(queryByTestId("web_picker")).toBeNull();
59
59
  });
60
60
 
61
- it("updates selected value when select field changes to a non-empty option", () => {
61
+ it("updates selected value when select field changes to a non-empty option", async () => {
62
62
  const editingOptions = [
63
63
  {label: "Option A", value: "a"},
64
64
  {label: "Option B", value: "b"},
@@ -66,14 +66,18 @@ describe("TableBadge", () => {
66
66
  const {getByTestId} = renderWithTheme(
67
67
  <TableBadge editingOptions={editingOptions} isEditing value="a" />
68
68
  );
69
- const picker = getByTestId("ios_picker");
70
69
 
71
- expect(picker.props.selectedValue).toBe("a");
72
- fireEvent(picker, "onValueChange", "b", 2);
73
- expect(getByTestId("ios_picker").props.selectedValue).toBe("b");
70
+ expect(getByTestId("text_input").props.children).toBe("Option A");
71
+ await act(async () => {
72
+ fireEvent.press(getByTestId("web_picker"));
73
+ });
74
+ await act(async () => {
75
+ fireEvent.press(getByTestId("web_dropdown_option_b"));
76
+ });
77
+ expect(getByTestId("text_input").props.children).toBe("Option B");
74
78
  });
75
79
 
76
- it("clears selected value when select field changes to an empty value", () => {
80
+ it("clears selected value when select field changes to an empty value", async () => {
77
81
  const editingOptions = [
78
82
  {label: "Option A", value: "a"},
79
83
  {label: "Option B", value: "b"},
@@ -81,9 +85,13 @@ describe("TableBadge", () => {
81
85
  const {getByTestId} = renderWithTheme(
82
86
  <TableBadge editingOptions={editingOptions} isEditing value="a" />
83
87
  );
84
- const picker = getByTestId("ios_picker");
85
88
 
86
- fireEvent(picker, "onValueChange", "", 0);
87
- expect(getByTestId("ios_picker").props.selectedValue).toBe("");
89
+ await act(async () => {
90
+ fireEvent.press(getByTestId("web_picker"));
91
+ });
92
+ await act(async () => {
93
+ fireEvent.press(getByTestId("web_dropdown_option_"));
94
+ });
95
+ expect(getByTestId("text_input").props.children).toBe("Please select an option.");
88
96
  });
89
97
  });
@@ -449,71 +449,36 @@ exports[`TableBadge renders select field when editing 1`] = `
449
449
  "children": [
450
450
  {
451
451
  "$$typeof": Symbol(react.test.json),
452
- "children": null,
452
+ "children": [
453
+ "Option A",
454
+ ],
453
455
  "props": {
454
- "editable": false,
455
- "multiline": true,
456
+ "numberOfLines": 1,
456
457
  "style": {
457
458
  "color": "#1C1C1C",
458
459
  "flex": 1,
460
+ "fontFamily": "text",
461
+ "fontSize": 16,
462
+ "paddingRight": 8,
459
463
  },
460
464
  "testID": "text_input",
461
- "value": "Option A",
462
- },
463
- "type": "TextInput",
464
- },
465
- {
466
- "$$typeof": Symbol(react.test.json),
467
- "children": null,
468
- "props": {
469
- "style": {
470
- "pointerEvents": "none",
471
- },
472
- "testID": "icon_container",
473
465
  },
474
- "type": "View",
466
+ "type": "Text",
475
467
  },
476
468
  ],
477
469
  "props": {
470
+ "aria-role": "button",
471
+ "disabled": false,
472
+ "onPress": [Function],
478
473
  "style": {
479
474
  "alignItems": "center",
480
475
  "flexDirection": "row",
481
- "pointerEvents": "box-only",
476
+ "justifyContent": "space-between",
477
+ "minHeight": 40,
478
+ "paddingHorizontal": 8,
482
479
  "width": "100%",
483
480
  },
484
- "testID": undefined,
485
- },
486
- "type": "View",
487
- },
488
- ],
489
- "props": {
490
- "disabled": false,
491
- "onPress": [Function],
492
- "style": {
493
- "alignItems": "center",
494
- "flexDirection": "row",
495
- "justifyContent": "center",
496
- "minHeight": 40,
497
- "paddingHorizontal": 8,
498
- "width": "100%",
499
- },
500
- "testID": "ios_touchable_wrapper",
501
- },
502
- "type": "Pressable",
503
- },
504
- {
505
- "$$typeof": Symbol(react.test.json),
506
- "children": [
507
- {
508
- "$$typeof": Symbol(react.test.json),
509
- "children": null,
510
- "props": {
511
- "aria-role": "button",
512
- "onPress": [Function],
513
- "style": {
514
- "flex": 1,
515
- },
516
- "testID": "ios_modal_top",
481
+ "testID": "web_picker",
517
482
  },
518
483
  "type": "Pressable",
519
484
  },
@@ -524,12 +489,15 @@ exports[`TableBadge renders select field when editing 1`] = `
524
489
  "$$typeof": Symbol(react.test.json),
525
490
  "children": null,
526
491
  "props": {
492
+ "aria-role": "button",
493
+ "onPress": [Function],
527
494
  "style": {
528
- "flexDirection": "row",
495
+ "flex": 1,
496
+ "zIndex": 0,
529
497
  },
530
- "testID": undefined,
498
+ "testID": "web_dropdown_backdrop",
531
499
  },
532
- "type": "View",
500
+ "type": "Pressable",
533
501
  },
534
502
  {
535
503
  "$$typeof": Symbol(react.test.json),
@@ -539,156 +507,238 @@ exports[`TableBadge renders select field when editing 1`] = `
539
507
  "children": [
540
508
  {
541
509
  "$$typeof": Symbol(react.test.json),
542
- "children": [
543
- "Done",
544
- ],
510
+ "children": null,
545
511
  "props": {
546
- "allowFontScaling": false,
547
- "style": [
548
- {
549
- "color": "#007aff",
550
- "fontSize": 17,
551
- "fontWeight": "600",
552
- "paddingRight": 11,
553
- "paddingTop": 1,
554
- },
555
- {},
556
- ],
557
- "testID": "done_text",
512
+ "autoFocus": true,
513
+ "onChangeText": [Function: dispatchSetState],
514
+ "placeholder": "Search...",
515
+ "placeholderTextColor": "#686868",
516
+ "ref": {
517
+ "current": null,
518
+ },
519
+ "style": {
520
+ "borderColor": "#9A9A9A",
521
+ "borderRadius": 4,
522
+ "borderWidth": 1,
523
+ "color": "#1C1C1C",
524
+ "fontSize": 14,
525
+ "paddingHorizontal": 8,
526
+ "paddingVertical": 4,
527
+ },
528
+ "testID": "web_dropdown_search",
529
+ "value": "",
558
530
  },
559
- "type": "Text",
531
+ "type": "TextInput",
560
532
  },
561
533
  ],
562
534
  "props": {
563
- "style": undefined,
564
- "testID": "needed_for_touchable",
535
+ "style": {
536
+ "borderBottomColor": "#CDCDCD",
537
+ "borderBottomWidth": 1,
538
+ "paddingHorizontal": 8,
539
+ "paddingVertical": 6,
540
+ },
541
+ "testID": undefined,
565
542
  },
566
543
  "type": "View",
567
544
  },
568
- ],
569
- "props": {
570
- "hitSlop": {
571
- "bottom": 4,
572
- "left": 4,
573
- "right": 4,
574
- "top": 4,
575
- },
576
- "onPress": [Function],
577
- "onPressIn": [Function],
578
- "onPressOut": [Function],
579
- "testID": "done_button",
580
- },
581
- "type": "Pressable",
582
- },
583
- ],
584
- "props": {
585
- "style": {
586
- "alignItems": "center",
587
- "backgroundColor": "#f8f8f8",
588
- "borderTopColor": "#dedede",
589
- "borderTopWidth": 1,
590
- "flexDirection": "row",
591
- "height": 45,
592
- "justifyContent": "space-between",
593
- "paddingHorizontal": 10,
594
- "zIndex": 2,
595
- },
596
- "testID": "input_accessory_view",
597
- },
598
- "type": "View",
599
- },
600
- {
601
- "$$typeof": Symbol(react.test.json),
602
- "children": [
603
- {
604
- "$$typeof": Symbol(react.test.json),
605
- "children": [
606
- {
607
- "$$typeof": Symbol(react.test.json),
608
- "children": null,
609
- "props": {
610
- "color": undefined,
611
- "label": "Please select an option.",
612
- "value": "",
613
- },
614
- "type": "Picker.Item",
615
- },
616
- {
617
- "$$typeof": Symbol(react.test.json),
618
- "children": null,
619
- "props": {
620
- "color": undefined,
621
- "label": "Option A",
622
- "value": "a",
623
- },
624
- "type": "Picker.Item",
625
- },
626
545
  {
627
546
  "$$typeof": Symbol(react.test.json),
628
- "children": null,
547
+ "children": [
548
+ {
549
+ "$$typeof": Symbol(react.test.json),
550
+ "children": [
551
+ {
552
+ "$$typeof": Symbol(react.test.json),
553
+ "children": [
554
+ {
555
+ "$$typeof": Symbol(react.test.json),
556
+ "children": [
557
+ "Please select an option.",
558
+ ],
559
+ "props": {
560
+ "style": {
561
+ "color": "#1C1C1C",
562
+ "fontWeight": "400",
563
+ },
564
+ },
565
+ "type": "Text",
566
+ },
567
+ ],
568
+ "props": {
569
+ "style": {
570
+ "alignSelf": "stretch",
571
+ },
572
+ "testID": undefined,
573
+ },
574
+ "type": "View",
575
+ },
576
+ ],
577
+ "props": {
578
+ "aria-role": "button",
579
+ "onLayout": [Function],
580
+ "onPress": [Function],
581
+ "style": [Function],
582
+ "testID": "web_dropdown_option_",
583
+ },
584
+ "type": "Pressable",
585
+ },
586
+ {
587
+ "$$typeof": Symbol(react.test.json),
588
+ "children": [
589
+ {
590
+ "$$typeof": Symbol(react.test.json),
591
+ "children": [
592
+ {
593
+ "$$typeof": Symbol(react.test.json),
594
+ "children": [
595
+ "Option A",
596
+ ],
597
+ "props": {
598
+ "style": {
599
+ "color": "#1C1C1C",
600
+ "fontWeight": "600",
601
+ },
602
+ },
603
+ "type": "Text",
604
+ },
605
+ ],
606
+ "props": {
607
+ "style": {
608
+ "alignSelf": "stretch",
609
+ },
610
+ "testID": undefined,
611
+ },
612
+ "type": "View",
613
+ },
614
+ ],
615
+ "props": {
616
+ "aria-role": "button",
617
+ "onLayout": [Function],
618
+ "onPress": [Function],
619
+ "style": [Function],
620
+ "testID": "web_dropdown_option_a",
621
+ },
622
+ "type": "Pressable",
623
+ },
624
+ {
625
+ "$$typeof": Symbol(react.test.json),
626
+ "children": [
627
+ {
628
+ "$$typeof": Symbol(react.test.json),
629
+ "children": [
630
+ {
631
+ "$$typeof": Symbol(react.test.json),
632
+ "children": [
633
+ "Option B",
634
+ ],
635
+ "props": {
636
+ "style": {
637
+ "color": "#1C1C1C",
638
+ "fontWeight": "400",
639
+ },
640
+ },
641
+ "type": "Text",
642
+ },
643
+ ],
644
+ "props": {
645
+ "style": {
646
+ "alignSelf": "stretch",
647
+ },
648
+ "testID": undefined,
649
+ },
650
+ "type": "View",
651
+ },
652
+ ],
653
+ "props": {
654
+ "aria-role": "button",
655
+ "onLayout": [Function],
656
+ "onPress": [Function],
657
+ "style": [Function],
658
+ "testID": "web_dropdown_option_b",
659
+ },
660
+ "type": "Pressable",
661
+ },
662
+ ],
629
663
  "props": {
630
- "color": undefined,
631
- "label": "Option B",
632
- "value": "b",
664
+ "keyboardShouldPersistTaps": "handled",
665
+ "onLayout": [Function],
666
+ "ref": {
667
+ "current": null,
668
+ },
633
669
  },
634
- "type": "Picker.Item",
670
+ "type": "ScrollView",
635
671
  },
636
672
  ],
637
673
  "props": {
638
- "onValueChange": [Function],
639
- "selectedValue": "a",
640
- "testID": "ios_picker",
674
+ "style": {
675
+ "backgroundColor": "#FFFFFF",
676
+ "borderColor": "#9A9A9A",
677
+ "borderRadius": 4,
678
+ "borderWidth": 1,
679
+ "left": 0,
680
+ "maxHeight": 300,
681
+ "minWidth": undefined,
682
+ "overflow": "hidden",
683
+ "position": "absolute",
684
+ "shadowColor": "#000",
685
+ "shadowOffset": {
686
+ "height": 2,
687
+ "width": 0,
688
+ },
689
+ "shadowOpacity": 0.15,
690
+ "shadowRadius": 8,
691
+ "top": 4,
692
+ "width": 0,
693
+ "zIndex": 1,
694
+ },
695
+ "testID": "web_dropdown_menu",
641
696
  },
642
- "type": "Picker",
697
+ "type": "View",
643
698
  },
644
699
  ],
645
700
  "props": {
646
- "style": [
647
- {
648
- "backgroundColor": "#d0d4da",
649
- "justifyContent": "center",
650
- },
651
- {
652
- "height": 215,
653
- },
654
- ],
655
- "testID": undefined,
701
+ "animationType": "fade",
702
+ "onRequestClose": [Function],
703
+ "testID": "web_dropdown_modal",
704
+ "transparent": true,
705
+ "visible": false,
656
706
  },
657
- "type": "View",
707
+ "type": "Modal",
658
708
  },
659
709
  ],
660
710
  "props": {
661
- "animationType": undefined,
662
- "onOrientationChange": [Function],
663
- "supportedOrientations": [
664
- "portrait",
665
- "landscape",
711
+ "ref": {
712
+ "current": null,
713
+ },
714
+ "style": [
715
+ {
716
+ "alignItems": "center",
717
+ "alignSelf": "stretch",
718
+ "borderRadius": 4,
719
+ "borderWidth": 1,
720
+ "flexDirection": "row",
721
+ "justifyContent": "flex-start",
722
+ "minHeight": 40,
723
+ "width": "100%",
724
+ },
725
+ {
726
+ "backgroundColor": "#FFFFFF",
727
+ "borderColor": "#9A9A9A",
728
+ },
729
+ false,
666
730
  ],
667
- "testID": "ios_modal",
668
- "transparent": true,
669
- "visible": false,
731
+ "testID": undefined,
670
732
  },
671
- "type": "Modal",
733
+ "type": "View",
672
734
  },
673
735
  ],
674
736
  "props": {
675
- "style": [
676
- {
677
- "alignItems": "center",
678
- "alignSelf": "stretch",
679
- "borderRadius": 4,
680
- "borderWidth": 1,
681
- "flexDirection": "row",
682
- "justifyContent": "center",
683
- "minHeight": 40,
684
- "width": "100%",
685
- },
686
- {
687
- "backgroundColor": "#FFFFFF",
688
- "borderColor": "#9A9A9A",
689
- },
690
- false,
691
- ],
737
+ "style": {
738
+ "alignSelf": "stretch",
739
+ "minWidth": 0,
740
+ "width": "100%",
741
+ },
692
742
  "testID": undefined,
693
743
  },
694
744
  "type": "View",
@@ -696,6 +746,7 @@ exports[`TableBadge renders select field when editing 1`] = `
696
746
  ],
697
747
  "props": {
698
748
  "style": {
749
+ "minWidth": 0,
699
750
  "width": "100%",
700
751
  },
701
752
  "testID": undefined,
@@ -0,0 +1,5 @@
1
+ declare module "react-dom" {
2
+ import type {ReactNode, ReactPortal} from "react";
3
+
4
+ export function createPortal(children: ReactNode, container: Element): ReactPortal;
5
+ }