@terreno/ui 0.22.1 → 0.23.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 (97) hide show
  1. package/README.md +27 -0
  2. package/dist/Accordion.js +3 -3
  3. package/dist/Accordion.js.map +1 -1
  4. package/dist/BooleanField.js +6 -4
  5. package/dist/BooleanField.js.map +1 -1
  6. package/dist/Box.js +3 -2
  7. package/dist/Box.js.map +1 -1
  8. package/dist/CheckBox.js +2 -2
  9. package/dist/CheckBox.js.map +1 -1
  10. package/dist/Common.d.ts +40 -57
  11. package/dist/Common.js +1 -0
  12. package/dist/Common.js.map +1 -1
  13. package/dist/CustomSelectField.js +5 -3
  14. package/dist/CustomSelectField.js.map +1 -1
  15. package/dist/DataTable.js +18 -12
  16. package/dist/DataTable.js.map +1 -1
  17. package/dist/DateTimeField.js +5 -3
  18. package/dist/DateTimeField.js.map +1 -1
  19. package/dist/Link.js +2 -2
  20. package/dist/Link.js.map +1 -1
  21. package/dist/MarkdownEditor.js +14 -2
  22. package/dist/MarkdownEditor.js.map +1 -1
  23. package/dist/MarkdownEditorField.js +18 -4
  24. package/dist/MarkdownEditorField.js.map +1 -1
  25. package/dist/Modal.js +10 -6
  26. package/dist/Modal.js.map +1 -1
  27. package/dist/MultiselectField.js +5 -3
  28. package/dist/MultiselectField.js.map +1 -1
  29. package/dist/Page.js +1 -1
  30. package/dist/Page.js.map +1 -1
  31. package/dist/Pagination.js +2 -2
  32. package/dist/Pagination.js.map +1 -1
  33. package/dist/SegmentedControl.js +5 -3
  34. package/dist/SegmentedControl.js.map +1 -1
  35. package/dist/SelectField.js +5 -3
  36. package/dist/SelectField.js.map +1 -1
  37. package/dist/SocialLoginButton.js +2 -1
  38. package/dist/SocialLoginButton.js.map +1 -1
  39. package/dist/Spinner.js +3 -2
  40. package/dist/Spinner.js.map +1 -1
  41. package/dist/TextField.js +6 -4
  42. package/dist/TextField.js.map +1 -1
  43. package/dist/fieldElements/FieldError.d.ts +1 -0
  44. package/dist/fieldElements/FieldError.js +3 -2
  45. package/dist/fieldElements/FieldError.js.map +1 -1
  46. package/dist/fieldElements/FieldHelperText.d.ts +1 -0
  47. package/dist/fieldElements/FieldHelperText.js +3 -2
  48. package/dist/fieldElements/FieldHelperText.js.map +1 -1
  49. package/dist/fieldElements/FieldTitle.d.ts +1 -0
  50. package/dist/fieldElements/FieldTitle.js +4 -3
  51. package/dist/fieldElements/FieldTitle.js.map +1 -1
  52. package/dist/testing/index.d.ts +2 -0
  53. package/dist/testing/index.js +3 -0
  54. package/dist/testing/index.js.map +1 -0
  55. package/dist/testing/resolveTestId.d.ts +39 -0
  56. package/dist/testing/resolveTestId.js +97 -0
  57. package/dist/testing/resolveTestId.js.map +1 -0
  58. package/dist/testing/types.d.ts +59 -0
  59. package/dist/testing/types.js +2 -0
  60. package/dist/testing/types.js.map +1 -0
  61. package/package.json +1 -1
  62. package/src/Accordion.tsx +3 -1
  63. package/src/BooleanField.tsx +13 -3
  64. package/src/Box.tsx +3 -2
  65. package/src/CheckBox.tsx +7 -1
  66. package/src/Common.ts +62 -60
  67. package/src/CustomSelectField.tsx +8 -1
  68. package/src/DataTable.tsx +40 -3
  69. package/src/DateTimeField.tsx +10 -3
  70. package/src/Link.tsx +2 -1
  71. package/src/MarkdownEditor.tsx +52 -27
  72. package/src/MarkdownEditorField.tsx +37 -16
  73. package/src/Modal.tsx +13 -0
  74. package/src/MultiselectField.tsx +8 -3
  75. package/src/Page.tsx +1 -0
  76. package/src/Pagination.tsx +2 -1
  77. package/src/SegmentedControl.tsx +15 -2
  78. package/src/SelectField.tsx +8 -3
  79. package/src/SocialLoginButton.tsx +2 -1
  80. package/src/Spinner.tsx +3 -2
  81. package/src/TextField.tsx +8 -5
  82. package/src/__snapshots__/AddressField.test.tsx.snap +4 -0
  83. package/src/__snapshots__/BooleanField.test.tsx.snap +4 -0
  84. package/src/__snapshots__/Field.test.tsx.snap +8 -0
  85. package/src/__snapshots__/Link.test.tsx.snap +1 -0
  86. package/src/__snapshots__/Page.test.tsx.snap +21 -0
  87. package/src/__snapshots__/SegmentedControl.test.tsx.snap +4 -0
  88. package/src/__snapshots__/UnifiedAddressAutoComplete.test.tsx.snap +1 -0
  89. package/src/fieldElements/FieldError.tsx +7 -2
  90. package/src/fieldElements/FieldHelperText.tsx +4 -2
  91. package/src/fieldElements/FieldTitle.tsx +4 -1
  92. package/src/login/__snapshots__/LoginScreen.test.tsx.snap +4 -0
  93. package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +5 -0
  94. package/src/testing/index.ts +2 -0
  95. package/src/testing/resolveTestId.test.ts +130 -0
  96. package/src/testing/resolveTestId.ts +142 -0
  97. package/src/testing/types.ts +67 -0
@@ -5,6 +5,7 @@ import type {CustomSelectFieldProps} from "./Common";
5
5
  import {FieldHelperText} from "./fieldElements";
6
6
  import {SelectField} from "./SelectField";
7
7
  import {TextField} from "./TextField";
8
+ import {resolveFieldTestIDsFromProps, resolveTestID} from "./testing/resolveTestId";
8
9
 
9
10
  export const CustomSelectField: FC<CustomSelectFieldProps> = ({
10
11
  value,
@@ -15,10 +16,13 @@ export const CustomSelectField: FC<CustomSelectFieldProps> = ({
15
16
  title,
16
17
  errorText,
17
18
  helperText,
19
+ testID,
20
+ testIDs,
18
21
  }) => {
19
22
  const [currentValue, setCurrentValue] = useState(value);
20
23
  const [showCustomInput, setShowCustomInput] = useState(false);
21
24
  const textInputRef = useRef<TextInput | null>(null);
25
+ const fieldTestIDs = resolveFieldTestIDsFromProps({testID, testIDs});
22
26
 
23
27
  // Boolean that checks if currentValue is a value from the
24
28
  // options prop or if it is a true custom value
@@ -86,6 +90,8 @@ export const CustomSelectField: FC<CustomSelectFieldProps> = ({
86
90
  onChange={handleCustomSelectListChange}
87
91
  options={[...options, {label: "Custom", value: "custom"}]}
88
92
  placeholder={placeholder}
93
+ testID={fieldTestIDs.input}
94
+ testIDs={testIDs}
89
95
  title={title}
90
96
  value={isValueCustom ? "custom" : currentValue}
91
97
  />
@@ -106,12 +112,13 @@ export const CustomSelectField: FC<CustomSelectFieldProps> = ({
106
112
  }}
107
113
  onChange={onChange}
108
114
  placeholder="None selected"
115
+ testID={resolveTestID(fieldTestIDs.input, "custom")}
109
116
  type="text"
110
117
  value={value}
111
118
  />
112
119
  </View>
113
120
  )}
114
- {Boolean(helperText) && <FieldHelperText text={helperText!} />}
121
+ {Boolean(helperText) && <FieldHelperText testID={fieldTestIDs.helper} text={helperText!} />}
115
122
  </View>
116
123
  );
117
124
  };
package/src/DataTable.tsx CHANGED
@@ -27,6 +27,11 @@ import {Pagination} from "./Pagination";
27
27
  import {Text} from "./Text";
28
28
  import {useTheme} from "./Theme";
29
29
  import {TableTitle} from "./table/TableTitle";
30
+ import {
31
+ resolveDataTableRowTestID,
32
+ resolveDataTableTestIDsFromProps,
33
+ toTestProps,
34
+ } from "./testing/resolveTestId";
30
35
 
31
36
  // TODO: Add permanent horizontal scroll bar so users with only a mouse can scroll left/right
32
37
  // easily.
@@ -119,6 +124,7 @@ interface DataTableRowProps {
119
124
  alternateRowBackground: boolean;
120
125
  customColumnComponentMap?: DataTableCustomComponentMap;
121
126
  rowHeight: number;
127
+ testID?: string;
122
128
  }
123
129
 
124
130
  const DataTableRow: FC<DataTableRowProps> = ({
@@ -130,6 +136,7 @@ const DataTableRow: FC<DataTableRowProps> = ({
130
136
  alternateRowBackground,
131
137
  customColumnComponentMap,
132
138
  rowHeight,
139
+ testID,
133
140
  }) => {
134
141
  const {theme} = useTheme();
135
142
  const backgroundColor =
@@ -143,6 +150,7 @@ const DataTableRow: FC<DataTableRowProps> = ({
143
150
  flexDirection: "row",
144
151
  height: rowHeight,
145
152
  }}
153
+ {...toTestProps(testID)}
146
154
  >
147
155
  {rowData.map((cell, colIndex) => (
148
156
  <DataTableCell
@@ -313,6 +321,7 @@ interface DataTableHeaderProps {
313
321
  onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>, isHeader: boolean) => void;
314
322
  rowHeight: number;
315
323
  headerHeight?: number;
324
+ testID?: string;
316
325
  }
317
326
 
318
327
  const DataTableHeader: FC<DataTableHeaderProps> = ({
@@ -326,11 +335,12 @@ const DataTableHeader: FC<DataTableHeaderProps> = ({
326
335
  onScroll,
327
336
  rowHeight,
328
337
  headerHeight,
338
+ testID,
329
339
  }) => {
330
340
  const {theme} = useTheme();
331
341
 
332
342
  return (
333
- <View style={{flexDirection: "row", position: "relative"}}>
343
+ <View style={{flexDirection: "row", position: "relative"}} testID={testID}>
334
344
  {/* Fixed-width container for "more" content button if present */}
335
345
  {hasMoreContent && (
336
346
  <View
@@ -422,6 +432,8 @@ interface DataTableContentProps {
422
432
  moreContentSize?: "sm" | "md" | "lg";
423
433
  customColumnComponentMap?: DataTableCustomComponentMap;
424
434
  rowHeight: number;
435
+ rowTestIdBase?: string;
436
+ getRowTestID?: (row: DataTableCellData[], rowIndex: number) => string | number;
425
437
  }
426
438
 
427
439
  const DataTableContent: FC<DataTableContentProps> = ({
@@ -437,10 +449,17 @@ const DataTableContent: FC<DataTableContentProps> = ({
437
449
  moreContentExtraData,
438
450
  moreContentSize = "md",
439
451
  rowHeight,
452
+ rowTestIdBase,
453
+ getRowTestID,
440
454
  }) => {
441
455
  const [modalRow, setModalRow] = useState<number | null>(null);
442
456
  const {theme} = useTheme();
443
457
 
458
+ const resolveRowTestId = (row: DataTableCellData[], rowIndex: number): string | undefined => {
459
+ const rowKey = getRowTestID ? getRowTestID(row, rowIndex) : rowIndex;
460
+ return resolveDataTableRowTestID(rowTestIdBase, rowKey);
461
+ };
462
+
444
463
  return (
445
464
  <>
446
465
  <ScrollView style={{flex: 1}}>
@@ -496,6 +515,7 @@ const DataTableContent: FC<DataTableContentProps> = ({
496
515
  rowData={row.slice(0, pinnedColumns)}
497
516
  rowHeight={rowHeight}
498
517
  rowIndex={rowIndex}
518
+ testID={pinnedColumns > 0 ? resolveRowTestId(row, rowIndex) : undefined}
499
519
  />
500
520
  ))}
501
521
  </View>
@@ -527,6 +547,7 @@ const DataTableContent: FC<DataTableContentProps> = ({
527
547
  rowData={row.slice(pinnedColumns)}
528
548
  rowHeight={rowHeight}
529
549
  rowIndex={rowIndex}
550
+ testID={pinnedColumns === 0 ? resolveRowTestId(row, rowIndex) : undefined}
530
551
  />
531
552
  ))}
532
553
  </View>
@@ -568,8 +589,12 @@ export const DataTable: FC<DataTableProps> = ({
568
589
  rowHeight = 54,
569
590
  headerHeight,
570
591
  defaultTextSize = "md",
592
+ testID,
593
+ testIDs,
594
+ getRowTestID,
571
595
  }) => {
572
596
  const {theme} = useTheme();
597
+ const tableTestIDs = resolveDataTableTestIDsFromProps({testID, testIDs});
573
598
  const headerScrollRef = useRef<ScrollView>(null);
574
599
  const bodyScrollRef = useRef<ScrollView>(null);
575
600
 
@@ -622,7 +647,10 @@ export const DataTable: FC<DataTableProps> = ({
622
647
  }, [data, defaultTextSize]);
623
648
 
624
649
  return (
625
- <View style={{display: "flex", flexDirection: "column", height: "100%"}}>
650
+ <View
651
+ style={{display: "flex", flexDirection: "column", height: "100%"}}
652
+ testID={tableTestIDs.root}
653
+ >
626
654
  <View
627
655
  style={{
628
656
  borderColor: theme.border.default,
@@ -631,6 +659,7 @@ export const DataTable: FC<DataTableProps> = ({
631
659
  height: "100%",
632
660
  minHeight: 0,
633
661
  }}
662
+ testID={tableTestIDs.body}
634
663
  >
635
664
  <DataTableHeader
636
665
  columns={columns}
@@ -643,6 +672,7 @@ export const DataTable: FC<DataTableProps> = ({
643
672
  pinnedColumns={pinnedColumns}
644
673
  rowHeight={rowHeight}
645
674
  sortColumn={sortColumn}
675
+ testID={tableTestIDs.header}
646
676
  />
647
677
 
648
678
  <View style={{flex: 1, minHeight: 0}}>
@@ -653,11 +683,13 @@ export const DataTable: FC<DataTableProps> = ({
653
683
  columnWidths={columnWidths}
654
684
  customColumnComponentMap={customColumnComponentMap}
655
685
  data={processedData}
686
+ getRowTestID={getRowTestID}
656
687
  moreContentComponent={moreContentComponent}
657
688
  moreContentExtraData={moreContentExtraData}
658
689
  onScroll={handleScroll}
659
690
  pinnedColumns={pinnedColumns}
660
691
  rowHeight={rowHeight}
692
+ rowTestIdBase={tableTestIDs.row}
661
693
  />
662
694
  </View>
663
695
  </View>
@@ -670,7 +702,12 @@ export const DataTable: FC<DataTableProps> = ({
670
702
  padding: 16,
671
703
  }}
672
704
  >
673
- <Pagination page={page} setPage={setPage!} totalPages={totalPages} />
705
+ <Pagination
706
+ page={page}
707
+ setPage={setPage!}
708
+ testID={tableTestIDs.pagination}
709
+ totalPages={totalPages}
710
+ />
674
711
  </View>
675
712
  )}
676
713
  </View>
@@ -13,6 +13,7 @@ import {SelectField} from "./SelectField";
13
13
  import {Text} from "./Text";
14
14
  import {useTheme} from "./Theme";
15
15
  import {TimezonePicker} from "./TimezonePicker";
16
+ import {resolveFieldTestIDsFromProps} from "./testing/resolveTestId";
16
17
 
17
18
  interface SeparatorProps {
18
19
  type: "date" | "time";
@@ -416,8 +417,11 @@ export const DateTimeField: FC<DateTimeFieldProps> = ({
416
417
  errorText,
417
418
  disabled,
418
419
  helperText,
420
+ testID,
421
+ testIDs,
419
422
  }): React.ReactElement => {
420
423
  const {theme} = useTheme();
424
+ const fieldTestIDs = resolveFieldTestIDsFromProps({testID, testIDs});
421
425
  // biome-ignore lint/suspicious/noExplicitAny: ActionSheet class is defined in ActionSheet.tsx which imports from Common.ts indirectly; using its type here would create a circular dependency
422
426
  const dateActionSheetRef: React.RefObject<any> = React.createRef();
423
427
  const [amPm, setAmPm] = useState<"am" | "pm">("am");
@@ -969,8 +973,8 @@ export const DateTimeField: FC<DateTimeFieldProps> = ({
969
973
 
970
974
  return (
971
975
  <>
972
- {Boolean(title) && <FieldTitle text={title as string} />}
973
- {Boolean(errorText) && <FieldError text={errorText as string} />}
976
+ {Boolean(title) && <FieldTitle testID={fieldTestIDs.label} text={title as string} />}
977
+ {Boolean(errorText) && <FieldError testID={fieldTestIDs.error} text={errorText as string} />}
974
978
 
975
979
  {isMobileTimeOnly && (
976
980
  <MobileTimeDisplay
@@ -1004,6 +1008,7 @@ export const DateTimeField: FC<DateTimeFieldProps> = ({
1004
1008
  minWidth: isMobileDatetime ? 200 : minimumWidth,
1005
1009
  paddingHorizontal: 6,
1006
1010
  }}
1011
+ testID={fieldTestIDs.input}
1007
1012
  >
1008
1013
  {showDateSection && (
1009
1014
  <DateRowWithIcon
@@ -1055,7 +1060,9 @@ export const DateTimeField: FC<DateTimeFieldProps> = ({
1055
1060
  visible={showDate}
1056
1061
  />
1057
1062
  )}
1058
- {Boolean(helperText) && <FieldHelperText text={helperText as string} />}
1063
+ {Boolean(helperText) && (
1064
+ <FieldHelperText testID={fieldTestIDs.helper} text={helperText as string} />
1065
+ )}
1059
1066
  </>
1060
1067
  );
1061
1068
  };
package/src/Link.tsx CHANGED
@@ -4,7 +4,7 @@ import {Linking, Pressable} from "react-native";
4
4
  import type {LinkProps} from "./Common";
5
5
  import {Text} from "./Text";
6
6
 
7
- export const Link: React.FC<LinkProps> = ({text, href, onClick}) => {
7
+ export const Link: React.FC<LinkProps> = ({text, href, onClick, testID}) => {
8
8
  if (!href && !onClick) {
9
9
  console.error("Link component requires either href or onClick prop");
10
10
  return null;
@@ -22,6 +22,7 @@ export const Link: React.FC<LinkProps> = ({text, href, onClick}) => {
22
22
  void Linking.openURL(href);
23
23
  }
24
24
  }}
25
+ testID={testID}
25
26
  >
26
27
  <Text color="link" skipLinking underline>
27
28
  {text}
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, {useMemo} from "react";
2
2
  import {ScrollView, useWindowDimensions} from "react-native";
3
3
  import {Box} from "./Box";
4
4
  import {Heading} from "./Heading";
@@ -15,6 +15,11 @@ interface MarkdownEditorProps {
15
15
  maxHeight?: number;
16
16
  }
17
17
 
18
+ const DEFAULT_MAX_HEIGHT = 500;
19
+ const MIN_PANE_HEIGHT = 200;
20
+ const TEXT_FIELD_ROW_HEIGHT = 40;
21
+ const TEXT_FIELD_CHROME_HEIGHT = 20;
22
+
18
23
  export const MarkdownEditor: React.FC<MarkdownEditorProps> = ({
19
24
  value,
20
25
  onChange,
@@ -22,43 +27,63 @@ export const MarkdownEditor: React.FC<MarkdownEditorProps> = ({
22
27
  title,
23
28
  disabled,
24
29
  testID,
25
- maxHeight = 500,
30
+ maxHeight = DEFAULT_MAX_HEIGHT,
26
31
  }) => {
27
32
  const {width} = useWindowDimensions();
28
33
  const isDesktop = width >= 768;
29
34
 
35
+ const paneContainerStyle = {
36
+ flex: 1,
37
+ height: maxHeight,
38
+ maxHeight,
39
+ minHeight: MIN_PANE_HEIGHT,
40
+ };
41
+
42
+ const editorRows = useMemo(
43
+ () => Math.max(3, Math.floor((maxHeight - TEXT_FIELD_CHROME_HEIGHT) / TEXT_FIELD_ROW_HEIGHT)),
44
+ [maxHeight]
45
+ );
46
+
30
47
  return (
31
48
  <Box direction="column" gap={2} testID={testID}>
32
49
  {Boolean(title) && <Heading size="sm">{title}</Heading>}
33
- <Box direction={isDesktop ? "row" : "column"} gap={3}>
34
- <Box dangerouslySetInlineStyle={{__style: {flexBasis: 0}}} flex="grow">
50
+ <Box alignItems="stretch" direction={isDesktop ? "row" : "column"} gap={3}>
51
+ <Box dangerouslySetInlineStyle={{__style: {flexBasis: 0}}} direction="column" flex="grow">
35
52
  <Heading size="sm">Edit</Heading>
36
- <Box marginTop={1}>
37
- <TextField
38
- disabled={disabled}
39
- grow
40
- multiline
41
- onChange={onChange}
42
- placeholder={placeholder}
43
- rows={10}
44
- testID={testID ? `${testID}-input` : undefined}
45
- value={value}
46
- />
53
+ <Box
54
+ dangerouslySetInlineStyle={{__style: paneContainerStyle}}
55
+ marginTop={1}
56
+ overflow="hidden"
57
+ >
58
+ <Box height="100%" overflow="hidden">
59
+ <TextField
60
+ disabled={disabled}
61
+ multiline
62
+ onChange={onChange}
63
+ placeholder={placeholder}
64
+ rows={editorRows}
65
+ testID={testID ? `${testID}-input` : undefined}
66
+ value={value}
67
+ />
68
+ </Box>
47
69
  </Box>
48
70
  </Box>
49
- <Box dangerouslySetInlineStyle={{__style: {flexBasis: 0}}} flex="grow">
71
+ <Box dangerouslySetInlineStyle={{__style: {flexBasis: 0}}} direction="column" flex="grow">
50
72
  <Heading size="sm">Preview</Heading>
51
- <ScrollView style={{maxHeight, minHeight: 100}}>
52
- <Box
53
- border="default"
54
- marginTop={1}
55
- padding={3}
56
- rounding="sm"
57
- testID={testID ? `${testID}-preview` : undefined}
58
- >
59
- <MarkdownView>{value || " "}</MarkdownView>
60
- </Box>
61
- </ScrollView>
73
+ <Box
74
+ border="default"
75
+ dangerouslySetInlineStyle={{__style: paneContainerStyle}}
76
+ marginTop={1}
77
+ overflow="hidden"
78
+ rounding="sm"
79
+ testID={testID ? `${testID}-preview` : undefined}
80
+ >
81
+ <ScrollView style={{flex: 1, height: maxHeight, maxHeight}}>
82
+ <Box padding={3}>
83
+ <MarkdownView>{value || " "}</MarkdownView>
84
+ </Box>
85
+ </ScrollView>
86
+ </Box>
62
87
  </Box>
63
88
  </Box>
64
89
  </Box>
@@ -36,6 +36,10 @@ const TOOLBAR_BUTTONS: ToolbarButton[] = [
36
36
  {insert: (v) => `${v}[text](url)`, label: "🔗"},
37
37
  ];
38
38
 
39
+ const DEFAULT_MAX_HEIGHT = 500;
40
+ const MIN_PANE_HEIGHT = 200;
41
+ const TOOLBAR_MIN_HEIGHT = 34;
42
+
39
43
  export const MarkdownEditorField: React.FC<MarkdownEditorFieldProps> = ({
40
44
  title,
41
45
  value = "",
@@ -45,7 +49,7 @@ export const MarkdownEditorField: React.FC<MarkdownEditorFieldProps> = ({
45
49
  errorText,
46
50
  helperText,
47
51
  testID,
48
- maxHeight = 500,
52
+ maxHeight = DEFAULT_MAX_HEIGHT,
49
53
  }) => {
50
54
  const {theme} = useTheme();
51
55
  const isWeb = Platform.OS === "web";
@@ -56,18 +60,28 @@ export const MarkdownEditorField: React.FC<MarkdownEditorFieldProps> = ({
56
60
  [isWeb]
57
61
  );
58
62
 
63
+ const paneContainerStyle = {
64
+ flex: 1,
65
+ height: maxHeight,
66
+ maxHeight,
67
+ minHeight: MIN_PANE_HEIGHT,
68
+ };
69
+
70
+ const editorAreaMinHeight = Math.max(MIN_PANE_HEIGHT - TOOLBAR_MIN_HEIGHT, 120);
71
+
59
72
  return (
60
73
  <View testID={testID}>
61
74
  {Boolean(title) && <FieldTitle text={title!} />}
62
75
  <Box
76
+ alignItems="stretch"
63
77
  border={errorText ? "error" : "default"}
64
78
  direction={isWeb ? "row" : "column"}
65
79
  gap={0}
66
80
  overflow="hidden"
67
81
  rounding="md"
68
82
  >
69
- <View style={{flex: 1, maxHeight, minHeight: 200}}>
70
- <ScrollView style={{flex: 1}}>
83
+ <View style={{...paneContainerStyle, flexDirection: "column"}}>
84
+ <View style={{flex: 1, minHeight: editorAreaMinHeight}}>
71
85
  <TextInput
72
86
  editable={!disabled}
73
87
  multiline
@@ -75,6 +89,7 @@ export const MarkdownEditorField: React.FC<MarkdownEditorFieldProps> = ({
75
89
  placeholder={placeholder ?? "Enter markdown..."}
76
90
  placeholderTextColor={theme.text.secondaryDark}
77
91
  ref={inputRef}
92
+ scrollEnabled
78
93
  style={{
79
94
  backgroundColor: theme.surface.base,
80
95
  borderBottomWidth: isWeb ? 0 : 1,
@@ -84,14 +99,16 @@ export const MarkdownEditorField: React.FC<MarkdownEditorFieldProps> = ({
84
99
  flex: 1,
85
100
  fontFamily: monoFont,
86
101
  fontSize: 14,
87
- minHeight: 200,
102
+ height: "100%",
103
+ minHeight: editorAreaMinHeight,
88
104
  padding: 12,
89
105
  textAlignVertical: "top",
106
+ width: "100%",
90
107
  }}
91
108
  testID={testID ? `${testID}-input` : undefined}
92
109
  value={value}
93
110
  />
94
- </ScrollView>
111
+ </View>
95
112
  {!disabled && (
96
113
  <View
97
114
  style={{
@@ -99,8 +116,10 @@ export const MarkdownEditorField: React.FC<MarkdownEditorFieldProps> = ({
99
116
  borderColor: theme.border.default,
100
117
  borderTopWidth: 1,
101
118
  flexDirection: "row",
119
+ flexShrink: 0,
102
120
  flexWrap: "wrap",
103
121
  gap: 2,
122
+ minHeight: TOOLBAR_MIN_HEIGHT,
104
123
  paddingHorizontal: 4,
105
124
  paddingVertical: 3,
106
125
  }}
@@ -139,17 +158,19 @@ export const MarkdownEditorField: React.FC<MarkdownEditorFieldProps> = ({
139
158
  </View>
140
159
  )}
141
160
  </View>
142
- <ScrollView style={{flex: 1, maxHeight, minHeight: 200}}>
143
- <Box color="base" padding={3} style={{minHeight: 200}}>
144
- {value ? (
145
- <MarkdownView>{value}</MarkdownView>
146
- ) : (
147
- <Text color="secondaryDark" size="sm">
148
- Preview
149
- </Text>
150
- )}
151
- </Box>
152
- </ScrollView>
161
+ <View style={paneContainerStyle}>
162
+ <ScrollView style={{flex: 1, height: maxHeight, maxHeight}}>
163
+ <Box color="base" padding={3} style={{minHeight: MIN_PANE_HEIGHT}}>
164
+ {value ? (
165
+ <MarkdownView>{value}</MarkdownView>
166
+ ) : (
167
+ <Text color="secondaryDark" size="sm">
168
+ Preview
169
+ </Text>
170
+ )}
171
+ </Box>
172
+ </ScrollView>
173
+ </View>
153
174
  </Box>
154
175
  {Boolean(errorText) && <FieldError text={errorText!} />}
155
176
  {Boolean(helperText) && <FieldHelperText text={helperText!} />}
package/src/Modal.tsx CHANGED
@@ -18,6 +18,7 @@ import {Icon} from "./Icon";
18
18
  import {isMobileDevice} from "./MediaQuery";
19
19
  import {Text} from "./Text";
20
20
  import {useTheme} from "./Theme";
21
+ import {resolveModalTestIDsFromProps, toTestProps} from "./testing/resolveTestId";
21
22
  import {isNative} from "./Utilities";
22
23
 
23
24
  const getModalSize = (size: "sm" | "md" | "lg"): DimensionValue => {
@@ -47,6 +48,7 @@ const ModalContent: FC<{
47
48
  sizePx: DimensionValue;
48
49
  theme: TerrenoTheme;
49
50
  isMobile: boolean;
51
+ modalTestIDs: ReturnType<typeof resolveModalTestIDsFromProps>;
50
52
  }> = ({
51
53
  children,
52
54
  title,
@@ -61,6 +63,7 @@ const ModalContent: FC<{
61
63
  sizePx,
62
64
  theme,
63
65
  isMobile,
66
+ modalTestIDs,
64
67
  }) => {
65
68
  return (
66
69
  <View
@@ -81,6 +84,7 @@ const ModalContent: FC<{
81
84
  margin: "auto",
82
85
  }),
83
86
  }}
87
+ {...toTestProps(modalTestIDs.root)}
84
88
  >
85
89
  <View style={{alignSelf: "flex-end", position: "relative"}}>
86
90
  <Pressable
@@ -98,6 +102,7 @@ const ModalContent: FC<{
98
102
  right: -8,
99
103
  top: -8,
100
104
  }}
105
+ {...toTestProps(modalTestIDs.dismiss)}
101
106
  >
102
107
  <Icon iconName="x" size="sm" />
103
108
  </Pressable>
@@ -108,6 +113,7 @@ const ModalContent: FC<{
108
113
  aria-label={title}
109
114
  aria-role="header"
110
115
  style={{alignSelf: "flex-start"}}
116
+ {...toTestProps(modalTestIDs.title)}
111
117
  >
112
118
  <Heading size="lg">{title}</Heading>
113
119
  </View>
@@ -154,6 +160,7 @@ const ModalContent: FC<{
154
160
  <View style={{marginRight: primaryButtonText ? 20 : 0}}>
155
161
  <Button
156
162
  onClick={secondaryButtonOnClick!}
163
+ testID={modalTestIDs.secondaryButton}
157
164
  text={secondaryButtonText as string}
158
165
  variant="muted"
159
166
  />
@@ -163,6 +170,7 @@ const ModalContent: FC<{
163
170
  <Button
164
171
  disabled={primaryButtonDisabled}
165
172
  onClick={primaryButtonOnClick!}
173
+ testID={modalTestIDs.primaryButton}
166
174
  text={primaryButtonText as string}
167
175
  />
168
176
  )}
@@ -179,6 +187,8 @@ export const Modal: FC<ModalProps> = ({
179
187
  secondaryButtonText,
180
188
  size = "sm",
181
189
  subtitle,
190
+ testID,
191
+ testIDs,
182
192
  text,
183
193
  title,
184
194
  visible,
@@ -188,6 +198,7 @@ export const Modal: FC<ModalProps> = ({
188
198
  }: ModalProps) => {
189
199
  const actionSheetRef = useRef<ActionSheetRef>(null);
190
200
  const {theme} = useTheme();
201
+ const modalTestIDs = resolveModalTestIDsFromProps({testID, testIDs});
191
202
 
192
203
  const handleDismiss = () => {
193
204
  if (visible && onDismiss) {
@@ -240,7 +251,9 @@ export const Modal: FC<ModalProps> = ({
240
251
  const sizePx = getModalSize(size);
241
252
 
242
253
  const modalContentProps = {
254
+ children,
243
255
  isMobile,
256
+ modalTestIDs,
244
257
  onDismiss: handleDismiss,
245
258
  persistOnBackgroundClick,
246
259
  primaryButtonDisabled,
@@ -7,6 +7,7 @@ import {FieldError, FieldHelperText} from "./fieldElements";
7
7
  import {Heading} from "./Heading";
8
8
  import {isMobileDevice} from "./MediaQuery";
9
9
  import {Text} from "./Text";
10
+ import {resolveFieldTestIDsFromProps} from "./testing/resolveTestId";
10
11
 
11
12
  interface OptionProps {
12
13
  isDefault: boolean;
@@ -61,9 +62,12 @@ export const MultiselectField: FC<MultiselectFieldProps> = ({
61
62
  errorText,
62
63
  helperText,
63
64
  disabled,
65
+ testID,
66
+ testIDs,
64
67
  }) => {
65
68
  const isMobile = isMobileDevice();
66
69
  const isDefault = variant === "leftText";
70
+ const fieldTestIDs = resolveFieldTestIDsFromProps({testID, testIDs});
67
71
  const [selectedItems, setSelectedItems] = useState<string[]>(value);
68
72
  // set the selected items to the value passed in the props
69
73
  useEffect(() => {
@@ -87,11 +91,12 @@ export const MultiselectField: FC<MultiselectFieldProps> = ({
87
91
  gap: isMobile ? 16 : 8,
88
92
  width: "100%",
89
93
  }}
94
+ testID={fieldTestIDs.input}
90
95
  >
91
- <Heading color="primary" size="sm">
96
+ <Heading color="primary" size="sm" testID={fieldTestIDs.label}>
92
97
  {title}
93
98
  </Heading>
94
- {Boolean(errorText) && <FieldError text={errorText!} />}
99
+ {Boolean(errorText) && <FieldError testID={fieldTestIDs.error} text={errorText!} />}
95
100
  {disabled ? (
96
101
  <Text>{value.join(", ")}</Text>
97
102
  ) : (
@@ -106,7 +111,7 @@ export const MultiselectField: FC<MultiselectFieldProps> = ({
106
111
  />
107
112
  ))
108
113
  )}
109
- {Boolean(helperText) && <FieldHelperText text={helperText!} />}
114
+ {Boolean(helperText) && <FieldHelperText testID={fieldTestIDs.helper} text={helperText!} />}
110
115
  </View>
111
116
  );
112
117
  };
package/src/Page.tsx CHANGED
@@ -74,6 +74,7 @@ export class Page extends React.Component<PageProps, {}> {
74
74
  maxWidth={this.props.maxWidth || 800}
75
75
  padding={this.props.padding !== undefined ? this.props.padding : 2}
76
76
  scroll={this.props.scroll === undefined ? true : this.props.scroll}
77
+ testID={this.props.testID}
77
78
  width="100%"
78
79
  >
79
80
  {this.renderHeader()}
@@ -75,7 +75,7 @@ const PaginationNumber: FC<{
75
75
  );
76
76
  };
77
77
 
78
- export const Pagination: FC<PaginationProps> = ({totalPages, page, setPage}) => {
78
+ export const Pagination: FC<PaginationProps> = ({totalPages, page, setPage, testID}) => {
79
79
  const {theme} = useTheme();
80
80
 
81
81
  // Determine the number of pages to show. Show the first page,
@@ -136,6 +136,7 @@ export const Pagination: FC<PaginationProps> = ({totalPages, page, setPage}) =>
136
136
  flexDirection: "row",
137
137
  gap: theme.spacing.xs,
138
138
  }}
139
+ testID={testID}
139
140
  >
140
141
  <PaginationButton
141
142
  onClick={() => {